Add ip command aliases and better matching
This commit is contained in:
parent
991d2c0d56
commit
ede723964a
|
|
@ -1,3 +1,11 @@
|
||||||
|
2005-11-22 Stephen Hemminger <shemminger@osdl.org
|
||||||
|
|
||||||
|
* Handle ambigious ip command matches
|
||||||
|
|
||||||
|
2005-11-22 Patrick McHardy <kaber@trash.net>
|
||||||
|
|
||||||
|
* Add back ip command aliases
|
||||||
|
|
||||||
2005-11-07 Masahide NAKAMURA <nakam@linux-ipv6.org>
|
2005-11-07 Masahide NAKAMURA <nakam@linux-ipv6.org>
|
||||||
|
|
||||||
* Updating for 2.6.14
|
* Updating for 2.6.14
|
||||||
|
|
|
||||||
29
ip/ip.c
29
ip/ip.c
|
|
@ -62,13 +62,15 @@ static const struct cmd {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
int (*func)(int argc, char **argv);
|
int (*func)(int argc, char **argv);
|
||||||
} cmds[] = {
|
} cmds[] = {
|
||||||
{ "addr", do_ipaddr },
|
{ "address", do_ipaddr },
|
||||||
{ "maddr", do_multiaddr },
|
{ "maddress", do_multiaddr },
|
||||||
{ "route", do_iproute },
|
{ "route", do_iproute },
|
||||||
{ "rule", do_iprule },
|
{ "rule", do_iprule },
|
||||||
{ "neigh", do_ipneigh },
|
{ "neighbor", do_ipneigh },
|
||||||
|
{ "neighbour", do_ipneigh },
|
||||||
{ "link", do_iplink },
|
{ "link", do_iplink },
|
||||||
{ "tunnel", do_iptunnel },
|
{ "tunnel", do_iptunnel },
|
||||||
|
{ "tunl", do_iptunnel },
|
||||||
{ "monitor", do_ipmonitor },
|
{ "monitor", do_ipmonitor },
|
||||||
{ "xfrm", do_xfrm },
|
{ "xfrm", do_xfrm },
|
||||||
{ "mroute", do_multiroute },
|
{ "mroute", do_multiroute },
|
||||||
|
|
@ -78,14 +80,25 @@ static const struct cmd {
|
||||||
|
|
||||||
static int do_cmd(const char *argv0, int argc, char **argv)
|
static int do_cmd(const char *argv0, int argc, char **argv)
|
||||||
{
|
{
|
||||||
const struct cmd *c;
|
const struct cmd *c, *m = NULL;
|
||||||
|
|
||||||
for (c = cmds; c->cmd; ++c)
|
for (c = cmds; c->cmd; ++c) {
|
||||||
if (matches(argv0, c->cmd) == 0)
|
if (matches(argv0, c->cmd) == 0) {
|
||||||
return c->func(argc-1, argv+1);
|
if (m && m->func != c->func) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Ambiguious command \"%s\" matches both %s and %s\n",
|
||||||
|
argv0, m->cmd, c->cmd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
m = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m)
|
||||||
|
return m->func(argc-1, argv+1);
|
||||||
|
|
||||||
fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
|
fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int batch(const char *name)
|
static int batch(const char *name)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue