summaryrefslogtreecommitdiff
path: root/networking/libiproute
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-12-01 23:04:06 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-12-01 23:04:06 +0000
commitf112daa232122dd114933d04a9e415cfc61f1717 (patch)
tree1e52823545fb3e20f89205fd6224017e19586c72 /networking/libiproute
parentf3faf41334fab96d20854c2b4c1acab022c98028 (diff)
downloadbusybox-w32-f112daa232122dd114933d04a9e415cfc61f1717.tar.gz
busybox-w32-f112daa232122dd114933d04a9e415cfc61f1717.tar.bz2
busybox-w32-f112daa232122dd114933d04a9e415cfc61f1717.zip
Enable ip commands to be compiled seperate from ip, modifed patch from Bastian Blank
Diffstat (limited to 'networking/libiproute')
-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
4 files changed, 77 insertions, 3 deletions
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)