diff options
Diffstat (limited to 'networking')
-rw-r--r-- | networking/Makefile.in | 22 | ||||
-rw-r--r-- | networking/config.in | 20 | ||||
-rw-r--r-- | networking/ip.c | 55 | ||||
-rw-r--r-- | networking/ipaddr.c | 27 | ||||
-rw-r--r-- | networking/iplink.c | 27 | ||||
-rw-r--r-- | networking/iproute.c | 27 | ||||
-rw-r--r-- | networking/iptunnel.c | 27 | ||||
-rw-r--r-- | networking/libiproute/Makefile.in | 1 | ||||
-rw-r--r-- | networking/libiproute/ip_common.h | 4 | ||||
-rw-r--r-- | networking/libiproute/ip_parse_common_args.c | 70 | ||||
-rw-r--r-- | networking/libiproute/ipaddress.c | 5 |
11 files changed, 249 insertions, 36 deletions
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/ endif NETWORKING-y:= -NETWORKING-$(CONFIG_HOSTNAME) += hostname.o -NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o -NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o -NETWORKING-$(CONFIG_IP) += ip.o -NETWORKING-$(CONFIG_IPCALC) += ipcalc.o +NETWORKING-$(CONFIG_HOSTNAME) += hostname.o +NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o +NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o +NETWORKING-$(CONFIG_IP) += ip.o +NETWORKING-$(CONFIG_IPCALC) += ipcalc.o +NETWORKING-$(CONFIG_IPADDR) += ipaddr.o +NETWORKING-$(CONFIG_IPLINK) += iplink.o +NETWORKING-$(CONFIG_IPROUTE) += iproute.o +NETWORKING-$(CONFIG_IPTUNNEL) += iptunnel.o NETWORKING-$(CONFIG_NC) += nc.o -NETWORKING-$(CONFIG_NETSTAT) += netstat.o -NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o +NETWORKING-$(CONFIG_NETSTAT) += netstat.o +NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o NETWORKING-$(CONFIG_PING) += ping.o NETWORKING-$(CONFIG_PING6) += ping6.o NETWORKING-$(CONFIG_ROUTE) += route.o NETWORKING-$(CONFIG_TELNET) += telnet.o -NETWORKING-$(CONFIG_TELNETD) += telnetd.o +NETWORKING-$(CONFIG_TELNETD) += telnetd.o NETWORKING-$(CONFIG_TFTP) += tftp.o -NETWORKING-$(CONFIG_TRACEROUTE) += traceroute.o +NETWORKING-$(CONFIG_TRACEROUTE) += traceroute.o NETWORKING-$(CONFIG_WGET) += wget.o libraries-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 if [ "$CONFIG_IPCALC" = "y" ]; then bool ' Fancy IPCALC, more options, adds 300 bytes' CONFIG_FEATURE_IPCALC_FANCY fi -bool 'nc' CONFIG_NC +bool 'ipaddr' CONFIG_IPADDR +if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPADDR" = "y" ]; then + define_bool CONFIG_FEATURE_IP_ADDRESS y +fi +bool 'iplink' CONFIG_IPLINK +if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPLINK" = "y" ]; then + define_bool CONFIG_FEATURE_IP_LINK y +fi +bool 'iproute' CONFIG_IPROUTE +if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPROUTE" = "y" ]; then + define_bool CONFIG_FEATURE_IP_ROUTE y +fi +bool 'iptunnel' CONFIG_IPTUNNEL +if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPTUNNEL" = "y" ]; then + define_bool CONFIG_FEATURE_IP_TUNNEL y +fi +bool 'nc' CONFIG_NC bool 'netstat' CONFIG_NETSTAT bool 'nslookup' CONFIG_NSLOOKUP -bool 'ping' CONFIG_PING +bool 'ping' CONFIG_PING if [ "$CONFIG_PING" = "y" ]; then bool ' Enable fancy ping output' CONFIG_FEATURE_FANCY_PING fi 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 @@ #include "busybox.h" +#if 0 int preferred_family = AF_UNSPEC; int oneline = 0; char * _SL_ = NULL; -int ip_main(int argc, char **argv) +void ip_parse_common_args(int *argcp, char ***argvp) { - char *basename; + int argc = *argcp; + char **argv = *argvp; - basename = strrchr(argv[0], '/'); - if (basename == NULL) - basename = argv[0]; - else - basename++; - while (argc > 1) { char *opt = argv[1]; + if (strcmp(opt,"--") == 0) { argc--; argv++; break; } + if (opt[0] != '-') break; + if (opt[1] == '-') opt++; + if (matches(opt, "-family") == 0) { argc--; argv++; @@ -72,33 +72,44 @@ int ip_main(int argc, char **argv) } else if (matches(opt, "-oneline") == 0) { ++oneline; } else { - fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt); - exit(-1); + show_usage(); } argc--; argv++; } - _SL_ = oneline ? "\\" : "\n" ; +} +#endif + +int ip_main(int argc, char **argv) +{ + int ret = EXIT_FAILURE; + + ip_parse_common_args(&argc, &argv); if (argc > 1) { #ifdef CONFIG_FEATURE_IP_ADDRESS - if (matches(argv[1], "address") == 0) - return do_ipaddr(argc-2, argv+2); + if (matches(argv[1], "address") == 0) { + ret = do_ipaddr(argc-2, argv+2); + } #endif #ifdef CONFIG_FEATURE_IP_ROUTE - if (matches(argv[1], "route") == 0) - return do_iproute(argc-2, argv+2); + else if (matches(argv[1], "route") == 0) { + ret = do_iproute(argc-2, argv+2); + } #endif #ifdef CONFIG_FEATURE_IP_LINK - if (matches(argv[1], "link") == 0) - return do_iplink(argc-2, argv+2); + else if (matches(argv[1], "link") == 0) { + ret = do_iplink(argc-2, argv+2); + } #endif #ifdef CONFIG_FEATURE_IP_TUNNEL - if (matches(argv[1], "tunnel") == 0 || - strcmp(argv[1], "tunl") == 0) - return do_iptunnel(argc-2, argv+2); + else if (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) { + ret = do_iptunnel(argc-2, argv+2); + } #endif - fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv[1]); - exit(-1); } + if (ret) { + show_usage(); + } + return(EXIT_SUCCESS); } 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 @@ +/* + * ip.c "ip" utility frontend. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> + * + * + * Changes: + * + * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses + */ + +#include "./libiproute/utils.h" +#include "./libiproute/ip_common.h" + +#include "busybox.h" + +int ipaddr_main(int argc, char **argv) +{ + ip_parse_common_args(&argc, &argv); + + return do_ipaddr(argc-1, argv+1); +} 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 @@ +/* + * ip.c "ip" utility frontend. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> + * + * + * Changes: + * + * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses + */ + +#include "./libiproute/utils.h" +#include "./libiproute/ip_common.h" + +#include "busybox.h" + +int iplink_main(int argc, char **argv) +{ + ip_parse_common_args(&argc, &argv); + + return do_iplink(argc-1, argv+1); +} 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 @@ +/* + * ip.c "ip" utility frontend. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> + * + * + * Changes: + * + * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses + */ + +#include "./libiproute/utils.h" +#include "./libiproute/ip_common.h" + +#include "busybox.h" + +int iproute_main(int argc, char **argv) +{ + ip_parse_common_args(&argc, &argv); + + return do_iproute(argc-1, argv+1); +} 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 @@ +/* + * ip.c "ip" utility frontend. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> + * + * + * Changes: + * + * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses + */ + +#include "./libiproute/utils.h" +#include "./libiproute/ip_common.h" + +#include "busybox.h" + +int iptunnel_main(int argc, char **argv) +{ + ip_parse_common_args(&argc, &argv); + + return do_iptunnel(argc-1, argv+1); +} 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/ endif LIBIPROUTE-$(CONFIG_IP) += \ + ip_parse_common_args.o \ ipaddress.o \ iplink.o \ 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 @@ +extern int preferred_family; +extern char * _SL_; + +extern void ip_parse_common_args(int *argcp, char ***argvp); extern int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); extern int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); extern 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 @@ +/* + * ip.c "ip" utility frontend. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> + * + * + * Changes: + * + * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses + */ + +#include "utils.h" +#include "ip_common.h" + +#include "busybox.h" + +int preferred_family = AF_UNSPEC; +int oneline = 0; +char * _SL_ = NULL; + +void ip_parse_common_args(int *argcp, char ***argvp) +{ + int argc = *argcp; + char **argv = *argvp; + + while (argc > 1) { + char *opt = argv[1]; + + if (strcmp(opt,"--") == 0) { + argc--; argv++; + break; + } + + if (opt[0] != '-') + break; + + if (opt[1] == '-') + opt++; + + if (matches(opt, "-family") == 0) { + argc--; + argv++; + if (strcmp(argv[1], "inet") == 0) + preferred_family = AF_INET; + else if (strcmp(argv[1], "inet6") == 0) + preferred_family = AF_INET6; + else if (strcmp(argv[1], "link") == 0) + preferred_family = AF_PACKET; + else + invarg(argv[1], "invalid protocol family"); + } else if (strcmp(opt, "-4") == 0) { + preferred_family = AF_INET; + } else if (strcmp(opt, "-6") == 0) { + preferred_family = AF_INET6; + } else if (strcmp(opt, "-0") == 0) { + preferred_family = AF_PACKET; + } else if (matches(opt, "-oneline") == 0) { + ++oneline; + } else { + show_usage(); + } + argc--; argv++; + } + _SL_ = oneline ? "\\" : "\n" ; +} 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) if ((filter.flags^ifa->ifa_flags)&filter.flagmask) return 0; if (filter.label) { - SPRINT_BUF(b1); const char *label; if (rta_tb[IFA_LABEL]) label = RTA_DATA(rta_tb[IFA_LABEL]); @@ -541,10 +540,10 @@ int ipaddr_list_link(int argc, char **argv) return ipaddr_list(argc, argv); } -void ipaddr_reset_filter(int oneline) +void ipaddr_reset_filter(int _oneline) { memset(&filter, 0, sizeof(filter)); - filter.oneline = oneline; + filter.oneline = _oneline; } int default_scope(inet_prefix *lcl) |