2006-07-02 19:47:05 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
2002-11-10 01:33:55 +00:00
|
|
|
/*
|
2006-10-20 13:28:22 +00:00
|
|
|
* iplink.c "ip link".
|
2002-11-10 01:33:55 +00:00
|
|
|
*
|
2006-10-20 13:28:22 +00:00
|
|
|
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
2002-11-10 01:33:55 +00:00
|
|
|
*
|
2010-08-16 18:14:46 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2002-11-10 01:33:55 +00:00
|
|
|
*/
|
2003-01-14 08:54:08 +00:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_packet.h>
|
|
|
|
#include <netpacket/packet.h>
|
|
|
|
#include <net/ethernet.h>
|
2002-11-10 01:33:55 +00:00
|
|
|
|
2007-05-31 22:42:12 +00:00
|
|
|
#include "ip_common.h" /* #include "libbb.h" is inside */
|
2002-11-10 01:33:55 +00:00
|
|
|
#include "rt_names.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2010-08-22 08:02:55 +00:00
|
|
|
#ifndef IFLA_LINKINFO
|
|
|
|
# define IFLA_LINKINFO 18
|
2010-08-30 17:20:09 +00:00
|
|
|
# define IFLA_INFO_KIND 1
|
2010-08-22 08:02:55 +00:00
|
|
|
#endif
|
2010-08-30 17:20:09 +00:00
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* taken from linux/sockios.h */
|
2010-10-28 16:57:19 +00:00
|
|
|
#define SIOCSIFNAME 0x8923 /* set interface name */
|
2003-01-14 08:54:08 +00:00
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
2002-11-10 01:33:55 +00:00
|
|
|
static int get_ctl_fd(void)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
fd = socket(PF_INET, SOCK_DGRAM, 0);
|
|
|
|
if (fd >= 0)
|
|
|
|
return fd;
|
|
|
|
fd = socket(PF_PACKET, SOCK_DGRAM, 0);
|
|
|
|
if (fd >= 0)
|
|
|
|
return fd;
|
2007-04-12 11:34:39 +00:00
|
|
|
return xsocket(PF_INET6, SOCK_DGRAM, 0);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
|
|
|
static void do_chflags(char *dev, uint32_t flags, uint32_t mask)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
|
|
|
struct ifreq ifr;
|
|
|
|
int fd;
|
|
|
|
|
2008-12-02 18:18:50 +00:00
|
|
|
strncpy_IFNAMSIZ(ifr.ifr_name, dev);
|
2002-11-10 01:33:55 +00:00
|
|
|
fd = get_ctl_fd();
|
2007-07-14 22:07:14 +00:00
|
|
|
xioctl(fd, SIOCGIFFLAGS, &ifr);
|
2007-04-07 01:14:45 +00:00
|
|
|
if ((ifr.ifr_flags ^ flags) & mask) {
|
2002-11-10 01:33:55 +00:00
|
|
|
ifr.ifr_flags &= ~mask;
|
2007-04-07 01:14:45 +00:00
|
|
|
ifr.ifr_flags |= mask & flags;
|
2007-07-14 22:07:14 +00:00
|
|
|
xioctl(fd, SIOCSIFFLAGS, &ifr);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
|
|
|
static void do_changename(char *dev, char *newdev)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
|
|
|
struct ifreq ifr;
|
|
|
|
int fd;
|
|
|
|
|
2008-12-02 18:18:50 +00:00
|
|
|
strncpy_IFNAMSIZ(ifr.ifr_name, dev);
|
|
|
|
strncpy_IFNAMSIZ(ifr.ifr_newname, newdev);
|
2002-11-10 01:33:55 +00:00
|
|
|
fd = get_ctl_fd();
|
2007-07-14 22:07:14 +00:00
|
|
|
xioctl(fd, SIOCSIFNAME, &ifr);
|
2002-11-10 01:33:55 +00:00
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
|
|
|
static void set_qlen(char *dev, int qlen)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
|
|
|
struct ifreq ifr;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = get_ctl_fd();
|
|
|
|
memset(&ifr, 0, sizeof(ifr));
|
2008-12-02 18:18:50 +00:00
|
|
|
strncpy_IFNAMSIZ(ifr.ifr_name, dev);
|
2004-03-15 08:29:22 +00:00
|
|
|
ifr.ifr_qlen = qlen;
|
2007-07-14 22:07:14 +00:00
|
|
|
xioctl(s, SIOCSIFTXQLEN, &ifr);
|
2002-11-10 01:33:55 +00:00
|
|
|
close(s);
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
|
|
|
static void set_mtu(char *dev, int mtu)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
|
|
|
struct ifreq ifr;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = get_ctl_fd();
|
|
|
|
memset(&ifr, 0, sizeof(ifr));
|
2008-12-02 18:18:50 +00:00
|
|
|
strncpy_IFNAMSIZ(ifr.ifr_name, dev);
|
2004-03-15 08:29:22 +00:00
|
|
|
ifr.ifr_mtu = mtu;
|
2007-07-14 22:07:14 +00:00
|
|
|
xioctl(s, SIOCSIFMTU, &ifr);
|
2002-11-10 01:33:55 +00:00
|
|
|
close(s);
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
2002-11-10 01:33:55 +00:00
|
|
|
static int get_address(char *dev, int *htype)
|
|
|
|
{
|
|
|
|
struct ifreq ifr;
|
|
|
|
struct sockaddr_ll me;
|
2006-01-30 18:00:02 +00:00
|
|
|
socklen_t alen;
|
2002-11-10 01:33:55 +00:00
|
|
|
int s;
|
|
|
|
|
2007-04-12 11:34:39 +00:00
|
|
|
s = xsocket(PF_PACKET, SOCK_DGRAM, 0);
|
2002-11-10 01:33:55 +00:00
|
|
|
|
|
|
|
memset(&ifr, 0, sizeof(ifr));
|
2008-12-02 18:18:50 +00:00
|
|
|
strncpy_IFNAMSIZ(ifr.ifr_name, dev);
|
2007-07-14 22:07:14 +00:00
|
|
|
xioctl(s, SIOCGIFINDEX, &ifr);
|
2002-11-10 01:33:55 +00:00
|
|
|
|
|
|
|
memset(&me, 0, sizeof(me));
|
|
|
|
me.sll_family = AF_PACKET;
|
|
|
|
me.sll_ifindex = ifr.ifr_ifindex;
|
|
|
|
me.sll_protocol = htons(ETH_P_LOOP);
|
2007-04-12 11:34:39 +00:00
|
|
|
xbind(s, (struct sockaddr*)&me, sizeof(me));
|
2002-11-10 01:33:55 +00:00
|
|
|
alen = sizeof(me);
|
2009-04-21 23:48:38 +00:00
|
|
|
getsockname(s, (struct sockaddr*)&me, &alen);
|
|
|
|
//never happens:
|
|
|
|
//if (getsockname(s, (struct sockaddr*)&me, &alen) == -1)
|
|
|
|
// bb_perror_msg_and_die("getsockname");
|
2002-11-10 01:33:55 +00:00
|
|
|
close(s);
|
|
|
|
*htype = me.sll_hatype;
|
|
|
|
return me.sll_halen;
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
|
|
|
static void parse_address(char *dev, int hatype, int halen, char *lla, struct ifreq *ifr)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
|
|
|
int alen;
|
|
|
|
|
|
|
|
memset(ifr, 0, sizeof(*ifr));
|
2008-12-02 18:18:50 +00:00
|
|
|
strncpy_IFNAMSIZ(ifr->ifr_name, dev);
|
2002-11-10 01:33:55 +00:00
|
|
|
ifr->ifr_hwaddr.sa_family = hatype;
|
2008-05-16 17:19:03 +00:00
|
|
|
|
|
|
|
alen = hatype == 1/*ARPHRD_ETHER*/ ? 14/*ETH_HLEN*/ : 19/*INFINIBAND_HLEN*/;
|
|
|
|
alen = ll_addr_a2n((unsigned char *)(ifr->ifr_hwaddr.sa_data), alen, lla);
|
2002-11-10 01:33:55 +00:00
|
|
|
if (alen < 0)
|
2008-05-16 17:19:03 +00:00
|
|
|
exit(EXIT_FAILURE);
|
2002-11-10 01:33:55 +00:00
|
|
|
if (alen != halen) {
|
2007-04-07 01:14:45 +00:00
|
|
|
bb_error_msg_and_die("wrong address (%s) length: expected %d bytes", lla, halen);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Exits on error */
|
|
|
|
static void set_address(struct ifreq *ifr, int brd)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = get_ctl_fd();
|
2007-07-14 22:07:14 +00:00
|
|
|
if (brd)
|
|
|
|
xioctl(s, SIOCSIFHWBROADCAST, ifr);
|
|
|
|
else
|
|
|
|
xioctl(s, SIOCSIFHWADDR, ifr);
|
2002-11-10 01:33:55 +00:00
|
|
|
close(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-05 09:18:54 +00:00
|
|
|
static void die_must_be_on_off(const char *msg) NORETURN;
|
2007-11-18 22:56:25 +00:00
|
|
|
static void die_must_be_on_off(const char *msg)
|
|
|
|
{
|
|
|
|
bb_error_msg_and_die("argument of \"%s\" must be \"on\" or \"off\"", msg);
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Return value becomes exitcode. It's okay to not return at all */
|
2007-11-18 22:56:25 +00:00
|
|
|
static int do_set(char **argv)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
|
|
|
char *dev = NULL;
|
2006-12-31 18:57:37 +00:00
|
|
|
uint32_t mask = 0;
|
|
|
|
uint32_t flags = 0;
|
2002-11-10 01:33:55 +00:00
|
|
|
int qlen = -1;
|
|
|
|
int mtu = -1;
|
|
|
|
char *newaddr = NULL;
|
|
|
|
char *newbrd = NULL;
|
|
|
|
struct ifreq ifr0, ifr1;
|
|
|
|
char *newname = NULL;
|
|
|
|
int htype, halen;
|
2007-08-12 20:58:27 +00:00
|
|
|
static const char keywords[] ALIGN1 =
|
2010-05-25 14:57:08 +00:00
|
|
|
"up\0""down\0""name\0""mtu\0""qlen\0""multicast\0"
|
2008-11-01 00:10:51 +00:00
|
|
|
"arp\0""address\0""dev\0";
|
2010-05-25 14:57:08 +00:00
|
|
|
enum { ARG_up = 0, ARG_down, ARG_name, ARG_mtu, ARG_qlen, ARG_multicast,
|
2008-11-01 00:10:51 +00:00
|
|
|
ARG_arp, ARG_addr, ARG_dev };
|
2007-11-18 22:56:25 +00:00
|
|
|
static const char str_on_off[] ALIGN1 = "on\0""off\0";
|
|
|
|
enum { PARM_on = 0, PARM_off };
|
2007-04-12 11:34:39 +00:00
|
|
|
smalluint key;
|
2002-11-10 01:33:55 +00:00
|
|
|
|
2007-11-18 22:56:25 +00:00
|
|
|
while (*argv) {
|
2008-11-01 00:10:51 +00:00
|
|
|
/* substring search ensures that e.g. "addr" and "address"
|
|
|
|
* are both accepted */
|
|
|
|
key = index_in_substrings(keywords, *argv);
|
2007-04-12 11:34:39 +00:00
|
|
|
if (key == ARG_up) {
|
2002-11-10 01:33:55 +00:00
|
|
|
mask |= IFF_UP;
|
|
|
|
flags |= IFF_UP;
|
2010-05-25 14:16:28 +00:00
|
|
|
} else if (key == ARG_down) {
|
2002-11-10 01:33:55 +00:00
|
|
|
mask |= IFF_UP;
|
|
|
|
flags &= ~IFF_UP;
|
2010-05-25 14:16:28 +00:00
|
|
|
} else if (key == ARG_name) {
|
2002-11-10 01:33:55 +00:00
|
|
|
NEXT_ARG();
|
|
|
|
newname = *argv;
|
2010-05-25 14:16:28 +00:00
|
|
|
} else if (key == ARG_mtu) {
|
2002-11-10 01:33:55 +00:00
|
|
|
NEXT_ARG();
|
|
|
|
if (mtu != -1)
|
|
|
|
duparg("mtu", *argv);
|
2009-03-05 09:21:57 +00:00
|
|
|
mtu = get_unsigned(*argv, "mtu");
|
2010-05-25 14:57:08 +00:00
|
|
|
} else if (key == ARG_qlen) {
|
|
|
|
NEXT_ARG();
|
|
|
|
if (qlen != -1)
|
|
|
|
duparg("qlen", *argv);
|
|
|
|
qlen = get_unsigned(*argv, "qlen");
|
2010-05-25 14:16:28 +00:00
|
|
|
} else if (key == ARG_addr) {
|
2005-12-15 05:29:48 +00:00
|
|
|
NEXT_ARG();
|
|
|
|
newaddr = *argv;
|
2010-05-25 14:16:28 +00:00
|
|
|
} else if (key >= ARG_dev) {
|
2007-04-12 11:34:39 +00:00
|
|
|
if (key == ARG_dev) {
|
2002-11-10 01:33:55 +00:00
|
|
|
NEXT_ARG();
|
|
|
|
}
|
|
|
|
if (dev)
|
|
|
|
duparg2("dev", *argv);
|
|
|
|
dev = *argv;
|
2010-05-25 14:16:28 +00:00
|
|
|
} else {
|
|
|
|
int param;
|
|
|
|
NEXT_ARG();
|
|
|
|
param = index_in_strings(str_on_off, *argv);
|
|
|
|
if (key == ARG_multicast) {
|
|
|
|
if (param < 0)
|
|
|
|
die_must_be_on_off("multicast");
|
|
|
|
mask |= IFF_MULTICAST;
|
|
|
|
if (param == PARM_on)
|
|
|
|
flags |= IFF_MULTICAST;
|
|
|
|
else
|
|
|
|
flags &= ~IFF_MULTICAST;
|
|
|
|
} else if (key == ARG_arp) {
|
|
|
|
if (param < 0)
|
|
|
|
die_must_be_on_off("arp");
|
|
|
|
mask |= IFF_NOARP;
|
|
|
|
if (param == PARM_on)
|
|
|
|
flags &= ~IFF_NOARP;
|
|
|
|
else
|
|
|
|
flags |= IFF_NOARP;
|
|
|
|
}
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
2007-11-18 22:56:25 +00:00
|
|
|
argv++;
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!dev) {
|
2007-04-07 01:14:45 +00:00
|
|
|
bb_error_msg_and_die(bb_msg_requires_arg, "\"dev\"");
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (newaddr || newbrd) {
|
|
|
|
halen = get_address(dev, &htype);
|
|
|
|
if (newaddr) {
|
2007-04-07 01:14:45 +00:00
|
|
|
parse_address(dev, htype, halen, newaddr, &ifr0);
|
2010-05-25 14:16:28 +00:00
|
|
|
set_address(&ifr0, 0);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
if (newbrd) {
|
2007-04-07 01:14:45 +00:00
|
|
|
parse_address(dev, htype, halen, newbrd, &ifr1);
|
2010-05-25 14:16:28 +00:00
|
|
|
set_address(&ifr1, 1);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newname && strcmp(dev, newname)) {
|
2007-04-07 01:14:45 +00:00
|
|
|
do_changename(dev, newname);
|
2002-11-10 01:33:55 +00:00
|
|
|
dev = newname;
|
|
|
|
}
|
2004-03-15 08:29:22 +00:00
|
|
|
if (qlen != -1) {
|
2007-04-07 01:14:45 +00:00
|
|
|
set_qlen(dev, qlen);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
2004-03-15 08:29:22 +00:00
|
|
|
if (mtu != -1) {
|
2007-04-07 01:14:45 +00:00
|
|
|
set_mtu(dev, mtu);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|
|
|
|
if (mask)
|
2007-04-07 01:14:45 +00:00
|
|
|
do_chflags(dev, flags, mask);
|
2002-11-10 01:33:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-18 22:56:25 +00:00
|
|
|
static int ipaddr_list_link(char **argv)
|
2002-12-02 01:40:05 +00:00
|
|
|
{
|
|
|
|
preferred_family = AF_PACKET;
|
2007-11-18 22:56:25 +00:00
|
|
|
return ipaddr_list_or_flush(argv, 0);
|
2002-12-02 01:40:05 +00:00
|
|
|
}
|
|
|
|
|
2010-05-25 08:34:27 +00:00
|
|
|
#ifndef NLMSG_TAIL
|
|
|
|
#define NLMSG_TAIL(nmsg) \
|
|
|
|
((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
|
|
|
|
#endif
|
|
|
|
/* Return value becomes exitcode. It's okay to not return at all */
|
|
|
|
static int do_change(char **argv, const unsigned rtm)
|
|
|
|
{
|
|
|
|
static const char keywords[] ALIGN1 =
|
|
|
|
"link\0""name\0""type\0""dev\0";
|
|
|
|
enum {
|
|
|
|
ARG_link,
|
|
|
|
ARG_name,
|
|
|
|
ARG_type,
|
|
|
|
ARG_dev,
|
|
|
|
};
|
|
|
|
struct rtnl_handle rth;
|
|
|
|
struct {
|
2010-10-29 09:46:52 +00:00
|
|
|
struct nlmsghdr n;
|
|
|
|
struct ifinfomsg i;
|
|
|
|
char buf[1024];
|
2010-05-25 08:34:27 +00:00
|
|
|
} req;
|
2010-05-25 14:16:28 +00:00
|
|
|
smalluint arg;
|
2010-05-25 08:34:27 +00:00
|
|
|
char *name_str = NULL, *link_str = NULL, *type_str = NULL, *dev_str = NULL;
|
|
|
|
|
|
|
|
memset(&req, 0, sizeof(req));
|
|
|
|
|
|
|
|
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
|
|
|
|
req.n.nlmsg_flags = NLM_F_REQUEST;
|
|
|
|
req.n.nlmsg_type = rtm;
|
|
|
|
req.i.ifi_family = preferred_family;
|
|
|
|
if (rtm == RTM_NEWLINK)
|
|
|
|
req.n.nlmsg_flags |= NLM_F_CREATE|NLM_F_EXCL;
|
|
|
|
|
|
|
|
while (*argv) {
|
|
|
|
arg = index_in_substrings(keywords, *argv);
|
|
|
|
if (arg == ARG_link) {
|
|
|
|
NEXT_ARG();
|
|
|
|
link_str = *argv;
|
|
|
|
} else if (arg == ARG_name) {
|
|
|
|
NEXT_ARG();
|
|
|
|
name_str = *argv;
|
|
|
|
} else if (arg == ARG_type) {
|
|
|
|
NEXT_ARG();
|
|
|
|
type_str = *argv;
|
|
|
|
} else {
|
|
|
|
if (arg == ARG_dev) {
|
|
|
|
if (dev_str)
|
|
|
|
duparg(*argv, "dev");
|
|
|
|
NEXT_ARG();
|
|
|
|
}
|
|
|
|
dev_str = *argv;
|
|
|
|
}
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
xrtnl_open(&rth);
|
|
|
|
ll_init_map(&rth);
|
|
|
|
if (type_str) {
|
|
|
|
struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
|
|
|
|
|
|
|
|
addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
|
|
|
|
addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type_str,
|
|
|
|
strlen(type_str));
|
|
|
|
linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo;
|
|
|
|
}
|
|
|
|
if (rtm != RTM_NEWLINK) {
|
|
|
|
if (!dev_str)
|
|
|
|
return 1; /* Need a device to delete */
|
|
|
|
req.i.ifi_index = xll_name_to_index(dev_str);
|
|
|
|
} else {
|
|
|
|
if (!name_str)
|
|
|
|
name_str = dev_str;
|
|
|
|
if (link_str) {
|
|
|
|
int idx = xll_name_to_index(link_str);
|
|
|
|
addattr_l(&req.n, sizeof(req), IFLA_LINK, &idx, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (name_str) {
|
|
|
|
const size_t name_len = strlen(name_str) + 1;
|
|
|
|
if (name_len < 2 || name_len > IFNAMSIZ)
|
|
|
|
invarg(name_str, "name");
|
|
|
|
addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name_str, name_len);
|
|
|
|
}
|
|
|
|
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
|
|
|
|
return 2;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-07 01:14:45 +00:00
|
|
|
/* Return value becomes exitcode. It's okay to not return at all */
|
2010-07-24 21:27:38 +00:00
|
|
|
int FAST_FUNC do_iplink(char **argv)
|
2002-11-10 01:33:55 +00:00
|
|
|
{
|
2007-08-12 20:58:27 +00:00
|
|
|
static const char keywords[] ALIGN1 =
|
2010-05-25 08:34:27 +00:00
|
|
|
"add\0""delete\0""set\0""show\0""lst\0""list\0";
|
2010-05-25 14:16:28 +00:00
|
|
|
if (*argv) {
|
|
|
|
smalluint key = index_in_substrings(keywords, *argv);
|
|
|
|
if (key > 5) /* invalid argument */
|
|
|
|
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
|
|
|
|
argv++;
|
|
|
|
if (key <= 1) /* add/delete */
|
|
|
|
return do_change(argv, key ? RTM_DELLINK : RTM_NEWLINK);
|
|
|
|
else if (key == 2) /* set */
|
|
|
|
return do_set(argv);
|
|
|
|
}
|
2007-11-18 22:56:25 +00:00
|
|
|
/* show, lst, list */
|
|
|
|
return ipaddr_list_link(argv);
|
2002-11-10 01:33:55 +00:00
|
|
|
}
|