diff options
Diffstat (limited to 'networking/libiproute')
-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 |
4 files changed, 77 insertions, 3 deletions
diff --git a/networking/libiproute/Makefile.in b/networking/libiproute/Makefile.in index 6d35d7b..9fe1462 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 5ac4321..771ca48 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 0000000..550d1dd --- /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 dd5a914..055aadf 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) |