1 /* vi: set sw=4 ts=4: */
3 * ip.c "ip" utility frontend.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
10 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
15 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
18 #include "ip_common.h" /* #include "libbb.h" is inside */
21 int preferred_family = AF_UNSPEC;
25 void ip_parse_common_args(int *argcp, char ***argvp)
29 static const char * const ip_common_commands[] =
30 {"-family", "inet", "inet6", "link",
31 "-4", "-6", "-0", "-oneline", 0};
47 if (strcmp(opt,"--") == 0) {
56 arg = index_in_str_array(ip_common_commands, opt) + 1;
57 if (arg == ARG_family) {
62 arg = index_in_str_array(ip_common_commands, argv[1]) + 1;
64 preferred_family = AF_INET;
65 else if (arg == ARG_inet6)
66 preferred_family = AF_INET6;
67 else if (arg == ARG_link)
68 preferred_family = AF_PACKET;
70 invarg(argv[1], "protocol family");
71 } else if (arg == ARG_IPv4) {
72 preferred_family = AF_INET;
73 } else if (arg == ARG_IPv6) {
74 preferred_family = AF_INET6;
75 } else if (arg == ARG_packet) {
76 preferred_family = AF_PACKET;
77 } else if (arg == ARG_oneline) {
85 _SL_ = oneline ? '\\' : '\n';