aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2002-12-01 23:04:06 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2002-12-01 23:04:06 +0000
commit5715527897ffb01ec5790327a90e1be47385923a (patch)
tree1e52823545fb3e20f89205fd6224017e19586c72
parent10dab9f810c2db369553b3373dc391c2c22749ed (diff)
downloadbusybox-w32-5715527897ffb01ec5790327a90e1be47385923a.tar.gz
busybox-w32-5715527897ffb01ec5790327a90e1be47385923a.tar.bz2
busybox-w32-5715527897ffb01ec5790327a90e1be47385923a.zip
Enable ip commands to be compiled seperate from ip, modifed patch from Bastian Blank
git-svn-id: svn://busybox.net/trunk/busybox@6071 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--include/applets.h14
-rw-r--r--include/usage.h51
-rw-r--r--networking/Makefile.in22
-rw-r--r--networking/config.in20
-rw-r--r--networking/ip.c55
-rw-r--r--networking/ipaddr.c27
-rw-r--r--networking/iplink.c27
-rw-r--r--networking/iproute.c27
-rw-r--r--networking/iptunnel.c27
-rw-r--r--networking/libiproute/Makefile.in1
-rw-r--r--networking/libiproute/ip_common.h4
-rw-r--r--networking/libiproute/ip_parse_common_args.c70
-rw-r--r--networking/libiproute/ipaddress.c5
13 files changed, 307 insertions, 43 deletions
diff --git a/include/applets.h b/include/applets.h
index a85a8bfcb..d8c4b38a0 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -255,11 +255,23 @@
255 APPLET(insmod, insmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER) 255 APPLET(insmod, insmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
256#endif 256#endif
257#ifdef CONFIG_IP 257#ifdef CONFIG_IP
258 APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER) 258 APPLET(ip, ip_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
259#endif 259#endif
260#ifdef CONFIG_IPCALC 260#ifdef CONFIG_IPCALC
261 APPLET(ipcalc, ipcalc_main, _BB_DIR_BIN, _BB_SUID_NEVER) 261 APPLET(ipcalc, ipcalc_main, _BB_DIR_BIN, _BB_SUID_NEVER)
262#endif 262#endif
263#ifdef CONFIG_IPADDRESS
264 APPLET(ipaddr, ipaddr_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
265#endif
266#ifdef CONFIG_IPLINK
267 APPLET(iplink, iplink_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
268#endif
269#ifdef CONFIG_IPROUTE
270 APPLET(iproute, iproute_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
271#endif
272#ifdef CONFIG_IPTUNNEL
273 APPLET(iptunnel, iptunnel_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
274#endif
263#ifdef CONFIG_KILL 275#ifdef CONFIG_KILL
264 APPLET(kill, kill_main, _BB_DIR_BIN, _BB_SUID_NEVER) 276 APPLET(kill, kill_main, _BB_DIR_BIN, _BB_SUID_NEVER)
265#endif 277#endif
diff --git a/include/usage.h b/include/usage.h
index c676754e3..eca05446f 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -989,25 +989,38 @@
989 "\t-x\tdo not export externs" 989 "\t-x\tdo not export externs"
990 990
991#define ip_trivial_usage \ 991#define ip_trivial_usage \
992 "not written yet" 992 "[ OPTIONS ] { address | link | route | tunnel } { COMMAND | help }"
993#define ip_full_usage \ 993#define ip_full_usage \
994 "not written yet" 994 "ip [ OPTIONS ] OBJECT { COMMAND | help }\n" \
995 "where OBJECT := { link | addr | route | tunnel }\n" \
996 "OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }\n"
997
998#define ipaddr_trivial_usage \
999 "{ {add|del} IFADDR dev STRING | {show|flush} [ dev STRING ] [ to PREFIX ] }"
1000#define ipaddr_full_usage \
1001 "ipaddr {add|del} IFADDR dev STRING\n" \
1002 "ipaddr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]\n" \
1003 " [ to PREFIX ] [ label PATTERN ]\n" \
1004 "IFADDR := PREFIX | ADDR peer PREFIX\n" \
1005 " [ broadcast ADDR ] [ anycast ADDR ]\n" \
1006 " [ label STRING ] [ scope SCOPE-ID ]\n" \
1007 "SCOPE-ID := [ host | link | global | NUMBER ]\n"
995 1008
996#ifndef CONFIG_FEATURE_IPCALC_FANCY 1009#ifndef CONFIG_FEATURE_IPCALC_FANCY
997#define ipcalc_trivial_usage \ 1010# define ipcalc_trivial_usage \
998 "[--broadcast] [--netmask] [--network] ipaddr <netmask>" 1011 "[--broadcast] [--netmask] [--network] ipaddr <netmask>"
999 1012
1000#define ipcalc_full_usage \ 1013# define ipcalc_full_usage \
1001 "Calculate IP network settings from a IP address\n\n" \ 1014 "Calculate IP network settings from a IP address\n\n" \
1002 "Options:\n" \ 1015 "Options:\n" \
1003 "\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \ 1016 "\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
1004 "\t-n\t--netmask\tDisplay default netmask for IP.\n" \ 1017 "\t-n\t--netmask\tDisplay default netmask for IP.\n" \
1005 "\t-w\t--network\tDisplay calculated network address." 1018 "\t-w\t--network\tDisplay calculated network address."
1006#else 1019#else
1007#define ipcalc_trivial_usage \ 1020# define ipcalc_trivial_usage \
1008 "[OPTION]... ipaddr <netmask>" 1021 "[OPTION]... ipaddr <netmask>"
1009 1022
1010#define ipcalc_full_usage \ 1023# define ipcalc_full_usage \
1011 "Calculate IP network settings from a IP address\n\n" \ 1024 "Calculate IP network settings from a IP address\n\n" \
1012 "Options:\n" \ 1025 "Options:\n" \
1013 "\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \ 1026 "\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
@@ -1023,6 +1036,32 @@
1023 "should display on standard out. Multiple options may be\n" \ 1036 "should display on standard out. Multiple options may be\n" \
1024 "specified.\n" 1037 "specified.\n"
1025 1038
1039#define iplink_trivial_usage \
1040 "{ set DEVICE { up | down | arp { on | off } | show [ DEVICE ] }"
1041#define iplink_full_usage \
1042 "iplink set DEVICE { up | down | arp { on | off } |\n" \
1043 " dynamic { on | off } |\n" \
1044 " mtu MTU }\n" \
1045 "iplink show [ DEVICE ]\n"
1046
1047#define iproute_trivial_usage \
1048 "{ list | flush | { add | del | change | append | replace | monitor } ROUTE }"
1049#define iproute_full_usage \
1050 "iproute { list | flush } SELECTOR\n" \
1051 "iproute get ADDRESS [ from ADDRESS iif STRING ]\n" \
1052 " [ oif STRING ] [ tos TOS ]\n" \
1053 "iproute { add | del | change | append | replace | monitor } ROUTE\n" \
1054 "SELECTOR := [ root PREFIX ] [ match PREFIX ] [ proto RTPROTO ]\n" \
1055 "ROUTE := [ TYPE ] PREFIX [ tos TOS ] [ proto RTPROTO ]\n"
1056
1057#define iptunnel_trivial_usage \
1058 "{ add | change | del | show } [ NAME ] [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ] [ ttl TTL ]"
1059#define iptunnel_full_usage \
1060 "iptunnel { add | change | del | show } [ NAME ]\n" \
1061 " [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n" \
1062 " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n" \
1063 " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n"
1064
1026#define kill_trivial_usage \ 1065#define kill_trivial_usage \
1027 "[-signal] process-id [process-id ...]" 1066 "[-signal] process-id [process-id ...]"
1028#define kill_full_usage \ 1067#define kill_full_usage \
diff --git a/networking/Makefile.in b/networking/Makefile.in
index 7404b041d..fc6a3b7e0 100644
--- a/networking/Makefile.in
+++ b/networking/Makefile.in
@@ -23,21 +23,25 @@ NETWORKING_DIR:=$(TOPDIR)networking/
23endif 23endif
24 24
25NETWORKING-y:= 25NETWORKING-y:=
26NETWORKING-$(CONFIG_HOSTNAME) += hostname.o 26NETWORKING-$(CONFIG_HOSTNAME) += hostname.o
27NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o 27NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o
28NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o 28NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o
29NETWORKING-$(CONFIG_IP) += ip.o 29NETWORKING-$(CONFIG_IP) += ip.o
30NETWORKING-$(CONFIG_IPCALC) += ipcalc.o 30NETWORKING-$(CONFIG_IPCALC) += ipcalc.o
31NETWORKING-$(CONFIG_IPADDR) += ipaddr.o
32NETWORKING-$(CONFIG_IPLINK) += iplink.o
33NETWORKING-$(CONFIG_IPROUTE) += iproute.o
34NETWORKING-$(CONFIG_IPTUNNEL) += iptunnel.o
31NETWORKING-$(CONFIG_NC) += nc.o 35NETWORKING-$(CONFIG_NC) += nc.o
32NETWORKING-$(CONFIG_NETSTAT) += netstat.o 36NETWORKING-$(CONFIG_NETSTAT) += netstat.o
33NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o 37NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o
34NETWORKING-$(CONFIG_PING) += ping.o 38NETWORKING-$(CONFIG_PING) += ping.o
35NETWORKING-$(CONFIG_PING6) += ping6.o 39NETWORKING-$(CONFIG_PING6) += ping6.o
36NETWORKING-$(CONFIG_ROUTE) += route.o 40NETWORKING-$(CONFIG_ROUTE) += route.o
37NETWORKING-$(CONFIG_TELNET) += telnet.o 41NETWORKING-$(CONFIG_TELNET) += telnet.o
38NETWORKING-$(CONFIG_TELNETD) += telnetd.o 42NETWORKING-$(CONFIG_TELNETD) += telnetd.o
39NETWORKING-$(CONFIG_TFTP) += tftp.o 43NETWORKING-$(CONFIG_TFTP) += tftp.o
40NETWORKING-$(CONFIG_TRACEROUTE) += traceroute.o 44NETWORKING-$(CONFIG_TRACEROUTE) += traceroute.o
41NETWORKING-$(CONFIG_WGET) += wget.o 45NETWORKING-$(CONFIG_WGET) += wget.o
42 46
43libraries-y+=$(NETWORKING_DIR)$(NETWORKING_AR) 47libraries-y+=$(NETWORKING_DIR)$(NETWORKING_AR)
diff --git a/networking/config.in b/networking/config.in
index d62a6e425..de5b92064 100644
--- a/networking/config.in
+++ b/networking/config.in
@@ -33,10 +33,26 @@ bool 'ipcalc' CONFIG_IPCALC
33if [ "$CONFIG_IPCALC" = "y" ]; then 33if [ "$CONFIG_IPCALC" = "y" ]; then
34 bool ' Fancy IPCALC, more options, adds 300 bytes' CONFIG_FEATURE_IPCALC_FANCY 34 bool ' Fancy IPCALC, more options, adds 300 bytes' CONFIG_FEATURE_IPCALC_FANCY
35fi 35fi
36bool 'nc' CONFIG_NC 36bool 'ipaddr' CONFIG_IPADDR
37if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPADDR" = "y" ]; then
38 define_bool CONFIG_FEATURE_IP_ADDRESS y
39fi
40bool 'iplink' CONFIG_IPLINK
41if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPLINK" = "y" ]; then
42 define_bool CONFIG_FEATURE_IP_LINK y
43fi
44bool 'iproute' CONFIG_IPROUTE
45if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPROUTE" = "y" ]; then
46 define_bool CONFIG_FEATURE_IP_ROUTE y
47fi
48bool 'iptunnel' CONFIG_IPTUNNEL
49if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPTUNNEL" = "y" ]; then
50 define_bool CONFIG_FEATURE_IP_TUNNEL y
51fi
52bool 'nc' CONFIG_NC
37bool 'netstat' CONFIG_NETSTAT 53bool 'netstat' CONFIG_NETSTAT
38bool 'nslookup' CONFIG_NSLOOKUP 54bool 'nslookup' CONFIG_NSLOOKUP
39bool 'ping' CONFIG_PING 55bool 'ping' CONFIG_PING
40if [ "$CONFIG_PING" = "y" ]; then 56if [ "$CONFIG_PING" = "y" ]; then
41 bool ' Enable fancy ping output' CONFIG_FEATURE_FANCY_PING 57 bool ' Enable fancy ping output' CONFIG_FEATURE_FANCY_PING
42fi 58fi
diff --git a/networking/ip.c b/networking/ip.c
index f045f5f78..e7cab74c9 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -28,30 +28,30 @@
28 28
29#include "busybox.h" 29#include "busybox.h"
30 30
31#if 0
31int preferred_family = AF_UNSPEC; 32int preferred_family = AF_UNSPEC;
32int oneline = 0; 33int oneline = 0;
33char * _SL_ = NULL; 34char * _SL_ = NULL;
34 35
35int ip_main(int argc, char **argv) 36void ip_parse_common_args(int *argcp, char ***argvp)
36{ 37{
37 char *basename; 38 int argc = *argcp;
39 char **argv = *argvp;
38 40
39 basename = strrchr(argv[0], '/');
40 if (basename == NULL)
41 basename = argv[0];
42 else
43 basename++;
44
45 while (argc > 1) { 41 while (argc > 1) {
46 char *opt = argv[1]; 42 char *opt = argv[1];
43
47 if (strcmp(opt,"--") == 0) { 44 if (strcmp(opt,"--") == 0) {
48 argc--; argv++; 45 argc--; argv++;
49 break; 46 break;
50 } 47 }
48
51 if (opt[0] != '-') 49 if (opt[0] != '-')
52 break; 50 break;
51
53 if (opt[1] == '-') 52 if (opt[1] == '-')
54 opt++; 53 opt++;
54
55 if (matches(opt, "-family") == 0) { 55 if (matches(opt, "-family") == 0) {
56 argc--; 56 argc--;
57 argv++; 57 argv++;
@@ -72,33 +72,44 @@ int ip_main(int argc, char **argv)
72 } else if (matches(opt, "-oneline") == 0) { 72 } else if (matches(opt, "-oneline") == 0) {
73 ++oneline; 73 ++oneline;
74 } else { 74 } else {
75 fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt); 75 show_usage();
76 exit(-1);
77 } 76 }
78 argc--; argv++; 77 argc--; argv++;
79 } 78 }
80
81 _SL_ = oneline ? "\\" : "\n" ; 79 _SL_ = oneline ? "\\" : "\n" ;
80}
81#endif
82
83int ip_main(int argc, char **argv)
84{
85 int ret = EXIT_FAILURE;
86
87 ip_parse_common_args(&argc, &argv);
82 88
83 if (argc > 1) { 89 if (argc > 1) {
84#ifdef CONFIG_FEATURE_IP_ADDRESS 90#ifdef CONFIG_FEATURE_IP_ADDRESS
85 if (matches(argv[1], "address") == 0) 91 if (matches(argv[1], "address") == 0) {
86 return do_ipaddr(argc-2, argv+2); 92 ret = do_ipaddr(argc-2, argv+2);
93 }
87#endif 94#endif
88#ifdef CONFIG_FEATURE_IP_ROUTE 95#ifdef CONFIG_FEATURE_IP_ROUTE
89 if (matches(argv[1], "route") == 0) 96 else if (matches(argv[1], "route") == 0) {
90 return do_iproute(argc-2, argv+2); 97 ret = do_iproute(argc-2, argv+2);
98 }
91#endif 99#endif
92#ifdef CONFIG_FEATURE_IP_LINK 100#ifdef CONFIG_FEATURE_IP_LINK
93 if (matches(argv[1], "link") == 0) 101 else if (matches(argv[1], "link") == 0) {
94 return do_iplink(argc-2, argv+2); 102 ret = do_iplink(argc-2, argv+2);
103 }
95#endif 104#endif
96#ifdef CONFIG_FEATURE_IP_TUNNEL 105#ifdef CONFIG_FEATURE_IP_TUNNEL
97 if (matches(argv[1], "tunnel") == 0 || 106 else if (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) {
98 strcmp(argv[1], "tunl") == 0) 107 ret = do_iptunnel(argc-2, argv+2);
99 return do_iptunnel(argc-2, argv+2); 108 }
100#endif 109#endif
101 fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv[1]);
102 exit(-1);
103 } 110 }
111 if (ret) {
112 show_usage();
113 }
114 return(EXIT_SUCCESS);
104} 115}
diff --git a/networking/ipaddr.c b/networking/ipaddr.c
new file mode 100644
index 000000000..7826194c9
--- /dev/null
+++ b/networking/ipaddr.c
@@ -0,0 +1,27 @@
1/*
2 * ip.c "ip" utility frontend.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 *
12 * Changes:
13 *
14 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
15 */
16
17#include "./libiproute/utils.h"
18#include "./libiproute/ip_common.h"
19
20#include "busybox.h"
21
22int ipaddr_main(int argc, char **argv)
23{
24 ip_parse_common_args(&argc, &argv);
25
26 return do_ipaddr(argc-1, argv+1);
27}
diff --git a/networking/iplink.c b/networking/iplink.c
new file mode 100644
index 000000000..7207e176c
--- /dev/null
+++ b/networking/iplink.c
@@ -0,0 +1,27 @@
1/*
2 * ip.c "ip" utility frontend.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 *
12 * Changes:
13 *
14 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
15 */
16
17#include "./libiproute/utils.h"
18#include "./libiproute/ip_common.h"
19
20#include "busybox.h"
21
22int iplink_main(int argc, char **argv)
23{
24 ip_parse_common_args(&argc, &argv);
25
26 return do_iplink(argc-1, argv+1);
27}
diff --git a/networking/iproute.c b/networking/iproute.c
new file mode 100644
index 000000000..d049a87c4
--- /dev/null
+++ b/networking/iproute.c
@@ -0,0 +1,27 @@
1/*
2 * ip.c "ip" utility frontend.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 *
12 * Changes:
13 *
14 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
15 */
16
17#include "./libiproute/utils.h"
18#include "./libiproute/ip_common.h"
19
20#include "busybox.h"
21
22int iproute_main(int argc, char **argv)
23{
24 ip_parse_common_args(&argc, &argv);
25
26 return do_iproute(argc-1, argv+1);
27}
diff --git a/networking/iptunnel.c b/networking/iptunnel.c
new file mode 100644
index 000000000..f2b2e8a77
--- /dev/null
+++ b/networking/iptunnel.c
@@ -0,0 +1,27 @@
1/*
2 * ip.c "ip" utility frontend.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 *
12 * Changes:
13 *
14 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
15 */
16
17#include "./libiproute/utils.h"
18#include "./libiproute/ip_common.h"
19
20#include "busybox.h"
21
22int iptunnel_main(int argc, char **argv)
23{
24 ip_parse_common_args(&argc, &argv);
25
26 return do_iptunnel(argc-1, argv+1);
27}
diff --git a/networking/libiproute/Makefile.in b/networking/libiproute/Makefile.in
index 6d35d7b3f..9fe146215 100644
--- a/networking/libiproute/Makefile.in
+++ b/networking/libiproute/Makefile.in
@@ -23,6 +23,7 @@ LIBIPROUTE_DIR:=$(TOPDIR)networking/libiproute/
23endif 23endif
24 24
25LIBIPROUTE-$(CONFIG_IP) += \ 25LIBIPROUTE-$(CONFIG_IP) += \
26 ip_parse_common_args.o \
26 ipaddress.o \ 27 ipaddress.o \
27 iplink.o \ 28 iplink.o \
28 iproute.o \ 29 iproute.o \
diff --git a/networking/libiproute/ip_common.h b/networking/libiproute/ip_common.h
index 5ac43218e..771ca48bd 100644
--- a/networking/libiproute/ip_common.h
+++ b/networking/libiproute/ip_common.h
@@ -1,3 +1,7 @@
1extern int preferred_family;
2extern char * _SL_;
3
4extern void ip_parse_common_args(int *argcp, char ***argvp);
1extern int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); 5extern int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
2extern int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); 6extern int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
3extern int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); 7extern int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c
new file mode 100644
index 000000000..550d1ddfe
--- /dev/null
+++ b/networking/libiproute/ip_parse_common_args.c
@@ -0,0 +1,70 @@
1/*
2 * ip.c "ip" utility frontend.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 *
12 * Changes:
13 *
14 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
15 */
16
17#include "utils.h"
18#include "ip_common.h"
19
20#include "busybox.h"
21
22int preferred_family = AF_UNSPEC;
23int oneline = 0;
24char * _SL_ = NULL;
25
26void ip_parse_common_args(int *argcp, char ***argvp)
27{
28 int argc = *argcp;
29 char **argv = *argvp;
30
31 while (argc > 1) {
32 char *opt = argv[1];
33
34 if (strcmp(opt,"--") == 0) {
35 argc--; argv++;
36 break;
37 }
38
39 if (opt[0] != '-')
40 break;
41
42 if (opt[1] == '-')
43 opt++;
44
45 if (matches(opt, "-family") == 0) {
46 argc--;
47 argv++;
48 if (strcmp(argv[1], "inet") == 0)
49 preferred_family = AF_INET;
50 else if (strcmp(argv[1], "inet6") == 0)
51 preferred_family = AF_INET6;
52 else if (strcmp(argv[1], "link") == 0)
53 preferred_family = AF_PACKET;
54 else
55 invarg(argv[1], "invalid protocol family");
56 } else if (strcmp(opt, "-4") == 0) {
57 preferred_family = AF_INET;
58 } else if (strcmp(opt, "-6") == 0) {
59 preferred_family = AF_INET6;
60 } else if (strcmp(opt, "-0") == 0) {
61 preferred_family = AF_PACKET;
62 } else if (matches(opt, "-oneline") == 0) {
63 ++oneline;
64 } else {
65 show_usage();
66 }
67 argc--; argv++;
68 }
69 _SL_ = oneline ? "\\" : "\n" ;
70}
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index dd5a91426..055aadfee 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -230,7 +230,6 @@ int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
230 if ((filter.flags^ifa->ifa_flags)&filter.flagmask) 230 if ((filter.flags^ifa->ifa_flags)&filter.flagmask)
231 return 0; 231 return 0;
232 if (filter.label) { 232 if (filter.label) {
233 SPRINT_BUF(b1);
234 const char *label; 233 const char *label;
235 if (rta_tb[IFA_LABEL]) 234 if (rta_tb[IFA_LABEL])
236 label = RTA_DATA(rta_tb[IFA_LABEL]); 235 label = RTA_DATA(rta_tb[IFA_LABEL]);
@@ -541,10 +540,10 @@ int ipaddr_list_link(int argc, char **argv)
541 return ipaddr_list(argc, argv); 540 return ipaddr_list(argc, argv);
542} 541}
543 542
544void ipaddr_reset_filter(int oneline) 543void ipaddr_reset_filter(int _oneline)
545{ 544{
546 memset(&filter, 0, sizeof(filter)); 545 memset(&filter, 0, sizeof(filter));
547 filter.oneline = oneline; 546 filter.oneline = _oneline;
548} 547}
549 548
550int default_scope(inet_prefix *lcl) 549int default_scope(inet_prefix *lcl)