2006-07-03 01:17:05 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
2002-11-10 07:03:55 +05:30
|
|
|
/*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2002-11-10 07:03:55 +05:30
|
|
|
*
|
2010-07-25 02:56:58 +05:30
|
|
|
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
2002-11-10 07:03:55 +05:30
|
|
|
*
|
|
|
|
* Changes:
|
2010-10-29 15:16:52 +05:30
|
|
|
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
|
2008-09-25 17:43:34 +05:30
|
|
|
* Bernhard Reutner-Fischer rewrote to use index_in_substr_array
|
2002-11-10 07:03:55 +05:30
|
|
|
*/
|
2016-11-23 13:35:14 +05:30
|
|
|
//config:config IP
|
|
|
|
//config: bool "ip"
|
|
|
|
//config: default y
|
|
|
|
//config: select PLATFORM_LINUX
|
|
|
|
//config: help
|
|
|
|
//config: The "ip" applet is a TCP/IP interface configuration and routing
|
|
|
|
//config: utility. You generally don't need "ip" to use busybox with
|
|
|
|
//config: TCP/IP.
|
|
|
|
//config:
|
2016-12-23 03:00:13 +05:30
|
|
|
//config:config IPADDR
|
|
|
|
//config: bool "ipaddr"
|
|
|
|
//config: default y
|
|
|
|
//config: select FEATURE_IP_ADDRESS
|
|
|
|
//config: select PLATFORM_LINUX
|
|
|
|
//config: help
|
|
|
|
//config: Support short form of ip addr: ipaddr
|
|
|
|
//config:
|
|
|
|
//config:config IPLINK
|
|
|
|
//config: bool "iplink"
|
|
|
|
//config: default y
|
|
|
|
//config: select FEATURE_IP_LINK
|
|
|
|
//config: select PLATFORM_LINUX
|
|
|
|
//config: help
|
|
|
|
//config: Support short form of ip link: iplink
|
|
|
|
//config:
|
|
|
|
//config:config IPROUTE
|
|
|
|
//config: bool "iproute"
|
|
|
|
//config: default y
|
|
|
|
//config: select FEATURE_IP_ROUTE
|
|
|
|
//config: select PLATFORM_LINUX
|
|
|
|
//config: help
|
|
|
|
//config: Support short form of ip route: iproute
|
|
|
|
//config:
|
|
|
|
//config:config IPTUNNEL
|
|
|
|
//config: bool "iptunnel"
|
|
|
|
//config: default y
|
|
|
|
//config: select FEATURE_IP_TUNNEL
|
|
|
|
//config: select PLATFORM_LINUX
|
|
|
|
//config: help
|
|
|
|
//config: Support short form of ip tunnel: iptunnel
|
|
|
|
//config:
|
|
|
|
//config:config IPRULE
|
|
|
|
//config: bool "iprule"
|
|
|
|
//config: default y
|
|
|
|
//config: select FEATURE_IP_RULE
|
|
|
|
//config: select PLATFORM_LINUX
|
|
|
|
//config: help
|
|
|
|
//config: Support short form of ip rule: iprule
|
|
|
|
//config:
|
|
|
|
//config:config IPNEIGH
|
|
|
|
//config: bool "ipneigh"
|
|
|
|
//config: default y
|
|
|
|
//config: select FEATURE_IP_NEIGH
|
|
|
|
//config: select PLATFORM_LINUX
|
|
|
|
//config: help
|
|
|
|
//config: Support short form of ip neigh: ipneigh
|
|
|
|
//config:
|
2016-11-23 13:35:14 +05:30
|
|
|
//config:config FEATURE_IP_ADDRESS
|
|
|
|
//config: bool "ip address"
|
|
|
|
//config: default y
|
2016-12-23 03:00:13 +05:30
|
|
|
//config: depends on IP || IPADDR
|
2016-11-23 13:35:14 +05:30
|
|
|
//config: help
|
|
|
|
//config: Address manipulation support for the "ip" applet.
|
|
|
|
//config:
|
|
|
|
//config:config FEATURE_IP_LINK
|
|
|
|
//config: bool "ip link"
|
|
|
|
//config: default y
|
2016-12-23 03:00:13 +05:30
|
|
|
//config: depends on IP || IPLINK
|
2016-11-23 13:35:14 +05:30
|
|
|
//config: help
|
|
|
|
//config: Configure network devices with "ip".
|
|
|
|
//config:
|
|
|
|
//config:config FEATURE_IP_ROUTE
|
|
|
|
//config: bool "ip route"
|
|
|
|
//config: default y
|
2016-12-23 03:00:13 +05:30
|
|
|
//config: depends on IP || IPROUTE
|
2016-11-23 13:35:14 +05:30
|
|
|
//config: help
|
|
|
|
//config: Add support for routing table management to "ip".
|
|
|
|
//config:
|
|
|
|
//config:config FEATURE_IP_ROUTE_DIR
|
|
|
|
//config: string "ip route configuration directory"
|
|
|
|
//config: default "/etc/iproute2"
|
|
|
|
//config: depends on FEATURE_IP_ROUTE
|
|
|
|
//config: help
|
|
|
|
//config: Location of the "ip" applet routing configuration.
|
|
|
|
//config:
|
|
|
|
//config:config FEATURE_IP_TUNNEL
|
|
|
|
//config: bool "ip tunnel"
|
|
|
|
//config: default y
|
2016-12-23 03:00:13 +05:30
|
|
|
//config: depends on IP || IPTUNNEL
|
2016-11-23 13:35:14 +05:30
|
|
|
//config: help
|
|
|
|
//config: Add support for tunneling commands to "ip".
|
|
|
|
//config:
|
|
|
|
//config:config FEATURE_IP_RULE
|
|
|
|
//config: bool "ip rule"
|
|
|
|
//config: default y
|
2016-12-23 03:00:13 +05:30
|
|
|
//config: depends on IP || IPRULE
|
2016-11-23 13:35:14 +05:30
|
|
|
//config: help
|
|
|
|
//config: Add support for rule commands to "ip".
|
|
|
|
//config:
|
|
|
|
//config:config FEATURE_IP_NEIGH
|
|
|
|
//config: bool "ip neighbor"
|
|
|
|
//config: default y
|
2016-12-23 03:00:13 +05:30
|
|
|
//config: depends on IP || IPNEIGH
|
2016-11-23 13:35:14 +05:30
|
|
|
//config: help
|
|
|
|
//config: Add support for neighbor commands to "ip".
|
|
|
|
//config:
|
|
|
|
//config:config FEATURE_IP_RARE_PROTOCOLS
|
|
|
|
//config: bool "Support displaying rarely used link types"
|
|
|
|
//config: default n
|
2016-12-23 03:00:13 +05:30
|
|
|
//config: depends on IP || IPADDR || IPLINK || IPROUTE || IPTUNNEL || IPRULE || IPNEIGH
|
2016-11-23 13:35:14 +05:30
|
|
|
//config: help
|
|
|
|
//config: If you are not going to use links of type "frad", "econet",
|
|
|
|
//config: "bif" etc, you probably don't need to enable this.
|
|
|
|
//config: Ethernet, wireless, infrared, ppp/slip, ip tunnelling
|
|
|
|
//config: link types are supported without this option selected.
|
|
|
|
|
|
|
|
//applet:IF_IP(APPLET(ip, BB_DIR_SBIN, BB_SUID_DROP))
|
|
|
|
//applet:IF_IPADDR(APPLET(ipaddr, BB_DIR_SBIN, BB_SUID_DROP))
|
|
|
|
//applet:IF_IPLINK(APPLET(iplink, BB_DIR_SBIN, BB_SUID_DROP))
|
|
|
|
//applet:IF_IPROUTE(APPLET(iproute, BB_DIR_SBIN, BB_SUID_DROP))
|
|
|
|
//applet:IF_IPRULE(APPLET(iprule, BB_DIR_SBIN, BB_SUID_DROP))
|
|
|
|
//applet:IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_SBIN, BB_SUID_DROP))
|
2016-11-23 13:48:05 +05:30
|
|
|
//applet:IF_IPNEIGH(APPLET(ipneigh, BB_DIR_SBIN, BB_SUID_DROP))
|
2016-11-23 13:35:14 +05:30
|
|
|
|
|
|
|
//kbuild:lib-$(CONFIG_IP) += ip.o
|
2016-12-23 03:00:13 +05:30
|
|
|
//kbuild:lib-$(CONFIG_IPADDR) += ip.o
|
|
|
|
//kbuild:lib-$(CONFIG_IPLINK) += ip.o
|
|
|
|
//kbuild:lib-$(CONFIG_IPROUTE) += ip.o
|
|
|
|
//kbuild:lib-$(CONFIG_IPRULE) += ip.o
|
|
|
|
//kbuild:lib-$(CONFIG_IPTUNNEL) += ip.o
|
|
|
|
//kbuild:lib-$(CONFIG_IPNEIGH) += ip.o
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define ipaddr_trivial_usage
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage: "add|del IFADDR dev IFACE | show|flush [dev IFACE] [to PREFIX]"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define ipaddr_full_usage "\n\n"
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage: "ipaddr add|change|replace|delete IFADDR dev IFACE\n"
|
|
|
|
//usage: "ipaddr show|flush [dev IFACE] [scope SCOPE-ID]\n"
|
2017-01-21 08:26:46 +05:30
|
|
|
//usage: " [to PREFIX] [label PATTERN]\n"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage: " IFADDR := PREFIX | ADDR peer PREFIX\n"
|
2017-01-21 08:26:46 +05:30
|
|
|
//usage: " [broadcast ADDR] [anycast ADDR]\n"
|
|
|
|
//usage: " [label STRING] [scope SCOPE-ID]\n"
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: " SCOPE-ID := [host|link|global|NUMBER]"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define iplink_trivial_usage
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage: "set IFACE [up|down] [arp on|off] | show [IFACE]"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define iplink_full_usage "\n\n"
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage: "iplink set IFACE [up|down]\n"
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: " [arp on|off]\n"
|
|
|
|
//usage: " [dynamic on|off]\n"
|
|
|
|
//usage: " [multicast on|off]\n"
|
|
|
|
//usage: " [mtu MTU]\n"
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage: "iplink show [IFACE]"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define iproute_trivial_usage
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: "list|flush|add|del|change|append|replace|test ROUTE"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define iproute_full_usage "\n\n"
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: "iproute list|flush SELECTOR\n"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage: "iproute get ADDRESS [from ADDRESS iif STRING]\n"
|
2011-12-06 23:29:55 +05:30
|
|
|
//usage: " [oif STRING] [tos TOS]\n"
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: "iproute add|del|change|append|replace|test ROUTE\n"
|
2011-12-06 23:29:55 +05:30
|
|
|
//usage: " SELECTOR := [root PREFIX] [match PREFIX] [proto RTPROTO]\n"
|
|
|
|
//usage: " ROUTE := [TYPE] PREFIX [tos TOS] [proto RTPROTO] [metric METRIC]"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define iprule_trivial_usage
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage: "[list] | add|del SELECTOR ACTION"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define iprule_full_usage "\n\n"
|
|
|
|
//usage: " SELECTOR := [from PREFIX] [to PREFIX] [tos TOS] [fwmark FWMARK]\n"
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage: " [dev IFACE] [pref NUMBER]\n"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage: " ACTION := [table TABLE_ID] [nat ADDRESS]\n"
|
2017-01-21 08:26:46 +05:30
|
|
|
//usage: " [prohibit|reject|unreachable]\n"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage: " [realms [SRCREALM/]DSTREALM]\n"
|
2017-01-21 08:26:46 +05:30
|
|
|
//usage: " TABLE_ID := [local|main|default|NUMBER]"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define iptunnel_trivial_usage
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: "add|change|del|show [NAME]\n"
|
|
|
|
//usage: " [mode ipip|gre|sit]\n"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage: " [remote ADDR] [local ADDR] [ttl TTL]"
|
|
|
|
//usage:#define iptunnel_full_usage "\n\n"
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: "iptunnel add|change|del|show [NAME]\n"
|
|
|
|
//usage: " [mode ipip|gre|sit] [remote ADDR] [local ADDR]\n"
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage: " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n"
|
|
|
|
//usage: " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]"
|
2015-10-14 16:23:47 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define ipneigh_trivial_usage
|
2017-01-21 08:16:35 +05:30
|
|
|
//usage: "show|flush [to PREFIX] [dev DEV] [nud STATE]"
|
2017-01-21 18:57:07 +05:30
|
|
|
//usage:#define ipneigh_full_usage ""
|
|
|
|
//usage:
|
|
|
|
//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE
|
|
|
|
//usage:# define IP_BAR_LINK "|"
|
|
|
|
//usage:#else
|
|
|
|
//usage:# define IP_BAR_LINK ""
|
|
|
|
//usage:#endif
|
|
|
|
//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE || ENABLE_FEATURE_IP_LINK
|
|
|
|
//usage:# define IP_BAR_TUNNEL "|"
|
|
|
|
//usage:#else
|
|
|
|
//usage:# define IP_BAR_TUNNEL ""
|
|
|
|
//usage:#endif
|
|
|
|
//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE || ENABLE_FEATURE_IP_LINK || ENABLE_FEATURE_IP_TUNNEL
|
|
|
|
//usage:# define IP_BAR_NEIGH "|"
|
|
|
|
//usage:#else
|
|
|
|
//usage:# define IP_BAR_NEIGH ""
|
|
|
|
//usage:#endif
|
|
|
|
//usage:#if ENABLE_FEATURE_IP_ADDRESS || ENABLE_FEATURE_IP_ROUTE || ENABLE_FEATURE_IP_LINK || ENABLE_FEATURE_IP_TUNNEL || ENABLE_FEATURE_IP_NEIGH
|
|
|
|
//usage:# define IP_BAR_RULE "|"
|
|
|
|
//usage:#else
|
|
|
|
//usage:# define IP_BAR_RULE ""
|
|
|
|
//usage:#endif
|
|
|
|
//usage:
|
|
|
|
//usage:#define ip_trivial_usage
|
|
|
|
//usage: "[OPTIONS] "
|
|
|
|
//usage: IF_FEATURE_IP_ADDRESS("address")
|
|
|
|
//usage: IF_FEATURE_IP_ROUTE( IF_FEATURE_IP_ADDRESS("|")"route")
|
|
|
|
//usage: IF_FEATURE_IP_LINK( IP_BAR_LINK "link")
|
|
|
|
//usage: IF_FEATURE_IP_TUNNEL( IP_BAR_TUNNEL"tunnel")
|
|
|
|
//usage: IF_FEATURE_IP_NEIGH( IP_BAR_NEIGH "neigh")
|
|
|
|
//usage: IF_FEATURE_IP_RULE( IP_BAR_RULE "rule")
|
|
|
|
//usage: " [COMMAND]"
|
|
|
|
//usage:#define ip_full_usage "\n\n"
|
|
|
|
//usage: "OPTIONS := -f[amily] inet|inet6|link | -o[neline]\n"
|
|
|
|
//usage: "COMMAND :="
|
|
|
|
//usage: IF_FEATURE_IP_ADDRESS("\n"
|
|
|
|
//usage: "ip addr "ipaddr_trivial_usage)
|
|
|
|
//usage: IF_FEATURE_IP_ROUTE("\n"
|
|
|
|
//usage: "ip route "iproute_trivial_usage)
|
|
|
|
//usage: IF_FEATURE_IP_LINK("\n"
|
|
|
|
//usage: "ip link "iplink_trivial_usage)
|
|
|
|
//usage: IF_FEATURE_IP_TUNNEL("\n"
|
|
|
|
//usage: "ip tunnel "iptunnel_trivial_usage)
|
|
|
|
//usage: IF_FEATURE_IP_NEIGH("\n"
|
|
|
|
//usage: "ip neigh "ipneigh_trivial_usage)
|
|
|
|
//usage: IF_FEATURE_IP_RULE("\n"
|
|
|
|
//usage: "ip rule "iprule_trivial_usage)
|
2011-04-11 06:59:49 +05:30
|
|
|
|
2007-05-27 00:30:18 +05:30
|
|
|
#include "libbb.h"
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2005-10-26 16:17:26 +05:30
|
|
|
#include "libiproute/utils.h"
|
|
|
|
#include "libiproute/ip_common.h"
|
2002-11-10 07:03:55 +05:30
|
|
|
|
2010-07-25 02:57:38 +05:30
|
|
|
typedef int FAST_FUNC (*ip_func_ptr_t)(char**);
|
2010-07-25 02:56:58 +05:30
|
|
|
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IPADDR \
|
|
|
|
|| ENABLE_IPLINK \
|
|
|
|
|| ENABLE_IPROUTE \
|
|
|
|
|| ENABLE_IPRULE \
|
|
|
|
|| ENABLE_IPTUNNEL \
|
|
|
|
|| ENABLE_IPNEIGH
|
2010-07-25 02:56:58 +05:30
|
|
|
static int ip_do(ip_func_ptr_t ip_func, char **argv)
|
2007-04-11 01:41:12 +05:30
|
|
|
{
|
2008-12-04 17:45:19 +05:30
|
|
|
argv = ip_parse_common_args(argv + 1);
|
2007-11-19 04:26:25 +05:30
|
|
|
return ip_func(argv);
|
2007-04-11 01:41:12 +05:30
|
|
|
}
|
2016-12-23 03:00:13 +05:30
|
|
|
#endif
|
2007-04-11 01:41:12 +05:30
|
|
|
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IPADDR
|
2007-10-11 15:35:36 +05:30
|
|
|
int ipaddr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int ipaddr_main(int argc UNUSED_PARAM, char **argv)
|
2007-04-11 01:41:12 +05:30
|
|
|
{
|
2008-03-28 06:30:09 +05:30
|
|
|
return ip_do(do_ipaddr, argv);
|
2007-04-11 01:41:12 +05:30
|
|
|
}
|
|
|
|
#endif
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IPLINK
|
2007-10-11 15:35:36 +05:30
|
|
|
int iplink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int iplink_main(int argc UNUSED_PARAM, char **argv)
|
2007-04-11 01:41:12 +05:30
|
|
|
{
|
2008-03-28 06:30:09 +05:30
|
|
|
return ip_do(do_iplink, argv);
|
2007-04-11 01:41:12 +05:30
|
|
|
}
|
|
|
|
#endif
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IPROUTE
|
2007-10-11 15:35:36 +05:30
|
|
|
int iproute_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int iproute_main(int argc UNUSED_PARAM, char **argv)
|
2007-04-11 01:41:12 +05:30
|
|
|
{
|
2008-03-28 06:30:09 +05:30
|
|
|
return ip_do(do_iproute, argv);
|
2007-04-11 01:41:12 +05:30
|
|
|
}
|
|
|
|
#endif
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IPRULE
|
2007-10-11 15:35:36 +05:30
|
|
|
int iprule_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int iprule_main(int argc UNUSED_PARAM, char **argv)
|
2007-04-11 01:41:12 +05:30
|
|
|
{
|
2008-03-28 06:30:09 +05:30
|
|
|
return ip_do(do_iprule, argv);
|
2007-04-11 01:41:12 +05:30
|
|
|
}
|
|
|
|
#endif
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IPTUNNEL
|
2007-10-11 15:35:36 +05:30
|
|
|
int iptunnel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int iptunnel_main(int argc UNUSED_PARAM, char **argv)
|
2007-04-11 01:41:12 +05:30
|
|
|
{
|
2008-03-28 06:30:09 +05:30
|
|
|
return ip_do(do_iptunnel, argv);
|
2007-04-11 01:41:12 +05:30
|
|
|
}
|
|
|
|
#endif
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IPNEIGH
|
2015-10-14 16:23:47 +05:30
|
|
|
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
|
2007-04-11 01:41:12 +05:30
|
|
|
|
2016-12-23 03:00:13 +05:30
|
|
|
#if ENABLE_IP
|
|
|
|
static int FAST_FUNC ip_print_help(char **argv UNUSED_PARAM)
|
|
|
|
{
|
|
|
|
bb_show_usage();
|
|
|
|
}
|
2007-04-11 01:41:12 +05:30
|
|
|
|
2007-10-11 15:35:36 +05:30
|
|
|
int ip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int ip_main(int argc UNUSED_PARAM, char **argv)
|
2002-12-02 04:34:06 +05:30
|
|
|
{
|
2016-12-23 03:00:13 +05:30
|
|
|
static const char keywords[] ALIGN1 = ""
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_IP_ADDRESS("address\0")
|
|
|
|
IF_FEATURE_IP_ROUTE("route\0")
|
2010-07-25 02:56:58 +05:30
|
|
|
IF_FEATURE_IP_ROUTE("r\0")
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_IP_LINK("link\0")
|
2010-07-25 02:56:58 +05:30
|
|
|
IF_FEATURE_IP_TUNNEL("tunnel\0")
|
|
|
|
IF_FEATURE_IP_TUNNEL("tunl\0")
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_IP_RULE("rule\0")
|
2015-10-14 16:23:47 +05:30
|
|
|
IF_FEATURE_IP_NEIGH("neigh\0")
|
2007-07-24 21:24:42 +05:30
|
|
|
;
|
2010-07-25 02:56:58 +05:30
|
|
|
static const ip_func_ptr_t ip_func_ptrs[] = {
|
|
|
|
ip_print_help,
|
|
|
|
IF_FEATURE_IP_ADDRESS(do_ipaddr,)
|
|
|
|
IF_FEATURE_IP_ROUTE(do_iproute,)
|
|
|
|
IF_FEATURE_IP_ROUTE(do_iproute,)
|
|
|
|
IF_FEATURE_IP_LINK(do_iplink,)
|
|
|
|
IF_FEATURE_IP_TUNNEL(do_iptunnel,)
|
|
|
|
IF_FEATURE_IP_TUNNEL(do_iptunnel,)
|
|
|
|
IF_FEATURE_IP_RULE(do_iprule,)
|
2015-10-14 16:23:47 +05:30
|
|
|
IF_FEATURE_IP_NEIGH(do_ipneigh,)
|
2007-04-11 00:13:27 +05:30
|
|
|
};
|
2010-07-25 02:56:58 +05:30
|
|
|
ip_func_ptr_t ip_func;
|
|
|
|
int key;
|
2007-04-07 06:44:45 +05:30
|
|
|
|
2007-11-19 04:26:25 +05:30
|
|
|
argv = ip_parse_common_args(argv + 1);
|
2016-12-23 03:00:13 +05:30
|
|
|
if (ARRAY_SIZE(ip_func_ptrs) > 1 && *argv)
|
|
|
|
key = index_in_substrings(keywords, *argv++);
|
|
|
|
else
|
|
|
|
key = -1;
|
2010-07-25 02:56:58 +05:30
|
|
|
ip_func = ip_func_ptrs[key + 1];
|
|
|
|
|
2007-11-19 04:26:25 +05:30
|
|
|
return ip_func(argv);
|
2002-11-10 07:03:55 +05:30
|
|
|
}
|
2016-12-23 03:00:13 +05:30
|
|
|
#endif
|