aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/ipaddress.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2007-06-20 14:53:49 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2007-06-20 14:53:49 +0000
commitcd0e80ce902f6e79b31888af4ff4545846ce1c0e (patch)
tree629489f5c5615a4949eb54ac93c6387e55710133 /networking/libiproute/ipaddress.c
parent75103841072d71603b49ad00648e204ffcca589d (diff)
downloadbusybox-cd0e80ce902f6e79b31888af4ff4545846ce1c0e.tar.gz
- move iprule and ipaddress from matches() to index_in_str_array
text data bss dec hex filename 2544 0 0 2544 9f0 networking/libiproute/iprule.o.oorig 2356 0 0 2356 934 networking/libiproute/iprule.o 6481 0 0 6481 1951 networking/libiproute/ipaddress.o.oorig 6464 0 0 6464 1940 networking/libiproute/ipaddress.o
Diffstat (limited to 'networking/libiproute/ipaddress.c')
-rw-r--r--networking/libiproute/ipaddress.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index e504862a9..a4add6a47 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -604,7 +604,6 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
"peer", "remote", "broadcast", "brd",
"anycast", "scope", "dev", "label", "local", 0
};
-
struct rtnl_handle rth;
struct {
struct nlmsghdr n;
@@ -619,7 +618,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
int peer_len = 0;
int brd_len = 0;
int any_len = 0;
- int scoped = 0;
+ bool scoped = 0;
memset(&req, 0, sizeof(req));
@@ -724,7 +723,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
bb_error_msg(bb_msg_requires_arg,"\"dev\"");
return -1;
}
- if (l && matches(d, l) != 0) {
+ if (l && strncmp(d, l, strlen(d)) != 0) {
bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l);
}
@@ -775,22 +774,21 @@ int do_ipaddr(int argc, char **argv)
"add", "delete", "list", "show", "lst", "flush", 0
};
- int command_num = 2;
+ int command_num = 2; /* default command is list */
if (*argv) {
command_num = index_in_substr_array(commands, *argv);
}
- switch (command_num) {
- case 0: /* add */
- return ipaddr_modify(RTM_NEWADDR, argc-1, argv+1);
- case 1: /* delete */
- return ipaddr_modify(RTM_DELADDR, argc-1, argv+1);
- case 2: /* list */
- case 3: /* show */
- case 4: /* lst */
- return ipaddr_list_or_flush(argc-1, argv+1, 0);
- case 5: /* flush */
- return ipaddr_list_or_flush(argc-1, argv+1, 1);
- }
- bb_error_msg_and_die("unknown command %s", *argv);
+ if (command_num < 0 || command_num > 5)
+ bb_error_msg_and_die("unknown command %s", *argv);
+ --argc;
+ ++argv;
+ if (command_num == 0) /* add */
+ return ipaddr_modify(RTM_NEWADDR, argc, argv);
+ else if (command_num == 1) /* delete */
+ return ipaddr_modify(RTM_DELADDR, argc, argv);
+ else if (command_num == 5) /* flush */
+ return ipaddr_list_or_flush(argc, argv, 1);
+ else /* 2 == list, 3 == show, 4 == lst */
+ return ipaddr_list_or_flush(argc, argv, 0);
}