From 07c394e69b0cfa7cd30e97ffc6edb0d857905f45 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Tue, 10 Apr 2007 20:11:12 +0000 Subject: - mv ip*_main into ip.c; use a dispatcher to save on needless duplication. Saves a minor 12b. --- networking/Kbuild | 5 ----- networking/ip.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++- networking/ipaddr.c | 26 -------------------------- networking/iplink.c | 26 -------------------------- networking/iproute.c | 26 -------------------------- networking/iprule.c | 26 -------------------------- networking/iptunnel.c | 26 -------------------------- 7 files changed, 51 insertions(+), 136 deletions(-) delete mode 100644 networking/ipaddr.c delete mode 100644 networking/iplink.c delete mode 100644 networking/iproute.c delete mode 100644 networking/iprule.c delete mode 100644 networking/iptunnel.c diff --git a/networking/Kbuild b/networking/Kbuild index 68d36132d..13b4452bd 100644 --- a/networking/Kbuild +++ b/networking/Kbuild @@ -19,11 +19,6 @@ lib-$(CONFIG_IFUPDOWN) += ifupdown.o lib-$(CONFIG_INETD) += inetd.o lib-$(CONFIG_IP) += ip.o lib-$(CONFIG_IPCALC) += ipcalc.o -lib-$(CONFIG_IPADDR) += ipaddr.o -lib-$(CONFIG_IPLINK) += iplink.o -lib-$(CONFIG_IPROUTE) += iproute.o -lib-$(CONFIG_IPRULE) += iprule.o -lib-$(CONFIG_IPTUNNEL) += iptunnel.o lib-$(CONFIG_NAMEIF) += nameif.o lib-$(CONFIG_NC) += nc.o lib-$(CONFIG_NETSTAT) += netstat.o diff --git a/networking/ip.c b/networking/ip.c index dc9ca1f91..dd1d863da 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -22,6 +22,57 @@ static int ATTRIBUTE_NORETURN ip_print_help(int ATTRIBUTE_UNUSED ac, char ATTRIB { bb_show_usage(); } + +static int (*ip_func)(int argc, char **argv) = ip_print_help; + +static int ip_do(int argc, char **argv) +{ + ip_parse_common_args(&argc, &argv); + return ip_func(argc-1, argv+1); +} + +#if ENABLE_FEATURE_IP_ADDRESS +int ipaddr_main(int argc, char **argv); +int ipaddr_main(int argc, char **argv) +{ + ip_func = do_ipaddr; + return ip_do(argc, argv); +} +#endif +#if ENABLE_FEATURE_IP_LINK +int iplink_main(int argc, char **argv); +int iplink_main(int argc, char **argv) +{ + ip_func = do_iplink; + return ip_do(argc, argv); +} +#endif +#if ENABLE_FEATURE_IP_ROUTE +int iproute_main(int argc, char **argv); +int iproute_main(int argc, char **argv) +{ + ip_func = do_iproute; + return ip_do(argc, argv); +} +#endif +#if ENABLE_FEATURE_IP_RULE +int iprule_main(int argc, char **argv); +int iprule_main(int argc, char **argv) +{ + ip_func = do_iprule; + return ip_do(argc, argv); +} +#endif +#if ENABLE_FEATURE_IP_TUNNEL +int iptunnel_main(int argc, char **argv); +int iptunnel_main(int argc, char **argv) +{ + ip_func = do_iptunnel; + return ip_do(argc, argv); +} +#endif + + int ip_main(int argc, char **argv); int ip_main(int argc, char **argv) { @@ -41,7 +92,6 @@ int ip_main(int argc, char **argv) USE_FEATURE_IP_RULE(IP_rule,) IP_none }; - int (*ip_func)(int argc, char **argv) = ip_print_help; ip_parse_common_args(&argc, &argv); if (argc > 1) { diff --git a/networking/ipaddr.c b/networking/ipaddr.c deleted file mode 100644 index fb0213702..000000000 --- a/networking/ipaddr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * ip.c "ip" utility frontend. - * - * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. - * - * Authors: Alexey Kuznetsov, - * - * - * Changes: - * - * Rani Assaf 980929: resolve addresses - */ - -#include "libiproute/utils.h" -#include "libiproute/ip_common.h" - -#include "busybox.h" - -int ipaddr_main(int argc, char **argv); -int ipaddr_main(int argc, char **argv) -{ - ip_parse_common_args(&argc, &argv); - - return do_ipaddr(argc-1, argv+1); -} diff --git a/networking/iplink.c b/networking/iplink.c deleted file mode 100644 index 54087e927..000000000 --- a/networking/iplink.c +++ /dev/null @@ -1,26 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * ip.c "ip" utility frontend. - * - * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. - * - * Authors: Alexey Kuznetsov, - * - * - * Changes: - * - * Rani Assaf 980929: resolve addresses - */ - -#include "libiproute/utils.h" -#include "libiproute/ip_common.h" - -#include "busybox.h" - -int iplink_main(int argc, char **argv); -int iplink_main(int argc, char **argv) -{ - ip_parse_common_args(&argc, &argv); - - return do_iplink(argc-1, argv+1); -} diff --git a/networking/iproute.c b/networking/iproute.c deleted file mode 100644 index 3d540b2ba..000000000 --- a/networking/iproute.c +++ /dev/null @@ -1,26 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * ip.c "ip" utility frontend. - * - * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. - * - * Authors: Alexey Kuznetsov, - * - * - * Changes: - * - * Rani Assaf 980929: resolve addresses - */ - -#include "libiproute/utils.h" -#include "libiproute/ip_common.h" - -#include "busybox.h" - -int iproute_main(int argc, char **argv); -int iproute_main(int argc, char **argv) -{ - ip_parse_common_args(&argc, &argv); - - return do_iproute(argc-1, argv+1); -} diff --git a/networking/iprule.c b/networking/iprule.c deleted file mode 100644 index 9c1fb50de..000000000 --- a/networking/iprule.c +++ /dev/null @@ -1,26 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * ip.c "ip" utility frontend. - * - * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. - * - * Authors: Alexey Kuznetsov, - * - * - * Changes: - * - * Rani Assaf 980929: resolve addresses - */ - -#include "libiproute/utils.h" -#include "libiproute/ip_common.h" - -#include "busybox.h" - -int iprule_main(int argc, char **argv); -int iprule_main(int argc, char **argv) -{ - ip_parse_common_args(&argc, &argv); - - return do_iprule(argc-1, argv+1); -} diff --git a/networking/iptunnel.c b/networking/iptunnel.c deleted file mode 100644 index 8a65413b6..000000000 --- a/networking/iptunnel.c +++ /dev/null @@ -1,26 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * ip.c "ip" utility frontend. - * - * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. - * - * Authors: Alexey Kuznetsov, - * - * - * Changes: - * - * Rani Assaf 980929: resolve addresses - */ - -#include "libiproute/utils.h" -#include "libiproute/ip_common.h" - -#include "busybox.h" - -int iptunnel_main(int argc, char **argv); -int iptunnel_main(int argc, char **argv) -{ - ip_parse_common_args(&argc, &argv); - - return do_iptunnel(argc-1, argv+1); -} -- cgit v1.2.3