From 6d681bd874dc7dee4300a5d3a5ced8bb1a679643 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 16 Dec 2016 05:39:44 +0000 Subject: [PATCH] all: use ->text when parsing protocol argument and match on full protocol name in proto_redistnum() Signed-off-by: Quentin Young --- bgpd/bgp_vty.c | 52 +++++++++++------------- isisd/isis_redist.c | 8 ++-- lib/log.c | 40 +++++++++---------- ospf6d/ospf6_asbr.c | 15 ++++--- ospfd/ospf_vty.c | 83 ++++++++++++++++++-------------------- ripd/rip_zebra.c | 95 +++++++++++++++++++------------------------- ripngd/ripng_zebra.c | 11 +++-- vtysh/vtysh.c | 2 +- zebra/zebra_vty.c | 38 ++++++++---------- 9 files changed, 160 insertions(+), 184 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1c2cc037f9d8..c52682240bdf 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9104,8 +9104,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; @@ -9128,8 +9128,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; @@ -9155,8 +9155,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; @@ -9186,8 +9186,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; @@ -9218,8 +9218,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; @@ -9433,8 +9433,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; @@ -9453,8 +9453,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; @@ -9478,8 +9478,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; @@ -9505,8 +9505,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; @@ -9536,8 +9536,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; @@ -9568,8 +9568,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; @@ -9597,8 +9597,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; @@ -9606,10 +9606,6 @@ DEFUN (no_bgp_redistribute_ipv6, return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); } - - - - #endif /* HAVE_IPV6 */ int diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 045c7daa32b4..f636d7f15661 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 f9877300b44a..3ed41c75e89a 100644 --- a/lib/log.c +++ b/lib/log.c @@ -1061,48 +1061,48 @@ 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 (strncmp (s, "v", 1) == 0) + else if (strmatch (s, "vnc")) return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strmatch (s, "vd")) 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 (strncmp (s, "v", 1) == 0) + else if (strmatch (s, "vnc")) return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strmatch (s, "vd")) return ZEBRA_ROUTE_VNC_DIRECT; } return -1; diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index d31b4b95b4a4..f962669e8d97 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 c2999ca02a02..adfaa33afa10 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 5aea4f52229c..40c25f4c731e 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 09472683d79e..7daa3a88756d 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 f67fc1f31d6b..f045b8bc39f1 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 e5f9b17e81b1..2f0fefdc674c 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 QUAGGA_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);