summaryrefslogtreecommitdiff
path: root/networking/ip.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/ip.c')
-rw-r--r--networking/ip.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/networking/ip.c b/networking/ip.c
index 3ea1b62..182813d 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -24,57 +24,50 @@
|| ENABLE_FEATURE_IP_TUNNEL \
|| ENABLE_FEATURE_IP_RULE
-static int ATTRIBUTE_NORETURN ip_print_help(int ATTRIBUTE_UNUSED ac, char ATTRIBUTE_UNUSED **av)
+static int ATTRIBUTE_NORETURN ip_print_help(char ATTRIBUTE_UNUSED **argv)
{
bb_show_usage();
}
-static int (*ip_func)(int argc, char **argv) = ip_print_help;
-
-static int ip_do(int argc, char **argv)
+static int ip_do(int (*ip_func)(char **argv), char **argv)
{
- ip_parse_common_args(&argc, &argv);
- return ip_func(argc-1, argv+1);
+ argv = ip_parse_common_args(argv);
+ return ip_func(argv);
}
#if ENABLE_FEATURE_IP_ADDRESS
int ipaddr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ipaddr_main(int argc, char **argv)
{
- ip_func = do_ipaddr;
- return ip_do(argc, argv);
+ return ip_do(do_ipaddr, argv);
}
#endif
#if ENABLE_FEATURE_IP_LINK
int iplink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iplink_main(int argc, char **argv)
{
- ip_func = do_iplink;
- return ip_do(argc, argv);
+ return ip_do(do_iplink, argv);
}
#endif
#if ENABLE_FEATURE_IP_ROUTE
int iproute_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iproute_main(int argc, char **argv)
{
- ip_func = do_iproute;
- return ip_do(argc, argv);
+ return ip_do(do_iproute, argv);
}
#endif
#if ENABLE_FEATURE_IP_RULE
int iprule_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iprule_main(int argc, char **argv)
{
- ip_func = do_iprule;
- return ip_do(argc, argv);
+ return ip_do(do_iprule, argv);
}
#endif
#if ENABLE_FEATURE_IP_TUNNEL
int iptunnel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int iptunnel_main(int argc, char **argv)
{
- ip_func = do_iptunnel;
- return ip_do(argc, argv);
+ return ip_do(do_iptunnel, argv);
}
#endif
@@ -97,12 +90,12 @@ int ip_main(int argc, char **argv)
USE_FEATURE_IP_RULE(IP_rule,)
IP_none
};
+ int (*ip_func)(char **argv) = ip_print_help;
- ip_parse_common_args(&argc, &argv);
- if (argc > 1) {
- int key = index_in_substrings(keywords, argv[1]);
- argc -= 2;
- argv += 2;
+ argv = ip_parse_common_args(argv + 1);
+ if (*argv) {
+ int key = index_in_substrings(keywords, *argv);
+ argv++;
#if ENABLE_FEATURE_IP_ADDRESS
if (key == IP_addr)
ip_func = do_ipaddr;
@@ -124,7 +117,7 @@ int ip_main(int argc, char **argv)
ip_func = do_iprule;
#endif
}
- return ip_func(argc, argv);
+ return ip_func(argv);
}
#endif /* any of ENABLE_FEATURE_IP_xxx is 1 */