aboutsummaryrefslogtreecommitdiff
path: root/networking/ip.c
diff options
context:
space:
mode:
authorCurt Brune <curt@cumulusnetworks.com>2015-10-14 12:53:47 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-14 12:53:47 +0200
commit69934701fd1b18327b3a779cb292a728834b2d0d (patch)
treecdae967517ee981a7e7f07bddfec7047c1f51221 /networking/ip.c
parent7b85ec30b5941f0b90c48a990f2f6840aca87bce (diff)
downloadbusybox-w32-69934701fd1b18327b3a779cb292a728834b2d0d.tar.gz
busybox-w32-69934701fd1b18327b3a779cb292a728834b2d0d.tar.bz2
busybox-w32-69934701fd1b18327b3a779cb292a728834b2d0d.zip
networking: add 'ip neigh' command
This patch ports the 'ip neigh' command, originally written by Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>, 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 <curt@cumulusnetworks.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ip.c')
-rw-r--r--networking/ip.c19
1 files changed, 18 insertions, 1 deletions
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 @@
16//usage: IF_FEATURE_IP_ROUTE("route | ") 16//usage: IF_FEATURE_IP_ROUTE("route | ")
17//usage: IF_FEATURE_IP_LINK("link | ") 17//usage: IF_FEATURE_IP_LINK("link | ")
18//usage: IF_FEATURE_IP_TUNNEL("tunnel | ") 18//usage: IF_FEATURE_IP_TUNNEL("tunnel | ")
19//usage: IF_FEATURE_IP_NEIGH("neigh | ")
19//usage: IF_FEATURE_IP_RULE("rule") 20//usage: IF_FEATURE_IP_RULE("rule")
20//usage: "} {COMMAND}" 21//usage: "} {COMMAND}"
21//usage:#define ip_full_usage "\n\n" 22//usage:#define ip_full_usage "\n\n"
@@ -25,6 +26,7 @@
25//usage: IF_FEATURE_IP_ROUTE("route | ") 26//usage: IF_FEATURE_IP_ROUTE("route | ")
26//usage: IF_FEATURE_IP_LINK("link | ") 27//usage: IF_FEATURE_IP_LINK("link | ")
27//usage: IF_FEATURE_IP_TUNNEL("tunnel | ") 28//usage: IF_FEATURE_IP_TUNNEL("tunnel | ")
29//usage: IF_FEATURE_IP_NEIGH("neigh | ")
28//usage: IF_FEATURE_IP_RULE("rule") 30//usage: IF_FEATURE_IP_RULE("rule")
29//usage: "}\n" 31//usage: "}\n"
30//usage: "OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }" 32//usage: "OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }"
@@ -80,6 +82,11 @@
80//usage: " [mode { ipip | gre | sit }] [remote ADDR] [local ADDR]\n" 82//usage: " [mode { ipip | gre | sit }] [remote ADDR] [local ADDR]\n"
81//usage: " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n" 83//usage: " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n"
82//usage: " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]" 84//usage: " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]"
85//usage:
86//usage:#define ipneigh_trivial_usage
87//usage: "{ show | flush} [ to PREFIX ] [ dev DEV ] [ nud STATE ]"
88//usage:#define ipneigh_full_usage "\n\n"
89//usage: "ipneigh { show | flush} [ to PREFIX ] [ dev DEV ] [ nud STATE ]"
83 90
84#include "libbb.h" 91#include "libbb.h"
85 92
@@ -90,7 +97,8 @@
90 || ENABLE_FEATURE_IP_ROUTE \ 97 || ENABLE_FEATURE_IP_ROUTE \
91 || ENABLE_FEATURE_IP_LINK \ 98 || ENABLE_FEATURE_IP_LINK \
92 || ENABLE_FEATURE_IP_TUNNEL \ 99 || ENABLE_FEATURE_IP_TUNNEL \
93 || ENABLE_FEATURE_IP_RULE 100 || ENABLE_FEATURE_IP_RULE \
101 || ENABLE_FEATURE_IP_NEIGH
94 102
95static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM) 103static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM)
96{ 104{
@@ -140,6 +148,13 @@ int iptunnel_main(int argc UNUSED_PARAM, char **argv)
140 return ip_do(do_iptunnel, argv); 148 return ip_do(do_iptunnel, argv);
141} 149}
142#endif 150#endif
151#if ENABLE_FEATURE_IP_NEIGH
152int ipneigh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
153int ipneigh_main(int argc UNUSED_PARAM, char **argv)
154{
155 return ip_do(do_ipneigh, argv);
156}
157#endif
143 158
144 159
145int ip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 160int ip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -153,6 +168,7 @@ int ip_main(int argc UNUSED_PARAM, char **argv)
153 IF_FEATURE_IP_TUNNEL("tunnel\0") 168 IF_FEATURE_IP_TUNNEL("tunnel\0")
154 IF_FEATURE_IP_TUNNEL("tunl\0") 169 IF_FEATURE_IP_TUNNEL("tunl\0")
155 IF_FEATURE_IP_RULE("rule\0") 170 IF_FEATURE_IP_RULE("rule\0")
171 IF_FEATURE_IP_NEIGH("neigh\0")
156 ; 172 ;
157 static const ip_func_ptr_t ip_func_ptrs[] = { 173 static const ip_func_ptr_t ip_func_ptrs[] = {
158 ip_print_help, 174 ip_print_help,
@@ -163,6 +179,7 @@ int ip_main(int argc UNUSED_PARAM, char **argv)
163 IF_FEATURE_IP_TUNNEL(do_iptunnel,) 179 IF_FEATURE_IP_TUNNEL(do_iptunnel,)
164 IF_FEATURE_IP_TUNNEL(do_iptunnel,) 180 IF_FEATURE_IP_TUNNEL(do_iptunnel,)
165 IF_FEATURE_IP_RULE(do_iprule,) 181 IF_FEATURE_IP_RULE(do_iprule,)
182 IF_FEATURE_IP_NEIGH(do_ipneigh,)
166 }; 183 };
167 ip_func_ptr_t ip_func; 184 ip_func_ptr_t ip_func;
168 int key; 185 int key;