summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_vty.c48
-rw-r--r--isisd/isis_redist.c8
-rw-r--r--lib/log.c44
-rw-r--r--ospf6d/ospf6_asbr.c15
-rw-r--r--ospfd/ospf_vty.c83
-rw-r--r--ripd/rip_zebra.c95
-rw-r--r--ripngd/ripng_zebra.c11
-rw-r--r--vtysh/vtysh.c2
-rw-r--r--zebra/zebra_vty.c38
9 files changed, 162 insertions, 182 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 547b627d88..a86908f199 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -9167,8 +9167,8 @@ DEFUN (bgp_redistribute_ipv4,
int idx_protocol = 1;
int type;
- type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9191,8 +9191,8 @@ DEFUN (bgp_redistribute_ipv4_rmap,
int type;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9218,8 +9218,8 @@ DEFUN (bgp_redistribute_ipv4_metric,
u_int32_t metric;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9249,8 +9249,8 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
u_int32_t metric;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9281,8 +9281,8 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
u_int32_t metric;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9496,8 +9496,8 @@ DEFUN (no_bgp_redistribute_ipv4,
int idx_protocol = 2;
int type;
- type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9516,8 +9516,8 @@ DEFUN (bgp_redistribute_ipv6,
int idx_protocol = 1;
int type;
- type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9541,8 +9541,8 @@ DEFUN (bgp_redistribute_ipv6_rmap,
int type;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9568,8 +9568,8 @@ DEFUN (bgp_redistribute_ipv6_metric,
u_int32_t metric;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9599,8 +9599,8 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
u_int32_t metric;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9631,8 +9631,8 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
u_int32_t metric;
struct bgp_redist *red;
- type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -9660,8 +9660,8 @@ DEFUN (no_bgp_redistribute_ipv6,
int idx_protocol = 2;
int type;
- type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_BGP)
+ type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
+ if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c
index 78014ce1df..e368180699 100644
--- a/isisd/isis_redist.c
+++ b/isisd/isis_redist.c
@@ -564,7 +564,7 @@ DEFUN (isis_redistribute,
unsigned long metric;
const char *routemap = NULL;
- family = str2family(argv[idx_afi]->arg);
+ family = str2family(argv[idx_afi]->text);
if (family < 0)
return CMD_WARNING;
@@ -572,8 +572,8 @@ DEFUN (isis_redistribute,
if (!afi)
return CMD_WARNING;
- type = proto_redistnum(afi, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_ISIS)
+ type = proto_redistnum(afi, argv[idx_protocol]->text);
+ if (type < 0)
return CMD_WARNING;
if (!strcmp("level-1", argv[idx_level]->arg))
@@ -637,7 +637,7 @@ DEFUN (no_isis_redistribute,
return CMD_WARNING;
type = proto_redistnum(afi, argv[idx_protocol]->text);
- if (type < 0 || type == ZEBRA_ROUTE_ISIS)
+ if (type < 0)
return CMD_WARNING;
level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2;
diff --git a/lib/log.c b/lib/log.c
index 6a3ce07799..d48534dc18 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1061,49 +1061,49 @@ proto_redistnum(int afi, const char *s)
if (afi == AFI_IP)
{
- if (strncmp (s, "k", 1) == 0)
+ if (strmatch (s, "kernel"))
return ZEBRA_ROUTE_KERNEL;
- else if (strncmp (s, "c", 1) == 0)
+ else if (strmatch (s, "connected"))
return ZEBRA_ROUTE_CONNECT;
- else if (strncmp (s, "s", 1) == 0)
+ else if (strmatch (s, "static"))
return ZEBRA_ROUTE_STATIC;
- else if (strncmp (s, "r", 1) == 0)
+ else if (strmatch (s, "rip"))
return ZEBRA_ROUTE_RIP;
- else if (strncmp (s, "o", 1) == 0)
+ else if (strmatch (s, "ospf"))
return ZEBRA_ROUTE_OSPF;
- else if (strncmp (s, "i", 1) == 0)
+ else if (strmatch (s, "isis"))
return ZEBRA_ROUTE_ISIS;
- else if (strncmp (s, "bg", 2) == 0)
+ else if (strmatch (s, "bgp"))
return ZEBRA_ROUTE_BGP;
- else if (strncmp (s, "ta", 2) == 0)
+ else if (strmatch (s, "table"))
return ZEBRA_ROUTE_TABLE;
- else if (strcmp (s, "vnc-direct") == 0)
- return ZEBRA_ROUTE_VNC_DIRECT;
- else if (strcmp (s, "vnc") == 0)
+ else if (strmatch (s, "vnc"))
return ZEBRA_ROUTE_VNC;
+ else if (strmatch (s, "vnc-direct"))
+ return ZEBRA_ROUTE_VNC_DIRECT;
}
if (afi == AFI_IP6)
{
- if (strncmp (s, "k", 1) == 0)
+ if (strmatch (s, "kernel"))
return ZEBRA_ROUTE_KERNEL;
- else if (strncmp (s, "c", 1) == 0)
+ else if (strmatch (s, "connected"))
return ZEBRA_ROUTE_CONNECT;
- else if (strncmp (s, "s", 1) == 0)
+ else if (strmatch (s, "static"))
return ZEBRA_ROUTE_STATIC;
- else if (strncmp (s, "r", 1) == 0)
+ else if (strmatch (s, "ripng"))
return ZEBRA_ROUTE_RIPNG;
- else if (strncmp (s, "o", 1) == 0)
+ else if (strmatch (s, "ospf6"))
return ZEBRA_ROUTE_OSPF6;
- else if (strncmp (s, "i", 1) == 0)
+ else if (strmatch (s, "isis"))
return ZEBRA_ROUTE_ISIS;
- else if (strncmp (s, "bg", 2) == 0)
+ else if (strmatch (s, "bgp"))
return ZEBRA_ROUTE_BGP;
- else if (strncmp (s, "ta", 2) == 0)
+ else if (strmatch (s, "table"))
return ZEBRA_ROUTE_TABLE;
- else if (strcmp (s, "vnc-direct") == 0)
- return ZEBRA_ROUTE_VNC_DIRECT;
- else if (strcmp (s, "vnc") == 0)
+ else if (strmatch (s, "vnc"))
return ZEBRA_ROUTE_VNC;
+ else if (strmatch (s, "vnc-direct"))
+ return ZEBRA_ROUTE_VNC_DIRECT;
}
return -1;
}
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 7d5aca1199..74c4802f2e 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -692,8 +692,9 @@ DEFUN (ospf6_redistribute,
{
int type;
- type = proto_redistnum(AFI_IP6, argv[2]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
+ char *proto = argv[argc - 1]->text;
+ type = proto_redistnum(AFI_IP6, proto);
+ if (type < 0)
return CMD_WARNING;
ospf6_asbr_redistribute_unset (type);
@@ -713,8 +714,9 @@ DEFUN (ospf6_redistribute_routemap,
int idx_word = 3;
int type;
- type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
- if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
+ char *proto = argv[idx_protocol]->text;
+ type = proto_redistnum(AFI_IP6, proto);
+ if (type < 0)
return CMD_WARNING;
ospf6_asbr_redistribute_unset (type);
@@ -735,8 +737,9 @@ DEFUN (no_ospf6_redistribute,
int idx_protocol = 2;
int type;
- type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
- if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
+ char *proto = argv[idx_protocol]->text;
+ type = proto_redistnum(AFI_IP6, proto);
+ if (type < 0)
return CMD_WARNING;
ospf6_asbr_redistribute_unset (type);
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index c5137c085c..fb24e05728 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -7108,40 +7108,36 @@ DEFUN (ospf_redistribute_source,
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_protocol = 1;
- int idx_redist_param = 2;
int source;
int type = -1;
int metric = -1;
struct ospf_redist *red;
-
- if (!ospf)
- return CMD_SUCCESS;
-
- if (argc < 4)
- return CMD_WARNING; /* should not happen */
+ int idx = 0;
if (!ospf)
return CMD_SUCCESS;
/* Get distribute source. */
- source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
+ source = proto_redistnum(AFI_IP, argv[idx_protocol]->text);
+ if (source < 0)
return CMD_WARNING;
+ red = ospf_redist_add(ospf, source, 0);
+
/* Get metric value. */
- if (strcmp (argv[idx_redist_param]->arg, "metric") == 0)
- if (!str2metric (argv[idx_redist_param+1]->arg, &metric))
+ if (argv_find (argv, argc, "(0-16777214)", &idx)) {
+ if (!str2metric (argv[idx]->arg, &metric))
return CMD_WARNING;
-
+ }
/* Get metric type. */
- if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0)
- if (!str2metric_type (argv[idx_redist_param+1]->arg, &type))
+ else if (argv_find (argv, argc, "(1-2)", &idx)) {
+ if (!str2metric_type (argv[idx]->arg, &type))
return CMD_WARNING;
-
- red = ospf_redist_add(ospf, source, 0);
-
- if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0)
- ospf_routemap_set (red, argv[idx_redist_param+1]->arg);
+ }
+ /* Get route-map */
+ else if (argv_find (argv, argc, "WORD", &idx)) {
+ ospf_routemap_set (red, argv[idx]->arg);
+ }
else
ospf_routemap_unset (red);
@@ -7167,8 +7163,8 @@ DEFUN (no_ospf_redistribute_source,
int source;
struct ospf_redist *red;
- source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
+ source = proto_redistnum(AFI_IP, argv[idx_protocol]->text);
+ if (source < 0)
return CMD_WARNING;
red = ospf_redist_lookup(ospf, source, 0);
@@ -7207,10 +7203,7 @@ DEFUN (ospf_redistribute_instance_source,
if (!ospf)
return CMD_SUCCESS;
- if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
- source = ZEBRA_ROUTE_OSPF;
- else
- source = ZEBRA_ROUTE_TABLE;
+ source = proto_redistnum (AFI_IP, argv[idx_ospf_table]->text);
VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
@@ -7315,9 +7308,11 @@ DEFUN (ospf_distribute_list_out,
int idx_word = 1;
int source;
+ char *proto = argv[argc - 1]->text;
+
/* Get distribute source. */
- source = proto_redistnum(AFI_IP, argv[4]->arg);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
+ source = proto_redistnum(AFI_IP, proto);
+ if (source < 0)
return CMD_WARNING;
return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg);
@@ -7336,8 +7331,9 @@ DEFUN (no_ospf_distribute_list_out,
int idx_word = 2;
int source;
- source = proto_redistnum(AFI_IP, argv[5]->arg);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
+ char *proto = argv[argc - 1]->text;
+ source = proto_redistnum(AFI_IP, proto);
+ if (source < 0)
return CMD_WARNING;
return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg);
@@ -7359,33 +7355,30 @@ DEFUN (ospf_default_information_originate,
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
- int idx_redist_param = 2;
int default_originate = DEFAULT_ORIGINATE_ZEBRA;
int type = -1;
int metric = -1;
struct ospf_redist *red;
+ int idx = 0;
- if (argc < 4)
- return CMD_WARNING; /* this should not happen */
+ red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0);
/* Check whether "always" was specified */
- if (argv[idx_redist_param]->arg != NULL)
+ if (argv_find (argv, argc, "always", &idx))
default_originate = DEFAULT_ORIGINATE_ALWAYS;
-
- red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0);
-
- /* Get metric value. */
- if (strcmp (argv[idx_redist_param]->arg, "metric") == 0)
- if (!str2metric (argv[idx_redist_param+1]->arg, &metric))
+ /* Get metric value */
+ else if (argv_find (argv, argc, "(0-16777214)", &idx)) {
+ if (!str2metric (argv[idx]->arg, &metric))
return CMD_WARNING;
-
+ }
/* Get metric type. */
- if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0)
- if (!str2metric_type (argv[idx_redist_param+1]->arg, &type))
+ else if (argv_find (argv, argc, "(1-2)", &idx)) {
+ if (!str2metric_type (argv[idx]->arg, &type))
return CMD_WARNING;
-
- if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0)
- ospf_routemap_set (red, argv[idx_redist_param+1]->arg);
+ }
+ /* Get route-map */
+ else if (argv_find (argv, argc, "WORD", &idx))
+ ospf_routemap_set (red, argv[idx]->arg);
else
ospf_routemap_unset (red);
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index dfebebb5bc..043f1c631e 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -394,8 +394,7 @@ DEFUN (rip_redistribute_type_routemap,
int i;
for (i = 0; redist_type[i].str; i++) {
- if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
- redist_type[i].str_min_len) == 0)
+ if (strmatch (redist_type[i].str, argv[idx_protocol]->text))
{
rip_routemap_set (redist_type[i].type, argv[idx_word]->arg);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
@@ -404,8 +403,7 @@ DEFUN (rip_redistribute_type_routemap,
}
}
- vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
- VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -423,20 +421,17 @@ DEFUN (no_rip_redistribute_type_routemap,
int idx_word = 4;
int i;
- for (i = 0; redist_type[i].str; i++)
- {
- if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
- redist_type[i].str_min_len) == 0)
- {
- if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg))
- return CMD_WARNING;
- rip_redistribute_unset (redist_type[i].type);
- return CMD_SUCCESS;
- }
- }
+ for (i = 0; redist_type[i].str; i++) {
+ if (strmatch (redist_type[i].str, argv[idx_protocol]->text))
+ {
+ if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg))
+ return CMD_WARNING;
+ rip_redistribute_unset (redist_type[i].type);
+ return CMD_SUCCESS;
+ }
+ }
- vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
- VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -457,8 +452,7 @@ DEFUN (rip_redistribute_type_metric,
metric = atoi (argv[idx_number]->arg);
for (i = 0; redist_type[i].str; i++) {
- if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
- redist_type[i].str_min_len) == 0)
+ if (strmatch (redist_type[i].str, argv[idx_protocol]->text))
{
rip_redistribute_metric_set (redist_type[i].type, metric);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
@@ -467,8 +461,7 @@ DEFUN (rip_redistribute_type_metric,
}
}
- vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
- VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -486,20 +479,17 @@ DEFUN (no_rip_redistribute_type_metric,
int idx_number = 4;
int i;
- for (i = 0; redist_type[i].str; i++)
- {
- if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
- redist_type[i].str_min_len) == 0)
- {
- if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
- return CMD_WARNING;
- rip_redistribute_unset (redist_type[i].type);
- return CMD_SUCCESS;
- }
- }
+ for (i = 0; redist_type[i].str; i++) {
+ if (strmatch (redist_type[i].str, argv[idx_protocol]->text))
+ {
+ if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
+ return CMD_WARNING;
+ rip_redistribute_unset (redist_type[i].type);
+ return CMD_SUCCESS;
+ }
+ }
- vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
- VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -523,8 +513,7 @@ DEFUN (rip_redistribute_type_metric_routemap,
metric = atoi (argv[idx_number]->arg);
for (i = 0; redist_type[i].str; i++) {
- if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
- redist_type[i].str_min_len) == 0)
+ if (strmatch (redist_type[i].str, argv[idx_protocol]->text))
{
rip_redistribute_metric_set (redist_type[i].type, metric);
rip_routemap_set (redist_type[i].type, argv[idx_word]->arg);
@@ -534,8 +523,7 @@ DEFUN (rip_redistribute_type_metric_routemap,
}
}
- vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
- VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -557,25 +545,22 @@ DEFUN (no_rip_redistribute_type_metric_routemap,
int idx_word = 6;
int i;
- for (i = 0; redist_type[i].str; i++)
- {
- if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
- redist_type[i].str_min_len) == 0)
- {
- if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
- return CMD_WARNING;
- if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg))
- {
- rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg));
- return CMD_WARNING;
- }
- rip_redistribute_unset (redist_type[i].type);
- return CMD_SUCCESS;
- }
+ for (i = 0; redist_type[i].str; i++) {
+ if (strmatch (redist_type[i].str, argv[idx_protocol]->text))
+ {
+ if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
+ return CMD_WARNING;
+ if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg))
+ {
+ rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg));
+ return CMD_WARNING;
+ }
+ rip_redistribute_unset (redist_type[i].type);
+ return CMD_SUCCESS;
+ }
}
- vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
- VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index c5096305e4..bb8fed3e93 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -321,11 +321,12 @@ DEFUN (ripng_redistribute_type,
{
int type;
- type = proto_redistnum(AFI_IP6, argv[2]->arg);
+ char *proto = argv[argc - 1]->text;
+ type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
{
- vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -345,11 +346,13 @@ DEFUN (no_ripng_redistribute_type,
"Pointer to route-map entries\n")
{
int type;
- type = proto_redistnum(AFI_IP6, argv[2]->text);
+
+ char *proto = argv[2]->text;
+ type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
{
- vty_out(vty, "Invalid type %s%s", argv[2]->text, VTY_NEWLINE);
+ vty_out(vty, "Invalid type %s%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 910747c96a..50677b5685 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1913,7 +1913,7 @@ DEFUN (vtysh_show_work_queues_daemon,
for (i = 0; i < array_size(vtysh_client); i++)
{
- if (begins_with(vtysh_client[i].name, argv[idx_protocol]->arg))
+ if (strmatch(vtysh_client[i].name, argv[idx_protocol]->text))
break;
}
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 5dc9a90e1f..27ef5f934d 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1482,15 +1482,12 @@ DEFUN (show_ip_route_protocol,
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
- if (strmatch(argv[3]->text, "vrf"))
- {
- type = proto_redistnum (AFI_IP, argv[5]->arg);
- VRF_GET_ID (vrf_id, argv[4]->arg);
- }
- else
- {
- type = proto_redistnum (AFI_IP, argv[3]->arg);
- }
+ int idx = 0;
+ if (argv_find (argv, argc, "NAME", &idx))
+ VRF_GET_ID (vrf_id, argv[idx]->arg);
+
+ char *proto = argv[argc - 1]->text;
+ type = proto_redistnum (AFI_IP, proto);
if (type < 0)
{
@@ -2083,7 +2080,9 @@ DEFUN (show_ip_route_vrf_all_protocol,
int first = 1;
int vrf_header = 1;
- type = proto_redistnum (AFI_IP, argv[6]->arg);
+ char *proto = argv[argc - 1]->text;
+ type = proto_redistnum (AFI_IP, proto);
+
if (type < 0)
{
vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
@@ -2965,16 +2964,12 @@ DEFUN (show_ipv6_route_protocol,
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
- char *vrfname = (argc == 6) ? argv[4]->arg : NULL;
- char *proto = argv[argc - 1]->text;
+ int idx = 0;
+ if (argv_find (argv, argc, "NAME", &idx))
+ VRF_GET_ID (vrf_id, argv[idx]->arg);
- if (vrfname)
- {
- VRF_GET_ID (vrf_id, vrfname);
- type = proto_redistnum (AFI_IP6, proto);
- }
- else
- type = proto_redistnum (AFI_IP6, proto);
+ char *proto = argv[argc - 1]->text;
+ type = proto_redistnum (AFI_IP, proto);
if (type < 0)
{
@@ -3358,7 +3353,6 @@ DEFUN (show_ipv6_route_vrf_all_protocol,
VRF_ALL_CMD_HELP_STR
FRR_IP6_REDIST_HELP_STR_ZEBRA)
{
- int idx_protocol = 5;
int type;
struct route_table *table;
struct route_node *rn;
@@ -3368,7 +3362,9 @@ DEFUN (show_ipv6_route_vrf_all_protocol,
int first = 1;
int vrf_header = 1;
- type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
+ char *proto = argv[argc - 1]->text;
+ type = proto_redistnum (AFI_IP, proto);
+
if (type < 0)
{
vty_out (vty, "Unknown route type%s", VTY_NEWLINE);