diff options
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ip.c | 13 | ||||
-rw-r--r-- | networking/libiproute/ipaddress.c | 19 | ||||
-rw-r--r-- | networking/libiproute/iproute.c | 10 | ||||
-rw-r--r-- | networking/libiproute/utils.c | 5 |
4 files changed, 18 insertions, 29 deletions
diff --git a/networking/ip.c b/networking/ip.c index fe5714f..6363155 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -12,20 +12,11 @@ * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses */ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <syslog.h> -#include <fcntl.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <string.h> +#include "busybox.h" #include "libiproute/utils.h" #include "libiproute/ip_common.h" -#include "busybox.h" - int ip_main(int argc, char **argv) { int ret = EXIT_FAILURE; @@ -57,5 +48,5 @@ int ip_main(int argc, char **argv) if (ret) { bb_show_usage(); } - return(EXIT_SUCCESS); + return EXIT_SUCCESS; } diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index fdbe611..fc6cf7b 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -441,7 +441,7 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush) } while (argc > 0) { - const int option_num = compare_string_array(option, *argv); + const int option_num = index_in_str_array(option, *argv); switch (option_num) { case 0: /* to */ NEXT_ARG(); @@ -653,7 +653,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) req.ifa.ifa_family = preferred_family; while (argc > 0) { - const int option_num = compare_string_array(option, *argv); + const int option_num = index_in_str_array(option, *argv); switch (option_num) { case 0: /* peer */ case 1: /* remote */ @@ -800,25 +800,24 @@ static int ipaddr_modify(int cmd, int argc, char **argv) int do_ipaddr(int argc, char **argv) { static const char *const commands[] = { - "add", "del", "delete", "list", "show", "lst", "flush", 0 + "add", "delete", "list", "show", "lst", "flush", 0 }; int command_num = 2; if (*argv) { - command_num = compare_string_array(commands, *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: /* del */ - case 2: /* delete */ + case 1: /* delete */ return ipaddr_modify(RTM_DELADDR, argc-1, argv+1); - case 3: /* list */ - case 4: /* show */ - case 5: /* lst */ + case 2: /* list */ + case 3: /* show */ + case 4: /* lst */ return ipaddr_list_or_flush(argc-1, argv+1, 0); - case 6: /* flush */ + case 5: /* flush */ return ipaddr_list_or_flush(argc-1, argv+1, 1); } bb_error_msg_and_die("unknown command %s", *argv); diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 3b2a677..9c3b870 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -670,7 +670,7 @@ static int iproute_get(int argc, char **argv) req.r.rtm_tos = 0; while (argc > 0) { - switch (compare_string_array(options, *argv)) { + switch (index_in_str_array(options, *argv)) { case 0: /* from */ { inet_prefix addr; @@ -811,14 +811,16 @@ static int iproute_get(int argc, char **argv) int do_iproute(int argc, char **argv) { static const char * const ip_route_commands[] = - { "add", "append", "change", "chg", "delete", "del", "get", + { "add", "append", "change", "chg", "delete", "get", "list", "show", "prepend", "replace", "test", "flush", 0 }; - int command_num = 7; + int command_num = 6; unsigned int flags = 0; int cmd = RTM_NEWROUTE; + /* "Standard" 'ip r a' treats 'a' as 'add', not 'append' */ + /* It probably means that it is using "first match" rule */ if (*argv) { - command_num = compare_string_array(ip_route_commands, *argv); + command_num = index_in_substr_array(ip_route_commands, *argv); } switch (command_num) { case 0: /* add*/ diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 552f4bf..f92179c 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c @@ -263,10 +263,7 @@ int matches(char *cmd, char *pattern) { int len = strlen(cmd); - if (len > strlen(pattern)) { - return -1; - } - return memcmp(pattern, cmd, len); + return strncmp(pattern, cmd, len); } int inet_addr_match(inet_prefix * a, inet_prefix * b, int bits) |