From 69934701fd1b18327b3a779cb292a728834b2d0d Mon Sep 17 00:00:00 2001 From: Curt Brune Date: Wed, 14 Oct 2015 12:53:47 +0200 Subject: networking: add 'ip neigh' command This patch ports the 'ip neigh' command, originally written by Alexey Kuznetsov, , to busybox. The base of the port is the version of iproute that shipped with Debian Squeeze, taken from: http://http.debian.net/debian/pool/main/i/iproute/iproute_20100519.orig.tar.gz This patch has actively been used by the Open Network Install Environment (ONIE) project for over 3 years without incident. function old new delta print_neigh - 933 +933 ipneigh_list_or_flush - 742 +742 get_hz - 109 +109 do_ipneigh - 62 +62 do_iproute 2112 2153 +41 packed_usage 30647 30667 +20 ipneigh_main - 14 +14 static.ip_neigh_commands - 12 +12 static.nuds - 9 +9 static.ip_func_ptrs 32 36 +4 print_route 1858 1727 -131 ------------------------------------------------------------------------------ (add/remove: 8/0 grow/shrink: 3/1 up/down: 1946/-131) Total: 1815 bytes Signed-off-by: Curt Brune Signed-off-by: Denys Vlasenko --- networking/ip.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'networking/ip.c') diff --git a/networking/ip.c b/networking/ip.c index d35345c36..ddfe74e9c 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -16,6 +16,7 @@ //usage: IF_FEATURE_IP_ROUTE("route | ") //usage: IF_FEATURE_IP_LINK("link | ") //usage: IF_FEATURE_IP_TUNNEL("tunnel | ") +//usage: IF_FEATURE_IP_NEIGH("neigh | ") //usage: IF_FEATURE_IP_RULE("rule") //usage: "} {COMMAND}" //usage:#define ip_full_usage "\n\n" @@ -25,6 +26,7 @@ //usage: IF_FEATURE_IP_ROUTE("route | ") //usage: IF_FEATURE_IP_LINK("link | ") //usage: IF_FEATURE_IP_TUNNEL("tunnel | ") +//usage: IF_FEATURE_IP_NEIGH("neigh | ") //usage: IF_FEATURE_IP_RULE("rule") //usage: "}\n" //usage: "OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }" @@ -80,6 +82,11 @@ //usage: " [mode { ipip | gre | sit }] [remote ADDR] [local ADDR]\n" //usage: " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n" //usage: " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]" +//usage: +//usage:#define ipneigh_trivial_usage +//usage: "{ show | flush} [ to PREFIX ] [ dev DEV ] [ nud STATE ]" +//usage:#define ipneigh_full_usage "\n\n" +//usage: "ipneigh { show | flush} [ to PREFIX ] [ dev DEV ] [ nud STATE ]" #include "libbb.h" @@ -90,7 +97,8 @@ || ENABLE_FEATURE_IP_ROUTE \ || ENABLE_FEATURE_IP_LINK \ || ENABLE_FEATURE_IP_TUNNEL \ - || ENABLE_FEATURE_IP_RULE + || ENABLE_FEATURE_IP_RULE \ + || ENABLE_FEATURE_IP_NEIGH static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM) { @@ -140,6 +148,13 @@ int iptunnel_main(int argc UNUSED_PARAM, char **argv) return ip_do(do_iptunnel, argv); } #endif +#if ENABLE_FEATURE_IP_NEIGH +int ipneigh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int ipneigh_main(int argc UNUSED_PARAM, char **argv) +{ + return ip_do(do_ipneigh, argv); +} +#endif int ip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; @@ -153,6 +168,7 @@ int ip_main(int argc UNUSED_PARAM, char **argv) IF_FEATURE_IP_TUNNEL("tunnel\0") IF_FEATURE_IP_TUNNEL("tunl\0") IF_FEATURE_IP_RULE("rule\0") + IF_FEATURE_IP_NEIGH("neigh\0") ; static const ip_func_ptr_t ip_func_ptrs[] = { ip_print_help, @@ -163,6 +179,7 @@ int ip_main(int argc UNUSED_PARAM, char **argv) IF_FEATURE_IP_TUNNEL(do_iptunnel,) IF_FEATURE_IP_TUNNEL(do_iptunnel,) IF_FEATURE_IP_RULE(do_iprule,) + IF_FEATURE_IP_NEIGH(do_ipneigh,) }; ip_func_ptr_t ip_func; int key; -- cgit v1.2.3