blob: 0f52b19dd6371803020babc5866275a00e38fd5e [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00002/*
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02003 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00004 *
Denys Vlasenkoe0a62202010-07-24 23:26:58 +02005 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00006 *
7 * Changes:
Denys Vlasenkofb132e42010-10-29 11:46:52 +02008 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
Bernhard Reutner-Fischer6c4dade2008-09-25 12:13:34 +00009 * Bernhard Reutner-Fischer rewrote to use index_in_substr_array
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000010 */
Denys Vlasenko47367e12016-11-23 09:05:14 +010011//config:config IP
12//config: bool "ip"
13//config: default y
14//config: select PLATFORM_LINUX
15//config: help
16//config: The "ip" applet is a TCP/IP interface configuration and routing
17//config: utility. You generally don't need "ip" to use busybox with
18//config: TCP/IP.
19//config:
Denys Vlasenko7c5dea32016-12-22 22:30:13 +010020//config:config IPADDR
21//config: bool "ipaddr"
22//config: default y
23//config: select FEATURE_IP_ADDRESS
24//config: select PLATFORM_LINUX
25//config: help
26//config: Support short form of ip addr: ipaddr
27//config:
28//config:config IPLINK
29//config: bool "iplink"
30//config: default y
31//config: select FEATURE_IP_LINK
32//config: select PLATFORM_LINUX
33//config: help
34//config: Support short form of ip link: iplink
35//config:
36//config:config IPROUTE
37//config: bool "iproute"
38//config: default y
39//config: select FEATURE_IP_ROUTE
40//config: select PLATFORM_LINUX
41//config: help
42//config: Support short form of ip route: iproute
43//config:
44//config:config IPTUNNEL
45//config: bool "iptunnel"
46//config: default y
47//config: select FEATURE_IP_TUNNEL
48//config: select PLATFORM_LINUX
49//config: help
50//config: Support short form of ip tunnel: iptunnel
51//config:
52//config:config IPRULE
53//config: bool "iprule"
54//config: default y
55//config: select FEATURE_IP_RULE
56//config: select PLATFORM_LINUX
57//config: help
58//config: Support short form of ip rule: iprule
59//config:
60//config:config IPNEIGH
61//config: bool "ipneigh"
62//config: default y
63//config: select FEATURE_IP_NEIGH
64//config: select PLATFORM_LINUX
65//config: help
66//config: Support short form of ip neigh: ipneigh
67//config:
Denys Vlasenko47367e12016-11-23 09:05:14 +010068//config:config FEATURE_IP_ADDRESS
69//config: bool "ip address"
70//config: default y
Denys Vlasenko7c5dea32016-12-22 22:30:13 +010071//config: depends on IP || IPADDR
Denys Vlasenko47367e12016-11-23 09:05:14 +010072//config: help
73//config: Address manipulation support for the "ip" applet.
74//config:
75//config:config FEATURE_IP_LINK
76//config: bool "ip link"
77//config: default y
Denys Vlasenko7c5dea32016-12-22 22:30:13 +010078//config: depends on IP || IPLINK
Denys Vlasenko47367e12016-11-23 09:05:14 +010079//config: help
80//config: Configure network devices with "ip".
81//config:
82//config:config FEATURE_IP_ROUTE
83//config: bool "ip route"
84//config: default y
Denys Vlasenko7c5dea32016-12-22 22:30:13 +010085//config: depends on IP || IPROUTE
Denys Vlasenko47367e12016-11-23 09:05:14 +010086//config: help
87//config: Add support for routing table management to "ip".
88//config:
89//config:config FEATURE_IP_ROUTE_DIR
90//config: string "ip route configuration directory"
91//config: default "/etc/iproute2"
92//config: depends on FEATURE_IP_ROUTE
93//config: help
94//config: Location of the "ip" applet routing configuration.
95//config:
96//config:config FEATURE_IP_TUNNEL
97//config: bool "ip tunnel"
98//config: default y
Denys Vlasenko7c5dea32016-12-22 22:30:13 +010099//config: depends on IP || IPTUNNEL
Denys Vlasenko47367e12016-11-23 09:05:14 +0100100//config: help
101//config: Add support for tunneling commands to "ip".
102//config:
103//config:config FEATURE_IP_RULE
104//config: bool "ip rule"
105//config: default y
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100106//config: depends on IP || IPRULE
Denys Vlasenko47367e12016-11-23 09:05:14 +0100107//config: help
108//config: Add support for rule commands to "ip".
109//config:
110//config:config FEATURE_IP_NEIGH
111//config: bool "ip neighbor"
112//config: default y
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100113//config: depends on IP || IPNEIGH
Denys Vlasenko47367e12016-11-23 09:05:14 +0100114//config: help
115//config: Add support for neighbor commands to "ip".
116//config:
Denys Vlasenko47367e12016-11-23 09:05:14 +0100117//config:config FEATURE_IP_RARE_PROTOCOLS
118//config: bool "Support displaying rarely used link types"
119//config: default n
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100120//config: depends on IP || IPADDR || IPLINK || IPROUTE || IPTUNNEL || IPRULE || IPNEIGH
Denys Vlasenko47367e12016-11-23 09:05:14 +0100121//config: help
122//config: If you are not going to use links of type "frad", "econet",
123//config: "bif" etc, you probably don't need to enable this.
124//config: Ethernet, wireless, infrared, ppp/slip, ip tunnelling
125//config: link types are supported without this option selected.
Denys Vlasenko47367e12016-11-23 09:05:14 +0100126
Denys Vlasenko47367e12016-11-23 09:05:14 +0100127//applet:IF_IP(APPLET(ip, BB_DIR_SBIN, BB_SUID_DROP))
Denys Vlasenko47367e12016-11-23 09:05:14 +0100128//applet:IF_IPADDR(APPLET(ipaddr, BB_DIR_SBIN, BB_SUID_DROP))
129//applet:IF_IPLINK(APPLET(iplink, BB_DIR_SBIN, BB_SUID_DROP))
130//applet:IF_IPROUTE(APPLET(iproute, BB_DIR_SBIN, BB_SUID_DROP))
131//applet:IF_IPRULE(APPLET(iprule, BB_DIR_SBIN, BB_SUID_DROP))
132//applet:IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_SBIN, BB_SUID_DROP))
Denys Vlasenko6bfab0c2016-11-23 09:18:05 +0100133//applet:IF_IPNEIGH(APPLET(ipneigh, BB_DIR_SBIN, BB_SUID_DROP))
Denys Vlasenko47367e12016-11-23 09:05:14 +0100134
135//kbuild:lib-$(CONFIG_IP) += ip.o
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100136//kbuild:lib-$(CONFIG_IPADDR) += ip.o
137//kbuild:lib-$(CONFIG_IPLINK) += ip.o
138//kbuild:lib-$(CONFIG_IPROUTE) += ip.o
139//kbuild:lib-$(CONFIG_IPRULE) += ip.o
140//kbuild:lib-$(CONFIG_IPTUNNEL) += ip.o
141//kbuild:lib-$(CONFIG_IPNEIGH) += ip.o
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000142
Pere Orga5bc8c002011-04-11 03:29:49 +0200143//usage:#define ipaddr_trivial_usage
Denys Vlasenko12389882017-01-21 14:27:07 +0100144//usage: "add|del IFADDR dev IFACE | show|flush [dev IFACE] [to PREFIX]"
Pere Orga5bc8c002011-04-11 03:29:49 +0200145//usage:#define ipaddr_full_usage "\n\n"
Denys Vlasenko12389882017-01-21 14:27:07 +0100146//usage: "ipaddr add|change|replace|delete IFADDR dev IFACE\n"
147//usage: "ipaddr show|flush [dev IFACE] [scope SCOPE-ID]\n"
Denys Vlasenko8908c1d2017-01-21 03:56:46 +0100148//usage: " [to PREFIX] [label PATTERN]\n"
Pere Orga5bc8c002011-04-11 03:29:49 +0200149//usage: " IFADDR := PREFIX | ADDR peer PREFIX\n"
Denys Vlasenko8908c1d2017-01-21 03:56:46 +0100150//usage: " [broadcast ADDR] [anycast ADDR]\n"
151//usage: " [label STRING] [scope SCOPE-ID]\n"
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100152//usage: " SCOPE-ID := [host|link|global|NUMBER]"
Pere Orga5bc8c002011-04-11 03:29:49 +0200153//usage:
154//usage:#define iplink_trivial_usage
Denys Vlasenko12389882017-01-21 14:27:07 +0100155//usage: "set IFACE [up|down] [arp on|off] | show [IFACE]"
Pere Orga5bc8c002011-04-11 03:29:49 +0200156//usage:#define iplink_full_usage "\n\n"
Denys Vlasenko12389882017-01-21 14:27:07 +0100157//usage: "iplink set IFACE [up|down]\n"
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100158//usage: " [arp on|off]\n"
159//usage: " [dynamic on|off]\n"
160//usage: " [multicast on|off]\n"
161//usage: " [mtu MTU]\n"
Denys Vlasenko12389882017-01-21 14:27:07 +0100162//usage: "iplink show [IFACE]"
Pere Orga5bc8c002011-04-11 03:29:49 +0200163//usage:
164//usage:#define iproute_trivial_usage
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100165//usage: "list|flush|add|del|change|append|replace|test ROUTE"
Pere Orga5bc8c002011-04-11 03:29:49 +0200166//usage:#define iproute_full_usage "\n\n"
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100167//usage: "iproute list|flush SELECTOR\n"
Pere Orga5bc8c002011-04-11 03:29:49 +0200168//usage: "iproute get ADDRESS [from ADDRESS iif STRING]\n"
Denys Vlasenko53782d92011-12-06 18:59:55 +0100169//usage: " [oif STRING] [tos TOS]\n"
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100170//usage: "iproute add|del|change|append|replace|test ROUTE\n"
Denys Vlasenko53782d92011-12-06 18:59:55 +0100171//usage: " SELECTOR := [root PREFIX] [match PREFIX] [proto RTPROTO]\n"
172//usage: " ROUTE := [TYPE] PREFIX [tos TOS] [proto RTPROTO] [metric METRIC]"
Pere Orga5bc8c002011-04-11 03:29:49 +0200173//usage:
174//usage:#define iprule_trivial_usage
Denys Vlasenko12389882017-01-21 14:27:07 +0100175//usage: "[list] | add|del SELECTOR ACTION"
Pere Orga5bc8c002011-04-11 03:29:49 +0200176//usage:#define iprule_full_usage "\n\n"
Pere Orga5bc8c002011-04-11 03:29:49 +0200177//usage: " SELECTOR := [from PREFIX] [to PREFIX] [tos TOS] [fwmark FWMARK]\n"
Denys Vlasenko12389882017-01-21 14:27:07 +0100178//usage: " [dev IFACE] [pref NUMBER]\n"
Pere Orga5bc8c002011-04-11 03:29:49 +0200179//usage: " ACTION := [table TABLE_ID] [nat ADDRESS]\n"
Denys Vlasenko8908c1d2017-01-21 03:56:46 +0100180//usage: " [prohibit|reject|unreachable]\n"
Pere Orga5bc8c002011-04-11 03:29:49 +0200181//usage: " [realms [SRCREALM/]DSTREALM]\n"
Denys Vlasenko8908c1d2017-01-21 03:56:46 +0100182//usage: " TABLE_ID := [local|main|default|NUMBER]"
Pere Orga5bc8c002011-04-11 03:29:49 +0200183//usage:
184//usage:#define iptunnel_trivial_usage
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100185//usage: "add|change|del|show [NAME]\n"
186//usage: " [mode ipip|gre|sit]\n"
Pere Orga5bc8c002011-04-11 03:29:49 +0200187//usage: " [remote ADDR] [local ADDR] [ttl TTL]"
188//usage:#define iptunnel_full_usage "\n\n"
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100189//usage: "iptunnel add|change|del|show [NAME]\n"
190//usage: " [mode ipip|gre|sit] [remote ADDR] [local ADDR]\n"
Pere Orga5bc8c002011-04-11 03:29:49 +0200191//usage: " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n"
192//usage: " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]"
Curt Brune69934702015-10-14 12:53:47 +0200193//usage:
194//usage:#define ipneigh_trivial_usage
Denys Vlasenkof3d705f2017-01-21 03:46:35 +0100195//usage: "show|flush [to PREFIX] [dev DEV] [nud STATE]"
Denys Vlasenko12389882017-01-21 14:27:07 +0100196//usage:#define ipneigh_full_usage ""
197//usage:
198//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE
199//usage:# define IP_BAR_LINK "|"
200//usage:#else
201//usage:# define IP_BAR_LINK ""
202//usage:#endif
203//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE || ENABLE_FEATURE_IP_LINK
204//usage:# define IP_BAR_TUNNEL "|"
205//usage:#else
206//usage:# define IP_BAR_TUNNEL ""
207//usage:#endif
208//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE || ENABLE_FEATURE_IP_LINK || ENABLE_FEATURE_IP_TUNNEL
209//usage:# define IP_BAR_NEIGH "|"
210//usage:#else
211//usage:# define IP_BAR_NEIGH ""
212//usage:#endif
213//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE || ENABLE_FEATURE_IP_LINK || ENABLE_FEATURE_IP_TUNNEL || ENABLE_FEATURE_IP_NEIGH
214//usage:# define IP_BAR_RULE "|"
215//usage:#else
216//usage:# define IP_BAR_RULE ""
217//usage:#endif
218//usage:
219//usage:#define ip_trivial_usage
220//usage: "[OPTIONS] "
221//usage: IF_FEATURE_IP_ADDRESS("address")
222//usage: IF_FEATURE_IP_ROUTE( IF_FEATURE_IP_ADDRESS("|")"route")
223//usage: IF_FEATURE_IP_LINK( IP_BAR_LINK "link")
224//usage: IF_FEATURE_IP_TUNNEL( IP_BAR_TUNNEL"tunnel")
225//usage: IF_FEATURE_IP_NEIGH( IP_BAR_NEIGH "neigh")
226//usage: IF_FEATURE_IP_RULE( IP_BAR_RULE "rule")
227//usage: " [COMMAND]"
228//usage:#define ip_full_usage "\n\n"
229//usage: "OPTIONS := -f[amily] inet|inet6|link | -o[neline]\n"
230//usage: "COMMAND :="
231//usage: IF_FEATURE_IP_ADDRESS("\n"
232//usage: "ip addr "ipaddr_trivial_usage)
233//usage: IF_FEATURE_IP_ROUTE("\n"
234//usage: "ip route "iproute_trivial_usage)
235//usage: IF_FEATURE_IP_LINK("\n"
236//usage: "ip link "iplink_trivial_usage)
237//usage: IF_FEATURE_IP_TUNNEL("\n"
238//usage: "ip tunnel "iptunnel_trivial_usage)
239//usage: IF_FEATURE_IP_NEIGH("\n"
240//usage: "ip neigh "ipneigh_trivial_usage)
241//usage: IF_FEATURE_IP_RULE("\n"
242//usage: "ip rule "iprule_trivial_usage)
Pere Orga5bc8c002011-04-11 03:29:49 +0200243
Denis Vlasenkob6adbf12007-05-26 19:00:18 +0000244#include "libbb.h"
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000245
Bernhard Reutner-Fischerab187822005-10-26 10:47:26 +0000246#include "libiproute/utils.h"
247#include "libiproute/ip_common.h"
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000248
Denys Vlasenko2e9b5512010-07-24 23:27:38 +0200249typedef int FAST_FUNC (*ip_func_ptr_t)(char**);
Denys Vlasenkoe0a62202010-07-24 23:26:58 +0200250
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100251#if ENABLE_IPADDR \
252 || ENABLE_IPLINK \
253 || ENABLE_IPROUTE \
254 || ENABLE_IPRULE \
255 || ENABLE_IPTUNNEL \
256 || ENABLE_IPNEIGH
Denys Vlasenkoe0a62202010-07-24 23:26:58 +0200257static int ip_do(ip_func_ptr_t ip_func, char **argv)
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000258{
Denis Vlasenko3246c0d2008-12-04 12:15:19 +0000259 argv = ip_parse_common_args(argv + 1);
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000260 return ip_func(argv);
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000261}
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100262#endif
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000263
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100264#if ENABLE_IPADDR
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +0000265int ipaddr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000266int ipaddr_main(int argc UNUSED_PARAM, char **argv)
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000267{
Denis Vlasenko2570b2e2008-03-28 01:00:09 +0000268 return ip_do(do_ipaddr, argv);
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000269}
270#endif
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100271#if ENABLE_IPLINK
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +0000272int iplink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000273int iplink_main(int argc UNUSED_PARAM, char **argv)
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000274{
Denis Vlasenko2570b2e2008-03-28 01:00:09 +0000275 return ip_do(do_iplink, argv);
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000276}
277#endif
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100278#if ENABLE_IPROUTE
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +0000279int iproute_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000280int iproute_main(int argc UNUSED_PARAM, char **argv)
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000281{
Denis Vlasenko2570b2e2008-03-28 01:00:09 +0000282 return ip_do(do_iproute, argv);
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000283}
284#endif
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100285#if ENABLE_IPRULE
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +0000286int iprule_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000287int iprule_main(int argc UNUSED_PARAM, char **argv)
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000288{
Denis Vlasenko2570b2e2008-03-28 01:00:09 +0000289 return ip_do(do_iprule, argv);
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000290}
291#endif
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100292#if ENABLE_IPTUNNEL
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +0000293int iptunnel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000294int iptunnel_main(int argc UNUSED_PARAM, char **argv)
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000295{
Denis Vlasenko2570b2e2008-03-28 01:00:09 +0000296 return ip_do(do_iptunnel, argv);
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000297}
298#endif
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100299#if ENABLE_IPNEIGH
Curt Brune69934702015-10-14 12:53:47 +0200300int ipneigh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
301int ipneigh_main(int argc UNUSED_PARAM, char **argv)
302{
303 return ip_do(do_ipneigh, argv);
304}
305#endif
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000306
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100307#if ENABLE_IP
308static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM)
309{
310 bb_show_usage();
311}
Bernhard Reutner-Fischer07c394e2007-04-10 20:11:12 +0000312
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +0000313int ip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000314int ip_main(int argc UNUSED_PARAM, char **argv)
Glenn L McGrathf112daa2002-12-01 23:04:06 +0000315{
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100316 static const char keywords[] ALIGN1 = ""
Denis Vlasenko5e34ff22009-04-21 11:09:40 +0000317 IF_FEATURE_IP_ADDRESS("address\0")
318 IF_FEATURE_IP_ROUTE("route\0")
Denys Vlasenkoe0a62202010-07-24 23:26:58 +0200319 IF_FEATURE_IP_ROUTE("r\0")
Denis Vlasenko5e34ff22009-04-21 11:09:40 +0000320 IF_FEATURE_IP_LINK("link\0")
Denys Vlasenkoe0a62202010-07-24 23:26:58 +0200321 IF_FEATURE_IP_TUNNEL("tunnel\0")
322 IF_FEATURE_IP_TUNNEL("tunl\0")
Denis Vlasenko5e34ff22009-04-21 11:09:40 +0000323 IF_FEATURE_IP_RULE("rule\0")
Curt Brune69934702015-10-14 12:53:47 +0200324 IF_FEATURE_IP_NEIGH("neigh\0")
Denis Vlasenko990d0f62007-07-24 15:54:42 +0000325 ;
Denys Vlasenkoe0a62202010-07-24 23:26:58 +0200326 static const ip_func_ptr_t ip_func_ptrs[] = {
327 ip_print_help,
328 IF_FEATURE_IP_ADDRESS(do_ipaddr,)
329 IF_FEATURE_IP_ROUTE(do_iproute,)
330 IF_FEATURE_IP_ROUTE(do_iproute,)
331 IF_FEATURE_IP_LINK(do_iplink,)
332 IF_FEATURE_IP_TUNNEL(do_iptunnel,)
333 IF_FEATURE_IP_TUNNEL(do_iptunnel,)
334 IF_FEATURE_IP_RULE(do_iprule,)
Curt Brune69934702015-10-14 12:53:47 +0200335 IF_FEATURE_IP_NEIGH(do_ipneigh,)
Bernhard Reutner-Fischere87d7952007-04-10 18:43:27 +0000336 };
Denys Vlasenkoe0a62202010-07-24 23:26:58 +0200337 ip_func_ptr_t ip_func;
338 int key;
Bernhard Reutner-Fischere87d7952007-04-10 18:43:27 +0000339
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000340 argv = ip_parse_common_args(argv + 1);
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100341 if (ARRAY_SIZE(ip_func_ptrs) > 1 && *argv)
342 key = index_in_substrings(keywords, *argv++);
343 else
344 key = -1;
Denys Vlasenkoe0a62202010-07-24 23:26:58 +0200345 ip_func = ip_func_ptrs[key + 1];
346
Denis Vlasenkoed6a49c2007-11-18 22:56:25 +0000347 return ip_func(argv);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +0000348}
Denys Vlasenko7c5dea32016-12-22 22:30:13 +0100349#endif