diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-23 22:11:04 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-09-23 22:11:04 +0200 |
commit | 86959b0e07cc32f88d5a7022c38ecf803bd353d9 (patch) | |
tree | 22c613cdf69e56489c87e36fb97ec826ea1d4fd2 | |
parent | lib: Implement removed ALIAS into DEFUN (diff) | |
parent | ripd: add 'int idx_foo' argv index variables (diff) | |
download | frr-86959b0e07cc32f88d5a7022c38ecf803bd353d9.tar.xz frr-86959b0e07cc32f88d5a7022c38ecf803bd353d9.zip |
Merge branch 'vtysh-grammar' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into vtysh-grammar
54 files changed, 4289 insertions, 1898 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 89b970d97..817a8e00a 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -630,7 +630,8 @@ DEFUN (debug_bgp_neighbor_events_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { - const char *host = argv[3]->arg; + int idx_peer = 3; + const char *host = argv[idx_peer]->arg; if (!bgp_debug_neighbor_events_peers) bgp_debug_neighbor_events_peers = list_new (); @@ -684,8 +685,9 @@ DEFUN (no_debug_bgp_neighbor_events_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { + int idx_peer = 4; int found_peer = 0; - const char *host = argv[4]->arg; + const char *host = argv[idx_peer]->arg; if (bgp_debug_neighbor_events_peers && !list_isempty(bgp_debug_neighbor_events_peers)) { @@ -774,7 +776,8 @@ DEFUN (debug_bgp_keepalive_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { - const char *host = argv[3]->arg; + int idx_peer = 3; + const char *host = argv[idx_peer]->arg; if (!bgp_debug_keepalive_peers) bgp_debug_keepalive_peers = list_new (); @@ -828,8 +831,9 @@ DEFUN (no_debug_bgp_keepalive_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { + int idx_peer = 4; int found_peer = 0; - const char *host = argv[4]->arg; + const char *host = argv[idx_peer]->arg; if (bgp_debug_keepalive_peers && !list_isempty(bgp_debug_keepalive_peers)) { @@ -863,11 +867,12 @@ DEFUN (debug_bgp_bestpath_prefix, "IPv6 prefix <network>/<length>\n") { + int idx_ipv4_ipv6_prefixlen = 3; struct prefix *argv_p; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[3]->arg, argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -881,7 +886,7 @@ DEFUN (debug_bgp_bestpath_prefix, if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, argv_p)) { - vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -894,7 +899,7 @@ DEFUN (debug_bgp_bestpath_prefix, else { TERM_DEBUG_ON (bestpath, BESTPATH); - vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); } return CMD_SUCCESS; @@ -911,12 +916,13 @@ DEFUN (no_debug_bgp_bestpath_prefix, "IPv6 prefix <network>/<length>\n") { + int idx_ipv4_ipv6_prefixlen = 4; struct prefix *argv_p; int found_prefix = 0; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[4]->arg, argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -943,9 +949,9 @@ DEFUN (no_debug_bgp_bestpath_prefix, } if (found_prefix) - vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); else - vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1005,22 +1011,23 @@ DEFUN (debug_bgp_update_direct, "Inbound updates\n" "Outbound updates\n") { + int idx_in_out = 3; - if (strncmp ("i", argv[3]->arg, 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) bgp_debug_list_free(bgp_debug_update_in_peers); else bgp_debug_list_free(bgp_debug_update_out_peers); if (vty->node == CONFIG_NODE) { - if (strncmp ("i", argv[3]->arg, 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) DEBUG_ON (update, UPDATE_IN); else DEBUG_ON (update, UPDATE_OUT); } else { - if (strncmp ("i", argv[3]->arg, 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) { TERM_DEBUG_ON (update, UPDATE_IN); vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE); @@ -1046,7 +1053,9 @@ DEFUN (debug_bgp_update_direct_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { - const char *host = argv[4]->arg; + int idx_in_out = 3; + int idx_peer = 4; + const char *host = argv[idx_peer]->arg; int inbound; if (!bgp_debug_update_in_peers) @@ -1055,7 +1064,7 @@ DEFUN (debug_bgp_update_direct_peer, if (!bgp_debug_update_out_peers) bgp_debug_update_out_peers = list_new (); - if (strncmp ("i", argv[3]->arg, 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) inbound = 1; else inbound = 0; @@ -1117,12 +1126,12 @@ DEFUN (debug_bgp_update_direct_peer, if (inbound) { TERM_DEBUG_ON (update, UPDATE_IN); - vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE); } else { TERM_DEBUG_ON (update, UPDATE_OUT); - vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE); } } return CMD_SUCCESS; @@ -1138,7 +1147,8 @@ DEFUN (no_debug_bgp_update_direct, "Inbound updates\n" "Outbound updates\n") { - if (strncmp ("i", argv[4]->arg, 1) == 0) + int idx_in_out = 4; + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) { bgp_debug_list_free(bgp_debug_update_in_peers); @@ -1183,11 +1193,13 @@ DEFUN (no_debug_bgp_update_direct_peer, "BGP IPv6 neighbor to debug\n" "BGP neighbor on interface to debug\n") { + int idx_in_out = 4; + int idx_peer = 5; int inbound; int found_peer = 0; - const char *host = argv[5]->arg; + const char *host = argv[idx_peer]->arg; - if (strncmp ("i", argv[4]->arg, 1) == 0) + if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0) inbound = 1; else inbound = 0; @@ -1271,11 +1283,12 @@ DEFUN (debug_bgp_update_prefix, "IPv6 prefix <network>/<length>\n") { + int idx_ipv4_ipv6_prefixlen = 4; struct prefix *argv_p; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[4]->arg, argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1289,7 +1302,7 @@ DEFUN (debug_bgp_update_prefix, if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) { - vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1302,7 +1315,7 @@ DEFUN (debug_bgp_update_prefix, else { TERM_DEBUG_ON (update, UPDATE_PREFIX); - vty_out (vty, "BGP updates debugging is on for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); } return CMD_SUCCESS; @@ -1320,12 +1333,13 @@ DEFUN (no_debug_bgp_update_prefix, "IPv6 prefix <network>/<length>\n") { + int idx_ipv4_ipv6_prefixlen = 5; struct prefix *argv_p; int found_prefix = 0; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[5]->arg, argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1352,9 +1366,9 @@ DEFUN (no_debug_bgp_update_prefix, } if (found_prefix) - vty_out (vty, "BGP updates debugging is off for %s%s", argv[5]->arg, VTY_NEWLINE); + vty_out (vty, "BGP updates debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); else - vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[5]->arg, VTY_NEWLINE); + vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1418,11 +1432,12 @@ DEFUN (debug_bgp_zebra_prefix, "IPv6 prefix <network>/<length>\n") { + int idx_ipv4_ipv6_prefixlen = 4; struct prefix *argv_p; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[4]->arg, argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1435,7 +1450,7 @@ DEFUN (debug_bgp_zebra_prefix, if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p)) { - vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -1446,7 +1461,7 @@ DEFUN (debug_bgp_zebra_prefix, else { TERM_DEBUG_ON (zebra, ZEBRA); - vty_out (vty, "BGP zebra debugging is on for %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); } return CMD_SUCCESS; @@ -1484,12 +1499,13 @@ DEFUN (no_debug_bgp_zebra_prefix, "IPv6 prefix <network>/<length>\n") { + int idx_ipv4_ipv6_prefixlen = 5; struct prefix *argv_p; int found_prefix = 0; int ret; argv_p = prefix_new(); - ret = str2prefix (argv[5]->arg, argv_p); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); if (!ret) { prefix_free(argv_p); @@ -1514,9 +1530,9 @@ DEFUN (no_debug_bgp_zebra_prefix, } if (found_prefix) - vty_out (vty, "BGP zebra debugging is off for %s%s", argv[5]->arg, VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); else - vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[5]->arg, VTY_NEWLINE); + vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE); return CMD_SUCCESS; } diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index c5fc05200..48c43b7f6 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -736,13 +736,16 @@ DEFUN (dump_bgp_all, "Output filename\n" "Interval of output\n") { + int idx_dump_routes = 2; + int idx_path = 3; + int idx_interval = 4; int bgp_dump_type = 0; const char *interval = NULL; struct bgp_dump *bgp_dump_struct = NULL; const struct bgp_dump_type_map *map = NULL; for (map = bgp_dump_type_map; map->str; map++) - if (strcmp(argv[2]->arg, map->str) == 0) + if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0) bgp_dump_type = map->type; switch (bgp_dump_type) @@ -763,10 +766,10 @@ DEFUN (dump_bgp_all, /* When an interval is given */ if (argc == 3) - interval = argv[4]->arg; + interval = argv[idx_interval]->arg; return bgp_dump_set (vty, bgp_dump_struct, bgp_dump_type, - argv[3]->arg, interval); + argv[idx_path]->arg, interval); } DEFUN (no_dump_bgp_all, @@ -781,12 +784,13 @@ DEFUN (no_dump_bgp_all, "Stop dump process updates-et\n" "Stop dump process route-mrt\n") { + int idx_dump_routes = 3; int bgp_dump_type = 0; const struct bgp_dump_type_map *map = NULL; struct bgp_dump *bgp_dump_struct = NULL; for (map = bgp_dump_type_map; map->str; map++) - if (strcmp(argv[3]->arg, map->str) == 0) + if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0) bgp_dump_type = map->type; switch (bgp_dump_type) diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index 6a39d0217..05d5eafae 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -437,6 +437,8 @@ DEFUN (ip_as_path, "Specify packets to forward\n" "A regular-expression to match the BGP AS paths\n") { + int idx_word = 3; + int idx_permit_deny = 4; enum as_filter_type type; struct as_filter *asfilter; struct as_list *aslist; @@ -444,9 +446,9 @@ DEFUN (ip_as_path, char *regstr; /* Check the filter type. */ - if (strncmp (argv[4]->arg, "p", 1) == 0) + if (strncmp (argv[idx_permit_deny]->arg, "p", 1) == 0) type = AS_FILTER_PERMIT; - else if (strncmp (argv[4]->arg, "d", 1) == 0) + else if (strncmp (argv[idx_permit_deny]->arg, "d", 1) == 0) type = AS_FILTER_DENY; else { @@ -461,7 +463,7 @@ DEFUN (ip_as_path, if (!regex) { XFREE (MTYPE_TMP, regstr); - vty_out (vty, "can't compile regexp %s%s", argv[3]->arg, + vty_out (vty, "can't compile regexp %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -471,7 +473,7 @@ DEFUN (ip_as_path, XFREE (MTYPE_TMP, regstr); /* Install new filter to the access_list. */ - aslist = as_list_get (argv[3]->arg); + aslist = as_list_get (argv[idx_word]->arg); /* Duplicate insertion check. */; if (as_list_dup_check (aslist, asfilter)) @@ -494,6 +496,8 @@ DEFUN (no_ip_as_path, "Specify packets to forward\n" "A regular-expression to match the BGP AS paths\n") { + int idx_word = 4; + int idx_permit_deny = 5; enum as_filter_type type; struct as_filter *asfilter; struct as_list *aslist; @@ -501,18 +505,18 @@ DEFUN (no_ip_as_path, regex_t *regex; /* Lookup AS list from AS path list. */ - aslist = as_list_lookup (argv[4]->arg); + aslist = as_list_lookup (argv[idx_word]->arg); if (aslist == NULL) { - vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[4]->arg, + vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } /* Check the filter type. */ - if (strncmp (argv[5]->arg, "p", 1) == 0) + if (strncmp (argv[idx_permit_deny]->arg, "p", 1) == 0) type = AS_FILTER_PERMIT; - else if (strncmp (argv[5]->arg, "d", 1) == 0) + else if (strncmp (argv[idx_permit_deny]->arg, "d", 1) == 0) type = AS_FILTER_DENY; else { @@ -527,7 +531,7 @@ DEFUN (no_ip_as_path, if (!regex) { XFREE (MTYPE_TMP, regstr); - vty_out (vty, "can't compile regexp %s%s", argv[4]->arg, + vty_out (vty, "can't compile regexp %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -558,12 +562,13 @@ DEFUN (no_ip_as_path_all, "Specify an access list name\n" "Regular expression access list name\n") { + int idx_word = 4; struct as_list *aslist; - aslist = as_list_lookup (argv[4]->arg); + aslist = as_list_lookup (argv[idx_word]->arg); if (aslist == NULL) { - vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[4]->arg, + vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -572,7 +577,7 @@ DEFUN (no_ip_as_path_all, /* Run hook function. */ if (as_list_master.delete_hook) - (*as_list_master.delete_hook) (argv[4]->arg); + (*as_list_master.delete_hook) (argv[idx_word]->arg); return CMD_SUCCESS; } @@ -628,9 +633,10 @@ DEFUN (show_ip_as_path_access_list, "List AS path access lists\n" "AS path access list name\n") { + int idx_word = 3; struct as_list *aslist; - aslist = as_list_lookup (argv[3]->arg); + aslist = as_list_lookup (argv[idx_word]->arg); if (aslist) as_list_show (vty, aslist); diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 629cfffb3..48baedcea 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -360,7 +360,10 @@ DEFUN (vpnv4_network, "BGP tag\n" "tag value\n") { - return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[1]->arg, argv[3]->arg, argv[5]->arg, NULL); + int idx_ipv4_prefixlen = 1; + int idx_ext_community = 3; + int idx_word = 5; + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL); } DEFUN (vpnv4_network_route_map, @@ -375,7 +378,11 @@ DEFUN (vpnv4_network_route_map, "route map\n" "route map name\n") { - return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[1]->arg, argv[3]->arg, argv[5]->arg, argv[7]->arg); + int idx_ipv4_prefixlen = 1; + int idx_ext_community = 3; + int idx_word = 5; + int idx_word_2 = 7; + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg); } /* For testing purpose, static route of MPLS-VPN. */ @@ -390,7 +397,10 @@ DEFUN (no_vpnv4_network, "BGP tag\n" "tag value\n") { - return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[2]->arg, argv[4]->arg, argv[6]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ext_community = 4; + int idx_word = 6; + return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg); } static int @@ -791,10 +801,11 @@ DEFUN (show_bgp_ipv4_vpn_rd, "VPN Route Distinguisher\n" JSON_STR) { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -814,10 +825,11 @@ DEFUN (show_bgp_ipv6_vpn_rd, "VPN Route Distinguisher\n" JSON_STR) { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (!ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -849,10 +861,11 @@ DEFUN (show_ip_bgp_vpnv4_rd, "Display information for a route distinguisher\n" "VPN Route Distinguisher\n") { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -885,10 +898,11 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags, "VPN Route Distinguisher\n" "Display BGP tags for prefixes\n") { + int idx_ext_community = 5; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -910,12 +924,13 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_ipv4 = 6; union sockunion su; struct peer *peer; int ret; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[6]->arg, &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -927,7 +942,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[6]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -964,13 +979,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_ext_community = 5; + int idx_ipv4 = 7; int ret; union sockunion su; struct peer *peer; struct prefix_rd prd; u_char uj = use_json(argc, argv); - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { if (uj) @@ -986,7 +1003,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, return CMD_WARNING; } - ret = str2sockunion (argv[7]->arg, &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -998,7 +1015,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[5]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1034,12 +1051,13 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_ipv4 = 6; int ret; struct peer *peer; union sockunion su; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[6]->arg, &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -1051,7 +1069,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[6]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -1087,13 +1105,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_ext_community = 5; + int idx_ipv4 = 7; int ret; struct peer *peer; struct prefix_rd prd; union sockunion su; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[7]->arg, &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { if (uj) @@ -1105,7 +1125,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, json_object_free(json_no); } else - vty_out (vty, "Malformed address: %s%s", argv[5]->arg, VTY_NEWLINE); + vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); return CMD_WARNING; } peer = peer_lookup (NULL, &su); @@ -1124,7 +1144,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, return CMD_WARNING; } - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { if (uj) diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index caecd80e6..e648af91e 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -520,7 +520,8 @@ DEFUN (show_ip_bgp_instance_nexthop, BGP_INSTANCE_HELP_STR "BGP nexthop table\n") { - return show_ip_bgp_nexthop_table (vty, argv[4]->arg, 0); + int idx_word = 4; + return show_ip_bgp_nexthop_table (vty, argv[idx_word]->arg, 0); } DEFUN (show_ip_bgp_instance_all_nexthop, @@ -545,7 +546,8 @@ DEFUN (show_ip_bgp_instance_nexthop_detail, BGP_INSTANCE_HELP_STR "BGP nexthop table\n") { - return show_ip_bgp_nexthop_table (vty, argv[4]->arg, 1); + int idx_word = 4; + return show_ip_bgp_nexthop_table (vty, argv[idx_word]->arg, 1); } void diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index d0eff6e20..6238f28dd 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4264,8 +4264,9 @@ DEFUN (bgp_table_map, "BGP table to RIB route download filter\n" "Name of the route map\n") { + int idx_word = 1; return bgp_table_map_set (vty, vty->index, - bgp_node_afi (vty), bgp_node_safi (vty), argv[1]->arg); + bgp_node_afi (vty), bgp_node_safi (vty), argv[idx_word]->arg); } DEFUN (no_bgp_table_map, no_bgp_table_map_cmd, @@ -4273,8 +4274,9 @@ DEFUN (no_bgp_table_map, "BGP table to RIB route download filter\n" "Name of the route map\n") { + int idx_word = 2; return bgp_table_map_unset (vty, vty->index, - bgp_node_afi (vty), bgp_node_safi (vty), argv[2]->arg); + bgp_node_afi (vty), bgp_node_safi (vty), argv[idx_word]->arg); } DEFUN (bgp_network, @@ -4283,7 +4285,8 @@ DEFUN (bgp_network, "Specify a network to announce via BGP\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { - return bgp_static_set (vty, vty->index, argv[1]->arg, + int idx_ipv4_prefixlen = 1; + return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty), NULL, 0); } @@ -4295,8 +4298,10 @@ DEFUN (bgp_network_route_map, "Route-map to modify the attributes\n" "Name of the route map\n") { - return bgp_static_set (vty, vty->index, argv[1]->arg, - AFI_IP, bgp_node_safi (vty), argv[3]->arg, 0); + int idx_ipv4_prefixlen = 1; + int idx_word = 3; + return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, + AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0); } DEFUN (bgp_network_backdoor, @@ -4306,7 +4311,8 @@ DEFUN (bgp_network_backdoor, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Specify a BGP backdoor route\n") { - return bgp_static_set (vty, vty->index, argv[1]->arg, AFI_IP, SAFI_UNICAST, + int idx_ipv4_prefixlen = 1; + return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1); } @@ -4318,10 +4324,12 @@ DEFUN (bgp_network_mask, "Network mask\n" "Network mask\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 3; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, argv[3]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4342,10 +4350,13 @@ DEFUN (bgp_network_mask_route_map, "Route-map to modify the attributes\n" "Name of the route map\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 3; + int idx_word = 5; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, argv[3]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4353,7 +4364,7 @@ DEFUN (bgp_network_mask_route_map, } return bgp_static_set (vty, vty->index, prefix_str, - AFI_IP, bgp_node_safi (vty), argv[5]->arg, 0); + AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0); } DEFUN (bgp_network_mask_backdoor, @@ -4365,10 +4376,12 @@ DEFUN (bgp_network_mask_backdoor, "Network mask\n" "Specify a BGP backdoor route\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 3; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, argv[3]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4385,10 +4398,11 @@ DEFUN (bgp_network_mask_natural, "Specify a network to announce via BGP\n" "Network number\n") { + int idx_ipv4 = 1; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4407,10 +4421,12 @@ DEFUN (bgp_network_mask_natural_route_map, "Route-map to modify the attributes\n" "Name of the route map\n") { + int idx_ipv4 = 1; + int idx_word = 3; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4418,7 +4434,7 @@ DEFUN (bgp_network_mask_natural_route_map, } return bgp_static_set (vty, vty->index, prefix_str, - AFI_IP, bgp_node_safi (vty), argv[3]->arg, 0); + AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0); } DEFUN (bgp_network_mask_natural_backdoor, @@ -4428,10 +4444,11 @@ DEFUN (bgp_network_mask_natural_backdoor, "Network number\n" "Specify a BGP backdoor route\n") { + int idx_ipv4 = 1; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4465,7 +4482,8 @@ DEFUN (no_bgp_network, "Specify a network to announce via BGP\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { - return bgp_static_unset (vty, vty->index, argv[2]->arg, AFI_IP, + int idx_ipv4_prefixlen = 2; + return bgp_static_unset (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty)); } @@ -4500,10 +4518,12 @@ DEFUN (no_bgp_network_mask, "Network mask\n" "Network mask\n") { + int idx_ipv4 = 2; + int idx_ipv4_2 = 4; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[2]->arg, argv[4]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4539,10 +4559,11 @@ DEFUN (no_bgp_network_mask_natural, "Specify a network to announce via BGP\n" "Network number\n") { + int idx_ipv4 = 2; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[2]->arg, NULL, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, NULL, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); @@ -4571,7 +4592,8 @@ DEFUN (ipv6_bgp_network, "Specify a network to announce via BGP\n" "IPv6 prefix <network>/<length>\n") { - return bgp_static_set (vty, vty->index, argv[1]->arg, AFI_IP6, bgp_node_safi(vty), + int idx_ipv6_prefixlen = 1; + return bgp_static_set (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty), NULL, 0); } @@ -4583,8 +4605,10 @@ DEFUN (ipv6_bgp_network_route_map, "Route-map to modify the attributes\n" "Name of the route map\n") { - return bgp_static_set (vty, vty->index, argv[1]->arg, AFI_IP6, - bgp_node_safi (vty), argv[3]->arg, 0); + int idx_ipv6_prefixlen = 1; + int idx_word = 3; + return bgp_static_set (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, + bgp_node_safi (vty), argv[idx_word]->arg, 0); } /* @@ -4611,7 +4635,8 @@ DEFUN (no_ipv6_bgp_network, "Specify a network to announce via BGP\n" "IPv6 prefix <network>/<length>\n") { - return bgp_static_unset (vty, vty->index, argv[2]->arg, AFI_IP6, bgp_node_safi(vty)); + int idx_ipv6_prefixlen = 2; + return bgp_static_unset (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty)); } @@ -5225,7 +5250,8 @@ DEFUN (aggregate_address, "Configure BGP aggregate entries\n" "Aggregate prefix\n") { - return bgp_aggregate_set (vty, argv[1]->arg, AFI_IP, bgp_node_safi (vty), 0, 0); + int idx_ipv4_prefixlen = 1; + return bgp_aggregate_set (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty), 0, 0); } DEFUN (aggregate_address_mask, @@ -5235,10 +5261,12 @@ DEFUN (aggregate_address_mask, "Aggregate address\n" "Aggregate mask\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 2; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, argv[2]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { @@ -5257,7 +5285,8 @@ DEFUN (aggregate_address_summary_only, "Aggregate prefix\n" "Filter more specific routes from updates\n") { - return bgp_aggregate_set (vty, argv[1]->arg, AFI_IP, bgp_node_safi (vty), + int idx_ipv4_prefixlen = 1; + return bgp_aggregate_set (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty), AGGREGATE_SUMMARY_ONLY, 0); } @@ -5269,10 +5298,12 @@ DEFUN (aggregate_address_mask_summary_only, "Aggregate mask\n" "Filter more specific routes from updates\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 2; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, argv[2]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { @@ -5291,7 +5322,8 @@ DEFUN (aggregate_address_as_set, "Aggregate prefix\n" "Generate AS set path information\n") { - return bgp_aggregate_set (vty, argv[1]->arg, AFI_IP, bgp_node_safi (vty), + int idx_ipv4_prefixlen = 1; + return bgp_aggregate_set (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty), 0, AGGREGATE_AS_SET); } @@ -5303,10 +5335,12 @@ DEFUN (aggregate_address_mask_as_set, "Aggregate mask\n" "Generate AS set path information\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 2; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, argv[2]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { @@ -5336,7 +5370,8 @@ DEFUN (aggregate_address_as_set_summary, "Generate AS set path information\n" "Filter more specific routes from updates\n") { - return bgp_aggregate_set (vty, argv[1]->arg, AFI_IP, bgp_node_safi (vty), + int idx_ipv4_prefixlen = 1; + return bgp_aggregate_set (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty), AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); } @@ -5360,10 +5395,12 @@ DEFUN (aggregate_address_mask_as_set_summary, "Generate AS set path information\n" "Filter more specific routes from updates\n") { + int idx_ipv4 = 1; + int idx_ipv4_2 = 2; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[1]->arg, argv[2]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { @@ -5412,7 +5449,8 @@ DEFUN (no_aggregate_address, "Configure BGP aggregate entries\n" "Aggregate prefix\n") { - return bgp_aggregate_unset (vty, argv[2]->arg, AFI_IP, bgp_node_safi (vty)); + int idx_ipv4_prefixlen = 2; + return bgp_aggregate_unset (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty)); } @@ -5460,10 +5498,12 @@ DEFUN (no_aggregate_address_mask, "Aggregate address\n" "Aggregate mask\n") { + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[2]->arg, argv[3]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { @@ -5494,7 +5534,8 @@ DEFUN (ipv6_aggregate_address, "Configure BGP aggregate entries\n" "Aggregate prefix\n") { - return bgp_aggregate_set (vty, argv[1]->arg, AFI_IP6, SAFI_UNICAST, 0, 0); + int idx_ipv6_prefixlen = 1; + return bgp_aggregate_set (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, 0, 0); } /* @@ -5514,7 +5555,8 @@ DEFUN (ipv6_aggregate_address_summary_only, "Aggregate prefix\n" "Filter more specific routes from updates\n") { - return bgp_aggregate_set (vty, argv[1]->arg, AFI_IP6, SAFI_UNICAST, + int idx_ipv6_prefixlen = 1; + return bgp_aggregate_set (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, AGGREGATE_SUMMARY_ONLY, 0); } @@ -5535,7 +5577,8 @@ DEFUN (no_ipv6_aggregate_address, "Configure BGP aggregate entries\n" "Aggregate prefix\n") { - return bgp_aggregate_unset (vty, argv[2]->arg, AFI_IP6, SAFI_UNICAST); + int idx_ipv6_prefixlen = 2; + return bgp_aggregate_unset (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST); } /* @@ -5557,7 +5600,8 @@ DEFUN (no_ipv6_aggregate_address_summary_only, "Aggregate prefix\n" "Filter more specific routes from updates\n") { - return bgp_aggregate_unset (vty, argv[2]->arg, AFI_IP6, SAFI_UNICAST); + int idx_ipv6_prefixlen = 2; + return bgp_aggregate_unset (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST); } @@ -7972,9 +8016,10 @@ DEFUN (show_ip_bgp_ipv4, "Address Family modifier\n" "JavaScript Object Notation\n") { + int idx_safi = 4; u_char uj = use_json(argc, argv); - if (strncmp (argv[4]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, NULL, uj); @@ -7991,7 +8036,8 @@ DEFUN (show_ip_bgp_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + int idx_ipv4 = 3; + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_ip_bgp_route_pathtype, @@ -8005,12 +8051,14 @@ DEFUN (show_ip_bgp_route_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_ipv4 = 3; + int idx_bestpath = 4; u_char uj = use_json(argc, argv); - if (strncmp (argv[4]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); } DEFUN (show_bgp_ipv4_safi_route_pathtype, @@ -8026,18 +8074,21 @@ DEFUN (show_bgp_ipv4_safi_route_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_safi = 3; + int idx_ipv4 = 4; + int idx_bestpath = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "m", 1) == 0) - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); else - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); } DEFUN (show_bgp_ipv4_prefix, @@ -8049,7 +8100,8 @@ DEFUN (show_bgp_ipv4_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" JSON_STR) { - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc, argv)); + int idx_ipv4_prefixlen = 3; + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_bgp_ipv6_route, @@ -8061,7 +8113,8 @@ DEFUN (show_bgp_ipv6_route, "Network in the BGP routing table to display\n" JSON_STR) { - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); + int idx_ipv6 = 3; + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_bgp_ipv6_prefix, @@ -8073,7 +8126,8 @@ DEFUN (show_bgp_ipv6_prefix, "IPv6 prefix <network>/<length>\n" JSON_STR) { - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc,argv)); + int idx_ipv6_prefixlen = 3; + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc,argv)); } /* @@ -8100,12 +8154,14 @@ DEFUN (show_ip_bgp_ipv4_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_ipv4 = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); } @@ -8120,7 +8176,8 @@ DEFUN (show_ip_bgp_vpnv4_all_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + int idx_ipv4 = 5; + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_bgp_ipv4_vpn_route, @@ -8133,7 +8190,8 @@ DEFUN (show_bgp_ipv4_vpn_route, "Network in the BGP routing table to display\n" JSON_STR) { - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); + int idx_ipv4 = 4; + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_bgp_ipv6_vpn_route, @@ -8146,7 +8204,8 @@ DEFUN (show_bgp_ipv6_vpn_route, "Network in the BGP routing table to display\n" JSON_STR) { - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); + int idx_ipv6 = 4; + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_bgp_ipv4_vpn_rd_route, @@ -8161,16 +8220,18 @@ DEFUN (show_bgp_ipv4_vpn_rd_route, "Network in the BGP routing table to display\n" JSON_STR) { + int idx_ext_community = 5; + int idx_ipv4 = 6; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[6]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_bgp_ipv6_vpn_rd_route, @@ -8185,16 +8246,18 @@ DEFUN (show_bgp_ipv6_vpn_rd_route, "Network in the BGP routing table to display\n" JSON_STR) { + int idx_ext_community = 5; + int idx_ipv6 = 6; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[6]->arg, AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_ip_bgp_vpnv4_rd_route, @@ -8209,17 +8272,19 @@ DEFUN (show_ip_bgp_vpnv4_rd_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { + int idx_ext_community = 5; + int idx_ipv4 = 6; int ret; struct prefix_rd prd; u_char uj= use_json(argc, argv); - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[6]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); } DEFUN (show_ip_bgp_prefix, @@ -8231,7 +8296,8 @@ DEFUN (show_ip_bgp_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + int idx_ipv4_prefixlen = 3; + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_ip_bgp_prefix_pathtype, @@ -8245,11 +8311,13 @@ DEFUN (show_ip_bgp_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_ipv4_prefixlen = 3; + int idx_bestpath = 4; u_char uj = use_json(argc, argv); - if (strncmp (argv[4]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); } /* @@ -8276,12 +8344,14 @@ DEFUN (show_ip_bgp_ipv4_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_ipv4_prefixlen = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); } @@ -8313,18 +8383,21 @@ DEFUN (show_ip_bgp_ipv4_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_ipv4_prefixlen = 5; + int idx_bestpath = 6; u_char uj = use_json(argc, argv); - if (strncmp (argv[4]->arg, "m", 1) == 0) - if (strncmp (argv[6]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); else - if (strncmp (argv[6]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); } @@ -8339,7 +8412,8 @@ DEFUN (show_ip_bgp_vpnv4_all_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[5]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + int idx_ipv4_prefixlen = 5; + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_ip_bgp_vpnv4_rd_prefix, @@ -8354,16 +8428,18 @@ DEFUN (show_ip_bgp_vpnv4_rd_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { + int idx_ext_community = 5; + int idx_ipv4_prefixlen = 6; int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[6]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_ip_bgp_view, @@ -8375,13 +8451,14 @@ DEFUN (show_ip_bgp_view, BGP_INSTANCE_HELP_STR "JavaScript Object Notation\n") { + int idx_word = 4; struct bgp *bgp; /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[4]->arg); + bgp = bgp_lookup_by_name (argv[idx_word]->arg); if (bgp == NULL) { - vty_out (vty, "Can't find BGP instance %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "Can't find BGP instance %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -8413,7 +8490,9 @@ DEFUN (show_ip_bgp_instance_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, argv[4]->arg, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + int idx_word = 4; + int idx_ipv4 = 5; + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_ip_bgp_instance_route_pathtype, @@ -8428,12 +8507,15 @@ DEFUN (show_ip_bgp_instance_route_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_ipv4 = 5; + int idx_bestpath = 6; u_char uj = use_json(argc, argv); - if (strncmp (argv[6]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[4]->arg, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, argv[4]->arg, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); } DEFUN (show_ip_bgp_instance_prefix, @@ -8446,7 +8528,9 @@ DEFUN (show_ip_bgp_instance_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, argv[4]->arg, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + int idx_word = 4; + int idx_ipv4_prefixlen = 5; + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_ip_bgp_instance_prefix_pathtype, @@ -8461,11 +8545,14 @@ DEFUN (show_ip_bgp_instance_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_ipv4_prefixlen = 5; + int idx_bestpath = 6; u_char uj = use_json(argc, argv); - if (strncmp (argv[6]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[4]->arg, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, argv[4]->arg, argv[5]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); } #ifdef HAVE_IPV6 @@ -8500,8 +8587,9 @@ DEFUN (show_bgp_ipv6_safi, "Address Family modifier\n" "JavaScript Object Notation\n") { + int idx_safi = 3; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, NULL, uj); @@ -8538,7 +8626,8 @@ DEFUN (show_bgp_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[2]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + int idx_ipv6 = 2; + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_bgp_ipv6_safi_route, @@ -8552,11 +8641,13 @@ DEFUN (show_bgp_ipv6_safi_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { + int idx_safi = 3; + int idx_ipv6 = 4; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); } /* @@ -8581,11 +8672,13 @@ DEFUN (show_bgp_route_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_ipv6 = 2; + int idx_bestpath = 3; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[2]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[2]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); } @@ -8602,17 +8695,20 @@ DEFUN (show_bgp_ipv6_safi_route_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_safi = 3; + int idx_ipv6 = 4; + int idx_bestpath = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "m", 1) == 0) - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); else - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); } /* old command */ @@ -8625,8 +8721,9 @@ DEFUN (show_ipv6_bgp_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { + int idx_ipv6 = 3; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_bgp_prefix, @@ -8637,7 +8734,8 @@ DEFUN (show_bgp_prefix, "IPv6 prefix <network>/<length>\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, NULL, argv[2]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + int idx_ipv6_prefixlen = 2; + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); } DEFUN (show_bgp_ipv6_safi_prefix, @@ -8651,11 +8749,13 @@ DEFUN (show_bgp_ipv6_safi_prefix, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "JavaScript Object Notation\n") { + int idx_safi = 3; + int idx_ipv6_prefixlen = 4; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); } /* @@ -8680,11 +8780,13 @@ DEFUN (show_bgp_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_ipv6_prefixlen = 2; + int idx_bestpath = 3; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[2]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[2]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); } @@ -8701,17 +8803,20 @@ DEFUN (show_bgp_ipv6_safi_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_safi = 3; + int idx_ipv6_prefixlen = 4; + int idx_bestpath = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "m", 1) == 0) - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); else - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); } /* old command */ @@ -8724,8 +8829,9 @@ DEFUN (show_ipv6_bgp_prefix, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "JavaScript Object Notation\n") { + int idx_ipv6_prefixlen = 3; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); } /* @@ -8746,13 +8852,14 @@ DEFUN (show_bgp_view, BGP_INSTANCE_HELP_STR "JavaScript Object Notation\n") { + int idx_word = 3; struct bgp *bgp; /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[3]->arg); + bgp = bgp_lookup_by_name (argv[idx_word]->arg); if (bgp == NULL) { - vty_out (vty, "Can't find BGP instance %s%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "Can't find BGP instance %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -8794,7 +8901,9 @@ DEFUN (show_bgp_instance_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, argv[3]->arg, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + int idx_word = 3; + int idx_ipv6 = 4; + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } @@ -8822,11 +8931,14 @@ DEFUN (show_bgp_instance_route_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_ipv6 = 4; + int idx_bestpath = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[3]->arg, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, argv[3]->arg, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); } @@ -8850,7 +8962,9 @@ DEFUN (show_bgp_instance_prefix, "IPv6 prefix <network>/<length>\n" "JavaScript Object Notation\n") { - return bgp_show_route (vty, argv[3]->arg, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + int idx_word = 3; + int idx_ipv6_prefixlen = 4; + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); } @@ -8878,11 +8992,14 @@ DEFUN (show_bgp_instance_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_ipv6_prefixlen = 4; + int idx_bestpath = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[5]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[3]->arg, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); + if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); else - return bgp_show_route (vty, argv[3]->arg, argv[4]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); } @@ -8906,7 +9023,9 @@ DEFUN (show_bgp_instance_prefix_list, "Display routes conforming to the prefix-list\n" "IPv6 prefix-list name\n") { - return bgp_show_prefix_list (vty, argv[3]->arg, argv[5]->arg, AFI_IP6, SAFI_UNICAST, + int idx_word = 3; + int idx_word_2 = 5; + return bgp_show_prefix_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_prefix_list); } @@ -8931,7 +9050,9 @@ DEFUN (show_bgp_instance_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - return bgp_show_filter_list (vty, argv[3]->arg, argv[5]->arg, AFI_IP6, SAFI_UNICAST, + int idx_word = 3; + int idx_word_2 = 5; + return bgp_show_filter_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_filter_list); } @@ -8956,7 +9077,9 @@ DEFUN (show_bgp_instance_route_map, "Display routes matching the route-map\n" "A route-map to match on\n") { - return bgp_show_route_map (vty, argv[3]->arg, argv[5]->arg, AFI_IP6, SAFI_UNICAST, + int idx_word = 3; + int idx_word_2 = 5; + return bgp_show_route_map (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_route_map); } @@ -8983,7 +9106,9 @@ DEFUN (show_bgp_instance_community_list, "community-list number\n" "community-list name\n") { - return bgp_show_community_list (vty, argv[3]->arg, argv[5]->arg, 0, AFI_IP6, SAFI_UNICAST); + int idx_word = 3; + int idx_comm_list = 5; + return bgp_show_community_list (vty, argv[idx_word]->arg, argv[idx_comm_list]->arg, 0, AFI_IP6, SAFI_UNICAST); } @@ -9007,7 +9132,9 @@ DEFUN (show_bgp_instance_prefix_longer, "IPv6 prefix <network>/<length>\n" "Display route and more specific routes\n") { - return bgp_show_prefix_longer (vty, argv[3]->arg, argv[4]->arg, AFI_IP6, SAFI_UNICAST, + int idx_word = 3; + int idx_ipv6_prefixlen = 4; + return bgp_show_prefix_longer (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_prefix_longer); } @@ -9036,8 +9163,9 @@ DEFUN (show_ipv6_mbgp_route, "Network in the MBGP routing table to display\n" "JavaScript Object Notation\n") { + int idx_ipv6 = 3; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } /* old command */ @@ -9050,8 +9178,9 @@ DEFUN (show_ipv6_mbgp_prefix, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "JavaScript Object Notation\n") { + int idx_ipv6_prefixlen = 3; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); } #endif @@ -9153,7 +9282,8 @@ DEFUN (show_ip_bgp_ipv4_regexp, "Display routes matching the AS path regular expression\n" "A regular-expression to match the BGP AS paths\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, bgp_show_type_regexp); @@ -9250,7 +9380,8 @@ DEFUN (show_ip_bgp_prefix_list, "Display routes conforming to the prefix-list\n" "IP prefix-list name\n") { - return bgp_show_prefix_list (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 4; + return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_prefix_list); } @@ -9264,7 +9395,9 @@ DEFUN (show_ip_bgp_instance_prefix_list, "Display routes conforming to the prefix-list\n" "IP prefix-list name\n") { - return bgp_show_prefix_list (vty, argv[4]->arg, argv[6]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 4; + int idx_word_2 = 6; + return bgp_show_prefix_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_prefix_list); } @@ -9290,7 +9423,8 @@ DEFUN (show_ip_bgp_flap_prefix_list, "Display routes conforming to the prefix-list\n" "IP prefix-list name\n") { - return bgp_show_prefix_list (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 5; + return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_prefix_list); } @@ -9307,11 +9441,13 @@ DEFUN (show_ip_bgp_ipv4_prefix_list, "Display routes conforming to the prefix-list\n" "IP prefix-list name\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_prefix_list (vty, NULL, argv[6]->arg, AFI_IP, SAFI_MULTICAST, + int idx_safi = 4; + int idx_word = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, bgp_show_type_prefix_list); - return bgp_show_prefix_list (vty, NULL, argv[6]->arg, AFI_IP, SAFI_UNICAST, + return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_prefix_list); } @@ -9334,7 +9470,8 @@ DEFUN (show_bgp_prefix_list, "Display routes conforming to the prefix-list\n" "IPv6 prefix-list name\n") { - return bgp_show_prefix_list (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, + int idx_word = 3; + return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_prefix_list); } @@ -9349,8 +9486,9 @@ DEFUN (show_ipv6_bgp_prefix_list, "Display routes matching the prefix-list\n" "IPv6 prefix-list name\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_list (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, + return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_prefix_list); } @@ -9364,8 +9502,9 @@ DEFUN (show_ipv6_mbgp_prefix_list, "Display routes matching the prefix-list\n" "IPv6 prefix-list name\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_list (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, + return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_MULTICAST, bgp_show_type_prefix_list); } #endif /* HAVE_IPV6 */ @@ -9403,7 +9542,8 @@ DEFUN (show_ip_bgp_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - return bgp_show_filter_list (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 4; + return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_filter_list); } @@ -9417,7 +9557,9 @@ DEFUN (show_ip_bgp_instance_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - return bgp_show_filter_list (vty, argv[4]->arg, argv[6]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 4; + int idx_word_2 = 6; + return bgp_show_filter_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_filter_list); } @@ -9443,7 +9585,8 @@ DEFUN (show_ip_bgp_flap_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - return bgp_show_filter_list (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 5; + return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_filter_list); } @@ -9460,11 +9603,13 @@ DEFUN (show_ip_bgp_ipv4_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_filter_list (vty, NULL, argv[6]->arg, AFI_IP, SAFI_MULTICAST, + int idx_safi = 4; + int idx_word = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, bgp_show_type_filter_list); - return bgp_show_filter_list (vty, NULL, argv[6]->arg, AFI_IP, SAFI_UNICAST, + return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_filter_list); } @@ -9487,7 +9632,8 @@ DEFUN (show_bgp_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - return bgp_show_filter_list (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, + int idx_word = 3; + return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_filter_list); } @@ -9502,8 +9648,9 @@ DEFUN (show_ipv6_bgp_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_filter_list (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_UNICAST, + return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_filter_list); } @@ -9517,8 +9664,9 @@ DEFUN (show_ipv6_mbgp_filter_list, "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_filter_list (vty, NULL, argv[4]->arg, AFI_IP6, SAFI_MULTICAST, + return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_MULTICAST, bgp_show_type_filter_list); } #endif /* HAVE_IPV6 */ @@ -9548,7 +9696,8 @@ DEFUN (show_ip_bgp_ipv4_dampening_parameters, "Display detailed information about dampening\n" "Display detail of configured dampening parameters\n") { - if (strncmp(argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); @@ -9567,7 +9716,8 @@ DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, "Display detailed information about dampening\n" "Display flap statistics of routes\n") { - if (strncmp(argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_flap_statistics, NULL, 0); @@ -9587,7 +9737,8 @@ DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, "Display detailed information about dampening\n" "Display paths suppressed due to dampening\n") { - if (strncmp(argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_dampend_paths, NULL, 0); @@ -9629,7 +9780,8 @@ DEFUN (show_ip_bgp_route_map, "Display routes matching the route-map\n" "A route-map to match on\n") { - return bgp_show_route_map (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 4; + return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_route_map); } @@ -9643,7 +9795,9 @@ DEFUN (show_ip_bgp_instance_route_map, "Display routes matching the route-map\n" "A route-map to match on\n") { - return bgp_show_route_map (vty, argv[4]->arg, argv[6]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 4; + int idx_word_2 = 6; + return bgp_show_route_map (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_route_map); } @@ -9669,7 +9823,8 @@ DEFUN (show_ip_bgp_flap_route_map, "Display routes matching the route-map\n" "A route-map to match on\n") { - return bgp_show_route_map (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 5; + return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_route_map); } @@ -9686,11 +9841,13 @@ DEFUN (show_ip_bgp_ipv4_route_map, "Display routes matching the route-map\n" "A route-map to match on\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_route_map (vty, NULL, argv[6]->arg, AFI_IP, SAFI_MULTICAST, + int idx_safi = 4; + int idx_word = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, bgp_show_type_route_map); - return bgp_show_route_map (vty, NULL, argv[6]->arg, AFI_IP, SAFI_UNICAST, + return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_route_map); } @@ -9712,7 +9869,8 @@ DEFUN (show_bgp_route_map, "Display routes matching the route-map\n" "A route-map to match on\n") { - return bgp_show_route_map (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, + int idx_word = 3; + return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_route_map); } @@ -9765,7 +9923,8 @@ DEFUN (show_ip_bgp_ipv4_cidr_only, "Address Family modifier\n" "Display only routes with non-natural netmasks\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_cidr_only, NULL, 0); @@ -9796,7 +9955,8 @@ DEFUN (show_ip_bgp_ipv4_community_all, "Address Family modifier\n" "Display routes matching the communities\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_community_all, NULL, 0); @@ -10074,7 +10234,8 @@ DEFUN (show_ip_bgp_ipv4_community, "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); @@ -10095,20 +10256,23 @@ DEFUN (show_bgp_instance_afi_safi_community_all, "Address Family modifier\n" "Display routes matching the communities\n") { + int idx_word = 3; + int idx_afi = 4; + int idx_safi = 5; int afi; int safi; struct bgp *bgp; /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[3]->arg); + bgp = bgp_lookup_by_name (argv[idx_word]->arg); if (bgp == NULL) { - vty_out (vty, "Can't find BGP instance %s%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "Can't find BGP instance %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } - afi = (strncmp (argv[4]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[5]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + afi = (strncmp (argv[idx_afi]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); } @@ -10197,12 +10361,15 @@ DEFUN (show_bgp_instance_afi_safi_community, "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") { + int idx_word = 3; + int idx_afi = 4; + int idx_safi = 5; int afi; int safi; - afi = (strncmp (argv[4]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[5]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - return bgp_show_community (vty, argv[3]->arg, argc, argv, 0, afi, safi); + afi = (strncmp (argv[idx_afi]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + return bgp_show_community (vty, argv[idx_word]->arg, argc, argv, 0, afi, safi); } @@ -10372,7 +10539,8 @@ DEFUN (show_ip_bgp_ipv4_community_exact, "Do not export to next AS (well-known community)\n" "Exact match of the communities") { - if (strncmp (argv[4]->arg, "m", 1) == 0) + int idx_safi = 4; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); @@ -11034,7 +11202,8 @@ DEFUN (show_ip_bgp_community_list, "community-list number\n" "community-list name\n") { - return bgp_show_community_list (vty, NULL, argv[4]->arg, 0, AFI_IP, SAFI_UNICAST); + int idx_comm_list = 4; + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_UNICAST); } DEFUN (show_ip_bgp_instance_community_list, @@ -11048,7 +11217,9 @@ DEFUN (show_ip_bgp_instance_community_list, "community-list number\n" "community-list name\n") { - return bgp_show_community_list (vty, argv[4]->arg, argv[6]->arg, 0, AFI_IP, SAFI_UNICAST); + int idx_word = 4; + int idx_comm_list = 6; + return bgp_show_community_list (vty, argv[idx_word]->arg, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_UNICAST); } DEFUN (show_ip_bgp_ipv4_community_list, @@ -11064,10 +11235,12 @@ DEFUN (show_ip_bgp_ipv4_community_list, "community-list number\n" "community-list name\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[6]->arg, 0, AFI_IP, SAFI_MULTICAST); + int idx_safi = 4; + int idx_comm_list = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_MULTICAST); - return bgp_show_community_list (vty, NULL, argv[6]->arg, 0, AFI_IP, SAFI_UNICAST); + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_UNICAST); } DEFUN (show_ip_bgp_community_list_exact, @@ -11081,7 +11254,8 @@ DEFUN (show_ip_bgp_community_list_exact, "community-list name\n" "Exact match of the communities\n") { - return bgp_show_community_list (vty, NULL, argv[4]->arg, 1, AFI_IP, SAFI_UNICAST); + int idx_comm_list = 4; + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP, SAFI_UNICAST); } DEFUN (show_ip_bgp_ipv4_community_list_exact, @@ -11098,10 +11272,12 @@ DEFUN (show_ip_bgp_ipv4_community_list_exact, "community-list name\n" "Exact match of the communities\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[6]->arg, 1, AFI_IP, SAFI_MULTICAST); + int idx_safi = 4; + int idx_comm_list = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP, SAFI_MULTICAST); - return bgp_show_community_list (vty, NULL, argv[6]->arg, 1, AFI_IP, SAFI_UNICAST); + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP, SAFI_UNICAST); } #ifdef HAVE_IPV6 @@ -11125,7 +11301,8 @@ DEFUN (show_bgp_community_list, "community-list number\n" "community-list name\n") { - return bgp_show_community_list (vty, NULL, argv[3]->arg, 0, AFI_IP6, SAFI_UNICAST); + int idx_comm_list = 3; + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP6, SAFI_UNICAST); } @@ -11139,8 +11316,9 @@ DEFUN (show_ipv6_bgp_community_list, "Display routes matching the community-list\n" "community-list name\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[4]->arg, 0, AFI_IP6, SAFI_UNICAST); + return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 0, AFI_IP6, SAFI_UNICAST); } /* old command */ @@ -11153,8 +11331,9 @@ DEFUN (show_ipv6_mbgp_community_list, "Display routes matching the community-list\n" "community-list name\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[4]->arg, 0, AFI_IP6, SAFI_MULTICAST); + return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 0, AFI_IP6, SAFI_MULTICAST); } /* @@ -11179,7 +11358,8 @@ DEFUN (show_bgp_community_list_exact, "community-list name\n" "Exact match of the communities\n") { - return bgp_show_community_list (vty, NULL, argv[3]->arg, 1, AFI_IP6, SAFI_UNICAST); + int idx_comm_list = 3; + return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP6, SAFI_UNICAST); } @@ -11194,8 +11374,9 @@ DEFUN (show_ipv6_bgp_community_list_exact, "community-list name\n" "Exact match of the communities\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[4]->arg, 1, AFI_IP6, SAFI_UNICAST); + return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 1, AFI_IP6, SAFI_UNICAST); } /* old command */ @@ -11209,8 +11390,9 @@ DEFUN (show_ipv6_mbgp_community_list_exact, "community-list name\n" "Exact match of the communities\n") { + int idx_word = 4; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[4]->arg, 1, AFI_IP6, SAFI_MULTICAST); + return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 1, AFI_IP6, SAFI_MULTICAST); } #endif /* HAVE_IPV6 */ @@ -11252,7 +11434,8 @@ DEFUN (show_ip_bgp_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Display route and more specific routes\n") { - return bgp_show_prefix_longer (vty, NULL, argv[3]->arg, AFI_IP, SAFI_UNICAST, + int idx_ipv4_prefixlen = 3; + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_prefix_longer); } @@ -11266,7 +11449,9 @@ DEFUN (show_ip_bgp_instance_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Display route and more specific routes\n") { - return bgp_show_prefix_longer (vty, argv[4]->arg, argv[5]->arg, AFI_IP, SAFI_UNICAST, + int idx_word = 4; + int idx_ipv4_prefixlen = 5; + return bgp_show_prefix_longer (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_prefix_longer); } @@ -11292,7 +11477,8 @@ DEFUN (show_ip_bgp_flap_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Display route and more specific routes\n") { - return bgp_show_prefix_longer (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, + int idx_ipv4_prefixlen = 4; + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_prefix_longer); } @@ -11309,11 +11495,13 @@ DEFUN (show_ip_bgp_ipv4_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Display route and more specific routes\n") { - if (strncmp (argv[4]->arg, "m", 1) == 0) - return bgp_show_prefix_longer (vty, NULL, argv[5]->arg, AFI_IP, SAFI_MULTICAST, + int idx_safi = 4; + int idx_ipv4_prefixlen = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, bgp_show_type_prefix_longer); - return bgp_show_prefix_longer (vty, NULL, argv[5]->arg, AFI_IP, SAFI_UNICAST, + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_prefix_longer); } @@ -11337,7 +11525,8 @@ DEFUN (show_ip_bgp_flap_address, "Display flap statistics of routes\n" "Network in the BGP routing table to display\n") { - return bgp_show_prefix_longer (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, + int idx_ipv4 = 4; + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_address); } @@ -11362,7 +11551,8 @@ DEFUN (show_ip_bgp_flap_prefix, "Display flap statistics of routes\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { - return bgp_show_prefix_longer (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, + int idx_ipv4_prefixlen = 4; + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_prefix); } @@ -11386,7 +11576,8 @@ DEFUN (show_bgp_prefix_longer, "IPv6 prefix <network>/<length>\n" "Display route and more specific routes\n") { - return bgp_show_prefix_longer (vty, NULL, argv[2]->arg, AFI_IP6, SAFI_UNICAST, + int idx_ipv6_prefixlen = 2; + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_prefix_longer); } @@ -11401,8 +11592,9 @@ DEFUN (show_ipv6_bgp_prefix_longer, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Display route and more specific routes\n") { + int idx_ipv6_prefixlen = 3; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_longer (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_UNICAST, + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, bgp_show_type_prefix_longer); } @@ -11416,8 +11608,9 @@ DEFUN (show_ipv6_mbgp_prefix_longer, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Display route and more specific routes\n") { + int idx_ipv6_prefixlen = 3; bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_longer (vty, NULL, argv[3]->arg, AFI_IP6, SAFI_MULTICAST, + return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, bgp_show_type_prefix_longer); } #endif /* HAVE_IPV6 */ @@ -11832,7 +12025,9 @@ DEFUN (show_bgp_statistics, "Address Family modifier\n" "BGP RIB advertisement statistics\n") { - return bgp_table_stats_vty (vty, NULL, argv[2]->arg, argv[3]->arg); + int idx_afi = 2; + int idx_safi = 3; + return bgp_table_stats_vty (vty, NULL, argv[idx_afi]->arg, argv[idx_safi]->arg); } DEFUN (show_bgp_statistics_view, @@ -11849,7 +12044,9 @@ DEFUN (show_bgp_statistics_view, "Address Family modifier\n" "BGP RIB advertisement statistics\n") { - return bgp_table_stats_vty (vty, NULL, argv[3]->arg, argv[4]->arg); + int idx_word = 3; + int idx_afi = 4; + return bgp_table_stats_vty (vty, NULL, argv[idx_word]->arg, argv[idx_afi]->arg); } enum bgp_pcounts @@ -12056,10 +12253,11 @@ DEFUN (show_ip_bgp_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12080,10 +12278,12 @@ DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[4]->arg, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12103,10 +12303,11 @@ DEFUN (show_bgp_ipv6_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12127,10 +12328,12 @@ DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[3]->arg, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12153,14 +12356,16 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if (strncmp (argv[4]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); @@ -12182,10 +12387,11 @@ DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, "Display detailed prefix count information\n" "JavaScript Object Notation\n") { + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12460,13 +12666,15 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route, "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - if (argc == 4 || (argc == 3 && argv[6]->arg && strcmp(argv[6]->arg, "json") != 0)) - peer = peer_lookup_in_view (vty, argv[4]->arg, argv[6]->arg, uj); + if (argc == 4 || (argc == 3 && argv[idx_peer]->arg && strcmp(argv[idx_peer]->arg, "json") != 0)) + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); else - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_word]->arg, uj); if (! peer) return CMD_WARNING; @@ -12502,18 +12710,20 @@ DEFUN (show_ip_bgp_neighbor_advertised_route, "JavaScript Object Notation\n") { + int idx_peer = 4; + int idx_json = 6; struct peer *peer; const char *rmap_name = NULL; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if ((argc == 2 && argv[6]->arg && strcmp(argv[6]->arg, "json") != 0) + if ((argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0) || (argc == 3)) - rmap_name = argv[6]->arg; + rmap_name = argv[idx_json]->arg; return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); } @@ -12553,18 +12763,21 @@ DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_peer = 6; + int idx_json = 8; struct peer *peer; const char *rmap_name = NULL; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if ((argc == 4) || (argc == 3 && argv[8]->arg && strcmp(argv[8]->arg, "json") != 0)) - rmap_name = argv[8]->arg; + if ((argc == 4) || (argc == 3 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) + rmap_name = argv[idx_json]->arg; - if (strncmp (argv[4]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); else return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); @@ -12600,13 +12813,15 @@ DEFUN (show_bgp_instance_neighbor_advertised_route, "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 5; struct peer *peer; u_char uj = use_json(argc, argv); - if (argc == 4 || (argc == 3 && argv[5]->arg && strcmp(argv[5]->arg, "json") != 0)) - peer = peer_lookup_in_view (vty, argv[3]->arg, argv[5]->arg, uj); + if (argc == 4 || (argc == 3 && argv[idx_peer]->arg && strcmp(argv[idx_peer]->arg, "json") != 0)) + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); else - peer = peer_lookup_in_view (vty, NULL, argv[3]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_word]->arg, uj); if (! peer) return CMD_WARNING; @@ -12653,17 +12868,19 @@ DEFUN (show_bgp_neighbor_advertised_route, "JavaScript Object Notation\n") { + int idx_peer = 3; + int idx_json = 5; struct peer *peer; const char *rmap_name = NULL; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[3]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (!peer) return CMD_WARNING; - if (argc == 3 || (argc == 2 && argv[5]->arg && strcmp(argv[5]->arg, "json") != 0)) - rmap_name = argv[5]->arg; + if (argc == 3 || (argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) + rmap_name = argv[idx_json]->arg; return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, rmap_name, uj); } @@ -12686,10 +12903,11 @@ DEFUN (ipv6_mbgp_neighbor_advertised_route, "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12726,10 +12944,12 @@ DEFUN (show_bgp_instance_neighbor_received_routes, "Display the received routes from neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 5; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[3]->arg, argv[5]->arg, uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12765,10 +12985,12 @@ DEFUN (show_ip_bgp_instance_neighbor_received_routes, "Display the received routes from neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[4]->arg, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -12804,17 +13026,19 @@ DEFUN (show_ip_bgp_neighbor_received_routes, "JavaScript Object Notation\n") { + int idx_peer = 4; + int idx_json = 6; struct peer *peer; const char *rmap_name = NULL; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if (argc == 3 || (argc == 2 && argv[6]->arg && strcmp(argv[6]->arg, "json") != 0)) - rmap_name = argv[6]->arg; + if (argc == 3 || (argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) + rmap_name = argv[idx_json]->arg; return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); } @@ -12854,18 +13078,21 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, "Display the received routes from neighbor\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_peer = 6; + int idx_json = 8; struct peer *peer; const char *rmap_name = NULL; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if (argc == 4 || (argc == 3 && argv[8]->arg && strcmp(argv[8]->arg, "json") != 0)) - rmap_name = argv[8]->arg; + if (argc == 4 || (argc == 3 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) + rmap_name = argv[idx_json]->arg; - if (strncmp (argv[4]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); else return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); @@ -12890,20 +13117,25 @@ DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, "Display the received routes from neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_afi = 4; + int idx_safi = 5; + int idx_peer = 7; + int idx_adv_rcvd_routes = 8; int afi; int safi; int in; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[3]->arg, argv[7]->arg, uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - afi = (strncmp (argv[4]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[5]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - in = (strncmp (argv[8]->arg, "r", 1) == 0) ? 1 : 0; + afi = (strncmp (argv[idx_afi]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + in = (strncmp (argv[idx_adv_rcvd_routes]->arg, "r", 1) == 0) ? 1 : 0; return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); } @@ -12922,16 +13154,17 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, "Display the prefixlist filter\n" "JavaScript Object Notation\n") { + int idx_peer = 4; char name[BUFSIZ]; union sockunion su; struct peer *peer; int count, ret; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[4]->arg, &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (NULL, argv[4]->arg); + peer = peer_lookup_by_conf_if (NULL, argv[idx_peer]->arg); if (! peer) { if (uj) @@ -12941,13 +13174,13 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, json_no = json_object_new_object(); json_sub = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[4]->arg); + json_object_string_add(json_sub, "warningCause", argv[idx_peer]->arg); json_object_object_add(json_no, "detail", json_sub); vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); json_object_free(json_no); } else - vty_out (vty, "%% Malformed address or name: %s%s", argv[4]->arg, VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -13012,16 +13245,18 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, "Display the prefixlist filter\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_peer = 6; char name[BUFSIZ]; union sockunion su; struct peer *peer; int count, ret; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[6]->arg, &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (NULL, argv[6]->arg); + peer = peer_lookup_by_conf_if (NULL, argv[idx_peer]->arg); if (! peer) { if (uj) @@ -13031,13 +13266,13 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, json_no = json_object_new_object(); json_sub = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[6]->arg); + json_object_string_add(json_sub, "warningCause", argv[idx_peer]->arg); json_object_object_add(json_no, "detail", json_sub); vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); json_object_free(json_no); } else - vty_out (vty, "%% Malformed address or name: %s%s", argv[6]->arg, VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -13060,7 +13295,7 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, } } - if (strncmp (argv[4]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) { sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); @@ -13149,17 +13384,19 @@ DEFUN (show_bgp_neighbor_received_routes, "Display the received routes from neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 3; + int idx_json = 5; struct peer *peer; const char *rmap_name = NULL; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[3]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if (argc == 3 || (argc == 2 && argv[5]->arg && strcmp(argv[5]->arg, "json") != 0)) - rmap_name = argv[5]->arg; + if (argc == 3 || (argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) + rmap_name = argv[idx_json]->arg; return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, rmap_name, uj); } @@ -13193,16 +13430,17 @@ DEFUN (show_bgp_neighbor_received_prefix_filter, "Display the prefixlist filter\n" "JavaScript Object Notation\n") { + int idx_peer = 3; char name[BUFSIZ]; union sockunion su; struct peer *peer; int count, ret; u_char uj = use_json(argc, argv); - ret = str2sockunion (argv[3]->arg, &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (NULL, argv[3]->arg); + peer = peer_lookup_by_conf_if (NULL, argv[idx_peer]->arg); if (! peer) { if (uj) @@ -13212,13 +13450,13 @@ DEFUN (show_bgp_neighbor_received_prefix_filter, json_no = json_object_new_object(); json_sub = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[3]->arg); + json_object_string_add(json_sub, "warningCause", argv[idx_peer]->arg); json_object_object_add(json_no, "detail", json_sub); vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); json_object_free(json_no); } else - vty_out (vty, "%% Malformed address or name: %s%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -13283,10 +13521,11 @@ DEFUN (ipv6_mbgp_neighbor_received_routes, "Display the received routes from neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -13324,6 +13563,8 @@ DEFUN (show_bgp_instance_neighbor_received_prefix_filter, "Display the prefixlist filter\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 5; char name[BUFSIZ]; union sockunion su; struct peer *peer; @@ -13332,7 +13573,7 @@ DEFUN (show_bgp_instance_neighbor_received_prefix_filter, u_char uj = use_json(argc, argv); /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[3]->arg); + bgp = bgp_lookup_by_name (argv[idx_word]->arg); if (bgp == NULL) { if (uj) @@ -13344,14 +13585,14 @@ DEFUN (show_bgp_instance_neighbor_received_prefix_filter, json_object_free(json_no); } else - vty_out (vty, "Can't find BGP instance %s%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "Can't find BGP instance %s%s", argv[idx_word]->arg, VTY_NEWLINE); return CMD_WARNING; } - ret = str2sockunion (argv[5]->arg, &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (bgp, argv[5]->arg); + peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); if (! peer) { if (uj) @@ -13361,13 +13602,13 @@ DEFUN (show_bgp_instance_neighbor_received_prefix_filter, json_no = json_object_new_object(); json_sub = json_object_new_object(); json_object_string_add(json_no, "warning", "Malformed address or name"); - json_object_string_add(json_sub, "warningCause", argv[5]->arg); + json_object_string_add(json_sub, "warningCause", argv[idx_peer]->arg); json_object_object_add(json_no, "detail", json_sub); vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); json_object_free(json_no); } else - vty_out (vty, "%% Malformed address or name: %s%s", argv[5]->arg, VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -13439,10 +13680,11 @@ DEFUN (show_ip_bgp_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -13464,10 +13706,12 @@ DEFUN (show_ip_bgp_instance_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[4]->arg, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -13488,10 +13732,11 @@ DEFUN (show_ip_bgp_neighbor_flap, "Display flap statistics of the routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -13512,10 +13757,11 @@ DEFUN (show_ip_bgp_neighbor_damp, "Display the dampened routes received from neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -13539,14 +13785,16 @@ DEFUN (show_ip_bgp_ipv4_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_safi = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[6]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - if (strncmp (argv[4]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, bgp_show_type_neighbor, uj); @@ -13583,10 +13831,12 @@ DEFUN (show_bgp_instance_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 5; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[3]->arg, argv[5]->arg, uj); + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -13644,14 +13894,17 @@ DEFUN (show_bgp_instance_neighbor_damp, "Display the dampened routes received from neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 5; + int idx_json = 7; struct peer *peer; u_char uj = use_json(argc, argv); - if ((argc == 4 && argv[7]->arg && strcmp(argv[7]->arg, "json") == 0) - || (argc == 3 && argv[5]->arg && strcmp(argv[5]->arg, "json") != 0)) - peer = peer_lookup_in_view (vty, argv[3]->arg, argv[5]->arg, uj); + if ((argc == 4 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") == 0) + || (argc == 3 && argv[idx_peer]->arg && strcmp(argv[idx_peer]->arg, "json") != 0)) + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); else - peer = peer_lookup_in_view (vty, NULL, argv[3]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_word]->arg, uj); if (! peer) return CMD_WARNING; @@ -13710,14 +13963,17 @@ DEFUN (show_bgp_instance_neighbor_flap, "Display flap statistics of the routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_peer = 5; + int idx_json = 7; struct peer *peer; u_char uj = use_json(argc, argv); - if ((argc == 4 && argv[7]->arg && strcmp(argv[7]->arg, "json") == 0) - || (argc == 3 && argv[5]->arg && strcmp(argv[5]->arg, "json") != 0)) - peer = peer_lookup_in_view (vty, argv[3]->arg, argv[5]->arg, uj); + if ((argc == 4 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") == 0) + || (argc == 3 && argv[idx_peer]->arg && strcmp(argv[idx_peer]->arg, "json") != 0)) + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); else - peer = peer_lookup_in_view (vty, NULL, argv[3]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_word]->arg, uj); if (! peer) return CMD_WARNING; @@ -13764,10 +14020,11 @@ DEFUN (show_bgp_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 3; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[3]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -13793,10 +14050,11 @@ DEFUN (ipv6_mbgp_neighbor_routes, "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { + int idx_peer = 4; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[4]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; @@ -14008,13 +14266,16 @@ DEFUN (bgp_distance, "Distance for routes internal to the AS\n" "Distance for local routes\n") { + int idx_number = 2; + int idx_number_2 = 3; + int idx_number_3 = 4; struct bgp *bgp; bgp = vty->index; - bgp->distance_ebgp = atoi (argv[2]->arg); - bgp->distance_ibgp = atoi (argv[3]->arg); - bgp->distance_local = atoi (argv[4]->arg); + bgp->distance_ebgp = atoi (argv[idx_number]->arg); + bgp->distance_ibgp = atoi (argv[idx_number_2]->arg); + bgp->distance_local = atoi (argv[idx_number_3]->arg); return CMD_SUCCESS; } @@ -14054,7 +14315,9 @@ DEFUN (bgp_distance_source, "Administrative distance\n" "IP source prefix\n") { - bgp_distance_set (vty, argv[1]->arg, argv[2]->arg, NULL); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + bgp_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } @@ -14066,7 +14329,9 @@ DEFUN (no_bgp_distance_source, "Administrative distance\n" "IP source prefix\n") { - bgp_distance_unset (vty, argv[2]->arg, argv[3]->arg, NULL); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + bgp_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } @@ -14078,7 +14343,10 @@ DEFUN (bgp_distance_source_access_list, "IP source prefix\n" "Access list name\n") { - bgp_distance_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + int idx_word = 3; + bgp_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -14091,7 +14359,10 @@ DEFUN (no_bgp_distance_source_access_list, "IP source prefix\n" "Access list name\n") { - bgp_distance_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + int idx_word = 4; + bgp_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -14117,6 +14388,10 @@ DEFUN (bgp_damp_set, "Value to start suppressing a route\n" "Maximum duration to suppress a stable route\n") { + int idx_number = 2; + int idx_number_2 = 3; + int idx_number_3 = 4; + int idx_number_4 = 5; struct bgp *bgp; int half = DEFAULT_HALF_LIFE * 60; int reuse = DEFAULT_REUSE; @@ -14125,14 +14400,14 @@ DEFUN (bgp_damp_set, if (argc == 4) { - half = atoi (argv[2]->arg) * 60; - reuse = atoi (argv[3]->arg); - suppress = atoi (argv[4]->arg); - max = atoi (argv[5]->arg) * 60; + half = atoi (argv[idx_number]->arg) * 60; + reuse = atoi (argv[idx_number_2]->arg); + suppress = atoi (argv[idx_number_3]->arg); + max = atoi (argv[idx_number_4]->arg) * 60; } else if (argc == 1) { - half = atoi (argv[2]->arg) * 60; + half = atoi (argv[idx_number]->arg) * 60; max = 4 * half; } @@ -14353,7 +14628,8 @@ DEFUN (clear_ip_bgp_dampening_prefix, "Clear route flap dampening information\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { - return bgp_clear_damp_route (vty, NULL, argv[4]->arg, AFI_IP, + int idx_ipv4_prefixlen = 4; + return bgp_clear_damp_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1); } @@ -14366,7 +14642,8 @@ DEFUN (clear_ip_bgp_dampening_address, "Clear route flap dampening information\n" "Network to clear damping information\n") { - return bgp_clear_damp_route (vty, NULL, argv[4]->arg, AFI_IP, + int idx_ipv4 = 4; + return bgp_clear_damp_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0); } @@ -14380,10 +14657,12 @@ DEFUN (clear_ip_bgp_dampening_address_mask, "Network to clear damping information\n" "Network mask\n") { + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; int ret; char prefix_str[BUFSIZ]; - ret = netmask_str2prefix_str (argv[4]->arg, argv[5]->arg, prefix_str); + ret = netmask_str2prefix_str (argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, prefix_str); if (! ret) { vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index dc342b110..0b43b14e6 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3000,7 +3000,8 @@ DEFUN (match_peer, "IP address of peer\n" "IPv6 address of peer\n") { - return bgp_route_match_add (vty, vty->index, "peer", argv[2]->arg, + int idx_ip = 2; + return bgp_route_match_add (vty, vty->index, "peer", argv[idx_ip]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -3054,7 +3055,8 @@ DEFUN (match_ip_address, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - return bgp_route_match_add (vty, vty->index, "ip address", argv[3]->arg, + int idx_acl = 3; + return bgp_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED); } @@ -3093,7 +3095,8 @@ DEFUN (match_ip_next_hop, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg, + int idx_acl = 3; + return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED); } @@ -3131,7 +3134,8 @@ DEFUN (match_probability, "Match portion of routes defined by percentage value\n" "Percentage of routes\n") { - return bgp_route_match_add (vty, vty->index, "probability", argv[2]->arg, + int idx_number = 2; + return bgp_route_match_add (vty, vty->index, "probability", argv[idx_number]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -3168,7 +3172,8 @@ DEFUN (match_ip_route_source, "IP access-list number (expanded range)\n" "IP standard access-list name\n") { - return bgp_route_match_add (vty, vty->index, "ip route-source", argv[3]->arg, + int idx_acl = 3; + return bgp_route_match_add (vty, vty->index, "ip route-source", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED); } @@ -3206,8 +3211,9 @@ DEFUN (match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return bgp_route_match_add (vty, vty->index, "ip address prefix-list", - argv[4]->arg, RMAP_EVENT_PLIST_ADDED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); } /* @@ -3244,8 +3250,9 @@ DEFUN (match_ip_next_hop_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[4]->arg, RMAP_EVENT_PLIST_ADDED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); } /* @@ -3282,8 +3289,9 @@ DEFUN (match_ip_route_source_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list", - argv[4]->arg, RMAP_EVENT_PLIST_ADDED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); } /* @@ -3318,7 +3326,8 @@ DEFUN (match_metric, "Match metric of route\n" "Metric value\n") { - return bgp_route_match_add (vty, vty->index, "metric", argv[2]->arg, + int idx_number = 2; + return bgp_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -3351,7 +3360,8 @@ DEFUN (match_local_pref, "Match local-preference of route\n" "Metric value\n") { - return bgp_route_match_add (vty, vty->index, "local-preference", argv[2]->arg, + int idx_number = 2; + return bgp_route_match_add (vty, vty->index, "local-preference", argv[idx_number]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -3386,7 +3396,8 @@ DEFUN (match_community, "Community-list number (expanded)\n" "Community-list name\n") { - return bgp_route_match_add (vty, vty->index, "community", argv[2]->arg, + int idx_comm_list = 2; + return bgp_route_match_add (vty, vty->index, "community", argv[idx_comm_list]->arg, RMAP_EVENT_CLIST_ADDED); } @@ -3400,13 +3411,14 @@ DEFUN (match_community_exact, "Community-list name\n" "Do exact matching of communities\n") { + int idx_comm_list = 2; int ret; char *argstr; argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, - strlen (argv[2]->arg) + strlen ("exact-match") + 2); + strlen (argv[idx_comm_list]->arg) + strlen ("exact-match") + 2); - sprintf (argstr, "%s exact-match", argv[2]->arg); + sprintf (argstr, "%s exact-match", argv[idx_comm_list]->arg); ret = bgp_route_match_add (vty, vty->index, "community", argstr, RMAP_EVENT_CLIST_ADDED); @@ -3458,7 +3470,8 @@ DEFUN (match_ecommunity, "Extended community-list number (expanded)\n" "Extended community-list name\n") { - return bgp_route_match_add (vty, vty->index, "extcommunity", argv[2]->arg, + int idx_comm_list = 2; + return bgp_route_match_add (vty, vty->index, "extcommunity", argv[idx_comm_list]->arg, RMAP_EVENT_ECLIST_ADDED); } @@ -3492,7 +3505,8 @@ DEFUN (match_aspath, "Match BGP AS path list\n" "AS path access-list name\n") { - return bgp_route_match_add (vty, vty->index, "as-path", argv[2]->arg, + int idx_word = 2; + return bgp_route_match_add (vty, vty->index, "as-path", argv[idx_word]->arg, RMAP_EVENT_ASLIST_ADDED); } @@ -3526,13 +3540,14 @@ DEFUN (match_origin, "local IGP\n" "unknown heritage\n") { - if (strncmp (argv[2]->arg, "igp", 2) == 0) + int idx_origin = 2; + if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0) return bgp_route_match_add (vty, vty->index, "origin", "igp", RMAP_EVENT_MATCH_ADDED); - if (strncmp (argv[2]->arg, "egp", 1) == 0) + if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0) return bgp_route_match_add (vty, vty->index, "origin", "egp", RMAP_EVENT_MATCH_ADDED); - if (strncmp (argv[2]->arg, "incomplete", 2) == 0) + if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0) return bgp_route_match_add (vty, vty->index, "origin", "incomplete", RMAP_EVENT_MATCH_ADDED); @@ -3569,7 +3584,8 @@ DEFUN (match_interface, "Match first hop interface of route\n" "Interface name\n") { - return bgp_route_match_add (vty, vty->index, "interface", argv[2]->arg, + int idx_word = 2; + return bgp_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -3601,7 +3617,8 @@ DEFUN (match_tag, "Match tag of route\n" "Tag value\n") { - return bgp_route_match_add (vty, vty->index, "tag", argv[2]->arg, + int idx_number = 2; + return bgp_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -3635,10 +3652,11 @@ DEFUN (set_ip_nexthop, "Next hop address\n" "IP address of next hop\n") { + int idx_ipv4 = 3; union sockunion su; int ret; - ret = str2sockunion (argv[3]->arg, &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); @@ -3652,7 +3670,7 @@ DEFUN (set_ip_nexthop, return CMD_WARNING; } - return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[3]->arg); + return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg); } DEFUN (set_ip_nexthop_peer, @@ -3728,7 +3746,8 @@ DEFUN (set_metric, "Metric value for destination routing protocol\n" "Metric value\n") { - return bgp_route_set_add (vty, vty->index, "metric", argv[2]->arg); + int idx_number = 2; + return bgp_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg); } @@ -3760,7 +3779,8 @@ DEFUN (set_local_pref, "BGP local preference path attribute\n" "Preference value\n") { - return bgp_route_set_add (vty, vty->index, "local-preference", argv[2]->arg); + int idx_number = 2; + return bgp_route_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg); } /* @@ -3790,7 +3810,8 @@ DEFUN (set_weight, "BGP weight for routing table\n" "Weight value\n") { - return bgp_route_set_add (vty, vty->index, "weight", argv[2]->arg); + int idx_number = 2; + return bgp_route_set_add (vty, vty->index, "weight", argv[idx_number]->arg); } /* @@ -4055,11 +4076,12 @@ DEFUN (set_community_delete, "Community-list name\n" "Delete matching communities\n") { + int idx_comm_list = 2; char *str; - str = XCALLOC (MTYPE_TMP, strlen (argv[2]->arg) + strlen (" delete") + 1); - strcpy (str, argv[2]->arg); - strcpy (str + strlen (argv[2]->arg), " delete"); + str = XCALLOC (MTYPE_TMP, strlen (argv[idx_comm_list]->arg) + strlen (" delete") + 1); + strcpy (str, argv[idx_comm_list]->arg); + strcpy (str + strlen (argv[idx_comm_list]->arg), " delete"); bgp_route_set_add (vty, vty->index, "comm-list", str); @@ -4178,11 +4200,12 @@ DEFUN (set_origin, "local IGP\n" "unknown heritage\n") { - if (strncmp (argv[2]->arg, "igp", 2) == 0) + int idx_origin = 2; + if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0) return bgp_route_set_add (vty, vty->index, "origin", "igp"); - if (strncmp (argv[2]->arg, "egp", 1) == 0) + if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0) return bgp_route_set_add (vty, vty->index, "origin", "egp"); - if (strncmp (argv[2]->arg, "incomplete", 2) == 0) + if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0) return bgp_route_set_add (vty, vty->index, "origin", "incomplete"); return CMD_WARNING; @@ -4238,11 +4261,13 @@ DEFUN (set_aggregator_as, "AS number\n" "IP address of aggregator\n") { + int idx_number = 3; + int idx_ipv4 = 4; int ret; struct in_addr address; char *argstr; - ret = inet_aton (argv[4]->arg, &address); + ret = inet_aton (argv[idx_ipv4]->arg, &address); if (ret == 0) { vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE); @@ -4250,9 +4275,9 @@ DEFUN (set_aggregator_as, } argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, - strlen (argv[3]->arg) + strlen (argv[4]->arg) + 2); + strlen (argv[idx_number]->arg) + strlen (argv[idx_ipv4]->arg) + 2); - sprintf (argstr, "%s %s", argv[3]->arg, argv[4]->arg); + sprintf (argstr, "%s %s", argv[idx_number]->arg, argv[idx_ipv4]->arg); ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr); @@ -4314,7 +4339,8 @@ DEFUN (set_tag, "Tag value for routing protocol\n" "Tag value\n") { - return bgp_route_set_add (vty, vty->index, "tag", argv[2]->arg); + int idx_number = 2; + return bgp_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); } /* @@ -4347,7 +4373,8 @@ DEFUN (match_ipv6_address, "Match IPv6 address of route\n" "IPv6 access-list name\n") { - return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[3]->arg, + int idx_word = 3; + return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[idx_word]->arg, RMAP_EVENT_FILTER_ADDED); } @@ -4360,7 +4387,8 @@ DEFUN (no_match_ipv6_address, "Match IPv6 address of route\n" "IPv6 access-list name\n") { - return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[4]->arg, + int idx_word = 4; + return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[idx_word]->arg, RMAP_EVENT_FILTER_DELETED); } @@ -4372,7 +4400,8 @@ DEFUN (match_ipv6_next_hop, "Match IPv6 next-hop address of route\n" "IPv6 address of next hop\n") { - return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[3]->arg, + int idx_ipv6 = 3; + return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -4385,7 +4414,8 @@ DEFUN (no_match_ipv6_next_hop, "Match IPv6 next-hop address of route\n" "IPv6 address of next hop\n") { - return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[4]->arg, + int idx_ipv6 = 4; + return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg, RMAP_EVENT_MATCH_DELETED); } @@ -4398,8 +4428,9 @@ DEFUN (match_ipv6_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list", - argv[4]->arg, RMAP_EVENT_PLIST_ADDED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); } DEFUN (no_match_ipv6_address_prefix_list, @@ -4412,8 +4443,9 @@ DEFUN (no_match_ipv6_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 5; return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list", - argv[5]->arg, RMAP_EVENT_PLIST_DELETED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); } DEFUN (set_ipv6_nexthop_peer, @@ -4471,10 +4503,11 @@ DEFUN (set_ipv6_nexthop_global, "IPv6 global address\n" "IPv6 address of next hop\n") { + int idx_ipv6 = 4; struct in6_addr addr; int ret; - ret = inet_pton (AF_INET6, argv[4]->arg, &addr); + ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); if (!ret) { vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); @@ -4489,7 +4522,7 @@ DEFUN (set_ipv6_nexthop_global, return CMD_WARNING; } - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[4]->arg); + return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg); } /* @@ -4525,10 +4558,11 @@ DEFUN (set_ipv6_nexthop_local, "IPv6 local address\n" "IPv6 address of next hop\n") { + int idx_ipv6 = 4; struct in6_addr addr; int ret; - ret = inet_pton (AF_INET6, argv[4]->arg, &addr); + ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); if (!ret) { vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); @@ -4540,7 +4574,7 @@ DEFUN (set_ipv6_nexthop_local, return CMD_WARNING; } - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[4]->arg); + return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg); } /* @@ -4576,7 +4610,8 @@ DEFUN (set_vpnv4_nexthop, "VPNv4 next-hop address\n" "IP address of next hop\n") { - return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[3]->arg); + int idx_ipv4 = 3; + return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg); } /* @@ -4608,7 +4643,8 @@ DEFUN (set_originator_id, "BGP originator ID attribute\n" "IP address of originator\n") { - return bgp_route_set_add (vty, vty->index, "originator-id", argv[2]->arg); + int idx_ipv4 = 2; + return bgp_route_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg); } /* diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1c015eb66..8f1db7624 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -614,7 +614,8 @@ DEFUN (bgp_config_type, "cisco\n" "zebra\n") { - if (strncmp (argv[2]->arg, "c", 1) == 0) + int idx_vendor = 2; + if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) bgp_option_set (BGP_OPT_CONFIG_CISCO); else bgp_option_unset (BGP_OPT_CONFIG_CISCO); @@ -684,6 +685,7 @@ DEFUN (router_bgp, BGP_STR AS_STR) { + int idx_number = 2; int ret; as_t as; struct bgp *bgp; @@ -712,7 +714,7 @@ DEFUN (router_bgp, // "router bgp X" else { - VTY_GET_INTEGER_RANGE ("AS", as, argv[2]->arg, 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); inst_type = BGP_INSTANCE_TYPE_DEFAULT; if (argc == 3) @@ -777,6 +779,7 @@ DEFUN (no_router_bgp, BGP_STR AS_STR) { + int idx_number = 3; as_t as; struct bgp *bgp; const char *name = NULL; @@ -802,7 +805,7 @@ DEFUN (no_router_bgp, } else { - VTY_GET_INTEGER_RANGE ("AS", as, argv[3]->arg, 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); if (argc == 3) name = argv[5]->arg; @@ -832,13 +835,14 @@ DEFUN (bgp_router_id, "Override configured router identifier\n" "Manually configured router identifier\n") { + int idx_ipv4 = 2; int ret; struct in_addr id; struct bgp *bgp; bgp = vty->index; - ret = inet_aton (argv[2]->arg, &id); + ret = inet_aton (argv[idx_ipv4]->arg, &id); if (! ret) { vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); @@ -912,13 +916,14 @@ DEFUN (bgp_cluster_id, "Configure Route-Reflector Cluster-id\n" "Route-Reflector Cluster-id in IP address format\n") { + int idx_ipv4 = 2; int ret; struct bgp *bgp; struct in_addr cluster; bgp = vty->index; - ret = inet_aton (argv[2]->arg, &cluster); + ret = inet_aton (argv[idx_ipv4]->arg, &cluster); if (! ret) { vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); @@ -986,12 +991,13 @@ DEFUN (bgp_confederation_identifier, "AS number\n" "Set routing domain confederation AS\n") { + int idx_number = 3; struct bgp *bgp; as_t as; bgp = vty->index; - VTY_GET_INTEGER_RANGE ("AS", as, argv[3]->arg, 1, BGP_AS4_MAX); + VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); bgp_confederation_id_set (bgp, as); @@ -1151,12 +1157,13 @@ DEFUN (bgp_maxmed_admin_medv, "Administratively applied, for an indefinite period\n" "Max MED value to be used\n") { + int idx_number = 3; struct bgp *bgp; bgp = vty->index; bgp->v_maxmed_admin = 1; - VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[3]->arg); + VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); bgp_maxmed_update(bgp); @@ -1203,6 +1210,7 @@ DEFUN (bgp_maxmed_onstartup, "Effective on a startup\n" "Time (seconds) period for max-med\n") { + int idx_number = 3; struct bgp *bgp; bgp = vty->index; @@ -1213,7 +1221,7 @@ DEFUN (bgp_maxmed_onstartup, return CMD_WARNING; } - VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[3]->arg); + VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; bgp_maxmed_update(bgp); @@ -1230,6 +1238,8 @@ DEFUN (bgp_maxmed_onstartup_medv, "Time (seconds) period for max-med\n" "Max MED value to be used\n") { + int idx_number = 3; + int idx_number_2 = 4; struct bgp *bgp; bgp = vty->index; @@ -1240,8 +1250,8 @@ DEFUN (bgp_maxmed_onstartup_medv, return CMD_WARNING; } - VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[3]->arg); - VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[4]->arg); + VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); + VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); bgp_maxmed_update(bgp); @@ -1366,7 +1376,8 @@ DEFUN (bgp_update_delay, "Force initial delay for best-path and updates\n" "Seconds\n") { - return bgp_update_delay_config_vty(vty, argv[1]->arg, NULL); + int idx_number = 1; + return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); } DEFUN (bgp_update_delay_establish_wait, @@ -1377,7 +1388,9 @@ DEFUN (bgp_update_delay_establish_wait, "Wait for peers to be established\n" "Seconds\n") { - return bgp_update_delay_config_vty(vty, argv[1]->arg, argv[2]->arg); + int idx_number = 1; + int idx_number_2 = 2; + return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); } /* Update-delay deconfiguration */ @@ -1434,7 +1447,8 @@ DEFUN (bgp_wpkt_quanta, "How many packets to write to peer socket per run\n" "Number of packets\n") { - return bgp_wpkt_quanta_config_vty(vty, argv[1]->arg, 1); + int idx_number = 1; + return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); } /* Update-delay deconfiguration */ @@ -1444,7 +1458,8 @@ DEFUN (no_bgp_wpkt_quanta, "How many packets to write to peer socket per run\n" "Number of packets\n") { - return bgp_wpkt_quanta_config_vty(vty, argv[2]->arg, 0); + int idx_number = 2; + return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); } static int @@ -1480,7 +1495,8 @@ DEFUN (bgp_coalesce_time, "Subgroup coalesce timer\n" "Subgroup coalesce timer value (in ms)\n") { - return bgp_coalesce_config_vty(vty, argv[1]->arg, 1); + int idx_number = 1; + return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); } DEFUN (no_bgp_coalesce_time, @@ -1489,7 +1505,8 @@ DEFUN (no_bgp_coalesce_time, "Subgroup coalesce timer\n" "Subgroup coalesce timer value (in ms)\n") { - return bgp_coalesce_config_vty(vty, argv[2]->arg, 0); + int idx_number = 2; + return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); } /* Maximum-paths configuration */ @@ -1499,7 +1516,8 @@ DEFUN (bgp_maxpaths, "Forward packets over multiple paths\n" "Number of paths\n") { - return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[1]->arg, 0, 1); + int idx_number = 1; + return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); } DEFUN (bgp_maxpaths_ibgp, @@ -1509,7 +1527,8 @@ DEFUN (bgp_maxpaths_ibgp, "iBGP-multipath\n" "Number of paths\n") { - return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[2]->arg, 0, 1); + int idx_number = 2; + return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); } DEFUN (bgp_maxpaths_ibgp_cluster, @@ -1520,7 +1539,8 @@ DEFUN (bgp_maxpaths_ibgp_cluster, "Number of paths\n" "Match the cluster length\n") { - return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[2]->arg, + int idx_number = 2; + return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); } @@ -1607,14 +1627,16 @@ DEFUN (bgp_timers, "Keepalive interval\n" "Holdtime\n") { + int idx_number = 2; + int idx_number_2 = 3; struct bgp *bgp; unsigned long keepalive = 0; unsigned long holdtime = 0; bgp = vty->index; - VTY_GET_INTEGER ("keepalive", keepalive, argv[2]->arg); - VTY_GET_INTEGER ("holdtime", holdtime, argv[3]->arg); + VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); + VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); /* Holdtime value check. */ if (holdtime < 3 && holdtime != 0) @@ -1826,6 +1848,7 @@ DEFUN (bgp_graceful_restart_stalepath_time, "Set the max time to hold onto restarting peer's stale paths\n" "Delay value (seconds)\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t stalepath; @@ -1833,7 +1856,7 @@ DEFUN (bgp_graceful_restart_stalepath_time, if (! bgp) return CMD_WARNING; - VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[3]->arg, 1, 3600); + VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); bgp->stalepath_time = stalepath; return CMD_SUCCESS; } @@ -1846,6 +1869,7 @@ DEFUN (bgp_graceful_restart_restart_time, "Set the time to wait to delete stale routes before a BGP open message is received\n" "Delay value (seconds)\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t restart; @@ -1853,7 +1877,7 @@ DEFUN (bgp_graceful_restart_restart_time, if (! bgp) return CMD_WARNING; - VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[3]->arg, 1, 3600); + VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); bgp->restart_time = restart; return CMD_SUCCESS; } @@ -2093,6 +2117,7 @@ DEFUN (bgp_bestpath_aspath_multipath_relax, "Generate an AS_SET\n" "Do not generate an AS_SET\n") { + int idx_as_set = 4; struct bgp *bgp; bgp = vty->index; @@ -2100,7 +2125,7 @@ DEFUN (bgp_bestpath_aspath_multipath_relax, /* no-as-set is now the default behavior so we can silently * ignore it */ - if (argv[4]->arg != NULL && strncmp (argv[4]->arg, "a", 1) == 0) + if (argv[idx_as_set]->arg != NULL && strncmp (argv[idx_as_set]->arg, "a", 1) == 0) bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); else bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; @@ -2169,11 +2194,12 @@ DEFUN (bgp_bestpath_med, "Compare MED among confederation paths\n" "Treat missing MED as the least preferred one\n") { + int idx_med_knob = 3; struct bgp *bgp; bgp = vty->index; - if (strncmp (argv[3]->arg, "confed", 1) == 0) + if (strncmp (argv[idx_med_knob]->arg, "confed", 1) == 0) bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); else bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); @@ -2223,11 +2249,12 @@ DEFUN (no_bgp_bestpath_med, "Compare MED among confederation paths\n" "Treat missing MED as the least preferred one\n") { + int idx_med_knob = 4; struct bgp *bgp; bgp = vty->index; - if (strncmp (argv[4]->arg, "confed", 1) == 0) + if (strncmp (argv[idx_med_knob]->arg, "confed", 1) == 0) bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); else bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); @@ -2385,12 +2412,13 @@ DEFUN (bgp_default_local_preference, "local preference (higher=more preferred)\n" "Configure default local preference value\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t local_pref; bgp = vty->index; - VTY_GET_INTEGER ("local preference", local_pref, argv[3]->arg); + VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); bgp_default_local_preference_set (bgp, local_pref); bgp_clear_star_soft_in (vty, bgp->name); @@ -2434,12 +2462,13 @@ DEFUN (bgp_default_subgroup_pkt_queue_max, "subgroup-pkt-queue-max\n" "Configure subgroup packet queue max\n") { + int idx_number = 3; struct bgp *bgp; u_int32_t max_size; bgp = vty->index; - VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[3]->arg); + VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); @@ -2523,12 +2552,13 @@ DEFUN (bgp_listen_limit, "maximum number of BGP Dynamic Neighbors that can be created\n" "Configure Dynamic Neighbors listen limit value\n") { + int idx_number = 3; struct bgp *bgp; int listen_limit; bgp = vty->index; - VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[3]->arg, + VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); @@ -2603,6 +2633,8 @@ DEFUN (bgp_listen_range, "add a listening range for Dynamic Neighbors\n" LISTEN_RANGE_ADDR_STR) { + int idx_ipv4_ipv6_prefixlen = 3; + int idx_word = 5; struct bgp *bgp; struct prefix range; struct peer_group *group, *existing_group; @@ -2611,10 +2643,10 @@ DEFUN (bgp_listen_range, bgp = vty->index; - //VTY_GET_IPV4_PREFIX ("listen range", range, argv[3]->arg); + //VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_ipv6_prefixlen]->arg); /* Convert IP prefix string to struct prefix. */ - ret = str2prefix (argv[3]->arg, &range); + ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, &range); if (! ret) { vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); @@ -2638,7 +2670,7 @@ DEFUN (bgp_listen_range, existing_group = listen_range_exists (bgp, &range, 1); if (existing_group) { - if (strcmp (existing_group->name, argv[5]->arg) == 0) + if (strcmp (existing_group->name, argv[idx_word]->arg) == 0) return CMD_SUCCESS; else { @@ -2656,7 +2688,7 @@ DEFUN (bgp_listen_range, return CMD_WARNING; } - group = peer_group_lookup (bgp, argv[5]->arg); + group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); @@ -2675,6 +2707,8 @@ DEFUN (no_bgp_listen_range, "delete a listening range for Dynamic Neighbors\n" "Remove Dynamic Neighbors listening range\n") { + int idx_ipv4_prefixlen = 4; + int idx_word = 6; struct bgp *bgp; struct prefix range; struct peer_group *group; @@ -2683,10 +2717,10 @@ DEFUN (no_bgp_listen_range, bgp = vty->index; - // VTY_GET_IPV4_PREFIX ("listen range", range, argv[4]->arg); + // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); /* Convert IP prefix string to struct prefix. */ - ret = str2prefix (argv[4]->arg, &range); + ret = str2prefix (argv[idx_ipv4_prefixlen]->arg, &range); if (! ret) { vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); @@ -2707,7 +2741,7 @@ DEFUN (no_bgp_listen_range, apply_mask (&range); - group = peer_group_lookup (bgp, argv[6]->arg); + group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); @@ -2858,7 +2892,9 @@ DEFUN (neighbor_remote_as, "Specify a BGP neighbor\n" AS_STR) { - return peer_remote_as_vty (vty, argv[1]->arg, argv[3]->arg, AFI_IP, SAFI_UNICAST); + int idx_peer = 1; + int idx_remote_as = 3; + return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); } static int @@ -2980,11 +3016,12 @@ DEFUN (neighbor_interface_config, "Interface name or neighbor tag\n" "Enable BGP on interface\n") { + int idx_word = 1; if (argc == 2) - return peer_conf_interface_get (vty, argv[1]->arg, AFI_IP, SAFI_UNICAST, 0, + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, argv[3]->arg, NULL); else - return peer_conf_interface_get (vty, argv[1]->arg, AFI_IP, SAFI_UNICAST, 0, + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, NULL, NULL); } @@ -3008,7 +3045,8 @@ DEFUN (neighbor_interface_config_v6only, "Enable BGP on interface\n" "Enable BGP with v6 link-local only\n") { - return peer_conf_interface_get (vty, argv[1]->arg, AFI_IP, SAFI_UNICAST, 1, + int idx_word = 1; + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, argv[5]->arg, NULL); } @@ -3021,8 +3059,10 @@ DEFUN (neighbor_interface_config_remote_as, "Enable BGP on interface\n" AS_STR) { - return peer_conf_interface_get (vty, argv[1]->arg, AFI_IP, SAFI_UNICAST, 0, - NULL, argv[4]->arg); + int idx_word = 1; + int idx_remote_as = 4; + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, + NULL, argv[idx_remote_as]->arg); } DEFUN (neighbor_interface_v6only_config_remote_as, @@ -3033,8 +3073,10 @@ DEFUN (neighbor_interface_v6only_config_remote_as, "Enable BGP on interface\n" AS_STR) { - return peer_conf_interface_get (vty, argv[1]->arg, AFI_IP, SAFI_UNICAST, 1, - NULL, argv[5]->arg); + int idx_word = 1; + int idx_remote_as = 5; + return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, + NULL, argv[idx_remote_as]->arg); } DEFUN (neighbor_peer_group, @@ -3044,19 +3086,20 @@ DEFUN (neighbor_peer_group, "Interface name or neighbor tag\n" "Configure peer-group\n") { + int idx_word = 1; struct bgp *bgp; struct peer *peer; struct peer_group *group; bgp = vty->index; - peer = peer_lookup_by_conf_if (bgp, argv[1]->arg); + peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); if (peer) { vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); return CMD_WARNING; } - group = peer_group_get (bgp, argv[1]->arg); + group = peer_group_get (bgp, argv[idx_word]->arg); if (! group) return CMD_WARNING; @@ -3080,17 +3123,18 @@ DEFUN (no_neighbor, NEIGHBOR_STR NEIGHBOR_ADDR_STR2) { + int idx_peer = 2; int ret; union sockunion su; struct peer_group *group; struct peer *peer; struct peer *other; - ret = str2sockunion (argv[2]->arg, &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { /* look up for neighbor by interface name config. */ - peer = peer_lookup_by_conf_if (vty->index, argv[2]->arg); + peer = peer_lookup_by_conf_if (vty->index, argv[idx_peer]->arg); if (peer) { /* Request zebra to terminate IPv6 RAs on this interface. */ @@ -3100,7 +3144,7 @@ DEFUN (no_neighbor, return CMD_SUCCESS; } - group = peer_group_lookup (vty->index, argv[2]->arg); + group = peer_group_lookup (vty->index, argv[idx_peer]->arg); if (group) peer_group_delete (group); else @@ -3182,10 +3226,11 @@ DEFUN (no_neighbor_interface_config, "Interface name\n" "Configure BGP on interface\n") { + int idx_word = 2; struct peer *peer; /* look up for neighbor by interface name config. */ - peer = peer_lookup_by_conf_if (vty->index, argv[2]->arg); + peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg); if (peer) { /* Request zebra to terminate IPv6 RAs on this interface. */ @@ -3214,9 +3259,10 @@ DEFUN (no_neighbor_peer_group, "Neighbor tag\n" "Configure peer-group\n") { + int idx_word = 2; struct peer_group *group; - group = peer_group_lookup (vty->index, argv[2]->arg); + group = peer_group_lookup (vty->index, argv[idx_word]->arg); if (group) peer_group_delete (group); else @@ -3236,18 +3282,19 @@ DEFUN (no_neighbor_interface_peer_group_remote_as, "Specify a BGP neighbor\n" AS_STR) { + int idx_word = 2; struct peer_group *group; struct peer *peer; /* look up for neighbor by interface name config. */ - peer = peer_lookup_by_conf_if (vty->index, argv[2]->arg); + peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg); if (peer) { peer_as_change (peer, 0, AS_SPECIFIED); return CMD_SUCCESS; } - group = peer_group_lookup (vty->index, argv[2]->arg); + group = peer_group_lookup (vty->index, argv[idx_word]->arg); if (group) peer_group_remote_as_delete (group); else @@ -3266,14 +3313,16 @@ DEFUN (neighbor_local_as, "Specify a local-as number\n" "AS number used as local AS\n") { + int idx_peer = 1; + int idx_number = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[3]->arg), 0, 0); + ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 0, 0); return bgp_vty_return (vty, ret); } @@ -3286,14 +3335,16 @@ DEFUN (neighbor_local_as_no_prepend, "AS number used as local AS\n" "Do not prepend local-as to updates from ebgp peers\n") { + int idx_peer = 1; + int idx_number = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[3]->arg), 1, 0); + ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 0); return bgp_vty_return (vty, ret); } @@ -3307,14 +3358,16 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, "Do not prepend local-as to updates from ebgp peers\n" "Do not prepend local-as to updates from ibgp peers\n") { + int idx_peer = 1; + int idx_number = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[3]->arg), 1, 1); + ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 1); return bgp_vty_return (vty, ret); } @@ -3354,10 +3407,11 @@ DEFUN (no_neighbor_local_as, NEIGHBOR_ADDR_STR2 "Specify a local-as number\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[2]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3375,10 +3429,11 @@ DEFUN (neighbor_solo, NEIGHBOR_ADDR_STR2 "Solo peer - part of its own update group\n") { + int idx_peer = 1; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3394,10 +3449,11 @@ DEFUN (no_neighbor_solo, NEIGHBOR_ADDR_STR2 "Solo peer - part of its own update group\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[2]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3413,14 +3469,16 @@ DEFUN (neighbor_password, "Set a password\n" "The password\n") { + int idx_peer = 1; + int idx_line = 3; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - ret = peer_password_set (peer, argv[3]->arg); + ret = peer_password_set (peer, argv[idx_line]->arg); return bgp_vty_return (vty, ret); } @@ -3442,10 +3500,11 @@ DEFUN (no_neighbor_password, NEIGHBOR_ADDR_STR2 "Set a password\n") { + int idx_peer = 2; struct peer *peer; int ret; - peer = peer_and_group_lookup_vty (vty, argv[2]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3461,10 +3520,11 @@ DEFUN (neighbor_activate, NEIGHBOR_ADDR_STR2 "Enable the Address Family for this Neighbor\n") { + int idx_peer = 1; int ret; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3483,11 +3543,12 @@ DEFUN (no_neighbor_activate, NEIGHBOR_ADDR_STR2 "Enable the Address Family for this Neighbor\n") { + int idx_peer = 2; int ret; struct peer *peer; /* Lookup peer. */ - peer = peer_and_group_lookup_vty (vty, argv[2]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -3506,6 +3567,8 @@ DEFUN (neighbor_set_peer_group, "Member of the peer-group\n" "peer-group name\n") { + int idx_peer = 1; + int idx_word = 3; int ret; as_t as; union sockunion su; @@ -3516,13 +3579,13 @@ DEFUN (neighbor_set_peer_group, bgp = vty->index; peer = NULL; - ret = str2sockunion (argv[1]->arg, &su); + ret = str2sockunion (argv[idx_peer]->arg, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (bgp, argv[1]->arg); + peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); if (!peer) { - vty_out (vty, "%% Malformed address or name: %s%s", argv[1]->arg, VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } } @@ -3545,7 +3608,7 @@ DEFUN (neighbor_set_peer_group, } } - group = peer_group_lookup (bgp, argv[3]->arg); + group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); @@ -3572,6 +3635,8 @@ DEFUN (no_neighbor_set_peer_group, "Member of the peer-group\n" "peer-group name\n") { + int idx_peer = 2; + int idx_word = 4; int ret; struct bgp *bgp; struct peer *peer; @@ -3579,11 +3644,11 @@ DEFUN (no_neighbor_set_peer_group, bgp = vty->index; - peer = peer_lookup_vty (vty, argv[2]->arg); + peer = peer_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - group = peer_group_lookup (bgp, argv[4]->arg); + group = peer_group_lookup (bgp, argv[idx_word]->arg); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); @@ -3644,7 +3709,8 @@ DEFUN (neighbor_passive, NEIGHBOR_ADDR_STR2 "Don't send open messages to this neighbor\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_PASSIVE); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); } DEFUN (no_neighbor_passive, @@ -3655,7 +3721,8 @@ DEFUN (no_neighbor_passive, NEIGHBOR_ADDR_STR2 "Don't send open messages to this neighbor\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_PASSIVE); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); } /* neighbor shutdown. */ @@ -3666,7 +3733,8 @@ DEFUN (neighbor_shutdown, NEIGHBOR_ADDR_STR2 "Administratively shut down this neighbor\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_SHUTDOWN); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); } DEFUN (no_neighbor_shutdown, @@ -3677,7 +3745,8 @@ DEFUN (no_neighbor_shutdown, NEIGHBOR_ADDR_STR2 "Administratively shut down this neighbor\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_SHUTDOWN); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); } /* neighbor capability dynamic. */ @@ -3689,7 +3758,8 @@ DEFUN (neighbor_capability_dynamic, "Advertise capability to the peer\n" "Advertise dynamic capability to this neighbor\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); } DEFUN (no_neighbor_capability_dynamic, @@ -3701,7 +3771,8 @@ DEFUN (no_neighbor_capability_dynamic, "Advertise capability to the peer\n" "Advertise dynamic capability to this neighbor\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); } /* neighbor dont-capability-negotiate */ @@ -3712,7 +3783,8 @@ DEFUN (neighbor_dont_capability_negotiate, NEIGHBOR_ADDR_STR2 "Do not perform capability negotiation\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_DONT_CAPABILITY); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); } DEFUN (no_neighbor_dont_capability_negotiate, @@ -3723,7 +3795,8 @@ DEFUN (no_neighbor_dont_capability_negotiate, NEIGHBOR_ADDR_STR2 "Do not perform capability negotiation\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_DONT_CAPABILITY); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); } /* neighbor capability extended next hop encoding */ @@ -3735,7 +3808,8 @@ DEFUN (neighbor_capability_enhe, "Advertise capability to the peer\n" "Advertise extended next-hop capability to the peer\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_CAPABILITY_ENHE); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); } DEFUN (no_neighbor_capability_enhe, @@ -3747,7 +3821,8 @@ DEFUN (no_neighbor_capability_enhe, "Advertise capability to the peer\n" "Advertise extended next-hop capability to the peer\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_CAPABILITY_ENHE); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); } static int @@ -3796,18 +3871,20 @@ DEFUN (neighbor_capability_orf_prefix, "Capability to RECEIVE the ORF from this neighbor\n" "Capability to SEND the ORF to this neighbor\n") { + int idx_peer = 1; + int idx_send_recv = 5; u_int16_t flag = 0; - if (strncmp (argv[5]->arg, "s", 1) == 0) + if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM; - else if (strncmp (argv[5]->arg, "r", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_RM; - else if (strncmp (argv[5]->arg, "b", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flag); } @@ -3824,18 +3901,20 @@ DEFUN (no_neighbor_capability_orf_prefix, "Capability to RECEIVE the ORF from this neighbor\n" "Capability to SEND the ORF to this neighbor\n") { + int idx_peer = 2; + int idx_send_recv = 6; u_int16_t flag = 0; - if (strncmp (argv[6]->arg, "s", 1) == 0) + if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM; - else if (strncmp (argv[6]->arg, "r", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_RM; - else if (strncmp (argv[6]->arg, "b", 1) == 0) + else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else return CMD_WARNING; - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flag); } @@ -3847,7 +3926,8 @@ DEFUN (neighbor_nexthop_self, NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); } @@ -3860,7 +3940,8 @@ DEFUN (neighbor_nexthop_self_force, "Disable the next hop calculation for this neighbor\n" "Set the next hop to self for reflected routes\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_FORCE_NEXTHOP_SELF); } @@ -3873,7 +3954,8 @@ DEFUN (no_neighbor_nexthop_self, NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); } @@ -3887,7 +3969,8 @@ DEFUN (no_neighbor_nexthop_self_force, "Disable the next hop calculation for this neighbor\n" "Set the next hop to self for reflected routes\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_FORCE_NEXTHOP_SELF); } @@ -3900,7 +3983,8 @@ DEFUN (neighbor_as_override, NEIGHBOR_ADDR_STR2 "Override ASNs in outbound updates if aspath equals remote-as\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_AS_OVERRIDE); } @@ -3913,7 +3997,8 @@ DEFUN (no_neighbor_as_override, NEIGHBOR_ADDR_STR2 "Override ASNs in outbound updates if aspath equals remote-as\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_AS_OVERRIDE); } @@ -3926,7 +4011,8 @@ DEFUN (neighbor_remove_private_as, NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS); } @@ -3939,7 +4025,8 @@ DEFUN (neighbor_remove_private_as_all, "Remove private ASNs in outbound updates\n" "Apply to all AS numbers") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL); } @@ -3952,7 +4039,8 @@ DEFUN (neighbor_remove_private_as_replace_as, "Remove private ASNs in outbound updates\n" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); } @@ -3966,7 +4054,8 @@ DEFUN (neighbor_remove_private_as_all_replace_as, "Apply to all AS numbers" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); } @@ -3979,7 +4068,8 @@ DEFUN (no_neighbor_remove_private_as, NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS); } @@ -3993,7 +4083,8 @@ DEFUN (no_neighbor_remove_private_as_all, "Remove private ASNs in outbound updates\n" "Apply to all AS numbers") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL); } @@ -4007,7 +4098,8 @@ DEFUN (no_neighbor_remove_private_as_replace_as, "Remove private ASNs in outbound updates\n" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); } @@ -4022,7 +4114,8 @@ DEFUN (no_neighbor_remove_private_as_all_replace_as, "Apply to all AS numbers" "Replace private ASNs with our ASN in outbound updates\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); } @@ -4036,7 +4129,8 @@ DEFUN (neighbor_send_community, NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); } @@ -4049,7 +4143,8 @@ DEFUN (no_neighbor_send_community, NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); } @@ -4065,16 +4160,18 @@ DEFUN (neighbor_send_community_type, "Send Extended Community attributes\n" "Send Standard Community attributes\n") { - if (strncmp (argv[3]->arg, "s", 1) == 0) - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + int idx_type = 3; + if (strncmp (argv[idx_type]->arg, "s", 1) == 0) + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); - if (strncmp (argv[3]->arg, "e", 1) == 0) - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + if (strncmp (argv[idx_type]->arg, "e", 1) == 0) + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_EXT_COMMUNITY); - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_SEND_COMMUNITY| PEER_FLAG_SEND_EXT_COMMUNITY)); @@ -4091,16 +4188,18 @@ DEFUN (no_neighbor_send_community_type, "Send Extended Community attributes\n" "Send Standard Community attributes\n") { - if (strncmp (argv[4]->arg, "s", 1) == 0) - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + int idx_type = 4; + if (strncmp (argv[idx_type]->arg, "s", 1) == 0) + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); - if (strncmp (argv[4]->arg, "e", 1) == 0) - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + if (strncmp (argv[idx_type]->arg, "e", 1) == 0) + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_EXT_COMMUNITY); - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY)); @@ -4115,7 +4214,8 @@ DEFUN (neighbor_soft_reconfiguration, "Per neighbor soft reconfiguration\n" "Allow inbound soft reconfiguration for this neighbor\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SOFT_RECONFIG); } @@ -4129,7 +4229,8 @@ DEFUN (no_neighbor_soft_reconfiguration, "Per neighbor soft reconfiguration\n" "Allow inbound soft reconfiguration for this neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SOFT_RECONFIG); } @@ -4141,14 +4242,15 @@ DEFUN (neighbor_route_reflector_client, NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Reflector client\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REFLECTOR_CLIENT); } @@ -4161,7 +4263,8 @@ DEFUN (no_neighbor_route_reflector_client, NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Reflector client\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REFLECTOR_CLIENT); } @@ -4174,12 +4277,13 @@ DEFUN (neighbor_route_server_client, NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Server client\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_RSERVER_CLIENT); } @@ -4192,7 +4296,8 @@ DEFUN (no_neighbor_route_server_client, NEIGHBOR_ADDR_STR2 "Configure a neighbor as Route Server client\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_RSERVER_CLIENT); } @@ -4205,7 +4310,8 @@ DEFUN (neighbor_nexthop_local_unchanged, "Configure treatment of outgoing link-local nexthop attribute\n" "Leave link-local nexthop unchanged for this peer\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); } @@ -4219,7 +4325,8 @@ DEFUN (no_neighbor_nexthop_local_unchanged, "Configure treatment of outgoing link-local-nexthop attribute\n" "Leave link-local nexthop unchanged for this peer\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); } @@ -4282,7 +4389,8 @@ DEFUN (neighbor_attr_unchanged, NEIGHBOR_ADDR_STR2 "BGP attribute is propagated unchanged to this neighbor\n") { - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_AS_PATH_UNCHANGED | PEER_FLAG_NEXTHOP_UNCHANGED | @@ -4299,16 +4407,18 @@ DEFUN (neighbor_attr_unchanged1, "Nexthop attribute\n" "Med attribute\n") { + int idx_peer = 1; + int idx_attribute = 3; u_int16_t flags = 0; - if (strncmp (argv[3]->arg, "as-path", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[3]->arg, "next-hop", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[3]->arg, "med", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4322,14 +4432,16 @@ DEFUN (neighbor_attr_unchanged2, "Nexthop attribute\n" "Med attribute\n") { + int idx_peer = 1; + int idx_attribute = 4; u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED; - if (strncmp (argv[4]->arg, "next-hop", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[4]->arg, "med", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4344,14 +4456,16 @@ DEFUN (neighbor_attr_unchanged3, "As-path attribute\n" "Med attribute\n") { + int idx_peer = 1; + int idx_attribute = 4; u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED; - if (strncmp (argv[4]->arg, "as-path", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[4]->arg, "med", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4365,14 +4479,16 @@ DEFUN (neighbor_attr_unchanged4, "As-path attribute\n" "Nexthop attribute\n") { + int idx_peer = 1; + int idx_attribute = 4; u_int16_t flags = PEER_FLAG_MED_UNCHANGED; - if (strncmp (argv[4]->arg, "as-path", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[4]->arg, "next-hop", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4447,7 +4563,8 @@ DEFUN (no_neighbor_attr_unchanged, NEIGHBOR_ADDR_STR2 "BGP attribute is propagated unchanged to this neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_AS_PATH_UNCHANGED | PEER_FLAG_NEXTHOP_UNCHANGED | @@ -4465,16 +4582,18 @@ DEFUN (no_neighbor_attr_unchanged1, "Nexthop attribute\n" "Med attribute\n") { + int idx_peer = 2; + int idx_attribute = 4; u_int16_t flags = 0; - if (strncmp (argv[4]->arg, "as-path", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[4]->arg, "next-hop", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[4]->arg, "med", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4489,14 +4608,16 @@ DEFUN (no_neighbor_attr_unchanged2, "Nexthop attribute\n" "Med attribute\n") { + int idx_peer = 2; + int idx_attribute = 5; u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED; - if (strncmp (argv[5]->arg, "next-hop", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - else if (strncmp (argv[5]->arg, "med", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4511,14 +4632,16 @@ DEFUN (no_neighbor_attr_unchanged3, "As-path attribute\n" "Med attribute\n") { + int idx_peer = 2; + int idx_attribute = 5; u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED; - if (strncmp (argv[5]->arg, "as-path", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[5]->arg, "med", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0) SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4533,14 +4656,16 @@ DEFUN (no_neighbor_attr_unchanged4, "As-path attribute\n" "Nexthop attribute\n") { + int idx_peer = 2; + int idx_attribute = 5; u_int16_t flags = PEER_FLAG_MED_UNCHANGED; - if (strncmp (argv[5]->arg, "as-path", 1) == 0) + if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0) SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); - else if (strncmp (argv[5]->arg, "next-hop", 1) == 0) + else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0) SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), flags); } @@ -4593,7 +4718,8 @@ DEFUN (neighbor_ebgp_multihop, NEIGHBOR_ADDR_STR2 "Allow EBGP neighbors not on directly connected networks\n") { - return peer_ebgp_multihop_set_vty (vty, argv[1]->arg, NULL); + int idx_peer = 1; + return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); } DEFUN (neighbor_ebgp_multihop_ttl, @@ -4604,7 +4730,9 @@ DEFUN (neighbor_ebgp_multihop_ttl, "Allow EBGP neighbors not on directly connected networks\n" "maximum hop count\n") { - return peer_ebgp_multihop_set_vty (vty, argv[1]->arg, argv[3]->arg); + int idx_peer = 1; + int idx_number = 3; + return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); } /* @@ -4625,7 +4753,8 @@ DEFUN (no_neighbor_ebgp_multihop, NEIGHBOR_ADDR_STR2 "Allow EBGP neighbors not on directly connected networks\n") { - return peer_ebgp_multihop_unset_vty (vty, argv[2]->arg); + int idx_peer = 2; + return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); } @@ -4645,7 +4774,8 @@ DEFUN (neighbor_disable_connected_check, NEIGHBOR_ADDR_STR2 "one-hop away EBGP peer using loopback address\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); } /* @@ -4665,7 +4795,8 @@ DEFUN (no_neighbor_disable_connected_check, NEIGHBOR_ADDR_STR2 "one-hop away EBGP peer using loopback address\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); } /* Enforce multihop. */ @@ -4680,10 +4811,11 @@ DEFUN (neighbor_description, "Neighbor specific description\n" "Up to 80 characters describing this neighbor\n") { + int idx_peer = 1; struct peer *peer; char *str; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -4717,9 +4849,10 @@ DEFUN (no_neighbor_description, NEIGHBOR_ADDR_STR2 "Neighbor specific description\n") { + int idx_peer = 2; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[2]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -4775,7 +4908,9 @@ DEFUN (neighbor_update_source, "Source of routing updates\n" BGP_UPDATE_SOURCE_HELP_STR) { - return peer_update_source_vty (vty, argv[1]->arg, argv[3]->arg); + int idx_peer = 1; + int idx_peer_2 = 3; + return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); } DEFUN (no_neighbor_update_source, @@ -4787,7 +4922,8 @@ DEFUN (no_neighbor_update_source, "Source of routing updates\n" BGP_UPDATE_SOURCE_HELP_STR) { - return peer_update_source_vty (vty, argv[2]->arg, NULL); + int idx_peer = 2; + return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); } static int @@ -4818,7 +4954,8 @@ DEFUN (neighbor_default_originate, NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n") { - return peer_default_originate_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + int idx_peer = 1; + return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), NULL, 1); } @@ -4831,8 +4968,10 @@ DEFUN (neighbor_default_originate_rmap, "Route-map to specify criteria to originate default\n" "route-map name\n") { - return peer_default_originate_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[4]->arg, 1); + int idx_peer = 1; + int idx_word = 4; + return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, 1); } /* @@ -4854,7 +4993,8 @@ DEFUN (no_neighbor_default_originate, NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n") { - return peer_default_originate_set_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), NULL, 0); } @@ -4896,7 +5036,9 @@ DEFUN (neighbor_port, "Neighbor's BGP port\n" "TCP port number\n") { - return peer_port_vty (vty, argv[1]->arg, AFI_IP, argv[3]->arg); + int idx_ip = 1; + int idx_number = 3; + return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); } /* @@ -4917,7 +5059,8 @@ DEFUN (no_neighbor_port, NEIGHBOR_ADDR_STR "Neighbor's BGP port\n") { - return peer_port_vty (vty, argv[2]->arg, AFI_IP, NULL); + int idx_ip = 2; + return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); } @@ -4962,7 +5105,9 @@ DEFUN (neighbor_weight, "Set default weight for routes from this neighbor\n" "default weight\n") { - return peer_weight_set_vty (vty, argv[1]->arg, argv[3]->arg); + int idx_peer = 1; + int idx_number = 3; + return peer_weight_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); } /* @@ -4983,7 +5128,8 @@ DEFUN (no_neighbor_weight, NEIGHBOR_ADDR_STR2 "Set default weight for routes from this neighbor\n") { - return peer_weight_unset_vty (vty, argv[2]->arg); + int idx_peer = 2; + return peer_weight_unset_vty (vty, argv[idx_peer]->arg); } @@ -4995,7 +5141,8 @@ DEFUN (neighbor_override_capability, NEIGHBOR_ADDR_STR2 "Override capability negotiation result\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); + int idx_peer = 1; + return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); } DEFUN (no_neighbor_override_capability, @@ -5006,7 +5153,8 @@ DEFUN (no_neighbor_override_capability, NEIGHBOR_ADDR_STR2 "Override capability negotiation result\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); + int idx_peer = 2; + return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); } DEFUN (neighbor_strict_capability, @@ -5016,7 +5164,8 @@ DEFUN (neighbor_strict_capability, NEIGHBOR_ADDR_STR "Strict capability negotiation match\n") { - return peer_flag_set_vty (vty, argv[1]->arg, PEER_FLAG_STRICT_CAP_MATCH); + int idx_ip = 1; + return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); } DEFUN (no_neighbor_strict_capability, @@ -5027,7 +5176,8 @@ DEFUN (no_neighbor_strict_capability, NEIGHBOR_ADDR_STR "Strict capability negotiation match\n") { - return peer_flag_unset_vty (vty, argv[2]->arg, PEER_FLAG_STRICT_CAP_MATCH); + int idx_ip = 2; + return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); } static int @@ -5075,7 +5225,10 @@ DEFUN (neighbor_timers, "Keepalive interval\n" "Holdtime\n") { - return peer_timers_set_vty (vty, argv[1]->arg, argv[3]->arg, argv[4]->arg); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); } /* @@ -5097,7 +5250,8 @@ DEFUN (no_neighbor_timers, NEIGHBOR_ADDR_STR2 "BGP per neighbor timers\n") { - return peer_timers_unset_vty (vty, argv[2]->arg); + int idx_peer = 2; + return peer_timers_unset_vty (vty, argv[idx_peer]->arg); } @@ -5144,7 +5298,9 @@ DEFUN (neighbor_timers_connect, "BGP connect timer\n" "Connect timer\n") { - return peer_timers_connect_set_vty (vty, argv[1]->arg, argv[4]->arg); + int idx_peer = 1; + int idx_number = 4; + return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); } /* @@ -5167,7 +5323,8 @@ DEFUN (no_neighbor_timers_connect, "BGP per neighbor timers\n" "BGP connect timer\n") { - return peer_timers_connect_unset_vty (vty, argv[2]->arg); + int idx_peer = 2; + return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); } @@ -5202,7 +5359,9 @@ DEFUN (neighbor_advertise_interval, "Minimum interval between sending BGP routing updates\n" "time in seconds\n") { - return peer_advertise_interval_vty (vty, argv[1]->arg, argv[3]->arg, 1); + int idx_peer = 1; + int idx_number = 3; + return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); } /* @@ -5223,7 +5382,8 @@ DEFUN (no_neighbor_advertise_interval, NEIGHBOR_ADDR_STR2 "Minimum interval between sending BGP routing updates\n") { - return peer_advertise_interval_vty (vty, argv[2]->arg, NULL, 0); + int idx_peer = 2; + return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); } @@ -5236,11 +5396,12 @@ DEFUN (bgp_set_route_map_delay_timer, "Time in secs to wait before processing route-map changes\n" "0 disables the timer, no route updates happen when route-maps change\n") { + int idx_number = 3; u_int32_t rmap_delay_timer; - if (argv[3]->arg) + if (argv[idx_number]->arg) { - VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[3]->arg, 0, 600); + VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); bm->rmap_update_timer = rmap_delay_timer; /* if the dynamic update handling is being disabled, and a timer is @@ -5306,10 +5467,12 @@ DEFUN (neighbor_interface, "Interface\n" "Interface name\n") { + int idx_ip = 1; + int idx_word = 3; if (argc == 3) - return peer_interface_vty (vty, argv[1]->arg, argv[3]->arg); + return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); else - return peer_interface_vty (vty, argv[1]->arg, argv[3]->arg); + return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); } DEFUN (no_neighbor_interface, @@ -5321,7 +5484,8 @@ DEFUN (no_neighbor_interface, "Interface\n" "Interface name\n") { - return peer_interface_vty (vty, argv[2]->arg, NULL); + int idx_peer = 2; + return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); } /* Set distribute list to the peer. */ @@ -5384,8 +5548,11 @@ DEFUN (neighbor_distribute_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_distribute_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, argv[4]->arg); + int idx_peer = 1; + int idx_acl = 3; + int idx_in_out = 4; + return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_distribute_list, @@ -5401,8 +5568,10 @@ DEFUN (no_neighbor_distribute_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_distribute_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[5]->arg); + int idx_peer = 2; + int idx_in_out = 5; + return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } /* Set prefix list to the peer. */ @@ -5463,8 +5632,11 @@ DEFUN (neighbor_prefix_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_prefix_list_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, argv[4]->arg); + int idx_peer = 1; + int idx_word = 3; + int idx_in_out = 4; + return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_prefix_list, @@ -5478,8 +5650,10 @@ DEFUN (no_neighbor_prefix_list, "Filter incoming updates\n" "Filter outgoing updates\n") { - return peer_prefix_list_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[5]->arg); + int idx_peer = 2; + int idx_in_out = 5; + return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } static int @@ -5540,8 +5714,11 @@ DEFUN (neighbor_filter_list, "Filter incoming routes\n" "Filter outgoing routes\n") { - return peer_aslist_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, argv[4]->arg); + int idx_peer = 1; + int idx_word = 3; + int idx_in_out = 4; + return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_filter_list, @@ -5555,8 +5732,10 @@ DEFUN (no_neighbor_filter_list, "Filter incoming routes\n" "Filter outgoing routes\n") { - return peer_aslist_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[5]->arg); + int idx_peer = 2; + int idx_in_out = 5; + return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } /* Set route-map to the peer. */ @@ -5617,8 +5796,11 @@ DEFUN (neighbor_route_map, "Apply map to incoming routes\n" "Apply map to outbound routes\n") { - return peer_route_map_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, argv[4]->arg); + int idx_peer = 1; + int idx_word = 3; + int idx_in_out = 4; + return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); } DEFUN (no_neighbor_route_map, @@ -5632,8 +5814,10 @@ DEFUN (no_neighbor_route_map, "Apply map to incoming routes\n" "Apply map to outbound routes\n") { - return peer_route_map_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[5]->arg); + int idx_peer = 2; + int idx_in_out = 5; + return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_in_out]->arg); } /* Set unsuppress-map to the peer. */ @@ -5678,8 +5862,10 @@ DEFUN (neighbor_unsuppress_map, "Route-map to selectively unsuppress suppressed routes\n" "Name of route map\n") { - return peer_unsuppress_map_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg); + int idx_peer = 1; + int idx_word = 3; + return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_word]->arg); } DEFUN (no_neighbor_unsuppress_map, @@ -5691,7 +5877,8 @@ DEFUN (no_neighbor_unsuppress_map, "Route-map to selectively unsuppress suppressed routes\n" "Name of route map\n") { - return peer_unsuppress_map_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); } @@ -5754,8 +5941,10 @@ DEFUN (neighbor_maximum_prefix, "Maximum number of prefix accept from this peer\n" "maximum no. of prefix limit\n") { - return peer_maximum_prefix_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, NULL, 0, + int idx_peer = 1; + int idx_number = 3; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, NULL); } @@ -5768,8 +5957,11 @@ DEFUN (neighbor_maximum_prefix_threshold, "maximum no. of prefix limit\n" "Threshold value (%) at which to generate a warning msg\n") { - return peer_maximum_prefix_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, argv[4]->arg, 0, + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); } @@ -5782,8 +5974,10 @@ DEFUN (neighbor_maximum_prefix_warning, "maximum no. of prefix limit\n" "Only give warning message when limit is exceeded\n") { - return peer_maximum_prefix_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, NULL, 1, + int idx_peer = 1; + int idx_number = 3; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, NULL); } @@ -5797,8 +5991,11 @@ DEFUN (neighbor_maximum_prefix_threshold_warning, "Threshold value (%) at which to generate a warning msg\n" "Only give warning message when limit is exceeded\n") { - return peer_maximum_prefix_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, argv[4]->arg, 1, NULL); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); } DEFUN (neighbor_maximum_prefix_restart, @@ -5811,8 +6008,11 @@ DEFUN (neighbor_maximum_prefix_restart, "Restart bgp connection after limit is exceeded\n" "Restart interval in minutes") { - return peer_maximum_prefix_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, NULL, 0, argv[5]->arg); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 5; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); } DEFUN (neighbor_maximum_prefix_threshold_restart, @@ -5826,8 +6026,12 @@ DEFUN (neighbor_maximum_prefix_threshold_restart, "Restart bgp connection after limit is exceeded\n" "Restart interval in minutes") { - return peer_maximum_prefix_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), - bgp_node_safi (vty), argv[3]->arg, argv[4]->arg, 0, argv[6]->arg); + int idx_peer = 1; + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 6; + return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), + bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); } /* @@ -5892,7 +6096,8 @@ DEFUN (no_neighbor_maximum_prefix, NEIGHBOR_ADDR_STR2 "Maximum number of prefix accept from this peer\n") { - return peer_maximum_prefix_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); } @@ -5919,11 +6124,12 @@ DEFUN (neighbor_allowas_in, NEIGHBOR_ADDR_STR2 "Accept as-path with my AS present in it\n") { + int idx_peer = 1; int ret; struct peer *peer; unsigned int allow_num; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -5957,10 +6163,11 @@ DEFUN (no_neighbor_allowas_in, NEIGHBOR_ADDR_STR2 "allow local ASN appears in aspath attribute\n") { + int idx_peer = 2; int ret; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[2]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -5977,14 +6184,16 @@ DEFUN (neighbor_ttl_security, NEIGHBOR_ADDR_STR2 "Specify the maximum number of hops to the BGP peer\n") { + int idx_peer = 1; + int idx_number = 4; struct peer *peer; int gtsm_hops; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[4]->arg, 1, 254); + VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); /* * If 'neighbor swpX', then this is for directly connected peers, @@ -5992,7 +6201,7 @@ DEFUN (neighbor_ttl_security, */ if (peer->conf_if && (gtsm_hops > 1)) { vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", - argv[1]->arg, VTY_NEWLINE); + argv[idx_peer]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -6007,9 +6216,10 @@ DEFUN (no_neighbor_ttl_security, NEIGHBOR_ADDR_STR2 "Specify the maximum number of hops to the BGP peer\n") { + int idx_peer = 2; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[2]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; @@ -6023,13 +6233,14 @@ DEFUN (neighbor_addpath_tx_all_paths, NEIGHBOR_ADDR_STR2 "Use addpath to advertise all paths to a neighbor\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_ALL_PATHS); } @@ -6042,7 +6253,8 @@ DEFUN (no_neighbor_addpath_tx_all_paths, NEIGHBOR_ADDR_STR2 "Use addpath to advertise all paths to a neighbor\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_ALL_PATHS); } @@ -6054,13 +6266,14 @@ DEFUN (neighbor_addpath_tx_bestpath_per_as, NEIGHBOR_ADDR_STR2 "Use addpath to advertise the bestpath per each neighboring AS\n") { + int idx_peer = 1; struct peer *peer; - peer = peer_and_group_lookup_vty (vty, argv[1]->arg); + peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); if (! peer) return CMD_WARNING; - return peer_af_flag_set_vty (vty, argv[1]->arg, bgp_node_afi (vty), + return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); } @@ -6073,7 +6286,8 @@ DEFUN (no_neighbor_addpath_tx_bestpath_per_as, NEIGHBOR_ADDR_STR2 "Use addpath to advertise the bestpath per each neighboring AS\n") { - return peer_af_flag_unset_vty (vty, argv[2]->arg, bgp_node_afi (vty), + int idx_peer = 2; + return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); } @@ -6098,7 +6312,8 @@ DEFUN (address_family_ipv4_safi, "Address Family modifier\n" "Address Family modifier\n") { - if (strncmp (argv[2]->arg, "m", 1) == 0) + int idx_safi = 2; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) vty->node = BGP_IPV4M_NODE; else vty->node = BGP_IPV4_NODE; @@ -6124,7 +6339,8 @@ DEFUN (address_family_ipv6_safi, "Address Family modifier\n" "Address Family modifier\n") { - if (strncmp (argv[2]->arg, "m", 1) == 0) + int idx_safi = 2; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) vty->node = BGP_IPV6M_NODE; else vty->node = BGP_IPV6_NODE; @@ -6400,10 +6616,11 @@ DEFUN (clear_ip_bgp_peer, "BGP IPv6 neighbor to clear\n" "BGP neighbor on interface to clear\n") { + int idx_peer = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[2]); - return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[3]->arg); + return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[idx_peer]->arg); } @@ -6459,10 +6676,11 @@ DEFUN (clear_ip_bgp_peer_group, "Clear all members of peer-group\n" "BGP peer-group name\n") { + int idx_word = 4; if (argc == 3) return bgp_clear_vty (vty, argv[1], 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[2]); - return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[4]->arg); + return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[idx_word]->arg); } @@ -6556,10 +6774,11 @@ DEFUN (clear_ip_bgp_prefix, "Clear bestpath and re-advertise\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { + int idx_ipv4_prefixlen = 4; if (argc == 3) return bgp_clear_prefix (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL); - return bgp_clear_prefix (vty, NULL, argv[4]->arg, AFI_IP, SAFI_UNICAST, NULL); + return bgp_clear_prefix (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL); } @@ -6607,11 +6826,12 @@ DEFUN (clear_ip_bgp_as, BGP_STR "Clear peers with the AS number\n") { + int idx_number = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[2]); - return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[3]->arg); -} + return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[idx_number]->arg); +} @@ -6693,7 +6913,8 @@ DEFUN (clear_ip_bgp_all_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_OUT, NULL); @@ -6728,11 +6949,14 @@ DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out, "Address Family modifier\n" BGP_SOFT_OUT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_all, + int idx_view_vrf = 3; + int idx_word = 4; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_OUT, NULL); - return bgp_clear_vty (vty, argv[3]->arg, AFI_IP, SAFI_UNICAST, clear_all, + return bgp_clear_vty (vty, argv[idx_view_vrf]->arg, AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_OUT, NULL); } @@ -6886,10 +7110,12 @@ DEFUN (clear_bgp_ipv6_safi_prefix, "Clear bestpath and re-advertise\n" "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") { - if (strncmp (argv[3]->arg, "m", 1) == 0) - return bgp_clear_prefix (vty, NULL, argv[5]->arg, AFI_IP6, SAFI_MULTICAST, NULL); + int idx_safi = 3; + int idx_ipv6_prefixlen = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL); else - return bgp_clear_prefix (vty, NULL, argv[5]->arg, AFI_IP6, SAFI_UNICAST, NULL); + return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL); } DEFUN (clear_bgp_instance_ipv6_safi_prefix, @@ -6903,10 +7129,13 @@ DEFUN (clear_bgp_instance_ipv6_safi_prefix, "Clear bestpath and re-advertise\n" "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") { - if (strncmp (argv[5]->arg, "m", 1) == 0) - return bgp_clear_prefix (vty, argv[3]->arg, argv[7]->arg, AFI_IP6, SAFI_MULTICAST, NULL); + int idx_word = 3; + int idx_safi = 5; + int idx_ipv6_prefixlen = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL); else - return bgp_clear_prefix (vty, argv[3]->arg, argv[7]->arg, AFI_IP6, SAFI_UNICAST, NULL); + return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL); } /* @@ -6950,12 +7179,13 @@ DEFUN (clear_ip_bgp_peer_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_ipv4_word = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, BGP_CLEAR_SOFT_OUT, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg); } @@ -6989,12 +7219,14 @@ DEFUN (clear_ip_bgp_peer_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_ipv4_word = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg); } /* @@ -7027,12 +7259,15 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[5]->arg); + int idx_word = 4; + int idx_ipv4_word = 5; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[5]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg); } @@ -7064,8 +7299,9 @@ DEFUN (clear_ip_bgp_peer_vpnv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_ipv4_word = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg); } @@ -7093,8 +7329,9 @@ DEFUN (clear_ip_bgp_peer_encap_soft_out, "Soft reconfig\n" "Soft reconfig outbound update\n") { + int idx_ipv4 = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_ipv4]->arg); } @@ -7179,12 +7416,13 @@ DEFUN (clear_bgp_peer_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_peer = 2; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer, BGP_CLEAR_SOFT_OUT, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_peer]->arg); } @@ -7235,12 +7473,13 @@ DEFUN (clear_ip_bgp_peer_group_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_word = 4; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_OUT, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[4]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg); } @@ -7274,12 +7513,14 @@ DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[6]->arg, "m", 1) == 0) + int idx_word = 4; + int idx_safi = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[4]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[4]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg); } /* @@ -7312,12 +7553,15 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[8]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[6]->arg); + int idx_word = 4; + int idx_word_2 = 6; + int idx_safi = 8; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_OUT, argv[idx_word_2]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[6]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_OUT, argv[idx_word_2]->arg); } @@ -7395,12 +7639,13 @@ DEFUN (clear_bgp_peer_group_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_word = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_OUT, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg); } @@ -7484,7 +7729,8 @@ DEFUN (clear_ip_bgp_external_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_OUT, NULL); @@ -7520,11 +7766,13 @@ DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_external, + int idx_word = 4; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_OUT, NULL); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_external, + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_external, BGP_CLEAR_SOFT_OUT, NULL); } @@ -7647,12 +7895,13 @@ DEFUN (clear_ip_bgp_as_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_number = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, BGP_CLEAR_SOFT_OUT, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); } @@ -7684,12 +7933,14 @@ DEFUN (clear_ip_bgp_as_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_number = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); } /* @@ -7720,12 +7971,15 @@ DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[5]->arg); + int idx_word = 4; + int idx_number = 5; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[5]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); } @@ -7754,8 +8008,9 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_number = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); } @@ -7783,8 +8038,9 @@ DEFUN (clear_ip_bgp_as_encap_soft_out, "Soft reconfig\n" "Soft reconfig outbound update\n") { + int idx_number = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_OUT, argv[3]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); } @@ -7853,12 +8109,13 @@ DEFUN (clear_bgp_as_soft_out, BGP_SOFT_STR BGP_SOFT_OUT_STR) { + int idx_number = 2; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as, BGP_CLEAR_SOFT_OUT, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]->arg); + BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg); } @@ -7961,7 +8218,8 @@ DEFUN (clear_ip_bgp_all_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_IN, NULL); @@ -7997,11 +8255,13 @@ DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_all, + int idx_word = 4; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_IN, NULL); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_all, + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_IN, NULL); } @@ -8020,7 +8280,8 @@ DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); @@ -8232,12 +8493,13 @@ DEFUN (clear_ip_bgp_peer_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_ipv4_word = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, BGP_CLEAR_SOFT_IN, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg); } @@ -8254,8 +8516,9 @@ DEFUN (clear_ip_bgp_peer_in_prefix_filter, BGP_SOFT_IN_STR "Push out the existing ORF prefix-list\n") { + int idx_ipv4_word = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[3]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_ipv4_word]->arg); } /* @@ -8286,12 +8549,14 @@ DEFUN (clear_ip_bgp_peer_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_ipv4_word = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg); } /* @@ -8324,12 +8589,15 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[5]->arg); + int idx_word = 4; + int idx_ipv4_word = 5; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[5]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg); } @@ -8348,12 +8616,14 @@ DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter, BGP_SOFT_IN_STR "Push out the existing ORF prefix-list\n") { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_ipv4_word = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[3]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_ipv4_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[3]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_ipv4_word]->arg); } /* @@ -8382,8 +8652,9 @@ DEFUN (clear_ip_bgp_peer_vpnv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_ipv4_word = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg); } @@ -8411,8 +8682,9 @@ DEFUN (clear_ip_bgp_peer_encap_soft_in, "Soft reconfig\n" "Soft reconfig inbound update\n") { + int idx_ipv4 = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_ipv4]->arg); } @@ -8497,12 +8769,13 @@ DEFUN (clear_bgp_peer_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_peer = 2; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer, BGP_CLEAR_SOFT_IN, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_peer]->arg); } @@ -8536,8 +8809,9 @@ DEFUN (clear_bgp_peer_in_prefix_filter, BGP_SOFT_IN_STR "Push out the existing ORF prefix-list\n") { + int idx_peer = 2; return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[2]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_peer]->arg); } @@ -8582,12 +8856,13 @@ DEFUN (clear_ip_bgp_peer_group_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_word = 4; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_IN, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[4]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_word]->arg); } @@ -8604,8 +8879,9 @@ DEFUN (clear_ip_bgp_peer_group_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { + int idx_word = 4; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[4]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg); } /* @@ -8636,12 +8912,14 @@ DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[6]->arg, "m", 1) == 0) + int idx_word = 4; + int idx_safi = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[4]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[4]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_word]->arg); } /* @@ -8674,12 +8952,15 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[8]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[6]->arg); + int idx_word = 4; + int idx_word_2 = 6; + int idx_safi = 8; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_IN, argv[idx_word_2]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[6]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_IN, argv[idx_word_2]->arg); } @@ -8698,12 +8979,14 @@ DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[6]->arg, "m", 1) == 0) + int idx_word = 4; + int idx_safi = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[4]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[4]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg); } /* @@ -8779,12 +9062,13 @@ DEFUN (clear_bgp_peer_group_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_word = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_IN, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_word]->arg); } @@ -8816,8 +9100,9 @@ DEFUN (clear_bgp_peer_group_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { + int idx_word = 3; return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[3]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg); } @@ -8909,7 +9194,8 @@ DEFUN (clear_ip_bgp_external_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_IN, NULL); @@ -8945,11 +9231,13 @@ DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_external, + int idx_word = 4; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_IN, NULL); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_external, + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_external, BGP_CLEAR_SOFT_IN, NULL); } @@ -8968,7 +9256,8 @@ DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); @@ -9118,12 +9407,13 @@ DEFUN (clear_ip_bgp_as_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_number = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, BGP_CLEAR_SOFT_IN, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); } @@ -9139,8 +9429,9 @@ DEFUN (clear_ip_bgp_as_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { + int idx_number = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[3]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg); } /* @@ -9169,12 +9460,14 @@ DEFUN (clear_ip_bgp_as_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_number = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); } /* @@ -9205,12 +9498,15 @@ DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[5]->arg); + int idx_word = 4; + int idx_number = 5; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[5]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); } @@ -9228,12 +9524,14 @@ DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_number = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[3]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[3]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg); } /* @@ -9260,8 +9558,9 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_number = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); } @@ -9289,8 +9588,9 @@ DEFUN (clear_ip_bgp_as_encap_soft_in, "Soft reconfig\n" "Soft reconfig inbound update\n") { + int idx_number = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_IN, argv[3]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); } @@ -9359,12 +9659,13 @@ DEFUN (clear_bgp_as_soft_in, BGP_SOFT_STR BGP_SOFT_IN_STR) { + int idx_number = 2; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as, BGP_CLEAR_SOFT_IN, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]->arg); + BGP_CLEAR_SOFT_IN, argv[idx_number]->arg); } @@ -9394,8 +9695,9 @@ DEFUN (clear_bgp_as_in_prefix_filter, BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { + int idx_number = 2; return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[2]->arg); + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg); } @@ -9442,7 +9744,8 @@ DEFUN (clear_ip_bgp_all_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_BOTH, NULL); @@ -9463,8 +9766,10 @@ DEFUN (clear_ip_bgp_instance_all_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_all, + int idx_word = 4; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_BOTH, NULL); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, @@ -9567,12 +9872,13 @@ DEFUN (clear_ip_bgp_peer_soft, "BGP neighbor on interface to clear\n" BGP_SOFT_STR) { + int idx_ipv4_word = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, BGP_CLEAR_SOFT_BOTH, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg); } @@ -9589,12 +9895,14 @@ DEFUN (clear_ip_bgp_peer_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_ipv4_word = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg); } DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, @@ -9611,12 +9919,15 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[5]->arg); + int idx_word = 4; + int idx_ipv4_word = 5; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[5]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg); } DEFUN (clear_ip_bgp_peer_vpnv4_soft, @@ -9631,8 +9942,9 @@ DEFUN (clear_ip_bgp_peer_vpnv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { + int idx_ipv4_word = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg); } DEFUN (clear_ip_bgp_peer_encap_soft, @@ -9646,8 +9958,9 @@ DEFUN (clear_ip_bgp_peer_encap_soft, "Address Family Modifier\n" "Soft reconfig\n") { + int idx_ipv4 = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4]->arg); } /* @@ -9691,12 +10004,13 @@ DEFUN (clear_bgp_peer_soft, "BGP neighbor on interface to clear\n" BGP_SOFT_STR) { + int idx_peer = 2; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer, BGP_CLEAR_SOFT_BOTH, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_peer]->arg); } @@ -9724,12 +10038,13 @@ DEFUN (clear_ip_bgp_peer_group_soft, "BGP peer-group name\n" BGP_SOFT_STR) { + int idx_word = 4; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_BOTH, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[4]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg); } @@ -9746,12 +10061,14 @@ DEFUN (clear_ip_bgp_peer_group_ipv4_soft, "Address Family modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[6]->arg, "m", 1) == 0) + int idx_word = 4; + int idx_safi = 6; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[4]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[4]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg); } DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft, @@ -9768,12 +10085,15 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft, "Address Family modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[8]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[6]->arg); + int idx_word = 4; + int idx_word_2 = 6; + int idx_safi = 8; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[idx_word_2]->arg); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[6]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[idx_word_2]->arg); } /* @@ -9813,12 +10133,13 @@ DEFUN (clear_bgp_peer_group_soft, "BGP peer-group name\n" BGP_SOFT_STR) { + int idx_word = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_BOTH, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg); } @@ -9865,7 +10186,8 @@ DEFUN (clear_ip_bgp_external_ipv4_soft, "Address Family modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_BOTH, NULL); @@ -9886,11 +10208,13 @@ DEFUN (clear_ip_bgp_instance_external_ipv4_soft, "Address Family modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_external, + int idx_word = 4; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_BOTH, NULL); - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, clear_external, + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_external, BGP_CLEAR_SOFT_BOTH, NULL); } @@ -9958,12 +10282,13 @@ DEFUN (clear_ip_bgp_as_soft, "Clear peers with the AS number\n" BGP_SOFT_STR) { + int idx_number = 3; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, BGP_CLEAR_SOFT_BOTH, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); } @@ -9979,12 +10304,14 @@ DEFUN (clear_ip_bgp_as_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[5]->arg, "m", 1) == 0) + int idx_number = 3; + int idx_safi = 5; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); } DEFUN (clear_ip_bgp_instance_as_ipv4_soft, @@ -10000,12 +10327,15 @@ DEFUN (clear_ip_bgp_instance_as_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[7]->arg, "m", 1) == 0) - return bgp_clear_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[5]->arg); + int idx_word = 4; + int idx_number = 5; + int idx_safi = 7; + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); - return bgp_clear_vty (vty, argv[4]->arg,AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[5]->arg); + return bgp_clear_vty (vty, argv[idx_word]->arg,AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); } DEFUN (clear_ip_bgp_as_vpnv4_soft, @@ -10019,8 +10349,9 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { + int idx_number = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); } DEFUN (clear_ip_bgp_as_encap_soft, @@ -10034,8 +10365,9 @@ DEFUN (clear_ip_bgp_as_encap_soft, "Address Family Modifier\n" "Soft reconfig\n") { + int idx_number = 3; return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[3]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); } /* @@ -10071,12 +10403,13 @@ DEFUN (clear_bgp_as_soft, "Clear peers with the AS number\n" BGP_SOFT_STR) { + int idx_number = 2; if (argc == 3) return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as, BGP_CLEAR_SOFT_BOTH, argv[2]); return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]->arg); + BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg); } @@ -10782,8 +11115,9 @@ DEFUN (show_ip_bgp_instance_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { + int idx_word = 4; u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, uj); } DEFUN (show_ip_bgp_instance_all_summary, @@ -10825,8 +11159,9 @@ DEFUN (show_ip_bgp_ipv4_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { + int idx_safi = 4; u_char uj = use_json(argc, argv); - if (strncmp (argv[4]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj); return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj); @@ -10887,11 +11222,13 @@ DEFUN (show_ip_bgp_instance_ipv4_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_safi = 6; u_char uj = use_json(argc, argv); - if (strncmp (argv[6]->arg, "m", 1) == 0) - return bgp_show_summary_vty (vty, argv[4]->arg, AFI_IP, SAFI_MULTICAST, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, uj); else - return bgp_show_summary_vty (vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, uj); } @@ -10922,11 +11259,12 @@ DEFUN (show_ip_bgp_vpnv4_rd_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { + int idx_ext_community = 5; int ret; struct prefix_rd prd; u_char uj = use_json(argc, argv); - ret = str2prefix_rd (argv[5]->arg, &prd); + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); @@ -10976,7 +11314,8 @@ DEFUN (show_bgp_instance_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - return bgp_show_summary_vty (vty, argv[3]->arg, AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); + int idx_word = 3; + return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); } DEFUN (show_bgp_instance_all_summary, @@ -11007,8 +11346,9 @@ DEFUN (show_bgp_ipv6_safi_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { + int idx_safi = 3; u_char uj = use_json(argc, argv); - if (strncmp (argv[3]->arg, "m", 1) == 0) + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj); return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj); @@ -11026,11 +11366,13 @@ DEFUN (show_bgp_instance_ipv6_safi_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { + int idx_word = 3; + int idx_safi = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[5]->arg, "m", 1) == 0) - return bgp_show_summary_vty (vty, argv[3]->arg, AFI_IP6, SAFI_MULTICAST, uj); + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_MULTICAST, uj); - return bgp_show_summary_vty (vty, argv[3]->arg, AFI_IP6, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, uj); } /* old command */ @@ -13061,9 +13403,10 @@ DEFUN (show_ip_bgp_instance_neighbors, "Detailed information on TCP and BGP neighbor connections\n" "JavaScript Object Notation\n") { + int idx_word = 4; u_char uj = use_json(argc, argv); - return bgp_show_neighbor_vty (vty, argv[4]->arg, show_all, NULL, uj, NULL); + return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_all, NULL, uj, NULL); } DEFUN (show_ip_bgp_instance_all_neighbors, @@ -13121,9 +13464,11 @@ DEFUN (show_ip_bgp_instance_neighbors_peer, "Neighbor on bgp configured interface\n" "JavaScript Object Notation\n") { + int idx_word = 4; + int idx_peer = 6; u_char uj = use_json(argc, argv); - return bgp_show_neighbor_vty (vty, argv[4]->arg, show_peer, argv[6]->arg, uj, NULL); + return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_peer, argv[idx_peer]->arg, uj, NULL); } @@ -13256,7 +13601,8 @@ DEFUN (show_ip_bgp_instance_updgrps, BGP_INSTANCE_HELP_STR "Detailed info about dynamic update groups\n") { - return (bgp_show_update_groups(vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, 0)); + int idx_word = 4; + return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0)); } DEFUN (show_ip_bgp_instance_all_updgrps, @@ -13290,7 +13636,8 @@ DEFUN (show_bgp_instance_ipv6_updgrps, BGP_INSTANCE_HELP_STR "Detailed info about v6 dynamic update groups\n") { - return (bgp_show_update_groups(vty, argv[3]->arg, AFI_IP6, SAFI_UNICAST, 0)); + int idx_word = 3; + return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, 0)); } DEFUN (show_bgp_instance_all_ipv6_updgrps, @@ -13316,11 +13663,13 @@ DEFUN (show_bgp_updgrps, "Address Family modifier\n" "Detailed info about dynamic update groups\n") { + int idx_afi = 2; + int idx_safi = 3; afi_t afi; safi_t safi; - afi = (strcmp(argv[2]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[3]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; return (bgp_show_update_groups(vty, NULL, afi, safi, 0)); } @@ -13349,10 +13698,11 @@ DEFUN (show_ip_bgp_instance_updgrps_s, "Detailed info about dynamic update groups\n" "Specific subgroup to display detailed info for\n") { + int idx_word = 4; uint64_t subgrp_id; VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return (bgp_show_update_groups(vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, subgrp_id)); + return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, subgrp_id)); } DEFUN (show_bgp_ipv6_updgrps_s, @@ -13377,10 +13727,11 @@ DEFUN (show_bgp_instance_ipv6_updgrps_s, "Detailed info about v6 dynamic update groups\n" "Specific subgroup to display detailed info for\n") { + int idx_word = 3; uint64_t subgrp_id; VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); - return(bgp_show_update_groups(vty, argv[3]->arg, AFI_IP6, SAFI_UNICAST, subgrp_id)); + return(bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, subgrp_id)); } DEFUN (show_bgp_updgrps_s, @@ -13395,12 +13746,14 @@ DEFUN (show_bgp_updgrps_s, "Detailed info about v6 dynamic update groups\n" "Specific subgroup to display detailed info for") { + int idx_afi = 2; + int idx_safi = 3; afi_t afi; safi_t safi; uint64_t subgrp_id; - afi = (strcmp(argv[2]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[3]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id)); @@ -13432,9 +13785,10 @@ DEFUN (show_bgp_instance_updgrps_stats, "BGP update groups\n" "Statistics\n") { + int idx_word = 3; struct bgp *bgp; - bgp = bgp_lookup_by_name (argv[3]->arg); + bgp = bgp_lookup_by_name (argv[idx_word]->arg); if (bgp) update_group_show_stats(bgp, vty); @@ -13476,7 +13830,8 @@ DEFUN (show_ip_bgp_updgrps_adj, "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[4]->arg, 0); + int idx_type = 4; + show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } @@ -13493,7 +13848,9 @@ DEFUN (show_ip_bgp_instance_updgrps_adj, "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, argv[6]->arg, 0); + int idx_word = 4; + int idx_type = 6; + show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } @@ -13512,12 +13869,15 @@ DEFUN (show_bgp_updgrps_afi_adj, "Packet queue\n" "Specific subgroup info wanted for\n") { + int idx_afi = 2; + int idx_safi = 3; + int idx_type = 5; afi_t afi; safi_t safi; - afi = (strcmp(argv[2]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[3]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[5]->arg, 0); + afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, 0); return CMD_SUCCESS; } @@ -13531,7 +13891,8 @@ DEFUN (show_bgp_updgrps_adj, "Announced routes\n" "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[3]->arg, 0); + int idx_type = 3; + show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } @@ -13546,7 +13907,9 @@ DEFUN (show_bgp_instance_updgrps_adj, "Announced routes\n" "Packet queue\n") { - show_bgp_updgrps_adj_info_aux(vty, argv[3]->arg, AFI_IP6, SAFI_UNICAST, argv[5]->arg, 0); + int idx_word = 3; + int idx_type = 5; + show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); return CMD_SUCCESS; } @@ -13563,9 +13926,10 @@ DEFUN (show_ip_bgp_updgrps_adj_s, "Packet queue\n") { + int idx_type = 5; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[5]->arg); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg); show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id); return CMD_SUCCESS; @@ -13585,11 +13949,13 @@ DEFUN (show_ip_bgp_instance_updgrps_adj_s, "Packet queue\n") { + int idx_word = 4; + int idx_type = 7; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[7]->arg); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg); - show_bgp_updgrps_adj_info_aux(vty, argv[4]->arg, AFI_IP, SAFI_UNICAST, argv[3], subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[3], subgrp_id); return CMD_SUCCESS; } @@ -13609,13 +13975,16 @@ DEFUN (show_bgp_updgrps_afi_adj_s, "Packet queue\n" "Specific subgroup info wanted for\n") { + int idx_afi = 2; + int idx_safi = 3; + int idx_type = 6; afi_t afi; safi_t safi; uint64_t subgrp_id; - afi = (strcmp(argv[2]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[3]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[6]->arg); + afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; + safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg); show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id); return CMD_SUCCESS; @@ -13632,9 +14001,10 @@ DEFUN (show_bgp_updgrps_adj_s, "Announced routes\n" "Packet queue\n") { + int idx_type = 4; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[4]->arg); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg); show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id); return CMD_SUCCESS; @@ -13652,11 +14022,13 @@ DEFUN (show_bgp_instance_updgrps_adj_s, "Announced routes\n" "Packet queue\n") { + int idx_word = 3; + int idx_type = 6; uint64_t subgrp_id; - VTY_GET_ULL("subgroup-id", subgrp_id, argv[6]->arg); + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg); - show_bgp_updgrps_adj_info_aux(vty, argv[3]->arg, AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id); return CMD_SUCCESS; } @@ -13841,7 +14213,8 @@ DEFUN (show_ip_bgp_instance_peer_groups, BGP_INSTANCE_HELP_STR "Detailed information on all BGP peer groups\n") { - return bgp_show_peer_group_vty (vty, argv[4]->arg, show_all_groups, NULL); + int idx_word = 4; + return bgp_show_peer_group_vty (vty, argv[idx_word]->arg, show_all_groups, NULL); } DEFUN (show_ip_bgp_peer_group, @@ -13853,7 +14226,8 @@ DEFUN (show_ip_bgp_peer_group, "BGP peer-group name\n" "Detailed information on a BGP peer group\n") { - return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[4]->arg); + int idx_word = 4; + return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[idx_word]->arg); } DEFUN (show_ip_bgp_instance_peer_group, @@ -13866,7 +14240,9 @@ DEFUN (show_ip_bgp_instance_peer_group, "BGP peer-group name\n" "Detailed information on a BGP peer group\n") { - return bgp_show_peer_group_vty (vty, argv[4]->arg, show_peer_group, argv[6]->arg); + int idx_word = 4; + int idx_word_2 = 6; + return bgp_show_peer_group_vty (vty, argv[idx_word]->arg, show_peer_group, argv[idx_word_2]->arg); } /* Redistribute VTY commands. */ @@ -13877,9 +14253,10 @@ DEFUN (bgp_redistribute_ipv4, "Redistribute information from another routing protocol\n" QUAGGA_IP_REDIST_HELP_STR_BGPD) { + int idx_protocol = 1; int type; - type = proto_redistnum (AFI_IP, argv[1]->arg); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -13897,10 +14274,12 @@ DEFUN (bgp_redistribute_ipv4_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int type; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[1]->arg); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -13908,7 +14287,7 @@ DEFUN (bgp_redistribute_ipv4_rmap, } red = bgp_redist_add(vty->index, AFI_IP, type, 0); - bgp_redistribute_rmap_set (red, argv[3]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, type, 0); } @@ -13920,17 +14299,19 @@ DEFUN (bgp_redistribute_ipv4_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_number = 3; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[1]->arg); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[3]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); @@ -13947,20 +14328,23 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_word = 3; + int idx_number = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[1]->arg); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[5]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, type, 0); - bgp_redistribute_rmap_set (red, argv[3]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); return bgp_redistribute_set (vty->index, AFI_IP, type, 0); } @@ -13975,21 +14359,24 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[1]->arg); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[3]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); - bgp_redistribute_rmap_set (red, argv[5]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, type, 0); } @@ -14001,12 +14388,14 @@ DEFUN (bgp_redistribute_ipv4_ospf, "Non-main Kernel Routing Table\n" "Instance ID/Table ID\n") { + int idx_ospf_table = 1; + int idx_number = 2; u_short instance; u_short protocol; - VTY_GET_INTEGER ("Instance ID", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); - if (strncmp(argv[1]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; @@ -14025,18 +14414,21 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_word = 4; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[1]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); - bgp_redistribute_rmap_set (red, argv[4]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); } @@ -14050,18 +14442,21 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_number_2 = 4; u_int32_t metric; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[1]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[2]->arg); - VTY_GET_INTEGER ("metric", metric, argv[4]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); @@ -14080,21 +14475,25 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_word = 4; + int idx_number_2 = 6; u_int32_t metric; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[1]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[2]->arg); - VTY_GET_INTEGER ("metric", metric, argv[6]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); - bgp_redistribute_rmap_set (red, argv[4]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); } @@ -14111,22 +14510,26 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_number_2 = 4; + int idx_word = 6; u_int32_t metric; struct bgp_redist *red; u_short instance; int protocol; - if (strncmp(argv[1]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[2]->arg); - VTY_GET_INTEGER ("metric", metric, argv[4]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); - bgp_redistribute_rmap_set (red, argv[6]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); } @@ -14182,15 +14585,17 @@ DEFUN (no_bgp_redistribute_ipv4_ospf, "Non-main Kernel Routing Table\n" "Instance ID/Table ID\n") { + int idx_ospf_table = 2; + int idx_number = 3; u_short instance; int protocol; - if (strncmp(argv[2]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) protocol = ZEBRA_ROUTE_OSPF; else protocol = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance); } @@ -14240,9 +14645,10 @@ DEFUN (no_bgp_redistribute_ipv4, "Redistribute information from another routing protocol\n" QUAGGA_IP_REDIST_HELP_STR_BGPD) { + int idx_protocol = 2; int type; - type = proto_redistnum (AFI_IP, argv[2]->arg); + type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -14262,9 +14668,10 @@ DEFUN (bgp_redistribute_ipv6, "Redistribute information from another routing protocol\n" QUAGGA_IP6_REDIST_HELP_STR_BGPD) { + int idx_protocol = 1; int type; - type = proto_redistnum (AFI_IP6, argv[1]->arg); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -14283,10 +14690,12 @@ DEFUN (bgp_redistribute_ipv6_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int type; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[1]->arg); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -14294,7 +14703,7 @@ DEFUN (bgp_redistribute_ipv6_rmap, } red = bgp_redist_add(vty->index, AFI_IP6, type, 0); - bgp_redistribute_rmap_set (red, argv[3]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); } @@ -14306,17 +14715,19 @@ DEFUN (bgp_redistribute_ipv6_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_number = 3; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[1]->arg); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[3]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP6, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric); @@ -14333,20 +14744,23 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric, "Metric for redistributed routes\n" "Default metric\n") { + int idx_protocol = 1; + int idx_word = 3; + int idx_number = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[1]->arg); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[5]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP6, type, 0); - bgp_redistribute_rmap_set (red, argv[3]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric); return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); } @@ -14361,21 +14775,24 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int type; u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[1]->arg); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_INTEGER ("metric", metric, argv[3]->arg); + VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); red = bgp_redist_add(vty->index, AFI_IP6, type, 0); bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric); - bgp_redistribute_rmap_set (red, argv[5]->arg); + bgp_redistribute_rmap_set (red, argv[idx_word]->arg); return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); } @@ -14421,9 +14838,10 @@ DEFUN (no_bgp_redistribute_ipv6, "Redistribute information from another routing protocol\n" QUAGGA_IP6_REDIST_HELP_STR_BGPD) { + int idx_protocol = 2; int type; - type = proto_redistnum (AFI_IP6, argv[2]->arg); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_BGP) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); @@ -16223,9 +16641,10 @@ DEFUN (show_ip_community_list_arg, "Community-list number\n" "Community-list name\n") { + int idx_comm_list = 3; struct community_list *list; - list = community_list_lookup (bgp_clist, argv[3]->arg, COMMUNITY_LIST_MASTER); + list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); if (! list) { vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); @@ -16604,9 +17023,10 @@ DEFUN (show_ip_extcommunity_list_arg, "Extcommunity-list number\n" "Extcommunity-list name\n") { + int idx_comm_list = 3; struct community_list *list; - list = community_list_lookup (bgp_clist, argv[3]->arg, EXTCOMMUNITY_LIST_MASTER); + list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); if (! list) { vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 62b057eab..fcdc11bba 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -551,6 +551,10 @@ DEFUN (isis_redistribute, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_afi = 1; + int idx_protocol = 2; + int idx_level = 3; + int idx_metric_rmap = 4; struct isis_area *area = vty->index; int family; int afi; @@ -562,7 +566,7 @@ DEFUN (isis_redistribute, if (argc < 5) return CMD_WARNING; - family = str2family(argv[1]->arg); + family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; @@ -570,13 +574,13 @@ DEFUN (isis_redistribute, if (!afi) return CMD_WARNING; - type = proto_redistnum(afi, argv[2]->arg); + type = proto_redistnum(afi, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_ISIS) return CMD_WARNING; - if (!strcmp("level-1", argv[3]->arg)) + if (!strcmp("level-1", argv[idx_level]->arg)) level = 1; - else if (!strcmp("level-2", argv[3]->arg)) + else if (!strcmp("level-2", argv[idx_level]->arg)) level = 2; else return CMD_WARNING; @@ -587,11 +591,11 @@ DEFUN (isis_redistribute, return CMD_WARNING; } - if (argv[4]->arg) + if (argv[idx_metric_rmap]->arg) { char *endp; - metric = strtoul(argv[4]->arg, &endp, 10); - if (argv[4]->arg[0] == '\0' || *endp != '\0') + metric = strtoul(argv[idx_metric_rmap]->arg, &endp, 10); + if (argv[idx_metric_rmap]->arg[0] == '\0' || *endp != '\0') return CMD_WARNING; } else @@ -616,6 +620,9 @@ DEFUN (no_isis_redistribute, "Redistribute into level-1\n" "Redistribute into level-2\n") { + int idx_afi = 2; + int idx_protocol = 3; + int idx_level = 4; struct isis_area *area = vty->index; int type; int level; @@ -625,7 +632,7 @@ DEFUN (no_isis_redistribute, if (argc < 3) return CMD_WARNING; - family = str2family(argv[2]->arg); + family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; @@ -633,13 +640,13 @@ DEFUN (no_isis_redistribute, if (!afi) return CMD_WARNING; - type = proto_redistnum(afi, argv[3]->arg); + type = proto_redistnum(afi, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_ISIS) return CMD_WARNING; - if (!strcmp("level-1", argv[4]->arg)) + if (!strcmp("level-1", argv[idx_level]->arg)) level = 1; - else if (!strcmp("level-2", argv[4]->arg)) + else if (!strcmp("level-2", argv[idx_level]->arg)) level = 2; else return CMD_WARNING; @@ -663,6 +670,9 @@ DEFUN (isis_default_originate, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_afi = 2; + int idx_level = 3; + int idx_metric_rmap = 4; struct isis_area *area = vty->index; int family; int originate_type; @@ -673,13 +683,13 @@ DEFUN (isis_default_originate, if (argc < 5) return CMD_WARNING; - family = str2family(argv[2]->arg); + family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; - if (!strcmp("level-1", argv[3]->arg)) + if (!strcmp("level-1", argv[idx_level]->arg)) level = 1; - else if (!strcmp("level-2", argv[3]->arg)) + else if (!strcmp("level-2", argv[idx_level]->arg)) level = 2; else return CMD_WARNING; @@ -690,7 +700,7 @@ DEFUN (isis_default_originate, return CMD_WARNING; } - if (argv[4]->arg && *argv[4]->arg != '\0') + if (argv[idx_metric_rmap]->arg && *argv[idx_metric_rmap]->arg != '\0') originate_type = DEFAULT_ORIGINATE_ALWAYS; else originate_type = DEFAULT_ORIGINATE; @@ -730,6 +740,8 @@ DEFUN (no_isis_default_originate, "Distribute default route into level-1\n" "Distribute default route into level-2\n") { + int idx_afi = 3; + int idx_level = 4; struct isis_area *area = vty->index; int family; @@ -738,13 +750,13 @@ DEFUN (no_isis_default_originate, if (argc < 2) return CMD_WARNING; - family = str2family(argv[3]->arg); + family = str2family(argv[idx_afi]->arg); if (family < 0) return CMD_WARNING; - if (!strcmp("level-1", argv[4]->arg)) + if (!strcmp("level-1", argv[idx_level]->arg)) level = 1; - else if (!strcmp("level-2", argv[4]->arg)) + else if (!strcmp("level-2", argv[idx_level]->arg)) level = 2; else return CMD_WARNING; diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c index fd6bff848..b9f6c7a55 100644 --- a/isisd/isis_routemap.c +++ b/isisd/isis_routemap.c @@ -354,7 +354,8 @@ DEFUN (match_ip_address, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - return isis_route_match_add(vty, vty->index, "ip address", argv[3]->arg); + int idx_acl = 3; + return isis_route_match_add(vty, vty->index, "ip address", argv[idx_acl]->arg); } /* @@ -377,9 +378,10 @@ DEFUN (no_match_ip_address, "IP access-list number (expanded range)\n" "IP Access-list name\n") { + int idx_acl = 4; if (argc == 0) return isis_route_match_delete(vty, vty->index, "ip address", NULL); - return isis_route_match_delete(vty, vty->index, "ip address", argv[4]->arg); + return isis_route_match_delete(vty, vty->index, "ip address", argv[idx_acl]->arg); } @@ -394,7 +396,8 @@ DEFUN (match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - return isis_route_match_add(vty, vty->index, "ip address prefix-list", argv[4]->arg); + int idx_word = 4; + return isis_route_match_add(vty, vty->index, "ip address prefix-list", argv[idx_word]->arg); } /* @@ -433,7 +436,8 @@ DEFUN (match_ipv6_address, "Match IPv6 address of route\n" "IPv6 access-list name\n") { - return isis_route_match_add(vty, vty->index, "ipv6 address", argv[3]->arg); + int idx_word = 3; + return isis_route_match_add(vty, vty->index, "ipv6 address", argv[idx_word]->arg); } /* @@ -454,9 +458,10 @@ DEFUN (no_match_ipv6_address, "Match IPv6 address of route\n" "IPv6 access-list name\n") { + int idx_word = 4; if (argc == 0) return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL); - return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[4]->arg); + return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[idx_word]->arg); } @@ -471,7 +476,8 @@ DEFUN (match_ipv6_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - return isis_route_match_add(vty, vty->index, "ipv6 address prefix-list", argv[4]->arg); + int idx_word = 4; + return isis_route_match_add(vty, vty->index, "ipv6 address prefix-list", argv[idx_word]->arg); } /* @@ -512,7 +518,8 @@ DEFUN (set_metric, "Metric vale for destination routing protocol\n" "Metric value\n") { - return isis_route_set_add(vty, vty->index, "metric", argv[2]->arg); + int idx_number = 2; + return isis_route_set_add(vty, vty->index, "metric", argv[idx_number]->arg); } /* @@ -534,9 +541,10 @@ DEFUN (no_set_metric, "Metric value for destination routing protocol\n" "Metric value\n") { + int idx_number = 3; if (argc == 0) return isis_route_set_delete(vty, vty->index, "metric", NULL); - return isis_route_set_delete(vty, vty->index, "metric", argv[3]->arg); + return isis_route_set_delete(vty, vty->index, "metric", argv[idx_number]->arg); } { diff --git a/isisd/isis_te.c b/isisd/isis_te.c index b958f0a21..b9e75bcf2 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -1163,11 +1163,12 @@ DEFUN (isis_mpls_te_router_addr, "Stable IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n") { + int idx_ipv4 = 2; struct in_addr value; struct listnode *node; struct isis_area *area; - if (! inet_aton (argv[2]->arg, &value)) + if (! inet_aton (argv[idx_ipv4]->arg, &value)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; @@ -1317,6 +1318,7 @@ DEFUN (show_isis_mpls_te_interface, "Interface information\n" "Interface name\n") { + int idx_interface = 4; struct interface *ifp; struct listnode *node; @@ -1329,7 +1331,7 @@ DEFUN (show_isis_mpls_te_interface, /* Interface name is specified. */ else { - if ((ifp = if_lookup_by_name (argv[4]->arg)) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else show_mpls_te_sub (vty, ifp); diff --git a/isisd/isis_vty.c b/isisd/isis_vty.c index a3890a595..aad8113fd 100644 --- a/isisd/isis_vty.c +++ b/isisd/isis_vty.c @@ -61,11 +61,13 @@ DEFUN (ip_router_isis, "IS-IS Routing for IP\n" "Routing process tag\n") { + int idx_afi = 0; + int idx_word = 3; struct interface *ifp; struct isis_circuit *circuit; struct isis_area *area; - const char *af = argv[0]->arg; - const char *area_tag = argv[3]->arg; + const char *af = argv[idx_afi]->arg; + const char *area_tag = argv[idx_word]->arg; ifp = (struct interface *) vty->index; assert (ifp); @@ -115,11 +117,13 @@ DEFUN (no_ip_router_isis, "IS-IS Routing for IP\n" "Routing process tag\n") { + int idx_afi = 1; + int idx_word = 4; struct interface *ifp; struct isis_area *area; struct isis_circuit *circuit; - const char *af = argv[1]->arg; - const char *area_tag = argv[4]->arg; + const char *af = argv[idx_afi]->arg; + const char *area_tag = argv[idx_word]->arg; ifp = (struct interface *) vty->index; if (!ifp) @@ -132,7 +136,7 @@ DEFUN (no_ip_router_isis, if (!area) { vty_out (vty, "Can't find ISIS instance %s%s", - argv[1]->arg, VTY_NEWLINE); + argv[idx_afi]->arg, VTY_NEWLINE); return CMD_ERR_NO_MATCH; } @@ -199,12 +203,13 @@ DEFUN (isis_circuit_type, "Level-1-2 adjacencies are formed\n" "Level-2 only adjacencies are formed\n") { + int idx_level = 2; int is_type; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - is_type = string2circuit_t (argv[2]->arg); + is_type = string2circuit_t (argv[idx_level]->arg); if (!is_type) { vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE); @@ -305,15 +310,17 @@ DEFUN (isis_passwd, "Cleartext password\n" "Circuit password\n") { + int idx_encryption = 2; + int idx_word = 3; struct isis_circuit *circuit = isis_circuit_lookup (vty); int rv; if (!circuit) return CMD_ERR_NO_MATCH; - if (argv[2]->arg[0] == 'm') - rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[3]->arg); + if (argv[idx_encryption]->arg[0] == 'm') + rv = isis_circuit_passwd_hmac_md5_set(circuit, argv[idx_word]->arg); else - rv = isis_circuit_passwd_cleartext_set(circuit, argv[3]->arg); + rv = isis_circuit_passwd_cleartext_set(circuit, argv[idx_word]->arg); if (rv) { vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); @@ -358,12 +365,13 @@ DEFUN (isis_priority, "Set priority for Designated Router election\n" "Priority value\n") { + int idx_number = 2; int prio; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - prio = atoi (argv[2]->arg); + prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { vty_out (vty, "Invalid priority %d - should be <0-127>%s", @@ -412,12 +420,13 @@ DEFUN (isis_priority_l1, "Priority value\n" "Specify priority for level-1 routing\n") { + int idx_number = 2; int prio; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - prio = atoi (argv[2]->arg); + prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { vty_out (vty, "Invalid priority %d - should be <0-127>%s", @@ -466,12 +475,13 @@ DEFUN (isis_priority_l2, "Priority value\n" "Specify priority for level-2 routing\n") { + int idx_number = 2; int prio; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - prio = atoi (argv[2]->arg); + prio = atoi (argv[idx_number]->arg); if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { vty_out (vty, "Invalid priority %d - should be <0-127>%s", @@ -520,12 +530,13 @@ DEFUN (isis_metric, "Set default metric for circuit\n" "Default metric value\n") { + int idx_number = 2; int met; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - met = atoi (argv[2]->arg); + met = atoi (argv[idx_number]->arg); /* RFC3787 section 5.1 */ if (circuit->area && circuit->area->oldmetric == 1 && @@ -586,12 +597,13 @@ DEFUN (isis_metric_l1, "Default metric value\n" "Specify metric for level-1 routing\n") { + int idx_number = 2; int met; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - met = atoi (argv[2]->arg); + met = atoi (argv[idx_number]->arg); /* RFC3787 section 5.1 */ if (circuit->area && circuit->area->oldmetric == 1 && @@ -652,12 +664,13 @@ DEFUN (isis_metric_l2, "Default metric value\n" "Specify metric for level-2 routing\n") { + int idx_number = 2; int met; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - met = atoi (argv[2]->arg); + met = atoi (argv[idx_number]->arg); /* RFC3787 section 5.1 */ if (circuit->area && circuit->area->oldmetric == 1 && @@ -719,12 +732,13 @@ DEFUN (isis_hello_interval, "Hello interval value\n" "Holdtime 1 seconds, interval depends on multiplier\n") { + int idx_number = 2; int interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atoi (argv[2]->arg); + interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s", @@ -775,12 +789,13 @@ DEFUN (isis_hello_interval_l1, "Holdtime 1 second, interval depends on multiplier\n" "Specify hello-interval for level-1 IIHs\n") { + int idx_number = 2; long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atoi (argv[2]->arg); + interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", @@ -831,12 +846,13 @@ DEFUN (isis_hello_interval_l2, "Holdtime 1 second, interval depends on multiplier\n" "Specify hello-interval for level-2 IIHs\n") { + int idx_number = 2; long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atoi (argv[2]->arg); + interval = atoi (argv[idx_number]->arg); if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", @@ -885,12 +901,13 @@ DEFUN (isis_hello_multiplier, "Set multiplier for Hello holding time\n" "Hello multiplier value\n") { + int idx_number = 2; int mult; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - mult = atoi (argv[2]->arg); + mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", @@ -939,12 +956,13 @@ DEFUN (isis_hello_multiplier_l1, "Hello multiplier value\n" "Specify hello multiplier for level-1 IIHs\n") { + int idx_number = 2; int mult; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - mult = atoi (argv[2]->arg); + mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", @@ -993,12 +1011,13 @@ DEFUN (isis_hello_multiplier_l2, "Hello multiplier value\n" "Specify hello multiplier for level-2 IIHs\n") { + int idx_number = 2; int mult; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - mult = atoi (argv[2]->arg); + mult = atoi (argv[idx_number]->arg); if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", @@ -1081,12 +1100,13 @@ DEFUN (csnp_interval, "Set CSNP interval in seconds\n" "CSNP interval value\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[2]->arg); + interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", @@ -1135,12 +1155,13 @@ DEFUN (csnp_interval_l1, "CSNP interval value\n" "Specify interval for level-1 CSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[2]->arg); + interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", @@ -1189,12 +1210,13 @@ DEFUN (csnp_interval_l2, "CSNP interval value\n" "Specify interval for level-2 CSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[2]->arg); + interval = atol (argv[idx_number]->arg); if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", @@ -1242,12 +1264,13 @@ DEFUN (psnp_interval, "Set PSNP interval in seconds\n" "PSNP interval value\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[2]->arg); + interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", @@ -1296,12 +1319,13 @@ DEFUN (psnp_interval_l1, "PSNP interval value\n" "Specify interval for level-1 PSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[2]->arg); + interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", @@ -1350,12 +1374,13 @@ DEFUN (psnp_interval_l2, "PSNP interval value\n" "Specify interval for level-2 PSNPs\n") { + int idx_number = 2; unsigned long interval; struct isis_circuit *circuit = isis_circuit_lookup (vty); if (!circuit) return CMD_ERR_NO_MATCH; - interval = atol (argv[2]->arg); + interval = atol (argv[idx_number]->arg); if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", @@ -1442,12 +1467,13 @@ DEFUN (metric_style, "Send and accept both styles of TLVs during transition\n" "Use new style of TLVs to carry wider metric\n") { + int idx_metric_style = 1; struct isis_area *area = vty->index; int ret; assert(area); - if (strncmp (argv[1]->arg, "w", 1) == 0) + if (strncmp (argv[idx_metric_style]->arg, "w", 1) == 0) { isis_area_metricstyle_set(area, false, true); return CMD_SUCCESS; @@ -1457,9 +1483,9 @@ DEFUN (metric_style, if (ret != CMD_SUCCESS) return ret; - if (strncmp (argv[1]->arg, "t", 1) == 0) + if (strncmp (argv[idx_metric_style]->arg, "t", 1) == 0) isis_area_metricstyle_set(area, true, true); - else if (strncmp (argv[1]->arg, "n", 1) == 0) + else if (strncmp (argv[idx_metric_style]->arg, "n", 1) == 0) isis_area_metricstyle_set(area, true, false); return CMD_SUCCESS; @@ -1597,9 +1623,10 @@ DEFUN (area_lsp_mtu, "Configure the maximum size of generated LSPs\n" "Maximum size of generated LSPs\n") { + int idx_number = 1; unsigned int lsp_mtu; - VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[1]->arg, 128, 4352); + VTY_GET_INTEGER_RANGE("lsp-mtu", lsp_mtu, argv[idx_number]->arg, 128, 4352); return area_lsp_mtu_set(vty, lsp_mtu); } @@ -1630,6 +1657,7 @@ DEFUN (is_type, "Act as both a station router and an area router\n" "Act as an area router only\n") { + int idx_level = 1; struct isis_area *area; int type; @@ -1641,7 +1669,7 @@ DEFUN (is_type, return CMD_ERR_NO_MATCH; } - type = string2circuit_t (argv[1]->arg); + type = string2circuit_t (argv[idx_level]->arg); if (!type) { vty_out (vty, "Unknown IS level %s", VTY_NEWLINE); @@ -1719,12 +1747,13 @@ DEFUN (lsp_gen_interval, "Minimum interval between regenerating same LSP\n" "Minimum interval in seconds\n") { + int idx_number = 1; struct isis_area *area; uint16_t interval; int level; area = vty->index; - interval = atoi (argv[1]->arg); + interval = atoi (argv[idx_number]->arg); level = IS_LEVEL_1 | IS_LEVEL_2; return set_lsp_gen_interval (vty, area, interval, level); } @@ -1761,12 +1790,13 @@ DEFUN (lsp_gen_interval_l1, "Set interval for level 1 only\n" "Minimum interval in seconds\n") { + int idx_number = 2; struct isis_area *area; uint16_t interval; int level; area = vty->index; - interval = atoi (argv[2]->arg); + interval = atoi (argv[idx_number]->arg); level = IS_LEVEL_1; return set_lsp_gen_interval (vty, area, interval, level); } @@ -1805,12 +1835,13 @@ DEFUN (lsp_gen_interval_l2, "Set interval for level 2 only\n" "Minimum interval in seconds\n") { + int idx_number = 2; struct isis_area *area; uint16_t interval; int level; area = vty->index; - interval = atoi (argv[2]->arg); + interval = atoi (argv[idx_number]->arg); level = IS_LEVEL_2; return set_lsp_gen_interval (vty, area, interval, level); } @@ -1848,11 +1879,12 @@ DEFUN (spf_interval, "Minimum interval between SPF calculations\n" "Minimum interval between consecutive SPFs in seconds\n") { + int idx_number = 1; struct isis_area *area; u_int16_t interval; area = vty->index; - interval = atoi (argv[1]->arg); + interval = atoi (argv[idx_number]->arg); area->min_spf_interval[0] = interval; area->min_spf_interval[1] = interval; @@ -1903,11 +1935,12 @@ DEFUN (spf_interval_l1, "Set interval for level 1 only\n" "Minimum interval between consecutive SPFs in seconds\n") { + int idx_number = 2; struct isis_area *area; u_int16_t interval; area = vty->index; - interval = atoi (argv[2]->arg); + interval = atoi (argv[idx_number]->arg); area->min_spf_interval[0] = interval; return CMD_SUCCESS; @@ -1937,11 +1970,12 @@ DEFUN (spf_interval_l2, "Set interval for level 2 only\n" "Minimum interval between consecutive SPFs in seconds\n") { + int idx_number = 2; struct isis_area *area; u_int16_t interval; area = vty->index; - interval = atoi (argv[2]->arg); + interval = atoi (argv[idx_number]->arg); area->min_spf_interval[1] = interval; return CMD_SUCCESS; @@ -2022,7 +2056,8 @@ DEFUN (max_lsp_lifetime, "Maximum LSP lifetime\n" "LSP lifetime in seconds\n") { - return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, atoi(argv[1]->arg)); + int idx_number = 1; + return area_max_lsp_lifetime_set(vty, IS_LEVEL_1_AND_2, atoi(argv[idx_number]->arg)); } /* @@ -2050,7 +2085,8 @@ DEFUN (max_lsp_lifetime_l1, "Maximum LSP lifetime for Level 1 only\n" "LSP lifetime for Level 1 only in seconds\n") { - return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, atoi(argv[2]->arg)); + int idx_number = 2; + return area_max_lsp_lifetime_set(vty, IS_LEVEL_1, atoi(argv[idx_number]->arg)); } /* @@ -2077,7 +2113,8 @@ DEFUN (max_lsp_lifetime_l2, "Maximum LSP lifetime for Level 2 only\n" "LSP lifetime for Level 2 only in seconds\n") { - return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, atoi(argv[2]->arg)); + int idx_number = 2; + return area_max_lsp_lifetime_set(vty, IS_LEVEL_2, atoi(argv[idx_number]->arg)); } /* @@ -2148,7 +2185,8 @@ DEFUN (lsp_refresh_interval, "LSP refresh interval\n" "LSP refresh interval in seconds\n") { - return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, atoi(argv[1]->arg)); + int idx_number = 1; + return area_lsp_refresh_interval_set(vty, IS_LEVEL_1_AND_2, atoi(argv[idx_number]->arg)); } /* @@ -2176,7 +2214,8 @@ DEFUN (lsp_refresh_interval_l1, "LSP refresh interval for Level 1 only\n" "LSP refresh interval for Level 1 only in seconds\n") { - return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, atoi(argv[2]->arg)); + int idx_number = 2; + return area_lsp_refresh_interval_set(vty, IS_LEVEL_1, atoi(argv[idx_number]->arg)); } /* @@ -2204,7 +2243,8 @@ DEFUN (lsp_refresh_interval_l2, "LSP refresh interval for Level 2 only\n" "LSP refresh interval for Level 2 only in seconds\n") { - return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, atoi(argv[2]->arg)); + int idx_number = 2; + return area_lsp_refresh_interval_set(vty, IS_LEVEL_2, atoi(argv[idx_number]->arg)); } /* @@ -2271,8 +2311,10 @@ DEFUN (area_passwd_md5, "Authentication type\n" "Level-wide password\n") { + int idx_password = 0; + int idx_word = 2; u_char snp_auth = 0; - int level = (argv[0]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; + int level = (argv[idx_password]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; if (argc > 2) { @@ -2282,7 +2324,7 @@ DEFUN (area_passwd_md5, } return area_passwd_set(vty, level, isis_area_passwd_hmac_md5_set, - argv[2]->arg, snp_auth); + argv[idx_word]->arg, snp_auth); } @@ -2307,8 +2349,10 @@ DEFUN (area_passwd_clear, "Authentication type\n" "Area password\n") { + int idx_password = 0; + int idx_word = 2; u_char snp_auth = 0; - int level = (argv[0]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; + int level = (argv[idx_password]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; if (argc > 2) { @@ -2318,7 +2362,7 @@ DEFUN (area_passwd_clear, } return area_passwd_set(vty, level, isis_area_passwd_cleartext_set, - argv[2]->arg, snp_auth); + argv[idx_word]->arg, snp_auth); } @@ -2329,7 +2373,8 @@ DEFUN (no_area_passwd, "Configure the authentication password for an area\n" "Set the authentication password for a routing domain\n") { - int level = (argv[1]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; + int idx_password = 1; + int level = (argv[idx_password]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1; struct isis_area *area = vty->index; if (!area) diff --git a/isisd/isisd.c b/isisd/isisd.c index 263fa63a3..b1c21b55c 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -533,7 +533,8 @@ DEFUN (show_isis_interface_arg, "ISIS interface\n" "ISIS interface name\n") { - return show_isis_interface_common (vty, argv[3]->arg, ISIS_UI_LEVEL_DETAIL); + int idx_word = 3; + return show_isis_interface_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } /* @@ -707,7 +708,8 @@ DEFUN (show_isis_neighbor_arg, "ISIS neighbor adjacencies\n" "System id\n") { - return show_isis_neighbor_common (vty, argv[3]->arg, ISIS_UI_LEVEL_DETAIL); + int idx_word = 3; + return show_isis_neighbor_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } DEFUN (clear_isis_neighbor, @@ -728,7 +730,8 @@ DEFUN (clear_isis_neighbor_arg, "ISIS neighbor adjacencies\n" "System id\n") { - return clear_isis_neighbor_common (vty, argv[3]->arg); + int idx_word = 3; + return clear_isis_neighbor_common (vty, argv[idx_word]->arg); } /* @@ -1530,7 +1533,8 @@ DEFUN (show_database_lsp_brief, "IS-IS link state database\n" "LSP ID\n") { - return show_isis_database (vty, argv[3]->arg, ISIS_UI_LEVEL_BRIEF); + int idx_word = 3; + return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_BRIEF); } DEFUN (show_database_lsp_detail, @@ -1542,7 +1546,8 @@ DEFUN (show_database_lsp_detail, "LSP ID\n" "Detailed information\n") { - return show_isis_database (vty, argv[3]->arg, ISIS_UI_LEVEL_DETAIL); + int idx_word = 3; + return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } DEFUN (show_database_detail, @@ -1564,7 +1569,8 @@ DEFUN (show_database_detail_lsp, "Detailed information\n" "LSP ID\n") { - return show_isis_database (vty, argv[4]->arg, ISIS_UI_LEVEL_DETAIL); + int idx_word = 4; + return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL); } /* @@ -1577,7 +1583,8 @@ DEFUN (router_isis, "ISO IS-IS\n" "ISO Routing area tag") { - return isis_area_get (vty, argv[2]->arg); + int idx_word = 2; + return isis_area_get (vty, argv[idx_word]->arg); } /* @@ -1588,7 +1595,8 @@ DEFUN (no_router_isis, "no router isis WORD", "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag") { - return isis_area_destroy (vty, argv[3]->arg); + int idx_word = 3; + return isis_area_destroy (vty, argv[idx_word]->arg); } /* @@ -1600,7 +1608,8 @@ DEFUN (net, "A Network Entity Title for this process (OSI only)\n" "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") { - return area_net_title (vty, argv[1]->arg); + int idx_word = 1; + return area_net_title (vty, argv[idx_word]->arg); } /* @@ -1613,7 +1622,8 @@ DEFUN (no_net, "A Network Entity Title for this process (OSI only)\n" "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") { - return area_clear_net_title (vty, argv[2]->arg); + int idx_word = 2; + return area_clear_net_title (vty, argv[idx_word]->arg); } void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu) @@ -1966,14 +1976,15 @@ DEFUN (topology_baseis, "A Network IS Base for this topology\n" "XXXX.XXXX.XXXX Network entity title (NET)\n") { + int idx_word = 2; struct isis_area *area; u_char buff[ISIS_SYS_ID_LEN]; area = vty->index; assert (area); - if (sysid2buff (buff, argv[2]->arg)) - sysid2buff (area->topology_baseis, argv[2]->arg); + if (sysid2buff (buff, argv[idx_word]->arg)) + sysid2buff (area->topology_baseis, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -2011,13 +2022,14 @@ DEFUN (topology_basedynh, "Dynamic hostname base for this topology\n" "Dynamic hostname base\n") { + int idx_word = 2; struct isis_area *area; area = vty->index; assert (area); /* I hope that it's enough. */ - area->topology_basedynh = strndup (argv[2]->arg, 16); + area->topology_basedynh = strndup (argv[idx_word]->arg, 16); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 1c1a524e4..d67621d7c 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -468,18 +468,20 @@ DEFUN (area_range, "Specify IPv6 prefix\n" ) { + int idx_ipv4 = 1; + int idx_ipv6_prefixlen = 3; int ret; struct ospf6_area *oa; struct prefix prefix; struct ospf6_route *range; u_int32_t cost = OSPF_AREA_RANGE_COST_UNSPEC; - OSPF6_CMD_AREA_GET (argv[1]->arg, oa); + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa); - ret = str2prefix (argv[3]->arg, &prefix); + ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &prefix); if (ret != 1 || prefix.family != AF_INET6) { - vty_out (vty, "Malformed argument: %s%s", argv[3]->arg, VNL); + vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv6_prefixlen]->arg, VNL); return CMD_SUCCESS; } @@ -514,7 +516,7 @@ DEFUN (area_range, range->path.u.cost_config = cost; - zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[3]->arg, range->flag); + zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[idx_ipv6_prefixlen]->arg, range->flag); if (range->rnode == NULL) { ospf6_route_add (range, oa->range_table); @@ -569,26 +571,27 @@ DEFUN (no_area_range, "Configured address range\n" "Specify IPv6 prefix\n") { + int idx_ipv4 = 2; int ret; struct ospf6_area *oa; struct prefix prefix; struct ospf6_route *range, *route; - OSPF6_CMD_AREA_GET (argv[2]->arg, oa); + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa); argc--; argv++; - ret = str2prefix (argv[2]->arg, &prefix); + ret = str2prefix (argv[idx_ipv4]->arg, &prefix); if (ret != 1 || prefix.family != AF_INET6) { - vty_out (vty, "Malformed argument: %s%s", argv[2]->arg, VNL); + vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } range = ospf6_route_lookup (&prefix, oa->range_table); if (range == NULL) { - vty_out (vty, "Range %s does not exists.%s", argv[2]->arg, VNL); + vty_out (vty, "Range %s does not exists.%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -677,21 +680,23 @@ DEFUN (area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4 = 1; + int idx_word = 4; struct ospf6_area *area; struct prefix_list *plist; - OSPF6_CMD_AREA_GET (argv[1]->arg, area); + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area); argc--; argv++; - plist = prefix_list_lookup (AFI_IP6, argv[1]->arg); - if (strncmp (argv[4]->arg, "in", 2) == 0) + plist = prefix_list_lookup (AFI_IP6, argv[idx_ipv4]->arg); + if (strncmp (argv[idx_word]->arg, "in", 2) == 0) { PREFIX_LIST_IN (area) = plist; if (PREFIX_NAME_IN (area)) free (PREFIX_NAME_IN (area)); - PREFIX_NAME_IN (area) = strdup (argv[1]->arg); + PREFIX_NAME_IN (area) = strdup (argv[idx_ipv4]->arg); ospf6_abr_reimport (area); } else @@ -700,7 +705,7 @@ DEFUN (area_filter_list, if (PREFIX_NAME_OUT (area)) free (PREFIX_NAME_OUT (area)); - PREFIX_NAME_OUT (area) = strdup (argv[1]->arg); + PREFIX_NAME_OUT (area) = strdup (argv[idx_ipv4]->arg); ospf6_abr_enable_area (area); } @@ -719,16 +724,18 @@ DEFUN (no_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4 = 2; + int idx_word = 5; struct ospf6_area *area; - OSPF6_CMD_AREA_GET (argv[2]->arg, area); + OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area); argc--; argv++; - if (strncmp (argv[5]->arg, "in", 2) == 0) + if (strncmp (argv[idx_word]->arg, "in", 2) == 0) { if (PREFIX_NAME_IN (area)) - if (strcmp (PREFIX_NAME_IN (area), argv[2]->arg) != 0) + if (strcmp (PREFIX_NAME_IN (area), argv[idx_ipv4]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_IN (area) = NULL; @@ -741,7 +748,7 @@ DEFUN (no_area_filter_list, else { if (PREFIX_NAME_OUT (area)) - if (strcmp (PREFIX_NAME_OUT (area), argv[2]->arg) != 0) + if (strcmp (PREFIX_NAME_OUT (area), argv[idx_ipv4]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_OUT (area) = NULL; @@ -763,19 +770,21 @@ DEFUN (area_import_list, "Set the filter for networks from other areas announced to the specified one\n" "Name of the acess-list\n") { + int idx_ipv4 = 1; + int idx_name = 3; struct ospf6_area *area; struct access_list *list; - OSPF6_CMD_AREA_GET(argv[1]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); - list = access_list_lookup (AFI_IP6, argv[3]->arg); + list = access_list_lookup (AFI_IP6, argv[idx_name]->arg); IMPORT_LIST (area) = list; if (IMPORT_NAME (area)) free (IMPORT_NAME (area)); - IMPORT_NAME (area) = strdup (argv[3]->arg); + IMPORT_NAME (area) = strdup (argv[idx_name]->arg); ospf6_abr_reimport (area); return CMD_SUCCESS; @@ -789,9 +798,10 @@ DEFUN (no_area_import_list, "Unset the filter for networks announced to other areas\n" "NAme of the access-list\n") { + int idx_ipv4 = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[2]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); IMPORT_LIST (area) = 0; @@ -812,19 +822,21 @@ DEFUN (area_export_list, "Set the filter for networks announced to other areas\n" "Name of the acess-list\n") { + int idx_ipv4 = 1; + int idx_name = 3; struct ospf6_area *area; struct access_list *list; - OSPF6_CMD_AREA_GET(argv[1]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); - list = access_list_lookup (AFI_IP6, argv[3]->arg); + list = access_list_lookup (AFI_IP6, argv[idx_name]->arg); EXPORT_LIST (area) = list; if (EXPORT_NAME (area)) free (EXPORT_NAME (area)); - EXPORT_NAME (area) = strdup (argv[3]->arg); + EXPORT_NAME (area) = strdup (argv[idx_name]->arg); ospf6_abr_enable_area (area); return CMD_SUCCESS; @@ -838,9 +850,10 @@ DEFUN (no_area_export_list, "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4 = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[2]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area); EXPORT_LIST (area) = 0; @@ -899,6 +912,7 @@ DEFUN (show_ipv6_ospf6_area_spf_tree, "Shortest Path First caculation\n" "Show SPF tree\n") { + int idx_ipv4 = 4; u_int32_t area_id; struct ospf6_area *oa; struct ospf6_vertex *root; @@ -909,15 +923,15 @@ DEFUN (show_ipv6_ospf6_area_spf_tree, ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); - if (inet_pton (AF_INET, argv[4]->arg, &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Malformed Area-ID: %s%s", argv[4]->arg, VNL); + vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } oa = ospf6_area_lookup (area_id, ospf6); if (oa == NULL) { - vty_out (vty, "No such Area: %s%s", argv[4]->arg, VNL); + vty_out (vty, "No such Area: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -944,6 +958,8 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, "Show SPF tree\n" "Specify root's router-id to calculate another router's SPF tree\n") { + int idx_ipv4 = 5; + int idx_ipv4_2 = 7; u_int32_t area_id; struct ospf6_area *oa; struct ospf6_vertex *root; @@ -955,18 +971,18 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, OSPF6_CMD_CHECK_RUNNING (); - inet_pton (AF_INET, argv[5]->arg, &router_id); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id); ospf6_linkstate_prefix (router_id, htonl (0), &prefix); - if (inet_pton (AF_INET, argv[7]->arg, &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4_2]->arg, &area_id) != 1) { - vty_out (vty, "Malformed Area-ID: %s%s", argv[7]->arg, VNL); + vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4_2]->arg, VNL); return CMD_SUCCESS; } oa = ospf6_area_lookup (area_id, ospf6); if (oa == NULL) { - vty_out (vty, "No such Area: %s%s", argv[7]->arg, VNL); + vty_out (vty, "No such Area: %s%s", argv[idx_ipv4_2]->arg, VNL); return CMD_SUCCESS; } @@ -1002,9 +1018,10 @@ DEFUN (ospf6_area_stub, "OSPF6 area ID as a decimal value\n" "Configure OSPF6 area as stub\n") { + int idx_ipv4_number = 1; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[1]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); if (!ospf6_area_stub_set (ospf6, area)) { @@ -1027,9 +1044,10 @@ DEFUN (ospf6_area_stub_no_summary, "Configure OSPF6 area as stub\n" "Do not inject inter-area routes into stub\n") { + int idx_ipv4_number = 1; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[1]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); if (!ospf6_area_stub_set (ospf6, area)) { @@ -1052,9 +1070,10 @@ DEFUN (no_ospf6_area_stub, "OSPF6 area ID as a decimal value\n" "Configure OSPF6 area as stub\n") { + int idx_ipv4_number = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[2]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); ospf6_area_stub_unset (ospf6, area); ospf6_area_no_summary_unset (ospf6, area); @@ -1072,9 +1091,10 @@ DEFUN (no_ospf6_area_stub_no_summary, "Configure OSPF6 area as stub\n" "Do not inject inter-area routes into area\n") { + int idx_ipv4_number = 2; struct ospf6_area *area; - OSPF6_CMD_AREA_GET(argv[2]->arg, area); + OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area); ospf6_area_stub_unset (ospf6, area); ospf6_area_no_summary_unset (ospf6, area); diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 143278b42..014320a2f 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -667,14 +667,16 @@ DEFUN (ospf6_redistribute_routemap, "Route map name\n" ) { + int idx_protocol = 1; + int idx_word = 3; int type; - type = proto_redistnum(AFI_IP6, argv[1]->arg); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg); if (type < 0 || type == ZEBRA_ROUTE_OSPF6) return CMD_WARNING; ospf6_asbr_redistribute_unset (type); - ospf6_asbr_routemap_set (type, argv[3]->arg); + ospf6_asbr_routemap_set (type, argv[idx_word]->arg); ospf6_asbr_redistribute_set (type); return CMD_SUCCESS; } @@ -1019,8 +1021,9 @@ DEFUN (ospf6_routemap_match_address_prefixlist, "Match entries of prefix-lists\n" "IPv6 prefix-list name\n") { + int idx_word = 4; int ret = route_map_add_match ((struct route_map_index *) vty->index, - "ipv6 address prefix-list", argv[4]->arg); + "ipv6 address prefix-list", argv[idx_word]->arg); return route_map_command_status (vty, ret); } @@ -1035,8 +1038,9 @@ DEFUN (ospf6_routemap_no_match_address_prefixlist, "Match entries of prefix-lists\n" "IPv6 prefix-list name\n") { + int idx_word = 5; int ret = route_map_delete_match ((struct route_map_index *) vty->index, - "ipv6 address prefix-list", argv[5]->arg); + "ipv6 address prefix-list", argv[idx_word]->arg); return route_map_command_status (vty, ret); } @@ -1048,8 +1052,9 @@ DEFUN (ospf6_routemap_match_interface, "Match first hop interface of route\n" "Interface name\n") { + int idx_word = 2; return route_map_add_match ((struct route_map_index *) vty->index, - "interface", argv[2]->arg); + "interface", argv[idx_word]->arg); } /* "no match interface WORD" */ @@ -1084,8 +1089,9 @@ DEFUN (ospf6_routemap_set_metric_type, "OSPF6 external type 1 metric\n" "OSPF6 external type 2 metric\n") { + int idx_external = 2; int ret = route_map_add_set ((struct route_map_index *) vty->index, - "metric-type", argv[2]->arg); + "metric-type", argv[idx_external]->arg); return route_map_command_status (vty, ret); } @@ -1099,8 +1105,9 @@ DEFUN (ospf6_routemap_no_set_metric_type, "OSPF6 external type 1 metric\n" "OSPF6 external type 2 metric\n") { + int idx_external = 3; int ret = route_map_delete_set ((struct route_map_index *) vty->index, - "metric-type", argv[3]->arg); + "metric-type", argv[idx_external]->arg); return route_map_command_status (vty, ret); } @@ -1112,8 +1119,9 @@ DEFUN (set_metric, "Metric value\n" "Metric value\n") { + int idx_number = 2; int ret = route_map_add_set ((struct route_map_index *) vty->index, - "metric", argv[2]->arg); + "metric", argv[idx_number]->arg); return route_map_command_status (vty, ret); } @@ -1154,8 +1162,9 @@ DEFUN (ospf6_routemap_set_forwarding, "Forwarding Address\n" "IPv6 Address\n") { + int idx_ipv6 = 2; int ret = route_map_add_set ((struct route_map_index *) vty->index, - "forwarding-address", argv[2]->arg); + "forwarding-address", argv[idx_ipv6]->arg); return route_map_command_status (vty, ret); } @@ -1168,8 +1177,9 @@ DEFUN (ospf6_routemap_no_set_forwarding, "Forwarding Address\n" "IPv6 Address\n") { + int idx_ipv6 = 3; int ret = route_map_delete_set ((struct route_map_index *) vty->index, - "forwarding-address", argv[3]->arg); + "forwarding-address", argv[idx_ipv6]->arg); return route_map_command_status (vty, ret); } diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c index 29368cb9b..5d1eae3e3 100644 --- a/ospf6d/ospf6_bfd.c +++ b/ospf6d/ospf6_bfd.c @@ -354,6 +354,9 @@ DEFUN (ipv6_ospf6_bfd_param, "Required min receive interval\n" "Desired min transmit interval\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; struct ospf6_interface *oi; struct interface *ifp; u_int32_t rx_val; @@ -369,7 +372,7 @@ DEFUN (ipv6_ospf6_bfd_param, oi = ospf6_interface_create (ifp); assert (oi); - if ((ret = bfd_validate_param (vty, argv[3]->arg, argv[4]->arg, argv[5]->arg, &dm_val, + if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val, &rx_val, &tx_val)) != CMD_SUCCESS) return ret; diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 2b7d180a8..e9d66419d 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1006,15 +1006,16 @@ DEFUN (show_ipv6_ospf6_interface, IFNAME_STR ) { + int idx_ifname = 4; struct interface *ifp; struct listnode *i; if (argc) { - ifp = if_lookup_by_name (argv[4]->arg); + ifp = if_lookup_by_name (argv[idx_ifname]->arg); if (ifp == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[4]->arg, + vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } @@ -1068,20 +1069,21 @@ DEFUN (show_ipv6_ospf6_interface_ifname_prefix, "Display connected prefixes to advertise\n" ) { + int idx_ifname = 4; struct interface *ifp; struct ospf6_interface *oi; - ifp = if_lookup_by_name (argv[4]->arg); + ifp = if_lookup_by_name (argv[idx_ifname]->arg); if (ifp == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[4]->arg, VNL); + vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } oi = ifp->info; if (oi == NULL) { - vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[4]->arg, VNL); + vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } @@ -1158,6 +1160,7 @@ DEFUN (ipv6_ospf6_ifmtu, "OSPFv3 Interface MTU\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; unsigned int ifmtu, iobuflen; @@ -1172,7 +1175,7 @@ DEFUN (ipv6_ospf6_ifmtu, oi = ospf6_interface_create (ifp); assert (oi); - ifmtu = strtol (argv[3]->arg, NULL, 10); + ifmtu = strtol (argv[idx_number]->arg, NULL, 10); if (oi->ifmtu == ifmtu) return CMD_SUCCESS; @@ -1266,6 +1269,7 @@ DEFUN (ipv6_ospf6_cost, "Outgoing metric of this interface\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; unsigned long int lcost; @@ -1278,7 +1282,7 @@ DEFUN (ipv6_ospf6_cost, oi = ospf6_interface_create (ifp); assert (oi); - lcost = strtol (argv[3]->arg, NULL, 10); + lcost = strtol (argv[idx_number]->arg, NULL, 10); if (lcost > UINT32_MAX) { @@ -1331,13 +1335,14 @@ DEFUN (auto_cost_reference_bandwidth, "Use reference bandwidth method to assign OSPF cost\n" "The reference bandwidth in terms of Mbits per second\n") { + int idx_number = 2; struct ospf6 *o = vty->index; struct ospf6_area *oa; struct ospf6_interface *oi; struct listnode *i, *j; u_int32_t refbw; - refbw = strtol (argv[2]->arg, NULL, 10); + refbw = strtol (argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); @@ -1398,6 +1403,7 @@ DEFUN (ipv6_ospf6_hellointerval, SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1409,7 +1415,7 @@ DEFUN (ipv6_ospf6_hellointerval, oi = ospf6_interface_create (ifp); assert (oi); - oi->hello_interval = strtol (argv[3]->arg, NULL, 10); + oi->hello_interval = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } @@ -1423,6 +1429,7 @@ DEFUN (ipv6_ospf6_deadinterval, SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1434,7 +1441,7 @@ DEFUN (ipv6_ospf6_deadinterval, oi = ospf6_interface_create (ifp); assert (oi); - oi->dead_interval = strtol (argv[3]->arg, NULL, 10); + oi->dead_interval = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } @@ -1448,6 +1455,7 @@ DEFUN (ipv6_ospf6_transmitdelay, SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1459,7 +1467,7 @@ DEFUN (ipv6_ospf6_transmitdelay, oi = ospf6_interface_create (ifp); assert (oi); - oi->transdelay = strtol (argv[3]->arg, NULL, 10); + oi->transdelay = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } @@ -1473,6 +1481,7 @@ DEFUN (ipv6_ospf6_retransmitinterval, SECONDS_STR ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1484,7 +1493,7 @@ DEFUN (ipv6_ospf6_retransmitinterval, oi = ospf6_interface_create (ifp); assert (oi); - oi->rxmt_interval = strtol (argv[3]->arg, NULL, 10); + oi->rxmt_interval = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } @@ -1498,6 +1507,7 @@ DEFUN (ipv6_ospf6_priority, "Priority value\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1509,7 +1519,7 @@ DEFUN (ipv6_ospf6_priority, oi = ospf6_interface_create (ifp); assert (oi); - oi->priority = strtol (argv[3]->arg, NULL, 10); + oi->priority = strtol (argv[idx_number]->arg, NULL, 10); if (oi->area && (oi->state == OSPF6_INTERFACE_DROTHER || @@ -1529,6 +1539,7 @@ DEFUN (ipv6_ospf6_instance, "Instance ID value\n" ) { + int idx_number = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1540,7 +1551,7 @@ DEFUN (ipv6_ospf6_instance, oi = ospf6_interface_create (ifp); assert (oi); - oi->instance_id = strtol (argv[3]->arg, NULL, 10); + oi->instance_id = strtol (argv[idx_number]->arg, NULL, 10); return CMD_SUCCESS; } @@ -1664,6 +1675,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list, "Prefix list name\n" ) { + int idx_word = 4; struct ospf6_interface *oi; struct interface *ifp; @@ -1677,7 +1689,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list, if (oi->plist_name) XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name); - oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[4]->arg); + oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[idx_word]->arg); ospf6_interface_connected_route_update (oi->interface); @@ -1748,6 +1760,7 @@ DEFUN (ipv6_ospf6_network, "Specify OSPF6 point-to-point network\n" ) { + int idx_network = 3; struct ospf6_interface *oi; struct interface *ifp; @@ -1760,14 +1773,14 @@ DEFUN (ipv6_ospf6_network, } assert (oi); - if (strncmp (argv[3]->arg, "b", 1) == 0) + if (strncmp (argv[idx_network]->arg, "b", 1) == 0) { if (oi->type == OSPF_IFTYPE_BROADCAST) return CMD_SUCCESS; oi->type = OSPF_IFTYPE_BROADCAST; } - else if (strncmp (argv[3]->arg, "point-to-p", 10) == 0) + else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0) { if (oi->type == OSPF_IFTYPE_POINTOPOINT) { return CMD_SUCCESS; @@ -1977,6 +1990,7 @@ DEFUN (clear_ipv6_ospf6_interface, IFNAME_STR ) { + int idx_ifname = 4; struct interface *ifp; struct listnode *node; @@ -1987,9 +2001,9 @@ DEFUN (clear_ipv6_ospf6_interface, } else /* Interface name is specified. */ { - if ((ifp = if_lookup_by_name (argv[4]->arg)) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg)) == NULL) { - vty_out (vty, "No such Interface: %s%s", argv[4]->arg, VNL); + vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL); return CMD_WARNING; } ospf6_interface_clear (vty, ifp); diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 6ed46f5cd..586bd77f7 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1730,8 +1730,9 @@ DEFUN (debug_ospf6_brouter_router, "Specify border-router's router-id\n" ) { + int idx_ipv4 = 4; u_int32_t router_id; - inet_pton (AF_INET, argv[4]->arg, &router_id); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id); OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON (router_id); return CMD_SUCCESS; } @@ -1760,8 +1761,9 @@ DEFUN (debug_ospf6_brouter_area, "Specify Area-ID\n" ) { + int idx_ipv4 = 4; u_int32_t area_id; - inet_pton (AF_INET, argv[4]->arg, &area_id); + inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id); OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON (area_id); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index db34214e1..a70e450f6 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -835,6 +835,7 @@ DEFUN (debug_ospf6_lsa_type, "Specify LS type as Hexadecimal\n" ) { + int idx_lsa = 3; unsigned int i; struct ospf6_lsa_handler *handler = NULL; @@ -845,9 +846,9 @@ DEFUN (debug_ospf6_lsa_type, handler = vector_slot (ospf6_lsa_handler_vector, i); if (handler == NULL) continue; - if (strncmp (argv[3]->arg, ospf6_lsa_handler_name(handler), strlen(argv[3]->arg)) == 0) + if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0) break; - if (! strcasecmp (argv[3]->arg, handler->name)) + if (! strcasecmp (argv[idx_lsa]->arg, handler->name)) break; handler = NULL; } @@ -892,6 +893,7 @@ DEFUN (no_debug_ospf6_lsa_type, "Specify LS type as Hexadecimal\n" ) { + int idx_lsa = 4; u_int i; struct ospf6_lsa_handler *handler = NULL; @@ -902,9 +904,9 @@ DEFUN (no_debug_ospf6_lsa_type, handler = vector_slot (ospf6_lsa_handler_vector, i); if (handler == NULL) continue; - if (strncmp (argv[4]->arg, ospf6_lsa_handler_name(handler), strlen(argv[4]->arg)) == 0) + if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0) break; - if (! strcasecmp (argv[4]->arg, handler->name)) + if (! strcasecmp (argv[idx_lsa]->arg, handler->name)) break; } diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index b2dd6b6ce..2cedc59ee 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -2371,6 +2371,7 @@ DEFUN (debug_ospf6_message, "Debug All message\n" ) { + int idx_packet = 3; unsigned char level = 0; int type = 0; int i; @@ -2378,19 +2379,19 @@ DEFUN (debug_ospf6_message, assert (argc > 0); /* check type */ - if (! strncmp (argv[3]->arg, "u", 1)) + if (! strncmp (argv[idx_packet]->arg, "u", 1)) type = OSPF6_MESSAGE_TYPE_UNKNOWN; - else if (! strncmp (argv[3]->arg, "h", 1)) + else if (! strncmp (argv[idx_packet]->arg, "h", 1)) type = OSPF6_MESSAGE_TYPE_HELLO; - else if (! strncmp (argv[3]->arg, "d", 1)) + else if (! strncmp (argv[idx_packet]->arg, "d", 1)) type = OSPF6_MESSAGE_TYPE_DBDESC; - else if (! strncmp (argv[3]->arg, "lsr", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsr", 3)) type = OSPF6_MESSAGE_TYPE_LSREQ; - else if (! strncmp (argv[3]->arg, "lsu", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsu", 3)) type = OSPF6_MESSAGE_TYPE_LSUPDATE; - else if (! strncmp (argv[3]->arg, "lsa", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsa", 3)) type = OSPF6_MESSAGE_TYPE_LSACK; - else if (! strncmp (argv[3]->arg, "a", 1)) + else if (! strncmp (argv[idx_packet]->arg, "a", 1)) type = OSPF6_MESSAGE_TYPE_ALL; if (argc == 1) @@ -2449,6 +2450,7 @@ DEFUN (no_debug_ospf6_message, "Debug All message\n" ) { + int idx_packet = 4; unsigned char level = 0; int type = 0; int i; @@ -2456,19 +2458,19 @@ DEFUN (no_debug_ospf6_message, assert (argc > 0); /* check type */ - if (! strncmp (argv[4]->arg, "u", 1)) + if (! strncmp (argv[idx_packet]->arg, "u", 1)) type = OSPF6_MESSAGE_TYPE_UNKNOWN; - else if (! strncmp (argv[4]->arg, "h", 1)) + else if (! strncmp (argv[idx_packet]->arg, "h", 1)) type = OSPF6_MESSAGE_TYPE_HELLO; - else if (! strncmp (argv[4]->arg, "d", 1)) + else if (! strncmp (argv[idx_packet]->arg, "d", 1)) type = OSPF6_MESSAGE_TYPE_DBDESC; - else if (! strncmp (argv[4]->arg, "lsr", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsr", 3)) type = OSPF6_MESSAGE_TYPE_LSREQ; - else if (! strncmp (argv[4]->arg, "lsu", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsu", 3)) type = OSPF6_MESSAGE_TYPE_LSUPDATE; - else if (! strncmp (argv[4]->arg, "lsa", 3)) + else if (! strncmp (argv[idx_packet]->arg, "lsa", 3)) type = OSPF6_MESSAGE_TYPE_LSACK; - else if (! strncmp (argv[4]->arg, "a", 1)) + else if (! strncmp (argv[idx_packet]->arg, "a", 1)) type = OSPF6_MESSAGE_TYPE_ALL; if (argc == 1) diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index fbf0efed8..76c3862ec 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -893,6 +893,7 @@ DEFUN (show_ipv6_ospf6_neighbor_one, "Specify Router-ID as IPv4 address notation\n" ) { + int idx_ipv4 = 4; struct ospf6_neighbor *on; struct ospf6_interface *oi; struct ospf6_area *oa; @@ -903,9 +904,9 @@ DEFUN (show_ipv6_ospf6_neighbor_one, OSPF6_CMD_CHECK_RUNNING (); showfunc = ospf6_neighbor_show_detail; - if ((inet_pton (AF_INET, argv[4]->arg, &router_id)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) { - vty_out (vty, "Router-ID is not parsable: %s%s", argv[4]->arg, + vty_out (vty, "Router-ID is not parsable: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 8cf819695..bc4c951f1 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -1573,15 +1573,16 @@ DEFUN (debug_ospf6_route, "Debug route memory use\n" ) { + int idx_type = 3; unsigned char level = 0; - if (! strncmp (argv[3]->arg, "table", 5)) + if (! strncmp (argv[idx_type]->arg, "table", 5)) level = OSPF6_DEBUG_ROUTE_TABLE; - else if (! strncmp (argv[3]->arg, "intra", 5)) + else if (! strncmp (argv[idx_type]->arg, "intra", 5)) level = OSPF6_DEBUG_ROUTE_INTRA; - else if (! strncmp (argv[3]->arg, "inter", 5)) + else if (! strncmp (argv[idx_type]->arg, "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; - else if (! strncmp (argv[3]->arg, "memor", 5)) + else if (! strncmp (argv[idx_type]->arg, "memor", 5)) level = OSPF6_DEBUG_ROUTE_MEMORY; OSPF6_DEBUG_ROUTE_ON (level); return CMD_SUCCESS; @@ -1597,15 +1598,16 @@ DEFUN (no_debug_ospf6_route, "Debug intra-area route calculation\n" "Debug route memory use\n") { + int idx_type = 4; unsigned char level = 0; - if (! strncmp (argv[4]->arg, "table", 5)) + if (! strncmp (argv[idx_type]->arg, "table", 5)) level = OSPF6_DEBUG_ROUTE_TABLE; - else if (! strncmp (argv[4]->arg, "intra", 5)) + else if (! strncmp (argv[idx_type]->arg, "intra", 5)) level = OSPF6_DEBUG_ROUTE_INTRA; - else if (! strncmp (argv[4]->arg, "inter", 5)) + else if (! strncmp (argv[idx_type]->arg, "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; - else if (! strncmp (argv[4]->arg, "memor", 5)) + else if (! strncmp (argv[idx_type]->arg, "memor", 5)) level = OSPF6_DEBUG_ROUTE_MEMORY; OSPF6_DEBUG_ROUTE_OFF (level); return CMD_SUCCESS; diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 80fb90416..3aa653814 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -885,6 +885,9 @@ DEFUN (ospf6_timers_throttle_spf, "Initial hold time (msec) between consecutive SPF calculations\n" "Maximum hold time (msec)\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; unsigned int delay, hold, max; if (argc != 3) @@ -893,9 +896,9 @@ DEFUN (ospf6_timers_throttle_spf, return CMD_WARNING; } - VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[3]->arg, 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[4]->arg, 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[5]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000); return ospf6_timers_spf_set (vty, delay, hold, max); } diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 9c51b4ee7..5fef06d7c 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -324,16 +324,17 @@ DEFUN (ospf6_router_id, "Configure OSPF Router-ID\n" V4NOTATION_STR) { + int idx_ipv4 = 1; int ret; u_int32_t router_id; struct ospf6 *o; o = (struct ospf6 *) vty->index; - ret = inet_pton (AF_INET, argv[1]->arg, &router_id); + ret = inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id); if (ret == 0) { - vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[1]->arg, VNL); + vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -404,6 +405,7 @@ DEFUN (ospf6_timers_lsa, "Minimum delay in receiving new version of a LSA\n" "Delay in milliseconds\n") { + int idx_number = 3; unsigned int minarrival; struct ospf6 *ospf = vty->index; @@ -416,7 +418,7 @@ DEFUN (ospf6_timers_lsa, return CMD_WARNING; } - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[3]->arg); + VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); ospf->lsa_minarrival = minarrival; @@ -471,6 +473,8 @@ DEFUN (ospf6_interface_area, "OSPF6 area ID in IPv4 address notation\n" ) { + int idx_ifname = 1; + int idx_ipv4 = 3; struct ospf6 *o; struct ospf6_area *oa; struct ospf6_interface *oi; @@ -480,7 +484,7 @@ DEFUN (ospf6_interface_area, o = (struct ospf6 *) vty->index; /* find/create ospf6 interface */ - ifp = if_get_by_name (argv[1]->arg); + ifp = if_get_by_name (argv[idx_ifname]->arg); oi = (struct ospf6_interface *) ifp->info; if (oi == NULL) oi = ospf6_interface_create (ifp); @@ -492,9 +496,9 @@ DEFUN (ospf6_interface_area, } /* parse Area-ID */ - if (inet_pton (AF_INET, argv[3]->arg, &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Invalid Area-ID: %s%s", argv[3]->arg, VNL); + vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -533,15 +537,17 @@ DEFUN (no_ospf6_interface_area, "OSPF6 area ID in IPv4 address notation\n" ) { + int idx_ifname = 2; + int idx_ipv4 = 4; struct ospf6_interface *oi; struct ospf6_area *oa; struct interface *ifp; u_int32_t area_id; - ifp = if_lookup_by_name (argv[2]->arg); + ifp = if_lookup_by_name (argv[idx_ifname]->arg); if (ifp == NULL) { - vty_out (vty, "No such interface %s%s", argv[2]->arg, VNL); + vty_out (vty, "No such interface %s%s", argv[idx_ifname]->arg, VNL); return CMD_SUCCESS; } @@ -553,16 +559,16 @@ DEFUN (no_ospf6_interface_area, } /* parse Area-ID */ - if (inet_pton (AF_INET, argv[4]->arg, &area_id) != 1) + if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1) { - vty_out (vty, "Invalid Area-ID: %s%s", argv[4]->arg, VNL); + vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } /* Verify Area */ if (oi->area == NULL) { - vty_out (vty, "No such Area-ID: %s%s", argv[4]->arg, VNL); + vty_out (vty, "No such Area-ID: %s%s", argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 10b6b27a8..6599fbc6c 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -726,13 +726,14 @@ DEFUN (debug_ospf6_zebra_sendrecv, "Debug Receiving zebra\n" ) { + int idx_send_recv = 3; unsigned char level = 0; if (argc) { - if (! strncmp (argv[3]->arg, "s", 1)) + if (! strncmp (argv[idx_send_recv]->arg, "s", 1)) level = OSPF6_DEBUG_ZEBRA_SEND; - else if (! strncmp (argv[3]->arg, "r", 1)) + else if (! strncmp (argv[idx_send_recv]->arg, "r", 1)) level = OSPF6_DEBUG_ZEBRA_RECV; } else @@ -765,13 +766,14 @@ DEFUN (no_debug_ospf6_zebra_sendrecv, "Debug Receiving zebra\n" ) { + int idx_send_recv = 4; unsigned char level = 0; if (argc) { - if (! strncmp (argv[4]->arg, "s", 1)) + if (! strncmp (argv[idx_send_recv]->arg, "s", 1)) level = OSPF6_DEBUG_ZEBRA_SEND; - else if (! strncmp (argv[4]->arg, "r", 1)) + else if (! strncmp (argv[idx_send_recv]->arg, "r", 1)) level = OSPF6_DEBUG_ZEBRA_RECV; } else diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 907cd118a..c72dde0ac 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -364,6 +364,7 @@ DEFUN (show_ipv6_ospf6_database_id, "Specify Link state ID as IPv4 address notation\n" ) { + int idx_ipv4 = 5; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -373,10 +374,10 @@ DEFUN (show_ipv6_ospf6_database_id, OSPF6_CMD_CHECK_RUNNING (); - if ((inet_pton (AF_INET, argv[5]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &id)) != 1) { vty_out (vty, "Link State ID is not parsable: %s%s", - argv[5]->arg, VNL); + argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -461,6 +462,7 @@ DEFUN (show_ipv6_ospf6_database_router, "Specify Advertising Router as IPv4 address notation\n" ) { + int idx_ipv4 = 6; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -470,10 +472,10 @@ DEFUN (show_ipv6_ospf6_database_router, OSPF6_CMD_CHECK_RUNNING (); - if ((inet_pton (AF_INET, argv[6]->arg, &adv_router)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router)) != 1) { vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[6]->arg, VNL); + argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -596,6 +598,7 @@ DEFUN (show_ipv6_ospf6_database_type_id, "Specify Link state ID as IPv4 address notation\n" ) { + int idx_lsa = 4; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -610,10 +613,10 @@ DEFUN (show_ipv6_ospf6_database_type_id, argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1) { vty_out (vty, "Link state ID is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } @@ -751,6 +754,7 @@ DEFUN (show_ipv6_ospf6_database_type_router, "Specify Advertising Router as IPv4 address notation\n" ) { + int idx_lsa = 4; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -765,10 +769,10 @@ DEFUN (show_ipv6_ospf6_database_type_router, argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &adv_router)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &adv_router)) != 1) { vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } @@ -844,6 +848,7 @@ DEFUN (show_ipv6_ospf6_database_id_router, "Specify Advertising Router as IPv4 address notation\n" ) { + int idx_ipv4 = 5; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -854,20 +859,20 @@ DEFUN (show_ipv6_ospf6_database_id_router, OSPF6_CMD_CHECK_RUNNING (); - if ((inet_pton (AF_INET, argv[5]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &id)) != 1) { vty_out (vty, "Link state ID is not parsable: %s%s", - argv[5]->arg, VNL); + argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } argc--; argv++; - if ((inet_pton (AF_INET, argv[5]->arg, &adv_router)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router)) != 1) { vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[5]->arg, VNL); + argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -930,6 +935,7 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, "Specify Link state ID as IPv4 address notation\n" ) { + int idx_ipv4 = 5; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -940,20 +946,20 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id, OSPF6_CMD_CHECK_RUNNING (); - if ((inet_pton (AF_INET, argv[5]->arg, &adv_router)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &adv_router)) != 1) { vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[5]->arg, VNL); + argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } argc--; argv++; - if ((inet_pton (AF_INET, argv[5]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &id)) != 1) { vty_out (vty, "Link state ID is not parsable: %s%s", - argv[5]->arg, VNL); + argv[idx_ipv4]->arg, VNL); return CMD_SUCCESS; } @@ -1031,6 +1037,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, "Specify Advertising Router as IPv4 address notation\n" ) { + int idx_lsa = 4; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1046,20 +1053,20 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1) { vty_out (vty, "Link state ID is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &adv_router)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &adv_router)) != 1) { vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } @@ -1155,6 +1162,7 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, "Specify Link state ID as IPv4 address notation\n" ) { + int idx_lsa = 4; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1170,20 +1178,20 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id, argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &adv_router)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &adv_router)) != 1) { vty_out (vty, "Advertising Router is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1) { vty_out (vty, "Link state ID is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } @@ -1436,6 +1444,7 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, "Specify Link state ID as IPv4 address notation\n" ) { + int idx_lsa = 4; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1451,10 +1460,10 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id, argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1) { vty_out (vty, "Link State ID is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } @@ -1549,6 +1558,7 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, "Display Self-originated LSAs\n" ) { + int idx_lsa = 4; int level; struct listnode *i, *j; struct ospf6 *o = ospf6; @@ -1564,10 +1574,10 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated, argc--; argv++; - if ((inet_pton (AF_INET, argv[4]->arg, &id)) != 1) + if ((inet_pton (AF_INET, argv[idx_lsa]->arg, &id)) != 1) { vty_out (vty, "Link State ID is not parsable: %s%s", - argv[4]->arg, VNL); + argv[idx_lsa]->arg, VNL); return CMD_SUCCESS; } diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c index 2689cecc4..d8fefab9c 100644 --- a/ospfd/ospf_bfd.c +++ b/ospfd/ospf_bfd.c @@ -387,6 +387,9 @@ DEFUN (ip_ospf_bfd_param, "Required min receive interval\n" "Desired min transmit interval\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; struct interface *ifp = (struct interface *) vty->index; u_int32_t rx_val; u_int32_t tx_val; @@ -395,7 +398,7 @@ DEFUN (ip_ospf_bfd_param, assert (ifp); - if ((ret = bfd_validate_param (vty, argv[3]->arg, argv[4]->arg, argv[5]->arg, &dm_val, + if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val, &rx_val, &tx_val)) != CMD_SUCCESS) return ret; diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 5c5e5ceb5..9952513dc 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -910,9 +910,10 @@ DEFUN (debug_ospf_instance_packet, "OSPF Link State Acknowledgment\n" "OSPF all packets\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1086,9 +1087,10 @@ DEFUN (no_debug_ospf_instance_packet, "OSPF Link State Acknowledgment\n" "OSPF all packets\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1176,9 +1178,10 @@ DEFUN (debug_ospf_instance_ism, "Instance ID\n" "OSPF Interface State Machine\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1268,9 +1271,10 @@ DEFUN (no_debug_ospf_instance_ism, "Instance ID\n" "OSPF Interface State Machine") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1356,9 +1360,10 @@ DEFUN (debug_ospf_instance_nsm, "Instance ID\n" "OSPF Neighbor State Machine\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1448,9 +1453,10 @@ DEFUN (no_debug_ospf_instance_nsm, "Instance ID\n" "OSPF Neighbor State Machine") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1543,9 +1549,10 @@ DEFUN (debug_ospf_instance_lsa, "Instance ID\n" "OSPF Link State Advertisement\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1641,9 +1648,10 @@ DEFUN (no_debug_ospf_instance_lsa, "Instance ID\n" "OSPF Link State Advertisement\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1724,9 +1732,10 @@ DEFUN (debug_ospf_instance_zebra, "Instance ID\n" "OSPF Zebra information\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1811,9 +1820,10 @@ DEFUN (no_debug_ospf_instance_zebra, "Instance ID\n" "OSPF Zebra information\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1857,9 +1867,10 @@ DEFUN (debug_ospf_instance_event, "Instance ID\n" "OSPF event information\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1878,9 +1889,10 @@ DEFUN (no_debug_ospf_instance_event, "Instance ID\n" "OSPF event information\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1925,9 +1937,10 @@ DEFUN (debug_ospf_instance_nssa, "Instance ID\n" "OSPF nssa information\n") { + int idx_number = 2; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -1946,9 +1959,10 @@ DEFUN (no_debug_ospf_instance_nssa, "Instance ID\n" "OSPF nssa information\n") { + int idx_number = 3; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if (!ospf_lookup_instance (instance)) return CMD_SUCCESS; @@ -2166,10 +2180,11 @@ DEFUN (show_debugging_ospf_instance, OSPF_STR "Instance ID\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL ) return CMD_SUCCESS; diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index b70433b87..d3875e373 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -1188,6 +1188,7 @@ DEFUN (router_info, "Enable the Router Information functionality with Area flooding scope\n" "OSPF area ID in IP format") { + int idx_ipv4 = 2; u_int8_t scope; @@ -1197,7 +1198,7 @@ DEFUN (router_info, /* Check and get Area value if present */ if (argc == 1) { - if (!inet_aton (argv[2]->arg, &OspfRI.area_id)) + if (!inet_aton (argv[idx_ipv4]->arg, &OspfRI.area_id)) { vty_out (vty, "Please specify Router Info Area by A.B.C.D%s", VTY_NEWLINE); @@ -1275,10 +1276,11 @@ DEFUN (pce_address, "Stable IP address of the PCE\n" "PCE address in IPv4 address format\n") { + int idx_ipv4 = 2; struct in_addr value; struct ospf_pce_info *pi = &OspfRI.pce_info; - if (!inet_aton (argv[2]->arg, &value)) + if (!inet_aton (argv[idx_ipv4]->arg, &value)) { vty_out (vty, "Please specify PCE Address by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; @@ -1322,10 +1324,11 @@ DEFUN (pce_path_scope, "Path scope visibilities of the PCE for path computation\n" "32-bit Hexadecimal value\n") { + int idx_bitpattern = 2; uint32_t scope; struct ospf_pce_info *pi = &OspfRI.pce_info; - if (sscanf (argv[2]->arg, "0x%x", &scope) != 1) + if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &scope) != 1) { vty_out (vty, "pce_path_scope: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1369,13 +1372,14 @@ DEFUN (pce_domain, "AS number where the PCE as visibilities for path computation\n" "AS number in decimal <0-65535>\n") { + int idx_number = 3; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; struct listnode *node; struct ri_pce_subtlv_domain *domain; - if (sscanf (argv[3]->arg, "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "pce_domain: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1408,11 +1412,12 @@ DEFUN (no_pce_domain, "AS number where the PCE as visibilities for path computation\n" "AS number in decimal <0-65535>\n") { + int idx_number = 4; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; - if (sscanf (argv[4]->arg, "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "no_pce_domain: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1437,13 +1442,14 @@ DEFUN (pce_neigbhor, "AS number of PCE neighbors\n" "AS number in decimal <0-65535>\n") { + int idx_number = 3; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; struct listnode *node; struct ri_pce_subtlv_neighbor *neighbor; - if (sscanf (argv[3]->arg, "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "pce_neighbor: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1476,11 +1482,12 @@ DEFUN (no_pce_neighbor, "AS number of PCE neighbor\n" "AS number in decimal <0-65535>\n") { + int idx_number = 4; uint32_t as; struct ospf_pce_info *pce = &OspfRI.pce_info; - if (sscanf (argv[4]->arg, "%d", &as) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &as) != 1) { vty_out (vty, "no_pce_neighbor: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1504,11 +1511,12 @@ DEFUN (pce_cap_flag, "Capabilities of the PCE for path computation\n" "32-bit Hexadecimal value\n") { + int idx_bitpattern = 2; uint32_t cap; struct ospf_pce_info *pce = &OspfRI.pce_info; - if (sscanf (argv[2]->arg, "0x%x", &cap) != 1) + if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &cap) != 1) { vty_out (vty, "pce_cap_flag: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c index f1fc484e3..e2a5f53fa 100644 --- a/ospfd/ospf_routemap.c +++ b/ospfd/ospf_routemap.c @@ -700,7 +700,8 @@ DEFUN (match_ip_nexthop, "IP access-list number (expanded range)\n" "IP access-list name\n") { - return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg); + int idx_acl = 3; + return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg); } /* @@ -736,8 +737,9 @@ DEFUN (match_ip_next_hop_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return ospf_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[4]->arg); + argv[idx_word]->arg); } /* @@ -775,7 +777,8 @@ DEFUN (match_ip_address, "IP access-list number (expanded range)\n" "IP access-list name\n") { - return ospf_route_match_add (vty, vty->index, "ip address", argv[3]->arg); + int idx_acl = 3; + return ospf_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg); } /* @@ -811,8 +814,9 @@ DEFUN (match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return ospf_route_match_add (vty, vty->index, "ip address prefix-list", - argv[4]->arg); + argv[idx_word]->arg); } /* @@ -847,7 +851,8 @@ DEFUN (match_interface, "Match first hop interface of route\n" "Interface name\n") { - return ospf_route_match_add (vty, vty->index, "interface", argv[2]->arg); + int idx_word = 2; + return ospf_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg); } /* @@ -877,7 +882,8 @@ DEFUN (match_tag, "Match tag of route\n" "Tag value\n") { - return ospf_route_match_add (vty, vty->index, "tag", argv[2]->arg); + int idx_number = 2; + return ospf_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg); } /* @@ -907,7 +913,8 @@ DEFUN (set_metric, "Metric value for destination routing protocol\n" "Metric value\n") { - return ospf_route_set_add (vty, vty->index, "metric", argv[2]->arg); + int idx_number = 2; + return ospf_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg); } /* @@ -938,12 +945,13 @@ DEFUN (set_metric_type, "OSPF[6] external type 1 metric\n" "OSPF[6] external type 2 metric\n") { - if (strcmp (argv[2]->arg, "1") == 0) + int idx_external = 2; + if (strcmp (argv[idx_external]->arg, "1") == 0) return ospf_route_set_add (vty, vty->index, "metric-type", "type-1"); - if (strcmp (argv[2]->arg, "2") == 0) + if (strcmp (argv[idx_external]->arg, "2") == 0) return ospf_route_set_add (vty, vty->index, "metric-type", "type-2"); - return ospf_route_set_add (vty, vty->index, "metric-type", argv[2]->arg); + return ospf_route_set_add (vty, vty->index, "metric-type", argv[idx_external]->arg); } /* @@ -974,7 +982,8 @@ DEFUN (set_tag, "Tag value for routing protocol\n" "Tag value\n") { - return ospf_route_set_add (vty, vty->index, "tag", argv[2]->arg); + int idx_number = 2; + return ospf_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); } /* diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index c90a5b2c4..7994bddca 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -2341,6 +2341,7 @@ DEFUN (ospf_mpls_te_router_addr, "Stable IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n") { + int idx_ipv4 = 2; struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr; struct in_addr value; struct ospf *ospf = vty->index; @@ -2348,7 +2349,7 @@ DEFUN (ospf_mpls_te_router_addr, if (!ospf) return CMD_SUCCESS; - if (! inet_aton (argv[2]->arg, &value)) + if (! inet_aton (argv[idx_ipv4]->arg, &value)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; @@ -2482,7 +2483,8 @@ DEFUN (ospf_mpls_te_inter_as_area, "OSPF area ID in IP format\n" "OSPF area ID as decimal value\n") { - return set_inter_as_mode (vty, "area", argv[3]->arg); + int idx_ipv4_number = 3; + return set_inter_as_mode (vty, "area", argv[idx_ipv4_number]->arg); } DEFUN (no_ospf_mpls_te_inter_as, @@ -2626,6 +2628,7 @@ DEFUN (show_ip_ospf_mpls_te_link, "Interface information\n" "Interface name\n") { + int idx_interface = 5; struct interface *ifp; struct listnode *node, *nnode; @@ -2638,7 +2641,7 @@ DEFUN (show_ip_ospf_mpls_te_link, /* Interface name is specified. */ else { - if ((ifp = if_lookup_by_name (argv[5]->arg)) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else show_mpls_te_link_sub (vty, ifp); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 8d0fb1d5d..b3019b465 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -228,6 +228,7 @@ DEFUN (ospf_router_id, "router-id for the OSPF process\n" "OSPF router-id in IP address format\n") { + int idx_ipv4 = 2; struct ospf *ospf = vty->index; struct listnode *node; struct ospf_area *area; @@ -237,7 +238,7 @@ DEFUN (ospf_router_id, if (!ospf) return CMD_SUCCESS; - ret = inet_aton (argv[2]->arg, &router_id); + ret = inet_aton (argv[idx_ipv4]->arg, &router_id); if (!ret) { vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); @@ -384,6 +385,7 @@ DEFUN (ospf_passive_interface, "Suppress routing updates on an interface\n" "Interface's name\n") { + int idx_ipv4 = 2; struct interface *ifp; struct in_addr addr = { .s_addr = INADDR_ANY }; int ret; @@ -400,7 +402,7 @@ DEFUN (ospf_passive_interface, return CMD_SUCCESS; } - ifp = if_get_by_name (argv[2]->arg); + ifp = if_get_by_name (argv[idx_ipv4]->arg); params = IF_DEF_PARAMS (ifp); @@ -469,6 +471,7 @@ DEFUN (no_ospf_passive_interface, "Allow routing updates on an interface\n" "Interface's name\n") { + int idx_ipv4 = 3; struct interface *ifp; struct in_addr addr = { .s_addr = INADDR_ANY }; struct ospf_if_params *params; @@ -485,7 +488,7 @@ DEFUN (no_ospf_passive_interface, return CMD_SUCCESS; } - ifp = if_get_by_name (argv[3]->arg); + ifp = if_get_by_name (argv[idx_ipv4]->arg); params = IF_DEF_PARAMS (ifp); @@ -536,6 +539,8 @@ DEFUN (ospf_network_area, "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { + int idx_ipv4_prefixlen = 1; + int idx_ipv4_number = 3; struct ospf *ospf= vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -559,8 +564,8 @@ DEFUN (ospf_network_area, } /* Get network prefix and Area ID. */ - VTY_GET_IPV4_PREFIX ("network prefix", p, argv[1]->arg); - VTY_GET_OSPF_AREA_ID (area_id, format, argv[3]->arg); + VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_network_set (ospf, &p, area_id); if (ret == 0) @@ -582,6 +587,8 @@ DEFUN (no_ospf_network_area, "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { + int idx_ipv4_prefixlen = 2; + int idx_ipv4_number = 4; struct ospf *ospf = (struct ospf *) vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -598,8 +605,8 @@ DEFUN (no_ospf_network_area, } /* Get network prefix and Area ID. */ - VTY_GET_IPV4_PREFIX ("network prefix", p, argv[2]->arg); - VTY_GET_OSPF_AREA_ID (area_id, format, argv[4]->arg); + VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_network_unset (ospf, &p, area_id); if (ret == 0) @@ -652,6 +659,8 @@ DEFUN (ospf_area_range, "Summarize routes matching address/mask (border routers only)\n" "Area range prefix\n") { + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -661,8 +670,8 @@ DEFUN (ospf_area_range, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); - VTY_GET_IPV4_PREFIX ("area range", p, argv[3]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); if (argc > 2) @@ -687,6 +696,8 @@ DEFUN (ospf_area_range_not_advertise, "Area range prefix\n" "DoNotAdvertise this range\n") { + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -695,8 +706,8 @@ DEFUN (ospf_area_range_not_advertise, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); - VTY_GET_IPV4_PREFIX ("area range", p, argv[3]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); ospf_area_range_set (ospf, area_id, &p, 0); @@ -747,6 +758,8 @@ DEFUN (no_ospf_area_range, "Summarize routes matching address/mask (border routers only)\n" "Area range prefix\n") { + int idx_ipv4_number = 2; + int idx_ipv4_prefixlen = 4; struct ospf *ospf = vty->index; struct prefix_ipv4 p; struct in_addr area_id; @@ -755,8 +768,8 @@ DEFUN (no_ospf_area_range, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); - VTY_GET_IPV4_PREFIX ("area range", p, argv[4]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); ospf_area_range_unset (ospf, area_id, &p); @@ -777,6 +790,9 @@ DEFUN (ospf_area_range_substitute, "Announce area range as another prefix\n" "Network prefix to be announced instead of range\n") { + int idx_ipv4_number = 1; + int idx_ipv4_prefixlen = 3; + int idx_ipv4_prefixlen_2 = 5; struct ospf *ospf = vty->index; struct prefix_ipv4 p, s; struct in_addr area_id; @@ -785,9 +801,9 @@ DEFUN (ospf_area_range_substitute, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); - VTY_GET_IPV4_PREFIX ("area range", p, argv[3]->arg); - VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[5]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); ospf_area_range_substitute_set (ospf, area_id, &p, &s); @@ -806,6 +822,9 @@ DEFUN (no_ospf_area_range_substitute, "Announce area range as another prefix\n" "Network prefix to be announced instead of range\n") { + int idx_ipv4_number = 2; + int idx_ipv4_prefixlen = 4; + int idx_ipv4_prefixlen_2 = 6; struct ospf *ospf = vty->index; struct prefix_ipv4 p, s; struct in_addr area_id; @@ -814,9 +833,9 @@ DEFUN (no_ospf_area_range_substitute, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); - VTY_GET_IPV4_PREFIX ("area range", p, argv[4]->arg); - VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[6]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); + VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); ospf_area_range_substitute_unset (ospf, area_id, &p); @@ -1165,6 +1184,8 @@ DEFUN (ospf_area_vlink, "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D", VLINK_HELPSTR_IPADDR) { + int idx_ipv4_number = 1; + int idx_ipv4 = 3; struct ospf *ospf = vty->index; struct ospf_vl_config_data vl_config; char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; @@ -1178,14 +1199,14 @@ DEFUN (ospf_area_vlink, ospf_vl_config_data_init(&vl_config, vty); /* Read off first 2 parameters and check them */ - ret = ospf_str2area_id (argv[1]->arg, &vl_config.area_id, &vl_config.format); + ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &vl_config.format); if (ret < 0) { vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); return CMD_WARNING; } - ret = inet_aton (argv[3]->arg, &vl_config.vl_peer); + ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); if (! ret) { vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", @@ -1398,6 +1419,8 @@ DEFUN (no_ospf_area_vlink, NO_STR VLINK_HELPSTR_IPADDR) { + int idx_ipv4_number = 2; + int idx_ipv4 = 4; struct ospf *ospf = vty->index; struct ospf_area *area; struct ospf_vl_config_data vl_config; @@ -1411,7 +1434,7 @@ DEFUN (no_ospf_area_vlink, ospf_vl_config_data_init(&vl_config, vty); - ret = ospf_str2area_id (argv[2]->arg, &vl_config.area_id, &format); + ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format); if (ret < 0) { vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); @@ -1425,7 +1448,7 @@ DEFUN (no_ospf_area_vlink, return CMD_WARNING; } - ret = inet_aton (argv[4]->arg, &vl_config.vl_peer); + ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); if (! ret) { vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", @@ -1547,6 +1570,8 @@ DEFUN (ospf_area_shortcut, "Enable shortcutting through the area\n" "Disable shortcutting through the area\n") { + int idx_ipv4_number = 1; + int idx_enable_disable = 3; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1556,15 +1581,15 @@ DEFUN (ospf_area_shortcut, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - if (strncmp (argv[3]->arg, "de", 2) == 0) + if (strncmp (argv[idx_enable_disable]->arg, "de", 2) == 0) mode = OSPF_SHORTCUT_DEFAULT; - else if (strncmp (argv[3]->arg, "di", 2) == 0) + else if (strncmp (argv[idx_enable_disable]->arg, "di", 2) == 0) mode = OSPF_SHORTCUT_DISABLE; - else if (strncmp (argv[3]->arg, "e", 1) == 0) + else if (strncmp (argv[idx_enable_disable]->arg, "e", 1) == 0) mode = OSPF_SHORTCUT_ENABLE; else return CMD_WARNING; @@ -1590,6 +1615,7 @@ DEFUN (no_ospf_area_shortcut, "Deconfigure enabled shortcutting through the area\n" "Deconfigure disabled shortcutting through the area\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1598,7 +1624,7 @@ DEFUN (no_ospf_area_shortcut, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (!area) @@ -1618,6 +1644,7 @@ DEFUN (ospf_area_stub, "OSPF area ID as a decimal value\n" "Configure OSPF area as stub\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct in_addr area_id; int ret, format; @@ -1625,7 +1652,7 @@ DEFUN (ospf_area_stub, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_area_stub_set (ospf, area_id); if (ret == 0) @@ -1649,6 +1676,7 @@ DEFUN (ospf_area_stub_no_summary, "Configure OSPF area as stub\n" "Do not inject inter-area routes into stub\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct in_addr area_id; int ret, format; @@ -1656,7 +1684,7 @@ DEFUN (ospf_area_stub_no_summary, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ret = ospf_area_stub_set (ospf, area_id); if (ret == 0) @@ -1680,6 +1708,7 @@ DEFUN (no_ospf_area_stub, "OSPF area ID as a decimal value\n" "Configure OSPF area as stub\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct in_addr area_id; int format; @@ -1687,7 +1716,7 @@ DEFUN (no_ospf_area_stub, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_stub_unset (ospf, area_id); ospf_area_no_summary_unset (ospf, area_id); @@ -1705,6 +1734,7 @@ DEFUN (no_ospf_area_stub_no_summary, "Configure OSPF area as stub\n" "Do not inject inter-area routes into area\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct in_addr area_id; int format; @@ -1712,7 +1742,7 @@ DEFUN (no_ospf_area_stub_no_summary, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_no_summary_unset (ospf, area_id); return CMD_SUCCESS; @@ -1842,6 +1872,7 @@ DEFUN (no_ospf_area_nssa, "OSPF area ID as a decimal value\n" "Configure OSPF area as nssa\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct in_addr area_id; int format; @@ -1849,7 +1880,7 @@ DEFUN (no_ospf_area_nssa, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[idx_ipv4_number]->arg); ospf_area_nssa_unset (ospf, area_id); ospf_area_no_summary_unset (ospf, area_id); @@ -1869,6 +1900,8 @@ DEFUN (ospf_area_default_cost, "Set the summary-default cost of a NSSA or stub area\n" "Stub's advertised default summary cost\n") { + int idx_ipv4_number = 1; + int idx_number = 3; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1879,8 +1912,8 @@ DEFUN (ospf_area_default_cost, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[1]->arg); - VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[3]->arg, 0, 16777215); + VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); + VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215); area = ospf_area_get (ospf, area_id, format); @@ -1914,6 +1947,8 @@ DEFUN (no_ospf_area_default_cost, "Set the summary-default cost of a NSSA or stub area\n" "Stub's advertised default summary cost\n") { + int idx_ipv4_number = 2; + int idx_number = 4; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1923,8 +1958,8 @@ DEFUN (no_ospf_area_default_cost, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[2]->arg); - VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[4]->arg, 0, OSPF_LS_INFINITY); + VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); + VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[idx_number]->arg, 0, OSPF_LS_INFINITY); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -1962,6 +1997,7 @@ DEFUN (ospf_area_export_list, "Set the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1970,7 +2006,7 @@ DEFUN (ospf_area_export_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); ospf_area_export_list_set (ospf, area, argv[1]); @@ -1988,6 +2024,7 @@ DEFUN (no_ospf_area_export_list, "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -1996,7 +2033,7 @@ DEFUN (no_ospf_area_export_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -2017,6 +2054,7 @@ DEFUN (ospf_area_import_list, "Set the filter for networks from other areas announced to the specified one\n" "Name of the access-list\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2025,7 +2063,7 @@ DEFUN (ospf_area_import_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); ospf_area_import_list_set (ospf, area, argv[1]); @@ -2043,6 +2081,7 @@ DEFUN (no_ospf_area_import_list, "Unset the filter for networks announced to other areas\n" "Name of the access-list\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2051,7 +2090,7 @@ DEFUN (no_ospf_area_import_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -2074,6 +2113,9 @@ DEFUN (ospf_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4_number = 1; + int idx_word = 4; + int idx_in_out = 5; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2083,17 +2125,17 @@ DEFUN (ospf_area_filter_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); - plist = prefix_list_lookup (AFI_IP, argv[4]->arg); - if (strncmp (argv[5]->arg, "in", 2) == 0) + plist = prefix_list_lookup (AFI_IP, argv[idx_word]->arg); + if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) { PREFIX_LIST_IN (area) = plist; if (PREFIX_NAME_IN (area)) free (PREFIX_NAME_IN (area)); - PREFIX_NAME_IN (area) = strdup (argv[4]->arg); + PREFIX_NAME_IN (area) = strdup (argv[idx_word]->arg); ospf_schedule_abr_task (ospf); } else @@ -2102,7 +2144,7 @@ DEFUN (ospf_area_filter_list, if (PREFIX_NAME_OUT (area)) free (PREFIX_NAME_OUT (area)); - PREFIX_NAME_OUT (area) = strdup (argv[4]->arg); + PREFIX_NAME_OUT (area) = strdup (argv[idx_word]->arg); ospf_schedule_abr_task (ospf); } @@ -2122,6 +2164,9 @@ DEFUN (no_ospf_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { + int idx_ipv4_number = 2; + int idx_word = 5; + int idx_in_out = 6; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2130,15 +2175,15 @@ DEFUN (no_ospf_area_filter_list, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) return CMD_SUCCESS; - if (strncmp (argv[6]->arg, "in", 2) == 0) + if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) { if (PREFIX_NAME_IN (area)) - if (strcmp (PREFIX_NAME_IN (area), argv[5]->arg) != 0) + if (strcmp (PREFIX_NAME_IN (area), argv[idx_word]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_IN (area) = NULL; @@ -2152,7 +2197,7 @@ DEFUN (no_ospf_area_filter_list, else { if (PREFIX_NAME_OUT (area)) - if (strcmp (PREFIX_NAME_OUT (area), argv[5]->arg) != 0) + if (strcmp (PREFIX_NAME_OUT (area), argv[idx_word]->arg) != 0) return CMD_SUCCESS; PREFIX_LIST_OUT (area) = NULL; @@ -2177,6 +2222,7 @@ DEFUN (ospf_area_authentication_message_digest, "Enable authentication\n" "Use message-digest authentication\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2185,7 +2231,7 @@ DEFUN (ospf_area_authentication_message_digest, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; @@ -2201,6 +2247,7 @@ DEFUN (ospf_area_authentication, "OSPF area ID as a decimal value\n" "Enable authentication\n") { + int idx_ipv4_number = 1; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2209,7 +2256,7 @@ DEFUN (ospf_area_authentication, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_get (ospf, area_id, format); area->auth_type = OSPF_AUTH_SIMPLE; @@ -2226,6 +2273,7 @@ DEFUN (no_ospf_area_authentication, "OSPF area ID as a decimal value\n" "Enable authentication\n") { + int idx_ipv4_number = 2; struct ospf *ospf = vty->index; struct ospf_area *area; struct in_addr area_id; @@ -2234,7 +2282,7 @@ DEFUN (no_ospf_area_authentication, if (!ospf) return CMD_SUCCESS; - VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); + VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); area = ospf_area_lookup_by_area_id (ospf, area_id); if (area == NULL) @@ -2258,19 +2306,20 @@ DEFUN (ospf_abr_type, "Shortcut ABR\n" "Standard behavior (RFC2328)\n") { + int idx_vendor = 2; struct ospf *ospf = vty->index; u_char abr_type = OSPF_ABR_UNKNOWN; if (!ospf) return CMD_SUCCESS; - if (strncmp (argv[2]->arg, "c", 1) == 0) + if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) abr_type = OSPF_ABR_CISCO; - else if (strncmp (argv[2]->arg, "i", 1) == 0) + else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) abr_type = OSPF_ABR_IBM; - else if (strncmp (argv[2]->arg, "sh", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) abr_type = OSPF_ABR_SHORTCUT; - else if (strncmp (argv[2]->arg, "st", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) abr_type = OSPF_ABR_STAND; else return CMD_WARNING; @@ -2295,19 +2344,20 @@ DEFUN (no_ospf_abr_type, "Alternative ABR, IBM implementation\n" "Shortcut ABR\n") { + int idx_vendor = 3; struct ospf *ospf = vty->index; u_char abr_type = OSPF_ABR_UNKNOWN; if (!ospf) return CMD_SUCCESS; - if (strncmp (argv[3]->arg, "c", 1) == 0) + if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) abr_type = OSPF_ABR_CISCO; - else if (strncmp (argv[3]->arg, "i", 1) == 0) + else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) abr_type = OSPF_ABR_IBM; - else if (strncmp (argv[3]->arg, "sh", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) abr_type = OSPF_ABR_SHORTCUT; - else if (strncmp (argv[3]->arg, "st", 2) == 0) + else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) abr_type = OSPF_ABR_STAND; else return CMD_WARNING; @@ -2468,6 +2518,7 @@ DEFUN (ospf_timers_min_ls_interval, "All LSA types\n" "Delay (msec) between sending LSAs\n") { + int idx_number = 4; struct ospf *ospf = vty->index; unsigned int interval; @@ -2480,7 +2531,7 @@ DEFUN (ospf_timers_min_ls_interval, return CMD_WARNING; } - VTY_GET_INTEGER ("LSA interval", interval, argv[4]->arg); + VTY_GET_INTEGER ("LSA interval", interval, argv[idx_number]->arg); ospf->min_ls_interval = interval; @@ -2522,6 +2573,7 @@ DEFUN (ospf_timers_min_ls_arrival, "OSPF minimum arrival interval delay\n" "Delay (msec) between accepted LSAs\n") { + int idx_number = 3; struct ospf *ospf = vty->index; unsigned int arrival; @@ -2534,7 +2586,7 @@ DEFUN (ospf_timers_min_ls_arrival, return CMD_WARNING; } - VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[3]->arg, 0, 1000); + VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[idx_number]->arg, 0, 1000); ospf->min_ls_arrival = arrival; @@ -2580,6 +2632,9 @@ DEFUN (ospf_timers_throttle_spf, "Initial hold time (msec) between consecutive SPF calculations\n" "Maximum hold time (msec)\n") { + int idx_number = 3; + int idx_number_2 = 4; + int idx_number_3 = 5; unsigned int delay, hold, max; if (argc != 3) @@ -2588,9 +2643,9 @@ DEFUN (ospf_timers_throttle_spf, return CMD_WARNING; } - VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[3]->arg, 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[4]->arg, 0, 600000); - VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[5]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000); + VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000); return ospf_timers_spf_set (vty, delay, hold, max); } @@ -2630,6 +2685,7 @@ DEFUN (ospf_timers_lsa, "Minimum delay in receiving new version of a LSA\n" "Delay in milliseconds\n") { + int idx_number = 3; unsigned int minarrival; struct ospf *ospf = vty->index; @@ -2642,7 +2698,7 @@ DEFUN (ospf_timers_lsa, return CMD_WARNING; } - VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[3]->arg); + VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); ospf->min_ls_arrival = minarrival; @@ -2712,6 +2768,7 @@ DEFUN (ospf_neighbor, NEIGHBOR_STR "Neighbor IP address\n") { + int idx_ipv4 = 1; struct ospf *ospf = vty->index; struct in_addr nbr_addr; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; @@ -2720,7 +2777,7 @@ DEFUN (ospf_neighbor, if (!ospf) return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[1]->arg); + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); if (argc > 1) VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); @@ -2758,6 +2815,8 @@ DEFUN (ospf_neighbor_poll_interval, "Dead Neighbor Polling interval\n" "Seconds\n") { + int idx_ipv4 = 1; + int idx_number = 3; struct ospf *ospf = vty->index; struct in_addr nbr_addr; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; @@ -2766,10 +2825,10 @@ DEFUN (ospf_neighbor_poll_interval, if (!ospf) return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[1]->arg); + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); if (argc > 1) - VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[3]->arg, 1, 65535); + VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_number]->arg, 1, 65535); if (argc > 2) VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); @@ -2826,13 +2885,14 @@ DEFUN (no_ospf_neighbor, NEIGHBOR_STR "Neighbor IP address\n") { + int idx_ipv4 = 2; struct ospf *ospf = vty->index; struct in_addr nbr_addr; if (!ospf) return CMD_SUCCESS; - VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[2]->arg); + VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); (void)ospf_nbr_nbma_unset (ospf, nbr_addr); @@ -2850,13 +2910,14 @@ DEFUN (ospf_refresh_timer, "Set refresh timer\n" "Timer value in seconds\n") { + int idx_number = 2; struct ospf *ospf = vty->index; unsigned int interval; if (!ospf) return CMD_SUCCESS; - VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[2]->arg, 10, 1800); + VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; ospf_timers_refresh_set (ospf, interval); @@ -2878,6 +2939,7 @@ DEFUN (no_ospf_refresh_timer, "Unset refresh timer\n" "Timer value in seconds\n") { + int idx_number = 3; struct ospf *ospf = vty->index; unsigned int interval; @@ -2886,7 +2948,7 @@ DEFUN (no_ospf_refresh_timer, if (argc == 1) { - VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[3]->arg, 10, 1800); + VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); if (ospf->lsa_refresh_interval != interval || interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) @@ -2906,6 +2968,7 @@ DEFUN (ospf_auto_cost_reference_bandwidth, "Use reference bandwidth method to assign OSPF cost\n" "The reference bandwidth in terms of Mbits per second\n") { + int idx_number = 2; struct ospf *ospf = vty->index; u_int32_t refbw; struct listnode *node; @@ -2914,7 +2977,7 @@ DEFUN (ospf_auto_cost_reference_bandwidth, if (!ospf) return CMD_SUCCESS; - refbw = strtol (argv[2]->arg, NULL, 10); + refbw = strtol (argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); @@ -2983,13 +3046,14 @@ DEFUN (ospf_write_multiplier, "Write multiplier\n" "Maximum number of interface serviced per write\n") { + int idx_number = 2; struct ospf *ospf = vty->index; u_int32_t write_oi_count; if (!ospf) return CMD_SUCCESS; - write_oi_count = strtol (argv[2]->arg, NULL, 10); + write_oi_count = strtol (argv[idx_number]->arg, NULL, 10); if (write_oi_count < 1 || write_oi_count > 100) { vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); @@ -3625,11 +3689,12 @@ DEFUN (show_ip_ospf_instance, "Instance ID\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4037,11 +4102,12 @@ DEFUN (show_ip_ospf_instance_interface, "Interface name\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4193,11 +4259,12 @@ DEFUN (show_ip_ospf_instance_neighbor, "Neighbor list\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4305,11 +4372,12 @@ DEFUN (show_ip_ospf_instance_neighbor_all, "include down status neighbor\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4399,11 +4467,12 @@ DEFUN (show_ip_ospf_instance_neighbor_int, "Interface name\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4765,11 +4834,12 @@ DEFUN (show_ip_ospf_instance_neighbor_id, "Neighbor ID\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4856,11 +4926,12 @@ DEFUN (show_ip_ospf_instance_neighbor_detail, "detail of all neighbors\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -4955,11 +5026,12 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all, "include down status neighbor\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -5057,11 +5129,12 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail, "detail of all neighbors\n" "JavaScript Object Notation\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; u_char uj = use_json(argc, argv); - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -5896,10 +5969,11 @@ DEFUN (show_ip_ospf_instance_database, "Instance ID\n" "Database summary\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -6021,10 +6095,11 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, "Advertising Router link states\n" "Advertising Router (as an IP address)\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -6053,6 +6128,8 @@ DEFUN (ip_ospf_authentication_args, "Use message-digest authentication\n" "Address of interface") { + int idx_encryption = 3; + int idx_ipv4 = 4; struct interface *ifp; struct in_addr addr; int ret; @@ -6063,7 +6140,7 @@ DEFUN (ip_ospf_authentication_args, if (argc == 2) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6076,7 +6153,7 @@ DEFUN (ip_ospf_authentication_args, } /* Handle null authentication */ - if ( argv[3]->arg[0] == 'n' ) + if ( argv[idx_encryption]->arg[0] == 'n' ) { SET_IF_PARAM (params, auth_type); params->auth_type = OSPF_AUTH_NULL; @@ -6084,7 +6161,7 @@ DEFUN (ip_ospf_authentication_args, } /* Handle message-digest authentication */ - if ( argv[3]->arg[0] == 'm' ) + if ( argv[idx_encryption]->arg[0] == 'm' ) { SET_IF_PARAM (params, auth_type); params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; @@ -6112,6 +6189,7 @@ DEFUN (ip_ospf_authentication, "Enable authentication on this interface\n" "Address of interface") { + int idx_ipv4 = 3; struct interface *ifp; struct in_addr addr; int ret; @@ -6122,7 +6200,7 @@ DEFUN (ip_ospf_authentication, if (argc == 1) { - ret = inet_aton(argv[3]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6163,6 +6241,8 @@ DEFUN (no_ip_ospf_authentication_args, "Use message-digest authentication\n" "Address of interface") { + int idx_encryption = 4; + int idx_ipv4 = 5; struct interface *ifp; struct in_addr addr; int ret; @@ -6175,7 +6255,7 @@ DEFUN (no_ip_ospf_authentication_args, if (argc == 2) { - ret = inet_aton(argv[5]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6199,11 +6279,11 @@ DEFUN (no_ip_ospf_authentication_args, } else { - if ( argv[4]->arg[0] == 'n' ) + if ( argv[idx_encryption]->arg[0] == 'n' ) { auth_type = OSPF_AUTH_NULL; } - else if ( argv[4]->arg[0] == 'm' ) + else if ( argv[idx_encryption]->arg[0] == 'm' ) { auth_type = OSPF_AUTH_CRYPTOGRAPHIC; } @@ -6264,6 +6344,7 @@ DEFUN (no_ip_ospf_authentication, "Enable authentication on this interface\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp; struct in_addr addr; int ret; @@ -6275,7 +6356,7 @@ DEFUN (no_ip_ospf_authentication, if (argc == 1) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6356,6 +6437,7 @@ DEFUN (ip_ospf_authentication_key, "The OSPF password (key)\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp; struct in_addr addr; int ret; @@ -6379,7 +6461,7 @@ DEFUN (ip_ospf_authentication_key, } memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); - strncpy ((char *) params->auth_simple, argv[4]->arg, OSPF_AUTH_SIMPLE_SIZE); + strncpy ((char *) params->auth_simple, argv[idx_ipv4]->arg, OSPF_AUTH_SIMPLE_SIZE); SET_IF_PARAM (params, auth_simple); return CMD_SUCCESS; @@ -6497,6 +6579,8 @@ DEFUN (ip_ospf_message_digest_key, "The OSPF password (key)" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 6; struct interface *ifp; struct crypt_key *ck; u_char key_id; @@ -6521,7 +6605,7 @@ DEFUN (ip_ospf_message_digest_key, ospf_if_update_params (ifp, addr); } - key_id = strtol (argv[3]->arg, NULL, 10); + key_id = strtol (argv[idx_number]->arg, NULL, 10); if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) { vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); @@ -6531,7 +6615,7 @@ DEFUN (ip_ospf_message_digest_key, ck = ospf_crypt_key_new (); ck->key_id = (u_char) key_id; memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); - strncpy ((char *) ck->auth_key, argv[6]->arg, OSPF_AUTH_MD5_SIZE); + strncpy ((char *) ck->auth_key, argv[idx_ipv4]->arg, OSPF_AUTH_MD5_SIZE); ospf_crypt_key_add (params->auth_crypt, ck); SET_IF_PARAM (params, auth_crypt); @@ -6573,6 +6657,7 @@ DEFUN (no_ip_ospf_message_digest_key_md5, "The OSPF password (key)" "Address of interface") { + int idx_number = 4; struct interface *ifp; struct crypt_key *ck; int key_id; @@ -6598,7 +6683,7 @@ DEFUN (no_ip_ospf_message_digest_key_md5, return CMD_SUCCESS; } - key_id = strtol (argv[4]->arg, NULL, 10); + key_id = strtol (argv[idx_number]->arg, NULL, 10); ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); if (ck == NULL) { @@ -6644,6 +6729,8 @@ DEFUN (no_ip_ospf_message_digest_key, "Key ID\n" "Address of interface") { + int idx_number = 4; + int idx_ipv4 = 5; struct interface *ifp; struct crypt_key *ck; int key_id; @@ -6656,7 +6743,7 @@ DEFUN (no_ip_ospf_message_digest_key, if (argc == 2) { - ret = inet_aton(argv[5]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6669,7 +6756,7 @@ DEFUN (no_ip_ospf_message_digest_key, return CMD_SUCCESS; } - key_id = strtol (argv[4]->arg, NULL, 10); + key_id = strtol (argv[idx_number]->arg, NULL, 10); ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); if (ck == NULL) { @@ -6708,6 +6795,8 @@ DEFUN (ip_ospf_cost, "Cost\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t cost; struct in_addr addr; @@ -6716,7 +6805,7 @@ DEFUN (ip_ospf_cost, params = IF_DEF_PARAMS (ifp); - cost = strtol (argv[3]->arg, NULL, 10); + cost = strtol (argv[idx_number]->arg, NULL, 10); /* cost range is <1-65535>. */ if (cost < 1 || cost > 65535) @@ -6727,7 +6816,7 @@ DEFUN (ip_ospf_cost, if (argc == 2) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6792,6 +6881,7 @@ DEFUN (no_ip_ospf_cost, "Interface cost\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -6802,7 +6892,7 @@ DEFUN (no_ip_ospf_cost, if (argc == 1) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -6864,6 +6954,7 @@ DEFUN (no_ip_ospf_cost2, "Interface cost\n" "Cost") { + int idx_number = 4; struct interface *ifp = vty->index; struct in_addr addr; u_int32_t cost; @@ -6878,7 +6969,7 @@ DEFUN (no_ip_ospf_cost2, * of N already configured for the interface. Thus the first argument * is always checked to be a number, but is ignored after that. */ - cost = strtol (argv[4]->arg, NULL, 10); + cost = strtol (argv[idx_number]->arg, NULL, 10); if (cost < 1 || cost > 65535) { vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); @@ -7030,10 +7121,12 @@ DEFUN (ip_ospf_dead_interval, "Seconds\n" "Address of interface\n") { + int idx_number = 3; + int idx_ipv4 = 4; if (argc == 2) - return ospf_vty_dead_interval_set (vty, argv[3]->arg, argv[4]->arg, NULL); + return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, argv[idx_ipv4]->arg, NULL); else - return ospf_vty_dead_interval_set (vty, argv[3]->arg, NULL, NULL); + return ospf_vty_dead_interval_set (vty, argv[idx_number]->arg, NULL, NULL); } @@ -7066,10 +7159,12 @@ DEFUN (ip_ospf_dead_interval_minimal, "Number of Hellos to send each second\n" "Address of interface\n") { + int idx_number = 5; + int idx_ipv4 = 6; if (argc == 2) - return ospf_vty_dead_interval_set (vty, NULL, argv[6]->arg, argv[5]->arg); + return ospf_vty_dead_interval_set (vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg); else - return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[5]->arg); + return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[idx_number]->arg); } @@ -7123,6 +7218,7 @@ DEFUN (no_ip_ospf_dead_interval, "Seconds\n" "Address of interface") { + int idx_ipv4 = 5; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -7135,7 +7231,7 @@ DEFUN (no_ip_ospf_dead_interval, if (argc == 2) { - ret = inet_aton(argv[5]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7205,6 +7301,8 @@ DEFUN (ip_ospf_hello_interval, "Seconds\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t seconds; struct in_addr addr; @@ -7213,7 +7311,7 @@ DEFUN (ip_ospf_hello_interval, params = IF_DEF_PARAMS (ifp); - seconds = strtol (argv[3]->arg, NULL, 10); + seconds = strtol (argv[idx_number]->arg, NULL, 10); /* HelloInterval range is <1-65535>. */ if (seconds < 1 || seconds > 65535) @@ -7224,7 +7322,7 @@ DEFUN (ip_ospf_hello_interval, if (argc == 2) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7282,6 +7380,7 @@ DEFUN (no_ip_ospf_hello_interval, "Seconds\n" "Address of interface") { + int idx_ipv4 = 5; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -7292,7 +7391,7 @@ DEFUN (no_ip_ospf_hello_interval, if (argc == 2) { - ret = inet_aton(argv[5]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7331,6 +7430,7 @@ DEFUN (ip_ospf_network, "Specify OSPF point-to-multipoint network\n" "Specify OSPF point-to-point network\n") { + int idx_network = 3; struct interface *ifp = vty->index; int old_type = IF_DEF_PARAMS (ifp)->type; struct route_node *rn; @@ -7341,13 +7441,13 @@ DEFUN (ip_ospf_network, return CMD_WARNING; } - if (strncmp (argv[3]->arg, "b", 1) == 0) + if (strncmp (argv[idx_network]->arg, "b", 1) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; - else if (strncmp (argv[3]->arg, "n", 1) == 0) + else if (strncmp (argv[idx_network]->arg, "n", 1) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; - else if (strncmp (argv[3]->arg, "point-to-m", 10) == 0) + else if (strncmp (argv[idx_network]->arg, "point-to-m", 10) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; - else if (strncmp (argv[3]->arg, "point-to-p", 10) == 0) + else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0) IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; if (IF_DEF_PARAMS (ifp)->type == old_type) @@ -7468,6 +7568,8 @@ DEFUN (ip_ospf_priority, "Priority\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; long priority; struct route_node *rn; @@ -7477,7 +7579,7 @@ DEFUN (ip_ospf_priority, params = IF_DEF_PARAMS (ifp); - priority = strtol (argv[3]->arg, NULL, 10); + priority = strtol (argv[idx_number]->arg, NULL, 10); /* Router Priority range is <0-255>. */ if (priority < 0 || priority > 255) @@ -7488,7 +7590,7 @@ DEFUN (ip_ospf_priority, if (argc == 2) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7561,6 +7663,7 @@ DEFUN (no_ip_ospf_priority, "Priority\n" "Address of interface") { + int idx_ipv4 = 5; struct interface *ifp = vty->index; struct route_node *rn; struct in_addr addr; @@ -7572,7 +7675,7 @@ DEFUN (no_ip_ospf_priority, if (argc == 2) { - ret = inet_aton(argv[5]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7634,6 +7737,8 @@ DEFUN (ip_ospf_retransmit_interval, "Seconds\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t seconds; struct in_addr addr; @@ -7641,7 +7746,7 @@ DEFUN (ip_ospf_retransmit_interval, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - seconds = strtol (argv[3]->arg, NULL, 10); + seconds = strtol (argv[idx_number]->arg, NULL, 10); /* Retransmit Interval range is <3-65535>. */ if (seconds < 3 || seconds > 65535) @@ -7653,7 +7758,7 @@ DEFUN (ip_ospf_retransmit_interval, if (argc == 2) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7794,6 +7899,8 @@ DEFUN (ip_ospf_transmit_delay, "Seconds\n" "Address of interface") { + int idx_number = 3; + int idx_ipv4 = 4; struct interface *ifp = vty->index; u_int32_t seconds; struct in_addr addr; @@ -7801,7 +7908,7 @@ DEFUN (ip_ospf_transmit_delay, struct ospf_if_params *params; params = IF_DEF_PARAMS (ifp); - seconds = strtol (argv[3]->arg, NULL, 10); + seconds = strtol (argv[idx_number]->arg, NULL, 10); /* Transmit Delay range is <1-65535>. */ if (seconds < 1 || seconds > 65535) @@ -7812,7 +7919,7 @@ DEFUN (ip_ospf_transmit_delay, if (argc == 2) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -7955,6 +8062,7 @@ DEFUN (ip_ospf_area, "OSPF area ID in IP address format\n" "OSPF area ID as a decimal value\n") { + int idx_ipv4_number = 3; struct interface *ifp = vty->index; int format, ret; struct in_addr area_id; @@ -7964,7 +8072,7 @@ DEFUN (ip_ospf_area, u_short instance = 0; if (argc == 2) - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_ipv4_number]->arg); ospf = ospf_lookup_instance (instance); if (ospf == NULL) @@ -8079,12 +8187,13 @@ DEFUN (no_ip_ospf_instance_area, "Instance ID\n" "Disable OSPF on this interface\n") { + int idx_number = 3; struct interface *ifp = vty->index; struct ospf *ospf; struct ospf_if_params *params; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL) return CMD_SUCCESS; @@ -8115,6 +8224,8 @@ DEFUN (ospf_redistribute_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_redist_param = 2; struct ospf *ospf = vty->index; int source; int type = -1; @@ -8131,13 +8242,13 @@ DEFUN (ospf_redistribute_source, return CMD_SUCCESS; /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[1]->arg); + source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; /* Get metric value. */ - if (argv[2]->arg != NULL) - if (!str2metric (argv[2]->arg, &metric)) + if (argv[idx_redist_param]->arg != NULL) + if (!str2metric (argv[idx_redist_param]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ @@ -8169,13 +8280,14 @@ DEFUN (no_ospf_redistribute_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; struct ospf *ospf = vty->index; int source; struct ospf_redist *red; if (!ospf) return CMD_SUCCESS; - source = proto_redistnum(AFI_IP, argv[2]->arg); + source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; @@ -8202,6 +8314,9 @@ DEFUN (ospf_redistribute_instance_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 1; + int idx_number = 2; + int idx_redist_param = 3; struct ospf *ospf = vty->index; int source; int type = -1; @@ -8212,12 +8327,12 @@ DEFUN (ospf_redistribute_instance_source, if (!ospf) return CMD_SUCCESS; - if (strncmp(argv[1]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) source = ZEBRA_ROUTE_OSPF; else source = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[2]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); if (!ospf) return CMD_SUCCESS; @@ -8237,8 +8352,8 @@ DEFUN (ospf_redistribute_instance_source, } /* Get metric value. */ - if (argv[3]->arg != NULL) - if (!str2metric (argv[3]->arg, &metric)) + if (argv[idx_redist_param]->arg != NULL) + if (!str2metric (argv[idx_redist_param]->arg, &metric)) return CMD_WARNING; /* Get metric type. */ @@ -8271,6 +8386,8 @@ DEFUN (no_ospf_redistribute_instance_source, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_ospf_table = 2; + int idx_number = 3; struct ospf *ospf = vty->index; u_int instance; struct ospf_redist *red; @@ -8279,12 +8396,12 @@ DEFUN (no_ospf_redistribute_instance_source, if (!ospf) return CMD_SUCCESS; - if (strncmp(argv[2]->arg, "o", 1) == 0) + if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) source = ZEBRA_ROUTE_OSPF; else source = ZEBRA_ROUTE_TABLE; - VTY_GET_INTEGER ("Instance ID", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) { @@ -8316,6 +8433,7 @@ DEFUN (ospf_distribute_list_out, OUT_STR QUAGGA_REDIST_HELP_STR_OSPFD) { + int idx_word = 1; struct ospf *ospf = vty->index; int source; @@ -8327,7 +8445,7 @@ DEFUN (ospf_distribute_list_out, if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; - return ospf_distribute_list_out_set (ospf, source, argv[1]->arg); + return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg); } DEFUN (no_ospf_distribute_list_out, @@ -8339,6 +8457,7 @@ DEFUN (no_ospf_distribute_list_out, OUT_STR QUAGGA_REDIST_HELP_STR_OSPFD) { + int idx_word = 2; struct ospf *ospf = vty->index; int source; @@ -8349,7 +8468,7 @@ DEFUN (no_ospf_distribute_list_out, if (source < 0 || source == ZEBRA_ROUTE_OSPF) return CMD_WARNING; - return ospf_distribute_list_out_unset (ospf, source, argv[2]->arg); + return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg); } /* Default information originate. */ @@ -8367,6 +8486,7 @@ DEFUN (ospf_default_information_originate, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_redist_param = 2; struct ospf *ospf = vty->index; int default_originate = DEFAULT_ORIGINATE_ZEBRA; int type = -1; @@ -8380,7 +8500,7 @@ DEFUN (ospf_default_information_originate, return CMD_WARNING; /* this should not happen */ /* Check whether "always" was specified */ - if (argv[2]->arg != NULL) + if (argv[idx_redist_param]->arg != NULL) default_originate = DEFAULT_ORIGINATE_ALWAYS; red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); @@ -8453,13 +8573,14 @@ DEFUN (ospf_default_metric, "Set metric of redistributed routes\n" "Default metric\n") { + int idx_number = 1; struct ospf *ospf = vty->index; int metric = -1; if (!ospf) return CMD_SUCCESS; - if (!str2metric (argv[1]->arg, &metric)) + if (!str2metric (argv[idx_number]->arg, &metric)) return CMD_WARNING; ospf->default_metric = metric; @@ -8498,12 +8619,13 @@ DEFUN (ospf_distance, "Define an administrative distance\n" "OSPF Administrative distance\n") { + int idx_number = 1; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf->distance_all = atoi (argv[1]->arg); + ospf->distance_all = atoi (argv[idx_number]->arg); return CMD_SUCCESS; } @@ -8538,6 +8660,7 @@ DEFUN (no_ospf_distance_ospf, "External routes\n" "Distance for external routes\n") { + int idx_area_distance = 3; struct ospf *ospf = vty->index; if (!ospf) @@ -8549,7 +8672,7 @@ DEFUN (no_ospf_distance_ospf, if (!ospf) return CMD_SUCCESS; - if (argv[3]->arg != NULL) + if (argv[idx_area_distance]->arg != NULL) ospf->distance_intra = 0; if (argv[1] != NULL) @@ -8558,7 +8681,7 @@ DEFUN (no_ospf_distance_ospf, if (argv[2] != NULL) ospf->distance_external = 0; - if (argv[3]->arg || argv[1] || argv[2]) + if (argv[idx_area_distance]->arg || argv[1] || argv[2]) return CMD_SUCCESS; /* If no arguments are given, clear all distance information */ @@ -8581,6 +8704,7 @@ DEFUN (ospf_distance_ospf, "External routes\n" "Distance for external routes\n") { + int idx_area_distance = 2; struct ospf *ospf = vty->index; if (!ospf) @@ -8589,15 +8713,15 @@ DEFUN (ospf_distance_ospf, if (argc < 3) /* should not happen */ return CMD_WARNING; - if (!argv[2]->arg && !argv[1] && !argv[2]) + if (!argv[idx_area_distance]->arg && !argv[1] && !argv[2]) { vty_out(vty, "%% Command incomplete. (Arguments required)%s", VTY_NEWLINE); return CMD_WARNING; } - if (argv[2]->arg != NULL) - ospf->distance_intra = atoi(argv[2]->arg); + if (argv[idx_area_distance]->arg != NULL) + ospf->distance_intra = atoi(argv[idx_area_distance]->arg); if (argv[1] != NULL) ospf->distance_inter = atoi(argv[1]); @@ -8615,12 +8739,14 @@ DEFUN (ospf_distance_source, "Distance value\n" "IP source prefix\n") { + int idx_number = 1; + int idx_ipv4_prefixlen = 2; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_set (vty, ospf, argv[1]->arg, argv[2]->arg, NULL); + ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } @@ -8633,12 +8759,14 @@ DEFUN (no_ospf_distance_source, "Distance value\n" "IP source prefix\n") { + int idx_number = 2; + int idx_ipv4_prefixlen = 3; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_unset (vty, ospf, argv[2]->arg, argv[3]->arg, NULL); + ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } @@ -8651,12 +8779,15 @@ DEFUN (ospf_distance_source_access_list, "IP source prefix\n" "Access list name\n") { + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + int idx_word = 3; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_set (vty, ospf, argv[1]->arg, argv[2]->arg, argv[3]->arg); + ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -8670,12 +8801,15 @@ DEFUN (no_ospf_distance_source_access_list, "IP source prefix\n" "Access list name\n") { + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + int idx_word = 4; struct ospf *ospf = vty->index; if (!ospf) return CMD_SUCCESS; - ospf_distance_unset (vty, ospf, argv[2]->arg, argv[3]->arg, argv[4]->arg); + ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -8696,6 +8830,7 @@ DEFUN (ip_ospf_mtu_ignore, "Disable mtu mismatch detection\n" "Address of interface") { + int idx_ipv4 = 3; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -8705,7 +8840,7 @@ DEFUN (ip_ospf_mtu_ignore, if (argc == 1) { - ret = inet_aton(argv[3]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -8748,6 +8883,7 @@ DEFUN (no_ip_ospf_mtu_ignore, "Disable mtu mismatch detection\n" "Address of interface") { + int idx_ipv4 = 4; struct interface *ifp = vty->index; struct in_addr addr; int ret; @@ -8757,7 +8893,7 @@ DEFUN (no_ip_ospf_mtu_ignore, if (argc == 1) { - ret = inet_aton(argv[4]->arg, &addr); + ret = inet_aton(argv[idx_ipv4]->arg, &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -8850,6 +8986,7 @@ DEFUN (ospf_max_metric_router_lsa_startup, "Automatically advertise stub Router-LSA on startup of OSPF\n" "Time (seconds) to advertise self as stub-router\n") { + int idx_number = 3; unsigned int seconds; struct ospf *ospf = vty->index; @@ -8862,7 +8999,7 @@ DEFUN (ospf_max_metric_router_lsa_startup, return CMD_WARNING; } - VTY_GET_INTEGER ("stub-router startup period", seconds, argv[3]->arg); + VTY_GET_INTEGER ("stub-router startup period", seconds, argv[idx_number]->arg); ospf->stub_router_startup_time = seconds; @@ -8920,6 +9057,7 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, "Advertise stub-router prior to full shutdown of OSPF\n" "Time (seconds) to wait till full shutdown\n") { + int idx_number = 3; unsigned int seconds; struct ospf *ospf = vty->index; @@ -8932,7 +9070,7 @@ DEFUN (ospf_max_metric_router_lsa_shutdown, return CMD_WARNING; } - VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[3]->arg); + VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[idx_number]->arg); ospf->stub_router_shutdown_time = seconds; @@ -9194,10 +9332,11 @@ DEFUN (show_ip_ospf_instance_border_routers, "Instance ID\n" "Show all the ABR's and ASBR's\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -9256,10 +9395,11 @@ DEFUN (show_ip_ospf_instance_route, "Instance ID\n" "OSPF routing table\n") { + int idx_number = 3; struct ospf *ospf; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) return CMD_SUCCESS; @@ -10240,6 +10380,7 @@ DEFUN (clear_ip_ospf_interface, "Interface information\n" "Interface name\n") { + int idx_ifname = 4; struct interface *ifp; struct listnode *node; @@ -10250,7 +10391,7 @@ DEFUN (clear_ip_ospf_interface, } else /* Interface name is specified. */ { - if ((ifp = if_lookup_by_name (argv[4]->arg)) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else ospf_interface_clear(ifp); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 62159ad08..9232c48e7 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -1533,8 +1533,9 @@ DEFUN (pim_interface, "Select an interface to configure\n" "Interface's name\n") { + int idx_ifname = 1; struct interface *ifp; - const char *ifname = argv[1]->arg; + const char *ifname = argv[idx_ifname]->arg; size_t sl; sl = strlen(ifname); @@ -2368,13 +2369,14 @@ DEFUN (show_ip_rib, RIB_STR "Unicast address\n") { + int idx_ipv4 = 3; struct in_addr addr; const char *addr_str; struct pim_nexthop nexthop; char nexthop_addr_str[100]; int result; - addr_str = argv[3]->arg; + addr_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, addr_str, &addr); if (result <= 0) { vty_out(vty, "Bad unicast address %s: errno=%d: %s%s", @@ -2466,16 +2468,17 @@ DEFUN (ip_pim_rp, "Rendevous Point\n" "ip address of RP\n") { + int idx_ipv4 = 3; int result; - result = inet_pton(AF_INET, argv[3]->arg, &qpim_rp.rpf_addr.s_addr); + result = inet_pton(AF_INET, argv[idx_ipv4]->arg, &qpim_rp.rpf_addr.s_addr); if (result <= 0) { - vty_out(vty, "%% Bad RP address specified: %s", argv[3]->arg); + vty_out(vty, "%% Bad RP address specified: %s", argv[idx_ipv4]->arg); return CMD_WARNING; } if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) { - vty_out(vty, "%% No Path to RP address specified: %s", argv[3]->arg); + vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -2484,7 +2487,7 @@ DEFUN (ip_pim_rp, DEFUN (no_ip_pim_rp, no_ip_pim_rp_cmd, - "no ip pim rp {A.B.C.D}", + "no ip pim rp [A.B.C.D]", NO_STR IP_STR "pim multicast routing\n" @@ -2531,9 +2534,10 @@ DEFUN (ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { + int idx_ipv4 = 2; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[2]->arg : "0.0.0.0"; + const char *source_str = (argc > 0) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -2560,9 +2564,10 @@ DEFUN (no_ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { + int idx_ipv4 = 3; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[3]->arg : "0.0.0.0"; + const char *source_str = (argc > 0) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -2648,6 +2653,8 @@ DEFUN (interface_ip_igmp_join, "Multicast group address\n" "Source address\n") { + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; struct interface *ifp; const char *group_str; const char *source_str; @@ -2658,7 +2665,7 @@ DEFUN (interface_ip_igmp_join, ifp = vty->index; /* Group address */ - group_str = argv[3]->arg; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -2667,7 +2674,7 @@ DEFUN (interface_ip_igmp_join, } /* Source address */ - source_str = argv[4]->arg; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -2695,6 +2702,8 @@ DEFUN (interface_no_ip_igmp_join, "Multicast group address\n" "Source address\n") { + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; struct interface *ifp; const char *group_str; const char *source_str; @@ -2705,7 +2714,7 @@ DEFUN (interface_no_ip_igmp_join, ifp = vty->index; /* Group address */ - group_str = argv[4]->arg; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -2714,7 +2723,7 @@ DEFUN (interface_no_ip_igmp_join, } /* Source address */ - source_str = argv[5]->arg; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -2865,7 +2874,7 @@ static void change_query_max_response_time(struct pim_interface *pim_ifp, DEFUN (interface_ip_igmp_query_interval, interface_ip_igmp_query_interval_cmd, - PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>", + PIM_CMD_IP_IGMP_QUERY_INTERVAL " (1-1800)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_INTERVAL_STR @@ -2960,7 +2969,7 @@ DEFUN (interface_no_ip_igmp_query_interval, DEFUN (interface_ip_igmp_query_max_response_time, interface_ip_igmp_query_max_response_time_cmd, - PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>", + PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " (1-25)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR @@ -3053,7 +3062,7 @@ DEFUN (interface_no_ip_igmp_query_max_response_time, DEFUN (interface_ip_igmp_query_max_response_time_dsec, interface_ip_igmp_query_max_response_time_dsec_cmd, - PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>", + PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " (10-250)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR @@ -3146,12 +3155,13 @@ DEFUN (interface_no_ip_igmp_query_max_response_time_dsec, DEFUN (interface_ip_pim_drprio, interface_ip_pim_drprio_cmd, - "ip pim drpriority <1-4294967295>", + "ip pim drpriority (1-4294967295)", IP_STR PIM_STR "Set the Designated Router Election Priority\n" "Value of the new DR Priority\n") { + int idx_number = 3; struct interface *ifp; struct pim_interface *pim_ifp; uint32_t old_dr_prio; @@ -3166,7 +3176,7 @@ DEFUN (interface_ip_pim_drprio, old_dr_prio = pim_ifp->pim_dr_priority; - pim_ifp->pim_dr_priority = strtol(argv[3]->arg, NULL, 10); + pim_ifp->pim_dr_priority = strtol(argv[idx_number]->arg, NULL, 10); if (old_dr_prio != pim_ifp->pim_dr_priority) { if (pim_if_dr_election(ifp)) @@ -3178,7 +3188,7 @@ DEFUN (interface_ip_pim_drprio, DEFUN (interface_no_ip_pim_drprio, interface_no_ip_pim_drprio_cmd, - "no ip pim drpriority {<1-4294967295>}", + "no ip pim drpriority [(1-4294967295)]", IP_STR PIM_STR "Revert the Designated Router Priority to default\n" @@ -3345,6 +3355,8 @@ DEFUN (interface_ip_mroute, "Outgoing interface name\n" "Group address\n") { + int idx_interface = 2; + int idx_ipv4 = 3; struct interface *iif; struct interface *oif; const char *oifname; @@ -3355,7 +3367,7 @@ DEFUN (interface_ip_mroute, iif = vty->index; - oifname = argv[2]->arg; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3363,7 +3375,7 @@ DEFUN (interface_ip_mroute, return CMD_WARNING; } - grp_str = argv[3]->arg; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3390,6 +3402,9 @@ DEFUN (interface_ip_mroute_source, "Group address\n" "Source address\n") { + int idx_interface = 2; + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; struct interface *iif; struct interface *oif; const char *oifname; @@ -3401,7 +3416,7 @@ DEFUN (interface_ip_mroute_source, iif = vty->index; - oifname = argv[2]->arg; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3409,7 +3424,7 @@ DEFUN (interface_ip_mroute_source, return CMD_WARNING; } - grp_str = argv[3]->arg; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3417,7 +3432,7 @@ DEFUN (interface_ip_mroute_source, return CMD_WARNING; } - src_str = argv[4]->arg; + src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -3442,6 +3457,8 @@ DEFUN (interface_no_ip_mroute, "Outgoing interface name\n" "Group Address\n") { + int idx_interface = 3; + int idx_ipv4 = 4; struct interface *iif; struct interface *oif; const char *oifname; @@ -3452,7 +3469,7 @@ DEFUN (interface_no_ip_mroute, iif = vty->index; - oifname = argv[3]->arg; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3460,7 +3477,7 @@ DEFUN (interface_no_ip_mroute, return CMD_WARNING; } - grp_str = argv[4]->arg; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3488,6 +3505,9 @@ DEFUN (interface_no_ip_mroute_source, "Group Address\n" "Source Address\n") { + int idx_interface = 3; + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; struct interface *iif; struct interface *oif; const char *oifname; @@ -3499,7 +3519,7 @@ DEFUN (interface_no_ip_mroute_source, iif = vty->index; - oifname = argv[3]->arg; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3507,7 +3527,7 @@ DEFUN (interface_no_ip_mroute_source, return CMD_WARNING; } - grp_str = argv[4]->arg; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3515,7 +3535,7 @@ DEFUN (interface_no_ip_mroute_source, return CMD_WARNING; } - src_str = argv[5]->arg; + src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -3543,12 +3563,13 @@ DEFUN (interface_no_ip_mroute_source, */ DEFUN (interface_ip_pim_hello, interface_ip_pim_hello_cmd, - "ip pim hello <1-180>", + "ip pim hello (1-180)", IP_STR PIM_STR IFACE_PIM_HELLO_STR IFACE_PIM_HELLO_TIME_STR) { + int idx_number = 3; struct interface *ifp; struct pim_interface *pim_ifp; @@ -3560,7 +3581,7 @@ DEFUN (interface_ip_pim_hello, return CMD_WARNING; } - pim_ifp->pim_hello_period = strtol(argv[3]->arg, NULL, 10); + pim_ifp->pim_hello_period = strtol(argv[idx_number]->arg, NULL, 10); if (argc == 2) pim_ifp->pim_default_holdtime = strtol(argv[4]->arg, NULL, 10); @@ -3572,7 +3593,7 @@ DEFUN (interface_ip_pim_hello, DEFUN (interface_no_ip_pim_hello, interface_no_ip_pim_hello_cmd, - "no ip pim hello {<1-180> <1-180>}", + "no ip pim hello [(1-180) (1-180)]", NO_STR IP_STR PIM_STR @@ -3867,19 +3888,20 @@ DEFUN (debug_pim_packets, DEFUN (debug_pim_packets_filter, debug_pim_packets_filter_cmd, - "debug pim packets (hello|joins)", + "debug pim packets <hello|joins>", DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_PACKETS_STR DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR) { - if (strncmp(argv[3]->arg,"h",1) == 0) + int idx_hello_join = 3; + if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) { PIM_DO_DEBUG_PIM_HELLO; vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE); } - else if (strncmp(argv[3]->arg,"j",1) == 0) + else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0) { PIM_DO_DEBUG_PIM_J_P; vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE); @@ -3912,7 +3934,7 @@ DEFUN (no_debug_pim_packets, DEFUN (no_debug_pim_packets_filter, no_debug_pim_packets_filter_cmd, - "no debug pim packets (hello|joins)", + "no debug pim packets <hello|joins>", NO_STR DEBUG_STR DEBUG_PIM_STR @@ -3920,12 +3942,13 @@ DEFUN (no_debug_pim_packets_filter, DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR) { - if (strncmp(argv[4]->arg,"h",1) == 0) + int idx_hello_join = 4; + if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) { PIM_DONT_DEBUG_PIM_HELLO; vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE); } - else if (strncmp(argv[4]->arg,"j",1) == 0) + else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0) { PIM_DONT_DEBUG_PIM_J_P; vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE); @@ -4137,7 +4160,7 @@ static struct igmp_sock *find_igmp_sock_by_fd(int fd) DEFUN (test_igmp_receive_report, test_igmp_receive_report_cmd, - "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE", + "test igmp receive report (0-65535) A.B.C.D (1-6) .LINE", "Test\n" "Test IGMP protocol\n" "Test IGMP message\n" @@ -4147,6 +4170,9 @@ DEFUN (test_igmp_receive_report, "Record type\n" "Sources\n") { + int idx_number = 4; + int idx_ipv4 = 5; + int idx_number_2 = 6; char buf[1000]; char *igmp_msg; struct ip *ip_hdr; @@ -4168,7 +4194,7 @@ DEFUN (test_igmp_receive_report, struct in_addr *src_addr; int argi; - socket = argv[4]->arg; + socket = argv[idx_number]->arg; socket_fd = atoi(socket); igmp = find_igmp_sock_by_fd(socket_fd); if (!igmp) { @@ -4177,7 +4203,7 @@ DEFUN (test_igmp_receive_report, return CMD_WARNING; } - grp_str = argv[5]->arg; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4185,7 +4211,7 @@ DEFUN (test_igmp_receive_report, return CMD_WARNING; } - record_type_str = argv[6]->arg; + record_type_str = argv[idx_number_2]->arg; record_type = atoi(record_type_str); /* @@ -4259,6 +4285,8 @@ DEFUN (test_pim_receive_dump, "Neighbor address\n" "Packet dump\n") { + int idx_interface = 4; + int idx_ipv4 = 5; uint8_t buf[1000]; uint8_t *pim_msg; struct ip *ip_hdr; @@ -4273,7 +4301,7 @@ DEFUN (test_pim_receive_dump, int result; /* Find interface */ - ifname = argv[4]->arg; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4282,7 +4310,7 @@ DEFUN (test_pim_receive_dump, } /* Neighbor address */ - neigh_str = argv[5]->arg; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4362,7 +4390,7 @@ DEFUN (test_pim_receive_dump, DEFUN (test_pim_receive_hello, test_pim_receive_hello_cmd, - "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]", + "test pim receive hello INTERFACE A.B.C.D (0-65535) (0-65535) (0-65535) (0-32767) (0-65535) (0-1) [LINE]", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4377,6 +4405,14 @@ DEFUN (test_pim_receive_hello, "Neighbor LAN prune delay T-bit\n" "Neighbor secondary addresses\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_number = 6; + int idx_number_2 = 7; + int idx_number_3 = 8; + int idx_number_4 = 9; + int idx_number_5 = 10; + int idx_number_6 = 11; uint8_t buf[1000]; uint8_t *pim_msg; struct ip *ip_hdr; @@ -4398,7 +4434,7 @@ DEFUN (test_pim_receive_hello, int result; /* Find interface */ - ifname = argv[4]->arg; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4407,7 +4443,7 @@ DEFUN (test_pim_receive_hello, } /* Neighbor address */ - neigh_str = argv[5]->arg; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4415,12 +4451,12 @@ DEFUN (test_pim_receive_hello, return CMD_WARNING; } - neigh_holdtime = atoi(argv[6]->arg); - neigh_dr_priority = atoi(argv[7]->arg); - neigh_generation_id = atoi(argv[8]->arg); - neigh_propagation_delay = atoi(argv[9]->arg); - neigh_override_interval = atoi(argv[10]->arg); - neigh_can_disable_join_suppression = atoi(argv[11]->arg); + neigh_holdtime = atoi(argv[idx_number]->arg); + neigh_dr_priority = atoi(argv[idx_number_2]->arg); + neigh_generation_id = atoi(argv[idx_number_3]->arg); + neigh_propagation_delay = atoi(argv[idx_number_4]->arg); + neigh_override_interval = atoi(argv[idx_number_5]->arg); + neigh_can_disable_join_suppression = atoi(argv[idx_number_6]->arg); /* Tweak IP header @@ -4489,7 +4525,7 @@ DEFUN (test_pim_receive_hello, DEFUN (test_pim_receive_assert, test_pim_receive_assert_cmd, - "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>", + "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D (0-65535) (0-65535) (0-1)", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4502,6 +4538,13 @@ DEFUN (test_pim_receive_assert, "Assert route metric\n" "Assert RPT bit flag\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + int idx_ipv4_3 = 7; + int idx_number = 8; + int idx_number_2 = 9; + int idx_number_3 = 10; uint8_t buf[1000]; uint8_t *buf_pastend = buf + sizeof(buf); uint8_t *pim_msg; @@ -4524,7 +4567,7 @@ DEFUN (test_pim_receive_assert, int result; /* Find interface */ - ifname = argv[4]->arg; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4533,7 +4576,7 @@ DEFUN (test_pim_receive_assert, } /* Neighbor address */ - neigh_str = argv[5]->arg; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4542,7 +4585,7 @@ DEFUN (test_pim_receive_assert, } /* Group address */ - group_str = argv[6]->arg; + group_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4551,7 +4594,7 @@ DEFUN (test_pim_receive_assert, } /* Source address */ - source_str = argv[7]->arg; + source_str = argv[idx_ipv4_3]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4559,9 +4602,9 @@ DEFUN (test_pim_receive_assert, return CMD_WARNING; } - assert_metric_preference = atoi(argv[8]->arg); - assert_route_metric = atoi(argv[9]->arg); - assert_rpt_bit_flag = atoi(argv[10]->arg); + assert_metric_preference = atoi(argv[idx_number]->arg); + assert_route_metric = atoi(argv[idx_number_2]->arg); + assert_rpt_bit_flag = atoi(argv[idx_number_3]->arg); remain = buf_pastend - buf; if (remain < (int) sizeof(struct ip)) { @@ -4797,7 +4840,7 @@ static int recv_joinprune(struct vty *vty, DEFUN (test_pim_receive_join, test_pim_receive_join_cmd, - "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "test pim receive join INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4814,7 +4857,7 @@ DEFUN (test_pim_receive_join, DEFUN (test_pim_receive_prune, test_pim_receive_prune_cmd, - "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "test pim receive prune INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4831,7 +4874,7 @@ DEFUN (test_pim_receive_prune, DEFUN (test_pim_receive_upcall, test_pim_receive_upcall_cmd, - "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D", + "test pim receive upcall <nocache|wrongvif|wholepkt> (0-65535) A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4843,13 +4886,17 @@ DEFUN (test_pim_receive_upcall, "Multicast group address\n" "Multicast source address\n") { + int idx_type = 4; + int idx_number = 5; + int idx_ipv4 = 6; + int idx_ipv4_2 = 7; struct igmpmsg msg; const char *upcall_type; const char *group_str; const char *source_str; int result; - upcall_type = argv[4]->arg; + upcall_type = argv[idx_type]->arg; if (upcall_type[0] == 'n') msg.im_msgtype = IGMPMSG_NOCACHE; @@ -4863,10 +4910,10 @@ DEFUN (test_pim_receive_upcall, return CMD_WARNING; } - msg.im_vif = atoi(argv[5]->arg); + msg.im_vif = atoi(argv[idx_number]->arg); /* Group address */ - group_str = argv[6]->arg; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &msg.im_dst); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4875,7 +4922,7 @@ DEFUN (test_pim_receive_upcall, } /* Source address */ - source_str = argv[7]->arg; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &msg.im_src); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index 3566d28ff..fbf2262b8 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -97,10 +97,11 @@ DEFUN (debug_rip_packet_direct, "RIP receive packet\n" "RIP send packet\n") { + int idx_recv_send = 3; rip_debug_packet |= RIP_DEBUG_PACKET; - if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) rip_debug_packet |= RIP_DEBUG_SEND; - if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) rip_debug_packet |= RIP_DEBUG_RECV; return CMD_SUCCESS; } @@ -150,14 +151,15 @@ DEFUN (no_debug_rip_packet_direct, "RIP option set for receive packet\n" "RIP option set for send packet\n") { - if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0) + int idx_recv_send = 4; + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIP_DEBUG_RECV) rip_debug_packet &= ~RIP_DEBUG_SEND; else rip_debug_packet = 0; } - else if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0) + else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIP_DEBUG_SEND) rip_debug_packet &= ~RIP_DEBUG_RECV; diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 4ad750304..036edeac8 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -1225,19 +1225,20 @@ DEFUN (rip_network, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Interface name\n") { + int idx_ipv4_word = 1; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[1]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p); if (ret) ret = rip_enable_network_add ((struct prefix *) &p); else - ret = rip_enable_if_add (argv[1]->arg); + ret = rip_enable_if_add (argv[idx_ipv4_word]->arg); if (ret < 0) { - vty_out (vty, "There is a same network configuration %s%s", argv[1]->arg, + vty_out (vty, "There is a same network configuration %s%s", argv[idx_ipv4_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1254,19 +1255,20 @@ DEFUN (no_rip_network, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Interface name\n") { + int idx_ipv4_word = 2; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[2]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p); if (ret) ret = rip_enable_network_delete ((struct prefix *) &p); else - ret = rip_enable_if_delete (argv[2]->arg); + ret = rip_enable_if_delete (argv[idx_ipv4_word]->arg); if (ret < 0) { - vty_out (vty, "Can't find network configuration %s%s", argv[2]->arg, + vty_out (vty, "Can't find network configuration %s%s", argv[idx_ipv4_word]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1281,10 +1283,11 @@ DEFUN (rip_neighbor, "Specify a neighbor router\n" "Neighbor address\n") { + int idx_ipv4 = 1; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[1]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { @@ -1305,10 +1308,11 @@ DEFUN (no_rip_neighbor, "Specify a neighbor router\n" "Neighbor address\n") { + int idx_ipv4 = 2; int ret; struct prefix_ipv4 p; - ret = str2prefix_ipv4 (argv[2]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { @@ -1331,6 +1335,7 @@ DEFUN (ip_rip_receive_version, "RIP version 1\n" "RIP version 2\n") { + int idx_type = 4; struct interface *ifp; struct rip_interface *ri; @@ -1338,12 +1343,12 @@ DEFUN (ip_rip_receive_version, ri = ifp->info; /* Version 1. */ - if (atoi (argv[4]->arg) == 1) + if (atoi (argv[idx_type]->arg) == 1) { ri->ri_receive = RI_RIP_VERSION_1; return CMD_SUCCESS; } - if (atoi (argv[4]->arg) == 2) + if (atoi (argv[idx_type]->arg) == 2) { ri->ri_receive = RI_RIP_VERSION_2; return CMD_SUCCESS; @@ -1435,6 +1440,7 @@ DEFUN (ip_rip_send_version, "RIP version 1\n" "RIP version 2\n") { + int idx_type = 4; struct interface *ifp; struct rip_interface *ri; @@ -1442,12 +1448,12 @@ DEFUN (ip_rip_send_version, ri = ifp->info; /* Version 1. */ - if (atoi (argv[4]->arg) == 1) + if (atoi (argv[idx_type]->arg) == 1) { ri->ri_send = RI_RIP_VERSION_1; return CMD_SUCCESS; } - if (atoi (argv[4]->arg) == 2) + if (atoi (argv[idx_type]->arg) == 2) { ri->ri_send = RI_RIP_VERSION_2; return CMD_SUCCESS; @@ -1553,6 +1559,7 @@ DEFUN (ip_rip_authentication_mode, "Keyed message digest\n" "Clear text authentication\n") { + int idx_encryption = 4; struct interface *ifp; struct rip_interface *ri; int auth_type; @@ -1566,9 +1573,9 @@ DEFUN (ip_rip_authentication_mode, return CMD_WARNING; } - if (strncmp ("md5", argv[4]->arg, strlen (argv[4]->arg)) == 0) + if (strncmp ("md5", argv[idx_encryption]->arg, strlen (argv[idx_encryption]->arg)) == 0) auth_type = RIP_AUTH_MD5; - else if (strncmp ("text", argv[4]->arg, strlen (argv[4]->arg)) == 0) + else if (strncmp ("text", argv[idx_encryption]->arg, strlen (argv[idx_encryption]->arg)) == 0) auth_type = RIP_AUTH_SIMPLE_PASSWORD; else { @@ -1657,13 +1664,14 @@ DEFUN (ip_rip_authentication_string, "Authentication string\n" "Authentication string\n") { + int idx_line = 4; struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; - if (strlen (argv[4]->arg) > 16) + if (strlen (argv[idx_line]->arg) > 16) { vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s", VTY_NEWLINE); @@ -1679,7 +1687,7 @@ DEFUN (ip_rip_authentication_string, if (ri->auth_str) free (ri->auth_str); - ri->auth_str = strdup (argv[4]->arg); + ri->auth_str = strdup (argv[idx_line]->arg); return CMD_SUCCESS; } @@ -1728,6 +1736,7 @@ DEFUN (ip_rip_authentication_key_chain, "Authentication key-chain\n" "name of key-chain\n") { + int idx_line = 4; struct interface *ifp; struct rip_interface *ri; @@ -1744,7 +1753,7 @@ DEFUN (ip_rip_authentication_key_chain, if (ri->key_chain) free (ri->key_chain); - ri->key_chain = strdup (argv[4]->arg); + ri->key_chain = strdup (argv[idx_line]->arg); return CMD_SUCCESS; } @@ -1878,7 +1887,8 @@ DEFUN (rip_passive_interface, "Interface name\n" "default for all interfaces\n") { - const char *ifname = argv[1]->arg; + int idx_ifname = 1; + const char *ifname = argv[idx_ifname]->arg; if (!strcmp(ifname,"default")) { passive_default = 1; @@ -1899,7 +1909,8 @@ DEFUN (no_rip_passive_interface, "Interface name\n" "default for all interfaces\n") { - const char *ifname = argv[2]->arg; + int idx_ifname = 2; + const char *ifname = argv[idx_ifname]->arg; if (!strcmp(ifname,"default")) { passive_default = 0; diff --git a/ripd/rip_offset.c b/ripd/rip_offset.c index f57c6684e..5e0e71579 100644 --- a/ripd/rip_offset.c +++ b/ripd/rip_offset.c @@ -289,7 +289,10 @@ DEFUN (rip_offset_list, "For outgoing updates\n" "Metric value\n") { - return rip_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, NULL); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (rip_offset_list_ifname, @@ -302,7 +305,11 @@ DEFUN (rip_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return rip_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, argv[4]->arg); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + int idx_ifname = 4; + return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } DEFUN (no_rip_offset_list, @@ -315,7 +322,10 @@ DEFUN (no_rip_offset_list, "For outgoing updates\n" "Metric value\n") { - return rip_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (no_rip_offset_list_ifname, @@ -329,7 +339,11 @@ DEFUN (no_rip_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return rip_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + int idx_ifname = 5; + return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } static int diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index 35e869172..e16f2d941 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -742,7 +742,8 @@ DEFUN (match_metric, "Match metric of route\n" "Metric value\n") { - return rip_route_match_add (vty, vty->index, "metric", argv[2]->arg); + int idx_number = 2; + return rip_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg); } /* @@ -772,7 +773,8 @@ DEFUN (match_interface, "Match first hop interface of route\n" "Interface name\n") { - return rip_route_match_add (vty, vty->index, "interface", argv[2]->arg); + int idx_word = 2; + return rip_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg); } /* @@ -805,7 +807,8 @@ DEFUN (match_ip_next_hop, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - return rip_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg); + int idx_acl = 3; + return rip_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg); } /* @@ -841,7 +844,8 @@ DEFUN (match_ip_next_hop_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[4]->arg); + int idx_word = 4; + return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[idx_word]->arg); } /* @@ -879,7 +883,8 @@ DEFUN (match_ip_address, "IP Access-list name\n") { - return rip_route_match_add (vty, vty->index, "ip address", argv[3]->arg); + int idx_acl = 3; + return rip_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg); } /* @@ -915,7 +920,8 @@ DEFUN (match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { - return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[4]->arg); + int idx_word = 4; + return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[idx_word]->arg); } /* @@ -949,7 +955,8 @@ DEFUN (match_tag, "Match tag of route\n" "Metric value\n") { - return rip_route_match_add (vty, vty->index, "tag", argv[2]->arg); + int idx_number = 2; + return rip_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg); } /* @@ -989,7 +996,8 @@ DEFUN (set_metric, "Metric value for destination routing protocol\n" "Metric value\n") { - return rip_route_set_add (vty, vty->index, "metric", argv[2]->arg); + int idx_number = 2; + return rip_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg); } @@ -1028,10 +1036,11 @@ DEFUN (set_ip_nexthop, "Next hop address\n" "IP address of next hop\n") { + int idx_ipv4 = 3; union sockunion su; int ret; - ret = str2sockunion (argv[3]->arg, &su); + ret = str2sockunion (argv[idx_ipv4]->arg, &su); if (ret < 0) { vty_out (vty, "%% Malformed next-hop address%s", VTY_NEWLINE); @@ -1045,7 +1054,7 @@ DEFUN (set_ip_nexthop, return CMD_WARNING; } - return rip_route_set_add (vty, vty->index, "ip next-hop", argv[3]->arg); + return rip_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg); } /* @@ -1077,7 +1086,8 @@ DEFUN (set_tag, "Tag value for routing protocol\n" "Tag value\n") { - return rip_route_set_add (vty, vty->index, "tag", argv[2]->arg); + int idx_number = 2; + return rip_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); } /* diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 56f4623f3..3596938bb 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -417,20 +417,22 @@ DEFUN (rip_redistribute_type_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[1]->arg, + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { - rip_routemap_set (redist_type[i].type, argv[3]->arg); + rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, redist_type[i].type, 0, VRF_DEFAULT); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[1]->arg, + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -445,21 +447,23 @@ DEFUN (no_rip_redistribute_type_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; + int idx_word = 4; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[2]->arg, + 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[4]->arg)) + 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[2]->arg, + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -473,13 +477,15 @@ DEFUN (rip_redistribute_type_metric, "Metric\n" "Metric value\n") { + int idx_protocol = 1; + int idx_number = 3; int i; int metric; - metric = atoi (argv[3]->arg); + metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[1]->arg, + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { rip_redistribute_metric_set (redist_type[i].type, metric); @@ -489,7 +495,7 @@ DEFUN (rip_redistribute_type_metric, } } - vty_out(vty, "Invalid type %s%s", argv[1]->arg, + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -504,21 +510,23 @@ DEFUN (no_rip_redistribute_type_metric, "Metric\n" "Metric value\n") { + int idx_protocol = 2; + int idx_number = 4; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[2]->arg, + 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[4]->arg))) + 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[2]->arg, + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -534,24 +542,27 @@ DEFUN (rip_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int i; int metric; - metric = atoi (argv[3]->arg); + metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[1]->arg, + if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, redist_type[i].str_min_len) == 0) { rip_redistribute_metric_set (redist_type[i].type, metric); - rip_routemap_set (redist_type[i].type, argv[5]->arg); + rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, redist_type[i].type, 0, VRF_DEFAULT); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[1]->arg, + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -569,18 +580,21 @@ DEFUN (no_rip_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; + int idx_number = 4; + int idx_word = 6; int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[2]->arg, + 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[4]->arg))) + 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[6]->arg)) + if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg)) { - rip_redistribute_metric_set(redist_type[i].type, atoi(argv[4]->arg)); + rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg)); return CMD_WARNING; } rip_redistribute_unset (redist_type[i].type); @@ -588,7 +602,7 @@ DEFUN (no_rip_redistribute_type_metric_routemap, } } - vty_out(vty, "Invalid type %s%s", argv[2]->arg, + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; diff --git a/ripd/ripd.c b/ripd/ripd.c index 9fa11ef9a..a7f35de27 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2947,9 +2947,10 @@ DEFUN (rip_version, "Set routing protocol version\n" "version\n") { + int idx_number = 1; int version; - version = atoi (argv[1]->arg); + version = atoi (argv[idx_number]->arg); if (version != RIPv1 && version != RIPv2) { vty_out (vty, "invalid rip version %d%s", version, @@ -2960,7 +2961,7 @@ DEFUN (rip_version, rip->version_recv = version; return CMD_SUCCESS; -} +} /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN @@ -2981,7 +2982,7 @@ DEFUN (no_rip_version, rip->version_recv = RI_RIP_VERSION_1_AND_2; return CMD_SUCCESS; -} +} DEFUN (rip_route, @@ -2990,11 +2991,12 @@ DEFUN (rip_route, "RIP static route configuration\n" "IP prefix <network>/<length>\n") { + int idx_ipv4_prefixlen = 1; int ret; struct prefix_ipv4 p; struct route_node *node; - ret = str2prefix_ipv4 (argv[1]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret < 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -3026,11 +3028,12 @@ DEFUN (no_rip_route, "RIP static route configuration\n" "IP prefix <network>/<length>\n") { + int idx_ipv4_prefixlen = 2; int ret; struct prefix_ipv4 p; struct route_node *node; - ret = str2prefix_ipv4 (argv[2]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret < 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -3042,7 +3045,7 @@ DEFUN (no_rip_route, node = route_node_lookup (rip->route, (struct prefix *) &p); if (! node) { - vty_out (vty, "Can't find route %s.%s", argv[2]->arg, + vty_out (vty, "Can't find route %s.%s", argv[idx_ipv4_prefixlen]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -3079,9 +3082,10 @@ DEFUN (rip_default_metric, "Set a metric of redistribute routes\n" "Default metric\n") { + int idx_number = 1; if (rip) { - rip->default_metric = atoi (argv[1]->arg); + rip->default_metric = atoi (argv[idx_number]->arg); /* rip_update_default_metric (); */ } return CMD_SUCCESS; @@ -3120,6 +3124,9 @@ DEFUN (rip_timers, "Routing information timeout timer. Default is 180.\n" "Garbage collection timer. Default is 120.\n") { + int idx_number = 2; + int idx_number_2 = 3; + int idx_number_3 = 4; unsigned long update; unsigned long timeout; unsigned long garbage; @@ -3127,21 +3134,21 @@ DEFUN (rip_timers, unsigned long RIP_TIMER_MAX = 2147483647; unsigned long RIP_TIMER_MIN = 5; - update = strtoul (argv[2]->arg, &endptr, 10); + update = strtoul (argv[idx_number]->arg, &endptr, 10); if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN || *endptr != '\0') { vty_out (vty, "update timer value error%s", VTY_NEWLINE); return CMD_WARNING; } - timeout = strtoul (argv[3]->arg, &endptr, 10); + timeout = strtoul (argv[idx_number_2]->arg, &endptr, 10); if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN || *endptr != '\0') { vty_out (vty, "timeout timer value error%s", VTY_NEWLINE); return CMD_WARNING; } - garbage = strtoul (argv[4]->arg, &endptr, 10); + garbage = strtoul (argv[idx_number_3]->arg, &endptr, 10); if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN || *endptr != '\0') { vty_out (vty, "garbage timer value error%s", VTY_NEWLINE); @@ -3392,7 +3399,8 @@ DEFUN (rip_distance, "Administrative distance\n" "Distance value\n") { - rip->distance = atoi (argv[1]->arg); + int idx_number = 1; + rip->distance = atoi (argv[idx_number]->arg); return CMD_SUCCESS; } @@ -3414,7 +3422,9 @@ DEFUN (rip_distance_source, "Distance value\n" "IP source prefix\n") { - rip_distance_set (vty, argv[1]->arg, argv[2]->arg, NULL); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } @@ -3426,7 +3436,9 @@ DEFUN (no_rip_distance_source, "Distance value\n" "IP source prefix\n") { - rip_distance_unset (vty, argv[2]->arg, argv[3]->arg, NULL); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); return CMD_SUCCESS; } @@ -3438,7 +3450,10 @@ DEFUN (rip_distance_source_access_list, "IP source prefix\n" "Access list name\n") { - rip_distance_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg); + int idx_number = 1; + int idx_ipv4_prefixlen = 2; + int idx_word = 3; + rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } @@ -3451,7 +3466,10 @@ DEFUN (no_rip_distance_source_access_list, "IP source prefix\n" "Access list name\n") { - rip_distance_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg); + int idx_number = 2; + int idx_ipv4_prefixlen = 3; + int idx_word = 4; + rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); return CMD_SUCCESS; } diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index ecbba5b30..de5367261 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -98,10 +98,11 @@ DEFUN (debug_ripng_packet_direct, "Debug option set for receive packet\n" "Debug option set for send packet\n") { + int idx_recv_send = 3; ripng_debug_packet |= RIPNG_DEBUG_PACKET; - if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) ripng_debug_packet |= RIPNG_DEBUG_SEND; - if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) ripng_debug_packet |= RIPNG_DEBUG_RECV; return CMD_SUCCESS; @@ -152,14 +153,15 @@ DEFUN (no_debug_ripng_packet_direct, "Debug option set for receive packet\n" "Debug option set for send packet\n") { - if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0) + int idx_recv_send = 4; + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIPNG_DEBUG_RECV) ripng_debug_packet &= ~RIPNG_DEBUG_SEND; else ripng_debug_packet = 0; } - else if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0) + else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) { if (IS_RIPNG_DEBUG_SEND) ripng_debug_packet &= ~RIPNG_DEBUG_RECV; diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 930752abd..9c434c8df 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -953,20 +953,21 @@ DEFUN (ripng_network, "RIPng enable on specified interface or network.\n" "Interface or address") { + int idx_if_or_addr = 1; int ret; struct prefix p; - ret = str2prefix (argv[1]->arg, &p); + ret = str2prefix (argv[idx_if_or_addr]->arg, &p); /* Given string is IPv6 network or interface name. */ if (ret) ret = ripng_enable_network_add (&p); else - ret = ripng_enable_if_add (argv[1]->arg); + ret = ripng_enable_if_add (argv[idx_if_or_addr]->arg); if (ret < 0) { - vty_out (vty, "There is same network configuration %s%s", argv[1]->arg, + vty_out (vty, "There is same network configuration %s%s", argv[idx_if_or_addr]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -982,20 +983,21 @@ DEFUN (no_ripng_network, "RIPng enable on specified interface or network.\n" "Interface or address") { + int idx_if_or_addr = 2; int ret; struct prefix p; - ret = str2prefix (argv[2]->arg, &p); + ret = str2prefix (argv[idx_if_or_addr]->arg, &p); /* Given string is interface name. */ if (ret) ret = ripng_enable_network_delete (&p); else - ret = ripng_enable_if_delete (argv[2]->arg); + ret = ripng_enable_if_delete (argv[idx_if_or_addr]->arg); if (ret < 0) { - vty_out (vty, "can't find network %s%s", argv[2]->arg, + vty_out (vty, "can't find network %s%s", argv[idx_if_or_addr]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1073,7 +1075,8 @@ DEFUN (ripng_passive_interface, "Suppress routing updates on an interface\n" "Interface name\n") { - return ripng_passive_interface_set (vty, argv[1]->arg); + int idx_ifname = 1; + return ripng_passive_interface_set (vty, argv[idx_ifname]->arg); } DEFUN (no_ripng_passive_interface, @@ -1083,7 +1086,8 @@ DEFUN (no_ripng_passive_interface, "Suppress routing updates on an interface\n" "Interface name\n") { - return ripng_passive_interface_unset (vty, argv[2]->arg); + int idx_ifname = 2; + return ripng_passive_interface_unset (vty, argv[idx_ifname]->arg); } static struct ripng_interface * diff --git a/ripngd/ripng_offset.c b/ripngd/ripng_offset.c index 46ca818c4..dcddf96eb 100644 --- a/ripngd/ripng_offset.c +++ b/ripngd/ripng_offset.c @@ -297,7 +297,10 @@ DEFUN (ripng_offset_list, "For outgoing updates\n" "Metric value\n") { - return ripng_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, NULL); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (ripng_offset_list_ifname, @@ -310,7 +313,11 @@ DEFUN (ripng_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return ripng_offset_list_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg, argv[4]->arg); + int idx_word = 1; + int idx_in_out = 2; + int idx_number = 3; + int idx_ifname = 4; + return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } DEFUN (no_ripng_offset_list, @@ -323,7 +330,10 @@ DEFUN (no_ripng_offset_list, "For outgoing updates\n" "Metric value\n") { - return ripng_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL); } DEFUN (no_ripng_offset_list_ifname, @@ -337,7 +347,11 @@ DEFUN (no_ripng_offset_list_ifname, "Metric value\n" "Interface to match\n") { - return ripng_offset_list_unset (vty, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg); + int idx_word = 2; + int idx_in_out = 3; + int idx_number = 4; + int idx_ifname = 5; + return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg); } static int diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index 0910f94a7..9e2c35b38 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -507,7 +507,8 @@ DEFUN (match_metric, "Match metric of route\n" "Metric value\n") { - return ripng_route_match_add (vty, vty->index, "metric", argv[2]->arg); + int idx_number = 2; + return ripng_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg); } /* @@ -537,7 +538,8 @@ DEFUN (match_interface, "Match first hop interface of route\n" "Interface name\n") { - return ripng_route_match_add (vty, vty->index, "interface", argv[2]->arg); + int idx_word = 2; + return ripng_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg); } /* @@ -567,7 +569,8 @@ DEFUN (match_tag, "Match tag of route\n" "Metric value\n") { - return ripng_route_match_add (vty, vty->index, "tag", argv[2]->arg); + int idx_number = 2; + return ripng_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg); } /* @@ -599,7 +602,8 @@ DEFUN (set_metric, "Metric value for destination routing protocol\n" "Metric value\n") { - return ripng_route_set_add (vty, vty->index, "metric", argv[2]->arg); + int idx_number = 2; + return ripng_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg); } /* @@ -631,10 +635,11 @@ DEFUN (set_ipv6_nexthop_local, "IPv6 local address\n" "IPv6 address of next hop\n") { + int idx_ipv6 = 4; union sockunion su; int ret; - ret = str2sockunion (argv[4]->arg, &su); + ret = str2sockunion (argv[idx_ipv6]->arg, &su); if (ret < 0) { vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE); @@ -647,7 +652,7 @@ DEFUN (set_ipv6_nexthop_local, return CMD_WARNING; } - return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[4]->arg); + return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg); } /* @@ -681,7 +686,8 @@ DEFUN (set_tag, "Tag value for routing protocol\n" "Tag value\n") { - return ripng_route_set_add (vty, vty->index, "tag", argv[2]->arg); + int idx_number = 2; + return ripng_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); } /* diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index e45521195..a6dc20072 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -400,15 +400,17 @@ DEFUN (ripng_redistribute_type_metric, "Metric\n" "Metric value\n") { + int idx_protocol = 1; + int idx_number = 3; int type; int metric; - metric = atoi (argv[3]->arg); - type = proto_redistnum(AFI_IP6, argv[1]->arg); + metric = atoi (argv[idx_number]->arg); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -427,17 +429,19 @@ DEFUN (ripng_redistribute_type_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; int type; - type = proto_redistnum(AFI_IP6, argv[1]->arg); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; } - ripng_redistribute_routemap_set (type, argv[3]->arg); + ripng_redistribute_routemap_set (type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); return CMD_SUCCESS; @@ -454,20 +458,23 @@ DEFUN (ripng_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int type; int metric; - type = proto_redistnum(AFI_IP6, argv[1]->arg); - metric = atoi (argv[3]->arg); + type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg); + metric = atoi (argv[idx_number]->arg); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE); return CMD_WARNING; } ripng_redistribute_metric_set (type, metric); - ripng_redistribute_routemap_set (type, argv[5]->arg); + ripng_redistribute_routemap_set (type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT); return CMD_SUCCESS; } diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 5e53d44b6..d3944c1c7 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -2261,11 +2261,12 @@ DEFUN (ripng_route, "Static route setup\n" "Set static RIPng route announcement\n") { + int idx_ipv6addr = 1; int ret; struct prefix_ipv6 p; struct route_node *rp; - ret = str2prefix_ipv6 (argv[1]->arg, (struct prefix_ipv6 *)&p); + ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2294,11 +2295,12 @@ DEFUN (no_ripng_route, "Static route setup\n" "Delete static RIPng route announcement\n") { + int idx_ipv6addr = 2; int ret; struct prefix_ipv6 p; struct route_node *rp; - ret = str2prefix_ipv6 (argv[2]->arg, (struct prefix_ipv6 *)&p); + ret = str2prefix_ipv6 (argv[idx_ipv6addr]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2328,11 +2330,12 @@ DEFUN (ripng_aggregate_address, "Set aggregate RIPng route announcement\n" "Aggregate network\n") { + int idx_ipv6_prefixlen = 1; int ret; struct prefix p; struct route_node *node; - ret = str2prefix_ipv6 (argv[1]->arg, (struct prefix_ipv6 *)&p); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *)&p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2361,11 +2364,12 @@ DEFUN (no_ripng_aggregate_address, "Delete aggregate RIPng route announcement\n" "Aggregate network") { + int idx_ipv6_prefixlen = 2; int ret; struct prefix p; struct route_node *rn; - ret = str2prefix_ipv6 (argv[2]->arg, (struct prefix_ipv6 *) &p); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, (struct prefix_ipv6 *) &p); if (ret <= 0) { vty_out (vty, "Malformed address%s", VTY_NEWLINE); @@ -2393,9 +2397,10 @@ DEFUN (ripng_default_metric, "Set a metric of redistribute routes\n" "Default metric\n") { + int idx_number = 1; if (ripng) { - ripng->default_metric = atoi (argv[1]->arg); + ripng->default_metric = atoi (argv[idx_number]->arg); } return CMD_SUCCESS; } @@ -2535,13 +2540,16 @@ DEFUN (ripng_timers, "Routing information timeout timer. Default is 180.\n" "Garbage collection timer. Default is 120.\n") { + int idx_number = 2; + int idx_number_2 = 3; + int idx_number_3 = 4; unsigned long update; unsigned long timeout; unsigned long garbage; - VTY_GET_INTEGER_RANGE("update timer", update, argv[2]->arg, 0, 65535); - VTY_GET_INTEGER_RANGE("timeout timer", timeout, argv[3]->arg, 0, 65535); - VTY_GET_INTEGER_RANGE("garbage timer", garbage, argv[4]->arg, 0, 65535); + VTY_GET_INTEGER_RANGE("update timer", update, argv[idx_number]->arg, 0, 65535); + VTY_GET_INTEGER_RANGE("timeout timer", timeout, argv[idx_number_2]->arg, 0, 65535); + VTY_GET_INTEGER_RANGE("garbage timer", garbage, argv[idx_number_3]->arg, 0, 65535); /* Set each timer value. */ ripng->update_time = update; diff --git a/tools/argv_translator.py b/tools/argv_translator.py index 4ee0831ed..b637cf69f 100755 --- a/tools/argv_translator.py +++ b/tools/argv_translator.py @@ -4,6 +4,7 @@ import re import sys import os import subprocess +from collections import OrderedDict from copy import deepcopy from pprint import pformat, pprint @@ -156,7 +157,7 @@ def get_argv_translator(line_number, line): return table ''' -def get_argv_variable_indexes(line_number, line): +def get_command_string_variable_indexes(line_number, line): indexes = {} line = line.strip() @@ -177,6 +178,359 @@ def get_argv_variable_indexes(line_number, line): return (max_index, indexes) +def get_token_index_variable_name(line_number, token): + + re_range = re.search('\(\d+-\d+\)', token) + + if token.startswith('['): + assert token.endswith(']'), "Token %s should end with ]" % token + token = token[1:-1] + + if token.startswith('<'): + assert token.endswith('>'), "Token %s should end with >" % token + token = token[1:-1] + + if token == 'A.B.C.D': + return 'idx_ipv4' + + elif token == 'A.B.C.D/M': + return 'idx_ipv4_prefixlen' + + elif token == 'X:X::X:X': + return 'idx_ipv6' + + elif token == 'X:X::X:X/M': + return 'idx_ipv6_prefixlen' + + elif token == 'ASN:nn_or_IP-address:nn': + return 'idx_ext_community' + + elif token == '.AA:NN': + return 'idx_community' + + elif token == 'WORD': + return 'idx_word' + + elif token == 'json': + return 'idx_json' + + elif token == '.LINE': + return 'idx_regex' + + elif token == 'A.B.C.D|INTERFACE': + return 'idx_ipv4_ifname' + + elif token == 'A.B.C.D|INTERFACE|null0': + return 'idx_ipv4_ifname_null' + + elif token == 'X:X::X:X|INTERFACE': + return 'idx_ipv6_ifname' + + elif token == 'reject|blackhole': + return 'idx_reject_blackhole' + + elif token == 'route-map NAME': + return 'idx_route_map' + + elif token == 'recv|send|detail': + return 'idx_recv_send' + + elif token == 'recv|send': + return 'idx_recv_send' + + elif token == 'up|down': + return 'idx_up_down' + + elif token == 'off-link': + return 'idx_off_link' + + elif token == 'no-autoconfig': + return 'idx_no_autoconfig' + + elif token == 'router-address': + return 'idx_router_address' + + elif token == 'high|medium|low': + return 'idx_high_medium_low' + + elif token == '(0-4294967295)|infinite': + return 'idx_number_infinite' + + elif token == '(1-199)|(1300-2699)|WORD': + return 'idx_acl' + + elif token == 'A.B.C.D|X:X::X:X': + return 'idx_ip' + + elif token == 'in|out': + return 'idx_in_out' + + elif token == 'deny|permit': + return 'idx_permit_deny' + + elif token == 'view|vrf': + return 'idx_view_vrf' + + elif token == 'unicast|multicast': + return 'idx_safi' + + elif token == 'bestpath|multipath': + return 'idx_bestpath' + + elif token == 'egp|igp|incomplete': + return 'idx_origin' + + elif token == 'cisco|zebra' or token == 'cisco|ibm|shortcut|standard': + return 'idx_vendor' + + elif token == 'as-set|no-as-set': + return 'idx_as_set' + + elif token == 'confed|missing-as-worst': + return 'idx_med_knob' + + elif token == 'both|send|receive' or token == 'send|recv': + return 'idx_send_recv' + + elif token == 'both|extended|standard' or token == '1|2': + return 'idx_type' + + elif token == 'A.B.C.D|WORD' or token == 'A.B.C.D/M|WORD': + return 'idx_ipv4_word' + + elif token == 'advertise-queue|advertised-routes|packet-queue': + return 'idx_type' + + elif token == 'ospf|table': + return 'idx_ospf_table' + + elif token == 'as-path|next-hop|med' or token == 'next-hop|med' or token == 'as-path|med' or token == 'as-path|next-hop': + return 'idx_attribute' + + elif token == '(1-4294967295)|external|internal' or token == '(1-4294967295)|internal|external': + return 'idx_remote_as' + + elif token == '(1-500)|WORD' or token == '(1-99)|(100-500)|WORD': + return 'idx_comm_list' + + elif token == 'ipv4|ipv6' or token == 'ip|ipv6': + return 'idx_afi' + + elif token == 'md5|clear' or token == 'null|message-digest' or token == 'md5|text': + return 'idx_encryption' + + elif token == 'IFNAME|default': + return 'idx_ifname' + + elif token == 'type-1|type-2': + return 'idx_external' + + elif token == 'table|intra-area|inter-area|memory': + return 'idx_type' + + elif token == 'translate-candidate|translate-never|translate-always': + return 'idx_translate' + + elif token == 'intra-area (1-255)|inter-area (1-255)|external (1-255)': + return 'idx_area_distance' + + elif token == 'metric (0-16777214)|metric-type <1|2>|route-map WORD' or token == 'always|metric (0-16777214)|metric-type <1|2>|route-map WORD': + return 'idx_redist_param' + + elif token == 'default|enable|disable' or token == 'enable|disable': + return 'idx_enable_disable' + + elif token == 'unknown|hello|dbdesc|lsreq|lsupdate|lsack|all' or token == 'hello|dd|ls-request|ls-update|ls-ack|all': + return 'idx_packet' + + elif token == 'router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown' or token == 'intra-area|inter-area|external-1|external-2' or token == 'router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix' or token == 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as': + return 'idx_lsa' + + elif token == 'broadcast|point-to-point' or token == 'broadcast|non-broadcast|point-to-multipoint|point-to-point': + return 'idx_network' + + elif token == 'A.B.C.D|(0-4294967295)': + return 'idx_ipv4_number' + + elif token == 'narrow|transition|wide': + return 'idx_metric_style' + + elif token == 'area-password|domain-password': + return 'idx_password' + + elif token == 'param': + return 'idx_param' + + elif token == 'advertised-routes|received-routes': + return 'idx_adv_rcvd_routes' + + elif token == 'encap|multicast|unicast|vpn' or token == 'unicast|multicast|vpn|encap': + return 'idx_safi' + + elif token == 'AA:NN|local-AS|no-advertise|no-export': + return 'idx_community' + + elif token == 'all|all-et|updates|updates-et|routes-mrt': + return 'idx_dump_routes' + + elif token == 'A.B.C.D|X:X::X:X|WORD': + return 'idx_peer' + + elif token == 'A.B.C.D/M|X:X::X:X/M': + return 'idx_ipv4_ipv6_prefixlen' + + elif token == 'level-1|level-2' or token == 'level-1|level-1-2|level-2-only': + return 'idx_level' + + elif token == 'metric (0-16777215)|route-map WORD' or token == 'always|metric (0-16777215)|route-map WORD': + return 'idx_metric_rmap' + + elif token == 'urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix': + return 'idx_rpf_lookup_mode' + + elif token == 'hello|joins': + return 'idx_hello_join' + + elif token == 'nocache|wrongvif|wholepkt': + return 'idx_type' + + elif token in ('kernel|connected|static|rip|ospf|isis|pim|table', + 'kernel|connected|static|ripng|ospf6|isis|table', + 'kernel|connected|static|rip|isis|bgp|pim|table', + 'kernel|connected|static|rip|ospf|isis|bgp|pim|table', + 'kernel|connected|static|rip|ospf|isis|bgp|pim|table', + 'kernel|connected|static|rip|ospf|isis|bgp|pim|table|any', + 'kernel|connected|static|ripng|ospf6|isis|bgp|table|any', + 'kernel|connected|static|ripng|ospf6|isis|bgp|table', + 'kernel|connected|static|ospf6|isis|bgp|table', + 'kernel|connected|static|ospf|isis|bgp|pim|table', + 'kernel|connected|static|ripng|isis|bgp|table', + # '', + 'bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static', + 'kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table'): + return 'idx_protocol' + + elif '|' in token: + raise Exception("%d: what variable name for %s" % (line_number, token)) + + elif re_range: + return 'idx_number' + + elif token.upper() == token: + return 'idx_%s' % token.lower() + + else: + raise Exception("%d: what variable name for %s" % (line_number, token)) + + +def get_command_string_index_variable_table(line_number, line): + """ + Return a table that maps an index position to a variable name such as 'idx_ipv4' + """ + indexes = OrderedDict() + + line = line.strip() + assert line.startswith('"'), "line does not start with \"\n%s" % (line) + assert line.endswith('",'), "line does not end with \",\n%s" % (line) + line = line[1:-2] + max_index = 0 + + for (token_index, token) in enumerate(line_to_tokens(line_number, line)): + if not token: + raise Exception("%d: empty token" % line_number) + + if token_is_variable(line_number, token): + # print "%s is a token" % token + idx_variable_name = get_token_index_variable_name(line_number, token) + count = 0 + for tmp in indexes.itervalues(): + if tmp == idx_variable_name: + count += 1 + elif re.search('^%s_\d+' % idx_variable_name, tmp): + count += 1 + if count: + idx_variable_name = "%s_%d" % (idx_variable_name, count + 1) + indexes[token_index] = idx_variable_name + + return indexes + +def expand_command_string(line): + + # in the middle + line = line.replace('" CMD_AS_RANGE "', '(1-4294967295)') + line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE "', '(1-5000)') + line = line.replace('" BGP_INSTANCE_CMD "', '<view|vrf> WORD') + line = line.replace('" BGP_INSTANCE_ALL_CMD "', '<view|vrf> all') + line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM) "', '(1-255)') + line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD "', '<kernel|connected|static|rip|ospf|isis|pim|table>') + line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD "', '<kernel|connected|static|ripng|ospf6|isis|table>') + line = line.replace('" OSPF_LSA_TYPES_CMD_STR "', 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as') + line = line.replace('" QUAGGA_REDIST_STR_OSPFD "', '<kernel|connected|static|rip|isis|bgp|pim|table>') + line = line.replace('" VRF_CMD_STR "', 'vrf NAME') + line = line.replace('" VRF_ALL_CMD_STR "', 'vrf all') + line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA "', '<kernel|connected|static|rip|ospf|isis|bgp|pim|table|any>') + line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA "', '<kernel|connected|static|ripng|ospf6|isis|bgp|table|any>') + line = line.replace('" QUAGGA_REDIST_STR_RIPNGD "', '<kernel|connected|static|ospf6|isis|bgp|table>') + line = line.replace('" QUAGGA_REDIST_STR_RIPD "', '<kernel|connected|static|ospf|isis|bgp|pim|table>') + line = line.replace('" QUAGGA_REDIST_STR_OSPF6D "', '<kernel|connected|static|ripng|isis|bgp|table>') + line = line.replace('" QUAGGA_REDIST_STR_ISISD "', '<kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table>') + line = line.replace('" LOG_FACILITIES "', '<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>') + + # endswith + line = line.replace('" CMD_AS_RANGE,', ' (1-4294967295)",') + line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE,', ' (1-5000)",') + line = line.replace('" BGP_INSTANCE_CMD,', ' <view|vrf> WORD",') + line = line.replace('" BGP_INSTANCE_ALL_CMD,', ' <view|vrf> all",') + line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM),', '(1-255)",') + line = line.replace('" CMD_RANGE_STR(1, MAXTTL),', '(1-255)",') + line = line.replace('" BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,', '(2-255) (50-60000) (50-60000)",') + line = line.replace('" OSPF_LSA_TYPES_CMD_STR,', + ' asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as",') + line = line.replace('" BGP_UPDATE_SOURCE_REQ_STR,', ' <A.B.C.D|X:X::X:X|WORD>",') + line = line.replace('" BGP_UPDATE_SOURCE_OPT_STR,', ' [A.B.C.D|X:X::X:X|WORD]",') + line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD,', ' <kernel|connected|static|rip|ospf|isis|pim|table>",') + line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD,', ' <kernel|connected|static|ripng|ospf6|isis|table>",') + line = line.replace('" QUAGGA_REDIST_STR_OSPFD,', ' <kernel|connected|static|rip|isis|bgp|pim|table>",') + line = line.replace('" VRF_CMD_STR,', ' vrf NAME",') + line = line.replace('" VRF_ALL_CMD_STR,', ' vrf all",') + line = line.replace('" QUAGGA_IP_REDIST_STR_ZEBRA,', ' <kernel|connected|static|rip|ospf|isis|bgp|pim|table>",') + line = line.replace('" QUAGGA_IP6_REDIST_STR_ZEBRA,', ' <kernel|connected|static|ripng|ospf6|isis|bgp|table>",') + line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA,', ' <kernel|connected|static|rip|ospf|isis|bgp|pim|table|any>",') + line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA,', ' <kernel|connected|static|ripng|ospf6|isis|bgp|table|any>",') + line = line.replace('" QUAGGA_REDIST_STR_RIPNGD,', ' <kernel|connected|static|ospf6|isis|bgp|table>",') + line = line.replace('" QUAGGA_REDIST_STR_RIPD,', ' <kernel|connected|static|ospf|isis|bgp|pim|table>",') + line = line.replace('" PIM_CMD_IP_MULTICAST_ROUTING,', ' ip multicast-routing",') + line = line.replace('" PIM_CMD_IP_IGMP_QUERY_INTERVAL,', ' ip igmp query-interval",') + line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,', ' ip igmp query-max-response-time-dsec",') + line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,', ' ip igmp query-max-response-time",') + line = line.replace('" QUAGGA_REDIST_STR_OSPF6D,', ' <kernel|connected|static|ripng|isis|bgp|table>",') + line = line.replace('" QUAGGA_REDIST_STR_ISISD,', ' <kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table>",') + line = line.replace('" LOG_FACILITIES,', ' <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",') + + # startswith + line = line.replace('LISTEN_RANGE_CMD "', '"bgp listen range <A.B.C.D/M|X:X::X:X/M> ') + line = line.replace('NO_NEIGHBOR_CMD2 "', '"no neighbor <A.B.C.D|X:X::X:X|WORD> ') + line = line.replace('NEIGHBOR_CMD2 "', '"neighbor <A.B.C.D|X:X::X:X|WORD> ') + line = line.replace('NO_NEIGHBOR_CMD "', '"no neighbor <A.B.C.D|X:X::X:X> ') + line = line.replace('NEIGHBOR_CMD "', '"neighbor <A.B.C.D|X:X::X:X> ') + line = line.replace('PIM_CMD_NO "', '"no ') + line = line.replace('PIM_CMD_IP_IGMP_QUERY_INTERVAL "', '"ip igmp query-interval ') + line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "', '"ip igmp query-max-response-time ') + line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "', '"ip igmp query-max-response-time-dsec ') + + # solo + line = line.replace('NO_NEIGHBOR_CMD2,', '"no neighbor <A.B.C.D|X:X::X:X|WORD>",') + line = line.replace('NEIGHBOR_CMD2,', '"neighbor <A.B.C.D|X:X::X:X|WORD>",') + line = line.replace('NO_NEIGHBOR_CMD,', '"no neighbor <A.B.C.D|X:X::X:X>",') + line = line.replace('NEIGHBOR_CMD,', '"neighbor <A.B.C.D|X:X::X:X>",') + line = line.replace('PIM_CMD_IP_MULTICAST_ROUTING,', '"ip multicast-routing",') + + if line.rstrip().endswith('" ,'): + line = line.replace('" ,', '",') + + return line + + class DEFUN(object): def __init__(self, line_number, command_string_expanded, lines): @@ -216,14 +570,14 @@ DEFUN (no_bgp_maxmed_onstartup, elif state == 'HELP': if line.strip() == '{': - self.guts.append(line) + # self.guts.append(line) state = 'BODY' else: self.help_strings.append(line) elif state == 'BODY': if line.rstrip() == '}': - self.guts.append(line) + # self.guts.append(line) state = None else: self.guts.append(line) @@ -239,7 +593,7 @@ DEFUN (no_bgp_maxmed_onstartup, return self.name def sanity_check(self): - (max_index, variable_indexes) = get_argv_variable_indexes(self.line_number, self.command_string_expanded) + (max_index, variable_indexes) = get_command_string_variable_indexes(self.line_number, self.command_string_expanded) # sanity check that each argv index matches a variable in the command string for line in self.guts: @@ -256,7 +610,6 @@ DEFUN (no_bgp_maxmed_onstartup, def get_new_command_string(self): line = self.command_string - # dwalton # Change <1-255> to (1-255) # Change (foo|bar) to <foo|bar> # Change {wazzup} to [wazzup]....there shouldn't be many of these @@ -284,16 +637,66 @@ DEFUN (no_bgp_maxmed_onstartup, line = re_space.group(1) + ' '.join(line.split()) + re_space.group(2) return line + def get_used_idx_variables(self, idx_table): + used = {} + + # sanity check that each argv index matches a variable in the command string + for line in self.guts: + if 'argv[' in line and '->arg' in line: + tmp_line = deepcopy(line) + re_argv = re.search('^.*?argv\[(\w+)\]->arg(.*)$', tmp_line) + + while re_argv: + index = re_argv.group(1) + + if index.isdigit(): + index = int(index) + if index in idx_table: + used[index] = idx_table[index] + else: + print "%d: could not find idx variable for %d" % (self.line_number, index) + else: + for (key, value) in idx_table.iteritems(): + if value == index: + used[key] = value + break + + tmp_line = re_argv.group(2) + re_argv = re.search('^.*?argv\[(\w+)\]->arg(.*)$', tmp_line) + + return used + def dump(self): + new_command_string = self.get_new_command_string() + new_command_string_expanded = expand_command_string(new_command_string) lines = [] lines.append("DEFUN (%s,\n" % self.name) lines.append(" %s,\n" % self.name_cmd) - lines.append(self.get_new_command_string()) + lines.append(new_command_string) lines.extend(self.help_strings) - lines.extend(self.guts) - return ''.join(lines) + lines.append('{\n') + # only print the variables that will be used else we get a compile error + idx_table = get_command_string_index_variable_table(self.line_number, new_command_string_expanded) + idx_table_used = self.get_used_idx_variables(idx_table) + for index in sorted(idx_table_used.keys()): + idx_variable = idx_table_used[index] + lines.append(" int %s = %d;\n" % (idx_variable, index)) + + # sanity check that each argv index matches a variable in the command string + for line in self.guts: + if line.startswith(' int idx_'): + pass + elif 'argv[' in line and '->arg' in line: + for (index, idx_variable) in idx_table.iteritems(): + line = line.replace("argv[%d]->arg" % index, "argv[%s]->arg" % idx_variable) + lines.append(line) + else: + lines.append(line) + + lines.append('}\n') + return ''.join(lines) def update_argvs(filename): @@ -334,78 +737,7 @@ def update_argvs(filename): state = 'DEFUN_BODY' elif line_number == defun_line_number + 2: - - # in the middle - line = line.replace('" CMD_AS_RANGE "', '<1-4294967295>') - line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE "', '<1-5000>') - line = line.replace('" BGP_INSTANCE_CMD "', '(view|vrf) WORD') - line = line.replace('" BGP_INSTANCE_ALL_CMD "', '(view|vrf) all') - line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM) "', '<1-255>') - line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD "', '(kernel|connected|static|rip|ospf|isis|pim|table)') - line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD "', '(kernel|connected|static|ripng|ospf6|isis|table)') - line = line.replace('" OSPF_LSA_TYPES_CMD_STR "', 'asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as') - line = line.replace('" QUAGGA_REDIST_STR_OSPFD "', '(kernel|connected|static|rip|isis|bgp|pim|table)') - line = line.replace('" VRF_CMD_STR "', 'vrf NAME') - line = line.replace('" VRF_ALL_CMD_STR "', 'vrf all') - line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA "', '(kernel|connected|static|rip|ospf|isis|bgp|pim|table|any)') - line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA "', '(kernel|connected|static|ripng|ospf6|isis|bgp|table|any)') - line = line.replace('" QUAGGA_REDIST_STR_RIPNGD "', '(kernel|connected|static|ospf6|isis|bgp|table)') - line = line.replace('" QUAGGA_REDIST_STR_RIPD "', '(kernel|connected|static|ospf|isis|bgp|pim|table)') - line = line.replace('" QUAGGA_REDIST_STR_OSPF6D "', '(kernel|connected|static|ripng|isis|bgp|table)') - line = line.replace('" QUAGGA_REDIST_STR_ISISD "', '(kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table)') - line = line.replace('" LOG_FACILITIES "', '(kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)') - - # endswith - line = line.replace('" CMD_AS_RANGE,', ' <1-4294967295>",') - line = line.replace('" DYNAMIC_NEIGHBOR_LIMIT_RANGE,', ' <1-5000>",') - line = line.replace('" BGP_INSTANCE_CMD,', ' (view|vrf) WORD",') - line = line.replace('" BGP_INSTANCE_ALL_CMD,', ' (view|vrf) all",') - line = line.replace('" CMD_RANGE_STR(1, MULTIPATH_NUM),', '<1-255>",') - line = line.replace('" CMD_RANGE_STR(1, MAXTTL),', '<1-255>",') - line = line.replace('" BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,', '<2-255> <50-60000> <50-60000>",') - line = line.replace('" OSPF_LSA_TYPES_CMD_STR,', - ' asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as",') - line = line.replace('" BGP_UPDATE_SOURCE_REQ_STR,', ' (A.B.C.D|X:X::X:X|WORD)",') - line = line.replace('" BGP_UPDATE_SOURCE_OPT_STR,', ' {A.B.C.D|X:X::X:X|WORD}",') - line = line.replace('" QUAGGA_IP_REDIST_STR_BGPD,', ' (kernel|connected|static|rip|ospf|isis|pim|table)",') - line = line.replace('" QUAGGA_IP6_REDIST_STR_BGPD,', ' (kernel|connected|static|ripng|ospf6|isis|table)",') - line = line.replace('" QUAGGA_REDIST_STR_OSPFD,', ' (kernel|connected|static|rip|isis|bgp|pim|table)",') - line = line.replace('" VRF_CMD_STR,', ' vrf NAME",') - line = line.replace('" VRF_ALL_CMD_STR,', ' vrf all",') - line = line.replace('" QUAGGA_IP_REDIST_STR_ZEBRA,', ' (kernel|connected|static|rip|ospf|isis|bgp|pim|table)",') - line = line.replace('" QUAGGA_IP6_REDIST_STR_ZEBRA,', ' (kernel|connected|static|ripng|ospf6|isis|bgp|table)",') - line = line.replace('" QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA,', ' (kernel|connected|static|rip|ospf|isis|bgp|pim|table|any)",') - line = line.replace('" QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA,', ' (kernel|connected|static|ripng|ospf6|isis|bgp|table|any)",') - line = line.replace('" QUAGGA_REDIST_STR_RIPNGD,', ' (kernel|connected|static|ospf6|isis|bgp|table)",') - line = line.replace('" QUAGGA_REDIST_STR_RIPD,', ' (kernel|connected|static|ospf|isis|bgp|pim|table)",') - line = line.replace('" PIM_CMD_IP_MULTICAST_ROUTING,', ' ip multicast-routing",') - line = line.replace('" PIM_CMD_IP_IGMP_QUERY_INTERVAL,', ' ip igmp query-interval",') - line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,', ' ip igmp query-max-response-time-dsec",') - line = line.replace('" PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,', ' ip igmp query-max-response-time",') - line = line.replace('" QUAGGA_REDIST_STR_OSPF6D,', ' (kernel|connected|static|ripng|isis|bgp|table)",') - line = line.replace('" QUAGGA_REDIST_STR_ISISD,', ' (kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table)",') - line = line.replace('" LOG_FACILITIES,', ' (kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)",') - - # startswith - line = line.replace('LISTEN_RANGE_CMD "', '"bgp listen range (A.B.C.D/M|X:X::X:X/M) ') - line = line.replace('NO_NEIGHBOR_CMD2 "', '"no neighbor (A.B.C.D|X:X::X:X|WORD) ') - line = line.replace('NEIGHBOR_CMD2 "', '"neighbor (A.B.C.D|X:X::X:X|WORD) ') - line = line.replace('NO_NEIGHBOR_CMD "', '"no neighbor (A.B.C.D|X:X::X:X) ') - line = line.replace('NEIGHBOR_CMD "', '"neighbor (A.B.C.D|X:X::X:X) ') - line = line.replace('PIM_CMD_NO "', '"no ') - line = line.replace('PIM_CMD_IP_IGMP_QUERY_INTERVAL "', '"ip igmp query-interval ') - line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "', '"ip igmp query-max-response-time ') - line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "', '"ip igmp query-max-response-time-dsec ') - - # solo - line = line.replace('NO_NEIGHBOR_CMD2,', '"no neighbor (A.B.C.D|X:X::X:X|WORD)",') - line = line.replace('NEIGHBOR_CMD2,', '"neighbor (A.B.C.D|X:X::X:X|WORD)",') - line = line.replace('NO_NEIGHBOR_CMD,', '"no neighbor (A.B.C.D|X:X::X:X)",') - line = line.replace('NEIGHBOR_CMD,', '"neighbor (A.B.C.D|X:X::X:X)",') - line = line.replace('PIM_CMD_IP_MULTICAST_ROUTING,', '"ip multicast-routing",') - - if line.rstrip().endswith('" ,'): - line = line.replace('" ,', '",') + line = expand_command_string(line) command_string = line ''' diff --git a/zebra/debug.c b/zebra/debug.c index cbdcdf27f..3714ffe3f 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -130,12 +130,13 @@ DEFUN (debug_zebra_packet_direct, "Debug option set for receive packet\n" "Debug option set for send packet\n") { + int idx_recv_send = 3; zebra_debug_packet = ZEBRA_DEBUG_PACKET; - if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); - if (strncmp ("detail", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("detail", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); return CMD_SUCCESS; } @@ -150,10 +151,11 @@ DEFUN (debug_zebra_packet_detail, "Debug option set for send packet\n" "Debug option set detailed information\n") { + int idx_recv_send = 3; zebra_debug_packet = ZEBRA_DEBUG_PACKET; - if (strncmp ("send", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[3]->arg, strlen (argv[3]->arg)) == 0) + if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); return CMD_SUCCESS; @@ -180,9 +182,10 @@ DEFUN (debug_zebra_kernel_msgdump, "Dump raw netlink messages received\n" "Dump raw netlink messages sent\n") { - if (argv[4]->arg && strncmp(argv[4]->arg, "recv", strlen(argv[4]->arg)) == 0) + int idx_recv_send = 4; + if (argv[idx_recv_send]->arg && strncmp(argv[idx_recv_send]->arg, "recv", strlen(argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); - if (!argv[4]->arg || strncmp(argv[4]->arg, "send", strlen(argv[4]->arg)) == 0) + if (!argv[idx_recv_send]->arg || strncmp(argv[idx_recv_send]->arg, "send", strlen(argv[idx_recv_send]->arg)) == 0) SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); return CMD_SUCCESS; } @@ -267,9 +270,10 @@ DEFUN (no_debug_zebra_packet_direct, "Debug option set for receive packet\n" "Debug option set for send packet\n") { - if (strncmp ("send", argv[4]->arg, strlen (argv[4]->arg)) == 0) + int idx_recv_send = 4; + if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[4]->arg, strlen (argv[4]->arg)) == 0) + if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0) UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); return CMD_SUCCESS; } @@ -296,9 +300,10 @@ DEFUN (no_debug_zebra_kernel_msgdump, "Dump raw netlink messages received\n" "Dump raw netlink messages sent\n") { - if (!argv[1] || (argv[5]->arg && strncmp(argv[5]->arg, "recv", strlen(argv[5]->arg)) == 0)) + int idx_recv_send = 5; + if (!argv[1] || (argv[idx_recv_send]->arg && strncmp(argv[idx_recv_send]->arg, "recv", strlen(argv[idx_recv_send]->arg)) == 0)) UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); - if (!argv[5]->arg || (argv[5]->arg && strncmp(argv[5]->arg, "send", strlen(argv[5]->arg)) == 0)) + if (!argv[idx_recv_send]->arg || (argv[idx_recv_send]->arg && strncmp(argv[idx_recv_send]->arg, "send", strlen(argv[idx_recv_send]->arg)) == 0)) UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); return CMD_SUCCESS; } diff --git a/zebra/interface.c b/zebra/interface.c index 1f1146e24..26315bd6c 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1361,19 +1361,21 @@ DEFUN (show_interface_name_vrf, "Interface name\n" VRF_CMD_HELP_STR) { + int idx_ifname = 2; + int idx_name = 4; struct interface *ifp; vrf_id_t vrf_id = VRF_DEFAULT; interface_update_stats (); if (argc > 1) - VRF_GET_ID (vrf_id, argv[4]->arg); + VRF_GET_ID (vrf_id, argv[idx_name]->arg); /* Specified interface print. */ - ifp = if_lookup_by_name_vrf (argv[2]->arg, vrf_id); + ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_id); if (ifp == NULL) { - vty_out (vty, "%% Can't find interface %s%s", argv[2]->arg, + vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1399,6 +1401,7 @@ DEFUN (show_interface_name_vrf_all, "Interface name\n" VRF_ALL_CMD_HELP_STR) { + int idx_ifname = 2; struct interface *ifp; vrf_iter_t iter; int found = 0; @@ -1409,7 +1412,7 @@ DEFUN (show_interface_name_vrf_all, for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) { /* Specified interface print. */ - ifp = if_lookup_by_name_vrf (argv[2]->arg, vrf_iter2id (iter)); + ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_iter2id (iter)); if (ifp) { if_dump_vty (vty, ifp); @@ -1419,7 +1422,7 @@ DEFUN (show_interface_name_vrf_all, if (!found) { - vty_out (vty, "%% Can't find interface %s%s", argv[2]->arg, VTY_NEWLINE); + vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, VTY_NEWLINE); return CMD_WARNING; } @@ -1678,11 +1681,12 @@ DEFUN (bandwidth_if, "Set bandwidth informational parameter\n" "Bandwidth in megabits\n") { + int idx_number = 1; struct interface *ifp; unsigned int bandwidth; ifp = (struct interface *) vty->index; - bandwidth = strtol(argv[1]->arg, NULL, 10); + bandwidth = strtol(argv[idx_number]->arg, NULL, 10); /* bandwidth range is <1-100000> */ if (bandwidth < 1 || bandwidth > 100000) @@ -1844,11 +1848,12 @@ DEFUN (link_params_metric, "Link metric for MPLS-TE purpose\n" "Metric value in decimal\n") { + int idx_number = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); u_int32_t metric; - VTY_GET_ULONG("metric", metric, argv[1]->arg); + VTY_GET_ULONG("metric", metric, argv[idx_number]->arg); /* Update TE metric if needed */ link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE, metric); @@ -1876,12 +1881,13 @@ DEFUN (link_params_maxbw, "Maximum bandwidth that can be used\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[1]->arg, "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_maxbw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1920,11 +1926,12 @@ DEFUN (link_params_max_rsv_bw, "Maximum bandwidth that may be reserved\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[1]->arg, "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_max_rsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1953,20 +1960,22 @@ DEFUN (link_params_unrsv_bw, "Priority\n" "Bytes/second (IEEE floating point format)\n") { + int idx_number = 1; + int idx_bandwidth = 2; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); int priority; float bw; /* We don't have to consider about range check here. */ - if (sscanf (argv[1]->arg, "%d", &priority) != 1) + if (sscanf (argv[idx_number]->arg, "%d", &priority) != 1) { vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); return CMD_WARNING; } - if (sscanf (argv[2]->arg, "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -1994,11 +2003,12 @@ DEFUN (link_params_admin_grp, "Administrative group membership\n" "32-bit Hexadecimal value (e.g. 0xa1)\n") { + int idx_bitpattern = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); unsigned long value; - if (sscanf (argv[1]->arg, "0x%lx", &value) != 1) + if (sscanf (argv[idx_bitpattern]->arg, "0x%lx", &value) != 1) { vty_out (vty, "link_params_admin_grp: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2034,19 +2044,21 @@ DEFUN (link_params_inter_as, "Remote AS number\n" "AS number in the range <1-4294967295>\n") { + int idx_ipv4 = 1; + int idx_number = 3; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); struct in_addr addr; u_int32_t as; - if (!inet_aton (argv[1]->arg, &addr)) + if (!inet_aton (argv[idx_ipv4]->arg, &addr)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; } - VTY_GET_ULONG("AS number", as, argv[3]->arg); + VTY_GET_ULONG("AS number", as, argv[idx_number]->arg); /* Update Remote IP and Remote AS fields if needed */ if (IS_PARAM_UNSET(iflp, LP_RMT_AS) @@ -2105,6 +2117,7 @@ DEFUN (link_params_delay, "Unidirectional Average Link Delay\n" "Average delay in micro-second as decimal (0...16777215)\n") { + int idx_number = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); @@ -2112,7 +2125,7 @@ DEFUN (link_params_delay, u_int8_t update = 0; /* Get and Check new delay values */ - VTY_GET_ULONG("delay", delay, argv[1]->arg); + VTY_GET_ULONG("delay", delay, argv[idx_number]->arg); switch (argc) { case 1: @@ -2212,11 +2225,12 @@ DEFUN (link_params_delay_var, "Unidirectional Link Delay Variation\n" "delay variation in micro-second as decimal (0...16777215)\n") { + int idx_number = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); u_int32_t value; - VTY_GET_ULONG("delay variation", value, argv[1]->arg); + VTY_GET_ULONG("delay variation", value, argv[idx_number]->arg); /* Update Delay Variation if needed */ link_param_cmd_set_uint32 (ifp, &iflp->delay_var, LP_DELAY_VAR, value); @@ -2244,11 +2258,12 @@ DEFUN (link_params_pkt_loss, "Unidirectional Link Packet Loss\n" "percentage of total traffic by 0.000003% step and less than 50.331642%\n") { + int idx_percentage = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); float fval; - if (sscanf (argv[1]->arg, "%g", &fval) != 1) + if (sscanf (argv[idx_percentage]->arg, "%g", &fval) != 1) { vty_out (vty, "link_params_pkt_loss: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2284,11 +2299,12 @@ DEFUN (link_params_res_bw, "Unidirectional Residual Bandwidth\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[1]->arg, "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_res_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2330,11 +2346,12 @@ DEFUN (link_params_ava_bw, "Unidirectional Available Bandwidth\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[1]->arg, "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_ava_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2376,11 +2393,12 @@ DEFUN (link_params_use_bw, "Unidirectional Utilised Bandwidth\n" "Bytes/second (IEEE floating point format)\n") { + int idx_bandwidth = 1; struct interface *ifp = (struct interface *) vty->index; struct if_link_params *iflp = if_link_params_get (ifp); float bw; - if (sscanf (argv[1]->arg, "%g", &bw) != 1) + if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) { vty_out (vty, "link_params_use_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE); @@ -2564,7 +2582,8 @@ DEFUN (ip_address, "Set the IP address of an interface\n" "IP address (e.g. 10.0.0.1/8)\n") { - return ip_address_install (vty, vty->index, argv[2]->arg, NULL, NULL); + int idx_ipv4_prefixlen = 2; + return ip_address_install (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, NULL); } DEFUN (no_ip_address, @@ -2575,7 +2594,8 @@ DEFUN (no_ip_address, "Set the IP address of an interface\n" "IP Address (e.g. 10.0.0.1/8)") { - return ip_address_uninstall (vty, vty->index, argv[3]->arg, NULL, NULL); + int idx_ipv4_prefixlen = 3; + return ip_address_uninstall (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, NULL); } @@ -2589,7 +2609,9 @@ DEFUN (ip_address_label, "Label of this address\n" "Label\n") { - return ip_address_install (vty, vty->index, argv[2]->arg, NULL, argv[4]->arg); + int idx_ipv4_prefixlen = 2; + int idx_line = 4; + return ip_address_install (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg); } DEFUN (no_ip_address_label, @@ -2602,7 +2624,9 @@ DEFUN (no_ip_address_label, "Label of this address\n" "Label\n") { - return ip_address_uninstall (vty, vty->index, argv[3]->arg, NULL, argv[5]->arg); + int idx_ipv4_prefixlen = 3; + int idx_line = 5; + return ip_address_uninstall (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg); } #endif /* HAVE_NETLINK */ @@ -2765,7 +2789,8 @@ DEFUN (ipv6_address, "Set the IP address of an interface\n" "IPv6 address (e.g. 3ffe:506::1/48)\n") { - return ipv6_address_install (vty, vty->index, argv[2]->arg, NULL, NULL, 0); + int idx_ipv6_prefixlen = 2; + return ipv6_address_install (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0); } DEFUN (no_ipv6_address, @@ -2776,7 +2801,8 @@ DEFUN (no_ipv6_address, "Set the IP address of an interface\n" "IPv6 address (e.g. 3ffe:506::1/48)\n") { - return ipv6_address_uninstall (vty, vty->index, argv[3]->arg, NULL, NULL, 0); + int idx_ipv6_prefixlen = 3; + return ipv6_address_uninstall (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0); } #endif /* HAVE_IPV6 */ diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 424f02788..2f741380f 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -469,6 +469,7 @@ DEFUN (ip_irdp_holdtime, "Set holdtime value\n" "Holdtime value in seconds. Default is 1800 seconds\n") { + int idx_number = 3; struct interface *ifp; struct zebra_if *zi; struct irdp_interface *irdp; @@ -480,7 +481,7 @@ DEFUN (ip_irdp_holdtime, zi=ifp->info; irdp=&zi->irdp; - irdp->Lifetime = atoi(argv[3]->arg); + irdp->Lifetime = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } @@ -492,6 +493,7 @@ DEFUN (ip_irdp_minadvertinterval, "Set minimum time between advertisement\n" "Minimum advertisement interval in seconds\n") { + int idx_number = 3; struct interface *ifp; struct zebra_if *zi; struct irdp_interface *irdp; @@ -503,8 +505,8 @@ DEFUN (ip_irdp_minadvertinterval, zi=ifp->info; irdp=&zi->irdp; - if( (unsigned) atoi(argv[3]->arg) <= irdp->MaxAdvertInterval) { - irdp->MinAdvertInterval = atoi(argv[3]->arg); + if( (unsigned) atoi(argv[idx_number]->arg) <= irdp->MaxAdvertInterval) { + irdp->MinAdvertInterval = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } @@ -525,6 +527,7 @@ DEFUN (ip_irdp_maxadvertinterval, "Set maximum time between advertisement\n" "Maximum advertisement interval in seconds\n") { + int idx_number = 3; struct interface *ifp; struct zebra_if *zi; struct irdp_interface *irdp; @@ -537,8 +540,8 @@ DEFUN (ip_irdp_maxadvertinterval, irdp=&zi->irdp; - if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[3]->arg) ) { - irdp->MaxAdvertInterval = atoi(argv[3]->arg); + if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[idx_number]->arg) ) { + irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } @@ -564,6 +567,7 @@ DEFUN (ip_irdp_preference, "Set default preference level for this interface\n" "Preference level\n") { + int idx_number = 3; struct interface *ifp; struct zebra_if *zi; struct irdp_interface *irdp; @@ -575,7 +579,7 @@ DEFUN (ip_irdp_preference, zi=ifp->info; irdp=&zi->irdp; - irdp->Preference = atoi(argv[3]->arg); + irdp->Preference = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } @@ -588,6 +592,8 @@ DEFUN (ip_irdp_address_preference, "Set IRDP address for advertise\n" "Preference level\n") { + int idx_ipv4 = 3; + int idx_number = 5; struct listnode *node; struct in_addr ip; int pref; @@ -605,10 +611,10 @@ DEFUN (ip_irdp_address_preference, zi=ifp->info; irdp=&zi->irdp; - ret = inet_aton(argv[3]->arg, &ip); + ret = inet_aton(argv[idx_ipv4]->arg, &ip); if(!ret) return CMD_WARNING; - pref = atoi(argv[5]->arg); + pref = atoi(argv[idx_number]->arg); for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv)) if(adv->ip.s_addr == ip.s_addr) @@ -633,6 +639,7 @@ DEFUN (no_ip_irdp_address_preference, "Select IRDP address\n" "Old preference level\n") { + int idx_ipv4 = 4; struct listnode *node, *nnode; struct in_addr ip; int ret; @@ -649,7 +656,7 @@ DEFUN (no_ip_irdp_address_preference, zi=ifp->info; irdp=&zi->irdp; - ret = inet_aton(argv[4]->arg, &ip); + ret = inet_aton(argv[idx_ipv4]->arg, &ip); if (!ret) return CMD_WARNING; diff --git a/zebra/router-id.c b/zebra/router-id.c index 05eee8ad3..6e1d434ec 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -228,10 +228,11 @@ DEFUN (router_id, "Manually set the router-id\n" "IP address to use for router-id\n") { + int idx_ipv4 = 1; struct prefix rid; vrf_id_t vrf_id = VRF_DEFAULT; - rid.u.prefix4.s_addr = inet_addr (argv[1]->arg); + rid.u.prefix4.s_addr = inet_addr (argv[idx_ipv4]->arg); if (!rid.u.prefix4.s_addr) return CMD_WARNING; diff --git a/zebra/rtadv.c b/zebra/rtadv.c index c13d85a4d..ec4736463 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -923,6 +923,7 @@ DEFUN (ipv6_nd_ra_interval_msec, "Router Advertisement interval\n" "Router Advertisement interval in milliseconds\n") { + int idx_number = 4; unsigned interval; struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; @@ -930,7 +931,7 @@ DEFUN (ipv6_nd_ra_interval_msec, struct zebra_ns *zns; zns = zvrf->zns; - VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[4]->arg, 70, 1800000); + VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[idx_number]->arg, 70, 1800000); if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime * 1000)) { vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); @@ -958,6 +959,7 @@ DEFUN (ipv6_nd_ra_interval, "Router Advertisement interval\n" "Router Advertisement interval in seconds\n") { + int idx_number = 3; unsigned interval; struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; @@ -965,7 +967,7 @@ DEFUN (ipv6_nd_ra_interval, struct zebra_ns *zns; zns = zvrf->zns; - VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[3]->arg, 1, 1800); + VTY_GET_INTEGER_RANGE ("router advertisement interval", interval, argv[idx_number]->arg, 1, 1800); if ((zif->rtadv.AdvDefaultLifetime != -1 && interval > (unsigned)zif->rtadv.AdvDefaultLifetime)) { vty_out (vty, "This ra-interval would conflict with configured ra-lifetime!%s", VTY_NEWLINE); @@ -1039,6 +1041,7 @@ DEFUN (ipv6_nd_ra_lifetime, "Router lifetime\n" "Router lifetime in seconds (0 stands for a non-default gw)\n") { + int idx_number = 3; int lifetime; struct interface *ifp; struct zebra_if *zif; @@ -1046,7 +1049,7 @@ DEFUN (ipv6_nd_ra_lifetime, ifp = (struct interface *) vty->index; zif = ifp->info; - VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[3]->arg, 0, 9000); + VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[idx_number]->arg, 0, 9000); /* The value to be placed in the Router Lifetime field * of Router Advertisements sent from the interface, @@ -1101,9 +1104,10 @@ DEFUN (ipv6_nd_reachable_time, "Reachable time\n" "Reachable time in milliseconds\n") { + int idx_number = 3; struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[3]->arg, 1, RTADV_MAX_REACHABLE_TIME); + VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[idx_number]->arg, 1, RTADV_MAX_REACHABLE_TIME); return CMD_SUCCESS; } @@ -1145,9 +1149,10 @@ DEFUN (ipv6_nd_homeagent_preference, "Home Agent preference\n" "preference value (default is 0, least preferred)\n") { + int idx_number = 3; struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[3]->arg, 0, 65535); + VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[idx_number]->arg, 0, 65535); return CMD_SUCCESS; } @@ -1189,9 +1194,10 @@ DEFUN (ipv6_nd_homeagent_lifetime, "Home Agent lifetime\n" "Home Agent lifetime in seconds (0 to track ra-lifetime)\n") { + int idx_number = 3; struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[3]->arg, 0, RTADV_MAX_HALIFETIME); + VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[idx_number]->arg, 0, RTADV_MAX_HALIFETIME); return CMD_SUCCESS; } @@ -1508,7 +1514,7 @@ DEFUN (no_ipv6_nd_other_config_flag, */ DEFUN (ipv6_nd_prefix, ipv6_nd_prefix_cmd, - "ipv6 nd prefix X:X::X:X/M <(0-4294967295)|infinite> <(0-4294967295)|infinite> <off-link|> <no-autoconfig|> <router-address|>", + "ipv6 nd prefix X:X::X:X/M <(0-4294967295)|infinite> <(0-4294967295)|infinite> <off-link> <no-autoconfig> <router-address>", "Interface IPv6 config commands\n" "Neighbor discovery\n" "Prefix information\n" @@ -1521,6 +1527,9 @@ DEFUN (ipv6_nd_prefix, "Do not use prefix for autoconfiguration\n" "Set Router Address flag\n") { + int idx_ipv6_prefixlen = 3; + int idx_number_infinite = 4; + int idx_number_infinite_2 = 5; int i; int ret; int cursor = 1; @@ -1531,7 +1540,7 @@ DEFUN (ipv6_nd_prefix, ifp = (struct interface *) vty->index; zebra_if = ifp->info; - ret = str2prefix_ipv6 (argv[3]->arg, &rp.prefix); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, &rp.prefix); if (!ret) { vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); @@ -1546,19 +1555,19 @@ DEFUN (ipv6_nd_prefix, if (argc > 1) { - if ((isdigit((unsigned char)argv[4]->arg[0])) - || strncmp (argv[4]->arg, "i", 1) == 0) + if ((isdigit((unsigned char)argv[idx_number_infinite]->arg[0])) + || strncmp (argv[idx_number_infinite]->arg, "i", 1) == 0) { - if ( strncmp (argv[4]->arg, "i", 1) == 0) + if ( strncmp (argv[idx_number_infinite]->arg, "i", 1) == 0) rp.AdvValidLifetime = UINT32_MAX; else - rp.AdvValidLifetime = (u_int32_t) strtoll (argv[4]->arg, + rp.AdvValidLifetime = (u_int32_t) strtoll (argv[idx_number_infinite]->arg, (char **)NULL, 10); - if ( strncmp (argv[5]->arg, "i", 1) == 0) + if ( strncmp (argv[idx_number_infinite_2]->arg, "i", 1) == 0) rp.AdvPreferredLifetime = UINT32_MAX; else - rp.AdvPreferredLifetime = (u_int32_t) strtoll (argv[5]->arg, + rp.AdvPreferredLifetime = (u_int32_t) strtoll (argv[idx_number_infinite_2]->arg, (char **)NULL, 10); if (rp.AdvPreferredLifetime > rp.AdvValidLifetime) @@ -1790,6 +1799,7 @@ DEFUN (ipv6_nd_router_preference, "Low default router preference\n" "Medium default router preference (default)\n") { + int idx_high_medium_low = 3; struct interface *ifp; struct zebra_if *zif; int i = 0; @@ -1799,7 +1809,7 @@ DEFUN (ipv6_nd_router_preference, while (0 != rtadv_pref_strs[i]) { - if (strncmp (argv[3]->arg, rtadv_pref_strs[i], 1) == 0) + if (strncmp (argv[idx_high_medium_low]->arg, rtadv_pref_strs[i], 1) == 0) { zif->rtadv.DefaultPreference = i; return CMD_SUCCESS; @@ -1850,9 +1860,10 @@ DEFUN (ipv6_nd_mtu, "Advertised MTU\n" "MTU in bytes\n") { + int idx_number = 3; struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; - VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[3]->arg, 1, 65535); + VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[idx_number]->arg, 1, 65535); return CMD_SUCCESS; } diff --git a/zebra/test_main.c b/zebra/test_main.c index 2908ddd94..4dd3e897f 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -124,6 +124,7 @@ DEFUN (test_interface_state, "up\n" "down\n") { + int idx_up_down = 1; struct interface *ifp; if (argc < 1) return CMD_WARNING; @@ -136,7 +137,7 @@ DEFUN (test_interface_state, ifp->flags = IFF_BROADCAST|IFF_MULTICAST; } - switch (argv[1]->arg[0]) + switch (argv[idx_up_down]->arg[0]) { case 'u': SET_FLAG (ifp->flags, IFF_UP); diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 6dcc7624e..9ca4cd947 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -301,7 +301,8 @@ DEFUN (match_interface, "match first hop interface of route\n" "Interface name\n") { - return zebra_route_match_add (vty, vty->index, "interface", argv[2]->arg, + int idx_word = 2; + return zebra_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -335,7 +336,8 @@ DEFUN (match_tag, "Match tag of route\n" "Tag value\n") { - return zebra_route_match_add (vty, vty->index, "tag", argv[2]->arg, + int idx_number = 2; + return zebra_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg, RMAP_EVENT_MATCH_ADDED); } @@ -373,7 +375,8 @@ DEFUN (match_ip_next_hop, "IP access-list number (expanded range)\n" "IP Access-list name\n") { - return zebra_route_match_add (vty, vty->index, "ip next-hop", argv[3]->arg, RMAP_EVENT_FILTER_ADDED); + int idx_acl = 3; + return zebra_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED); } /* @@ -414,8 +417,9 @@ DEFUN (match_ip_next_hop_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return zebra_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[4]->arg, RMAP_EVENT_PLIST_ADDED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); } /* @@ -460,7 +464,8 @@ DEFUN (match_ip_address, "IP Access-list name\n") { - return zebra_route_match_add (vty, vty->index, "ip address", argv[3]->arg, + int idx_acl = 3; + return zebra_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED); } @@ -502,8 +507,9 @@ DEFUN (match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") { + int idx_word = 4; return zebra_route_match_add (vty, vty->index, "ip address prefix-list", - argv[4]->arg, RMAP_EVENT_PLIST_ADDED); + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); } /* @@ -627,17 +633,18 @@ DEFUN (match_source_protocol, MATCH_STR "Match protocol via which the route was learnt\n") { + int idx_protocol = 2; int i; - i = proto_name2num(argv[2]->arg); + i = proto_name2num(argv[idx_protocol]->arg); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", + vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "", VTY_NEWLINE); return CMD_WARNING; } return zebra_route_match_add (vty, vty->index, "source-protocol", - argv[2]->arg, RMAP_EVENT_MATCH_ADDED); + argv[idx_protocol]->arg, RMAP_EVENT_MATCH_ADDED); } DEFUN (no_match_source_protocol, @@ -647,20 +654,21 @@ DEFUN (no_match_source_protocol, MATCH_STR "No match protocol via which the route was learnt\n") { + int idx_protocol = 3; int i; if (argc >= 1) { - i = proto_name2num(argv[3]->arg); + i = proto_name2num(argv[idx_protocol]->arg); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[3]->arg ? argv[3]->arg : "", + vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "", VTY_NEWLINE); return CMD_WARNING; } } return zebra_route_match_delete (vty, vty->index, - "source-protocol", argv[3]->arg ? argv[3]->arg : NULL, + "source-protocol", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : NULL, RMAP_EVENT_MATCH_DELETED); } @@ -673,15 +681,16 @@ DEFUN (set_src, "src address for route\n" "src address\n") { + int idx_ip = 2; union g_addr src; struct interface *pif = NULL; int family; struct prefix p; vrf_iter_t iter; - if (inet_pton(AF_INET, argv[2]->arg, &src.ipv4) != 1) + if (inet_pton(AF_INET, argv[idx_ip]->arg, &src.ipv4) != 1) { - if (inet_pton(AF_INET6, argv[2]->arg, &src.ipv6) != 1) + if (inet_pton(AF_INET6, argv[idx_ip]->arg, &src.ipv6) != 1) { vty_out (vty, "%% not a valid IPv4/v6 address%s", VTY_NEWLINE); return CMD_WARNING; @@ -722,7 +731,7 @@ DEFUN (set_src, vty_out (vty, "%% not a local address%s", VTY_NEWLINE); return CMD_WARNING; } - return zebra_route_set_add (vty, vty->index, "src", argv[2]->arg); + return zebra_route_set_add (vty, vty->index, "src", argv[idx_ip]->arg); } DEFUN (no_set_src, @@ -732,10 +741,11 @@ DEFUN (no_set_src, SET_STR "Source address for route\n") { + int idx_ip = 3; if (argc == 0) return zebra_route_set_delete (vty, vty->index, "src", NULL); - return zebra_route_set_delete (vty, vty->index, "src", argv[3]->arg); + return zebra_route_set_delete (vty, vty->index, "src", argv[idx_ip]->arg); } DEFUN (zebra_route_map_timer, @@ -744,9 +754,10 @@ DEFUN (zebra_route_map_timer, "Time to wait before route-map updates are processed\n" "0 means event-driven updates are disabled\n") { + int idx_number = 3; u_int32_t rmap_delay_timer; - VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[3]->arg, 0, 600); + VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); zebra_route_map_set_delay_timer(rmap_delay_timer); return (CMD_SUCCESS); @@ -782,15 +793,16 @@ DEFUN (ip_protocol, QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { + int idx_protocol = 2; int i; - if (strcasecmp(argv[2]->arg, "any") == 0) + if (strcasecmp(argv[idx_protocol]->arg, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[2]->arg); + i = proto_name2num(argv[idx_protocol]->arg); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", + vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "", VTY_NEWLINE); return CMD_WARNING; } @@ -805,7 +817,7 @@ DEFUN (ip_protocol, if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug ("%u: IPv4 Routemap config for protocol %s, scheduling RIB processing", - VRF_DEFAULT, argv[2]->arg); + VRF_DEFAULT, argv[idx_protocol]->arg); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); return CMD_SUCCESS; @@ -897,15 +909,16 @@ DEFUN (ipv6_protocol, QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { + int idx_protocol = 2; int i; - if (strcasecmp(argv[2]->arg, "any") == 0) + if (strcasecmp(argv[idx_protocol]->arg, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[2]->arg); + i = proto_name2num(argv[idx_protocol]->arg); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", + vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "", VTY_NEWLINE); return CMD_WARNING; } @@ -920,7 +933,7 @@ DEFUN (ipv6_protocol, if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug ("%u: IPv6 Routemap config for protocol %s, scheduling RIB processing", - VRF_DEFAULT, argv[2]->arg); + VRF_DEFAULT, argv[idx_protocol]->arg); rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE); return CMD_SUCCESS; @@ -1013,15 +1026,16 @@ DEFUN (ip_protocol_nht_rmap, QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { + int idx_protocol = 2; int i; - if (strcasecmp(argv[2]->arg, "any") == 0) + if (strcasecmp(argv[idx_protocol]->arg, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[2]->arg); + i = proto_name2num(argv[idx_protocol]->arg); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", + vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "", VTY_NEWLINE); return CMD_WARNING; } @@ -1119,15 +1133,16 @@ DEFUN (ipv6_protocol_nht_rmap, QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { + int idx_protocol = 2; int i; - if (strcasecmp(argv[2]->arg, "any") == 0) + if (strcasecmp(argv[idx_protocol]->arg, "any") == 0) i = ZEBRA_ROUTE_MAX; else - i = proto_name2num(argv[2]->arg); + i = proto_name2num(argv[idx_protocol]->arg); if (i < 0) { - vty_out (vty, "invalid protocol name \"%s\"%s", argv[2]->arg ? argv[2]->arg : "", + vty_out (vty, "invalid protocol name \"%s\"%s", argv[idx_protocol]->arg ? argv[idx_protocol]->arg : "", VTY_NEWLINE); return CMD_WARNING; } diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 505da4923..99d7bd6fd 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -201,7 +201,10 @@ DEFUN (ip_mroute_dist, "Nexthop interface name\n" "Distance\n") { - return zebra_static_ipv4 (vty, SAFI_MULTICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, argc > 2 ? argv[4]->arg : NULL, NULL); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_number = 4; + return zebra_static_ipv4 (vty, SAFI_MULTICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, NULL, NULL, argc > 2 ? argv[idx_number]->arg : NULL, NULL); } @@ -226,7 +229,10 @@ DEFUN (no_ip_mroute_dist, "Nexthop interface name\n" "Distance\n") { - return zebra_static_ipv4 (vty, SAFI_MULTICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, argc > 2 ? argv[5]->arg : NULL, NULL); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_MULTICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, NULL, NULL, argc > 2 ? argv[idx_number]->arg : NULL, NULL); } @@ -242,16 +248,17 @@ DEFUN (ip_multicast_mode, "Lookup both, use entry with lower distance\n" "Lookup both, use entry with longer prefix\n") { + int idx_rpf_lookup_mode = 3; - if (!strncmp (argv[3]->arg, "u", 1)) + if (!strncmp (argv[idx_rpf_lookup_mode]->arg, "u", 1)) multicast_mode_ipv4_set (MCAST_URIB_ONLY); - else if (!strncmp (argv[3]->arg, "mrib-o", 6)) + else if (!strncmp (argv[idx_rpf_lookup_mode]->arg, "mrib-o", 6)) multicast_mode_ipv4_set (MCAST_MRIB_ONLY); - else if (!strncmp (argv[3]->arg, "mrib-t", 6)) + else if (!strncmp (argv[idx_rpf_lookup_mode]->arg, "mrib-t", 6)) multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST); - else if (!strncmp (argv[3]->arg, "low", 3)) + else if (!strncmp (argv[idx_rpf_lookup_mode]->arg, "low", 3)) multicast_mode_ipv4_set (MCAST_MIX_DISTANCE); - else if (!strncmp (argv[3]->arg, "lon", 3)) + else if (!strncmp (argv[idx_rpf_lookup_mode]->arg, "lon", 3)) multicast_mode_ipv4_set (MCAST_MIX_PFXLEN); else { @@ -307,12 +314,13 @@ DEFUN (show_ip_rpf_addr, "Display RPF information for multicast source\n" "IP multicast source address (e.g. 10.0.0.0)\n") { + int idx_ipv4 = 3; struct in_addr addr; struct route_node *rn; struct rib *rib; int ret; - ret = inet_aton (argv[3]->arg, &addr); + ret = inet_aton (argv[idx_ipv4]->arg, &addr); if (ret == 0) { vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); @@ -340,7 +348,9 @@ DEFUN (ip_route, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, NULL); } @@ -356,7 +366,10 @@ DEFUN (ip_route_tag, "Set tag for this route\n" "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, NULL); } @@ -371,7 +384,10 @@ DEFUN (ip_route_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } @@ -389,7 +405,11 @@ DEFUN (ip_route_flags_tag, "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, argv[6]->arg, + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } @@ -402,7 +422,9 @@ DEFUN (ip_route_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, NULL, + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } @@ -418,7 +440,10 @@ DEFUN (ip_route_flags2_tag, "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, argv[5]->arg, + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } @@ -434,7 +459,10 @@ DEFUN (ip_route_mask, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, NULL); } @@ -452,7 +480,11 @@ DEFUN (ip_route_mask_tag, "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, NULL); } @@ -468,7 +500,11 @@ DEFUN (ip_route_mask_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } @@ -487,7 +523,12 @@ DEFUN (ip_route_mask_flags_tag, "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } @@ -501,7 +542,10 @@ DEFUN (ip_route_mask_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } @@ -517,7 +561,11 @@ DEFUN (ip_route_mask_flags2_tag, "Set tag for this route\n" "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } @@ -533,8 +581,11 @@ DEFUN (ip_route_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, - argv[4]->arg, NULL); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_number = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, + argv[idx_number]->arg, NULL); } DEFUN (ip_route_tag_distance, @@ -551,8 +602,12 @@ DEFUN (ip_route_tag_distance, "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, - argv[6]->arg, NULL); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_number = 5; + int idx_number_2 = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (ip_route_flags_distance, @@ -567,8 +622,12 @@ DEFUN (ip_route_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, - argv[5]->arg, NULL); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (ip_route_flags_tag_distance, @@ -585,8 +644,13 @@ DEFUN (ip_route_flags_tag_distance, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, argv[6]->arg, - argv[7]->arg, NULL); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (ip_route_flags_distance2, @@ -599,8 +663,11 @@ DEFUN (ip_route_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, NULL, - argv[4]->arg, NULL); + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_number = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (ip_route_flags_tag_distance2, @@ -615,8 +682,12 @@ DEFUN (ip_route_flags_tag_distance2, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, argv[5]->arg, - argv[6]->arg, NULL); + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_number = 5; + int idx_number_2 = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (ip_route_mask_distance, @@ -631,8 +702,12 @@ DEFUN (ip_route_mask_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, - argv[5]->arg, NULL); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, + argv[idx_number]->arg, NULL); } DEFUN (ip_route_mask_tag_distance, @@ -649,8 +724,13 @@ DEFUN (ip_route_mask_tag_distance, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, - argv[7]->arg, NULL); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + int idx_number_2 = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (ip_route_mask_flags_tag_distance, @@ -668,8 +748,14 @@ DEFUN (ip_route_mask_flags_tag_distance, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, - argv[8]->arg, NULL); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } @@ -686,8 +772,13 @@ DEFUN (ip_route_mask_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, - argv[6]->arg, NULL); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (ip_route_mask_flags_distance2, @@ -701,8 +792,12 @@ DEFUN (ip_route_mask_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, - argv[5]->arg, NULL); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (ip_route_mask_flags_tag_distance2, @@ -718,8 +813,13 @@ DEFUN (ip_route_mask_flags_tag_distance2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, - argv[7]->arg, NULL); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } /* @@ -746,7 +846,9 @@ DEFUN (no_ip_route, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, NULL); } @@ -778,7 +880,10 @@ DEFUN (no_ip_route_tag, "Tag of this route\n" "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, NULL); } @@ -794,7 +899,8 @@ DEFUN (no_ip_route_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, NULL, NULL, + int idx_ipv4_prefixlen = 3; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, NULL, NULL, NULL, NULL); } @@ -810,7 +916,9 @@ DEFUN (no_ip_route_flags2_tag, "Tag of this route\n" "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, NULL, argv[4]->arg, + int idx_ipv4_prefixlen = 3; + int idx_reject_blackhole = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL); } @@ -840,7 +948,10 @@ DEFUN (no_ip_route_mask, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, NULL); } @@ -874,7 +985,11 @@ DEFUN (no_ip_route_mask_tag, "Tag of this route\n" "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_number = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, NULL); } @@ -891,7 +1006,9 @@ DEFUN (no_ip_route_mask_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, NULL, NULL, NULL, NULL); } @@ -908,7 +1025,10 @@ DEFUN (no_ip_route_mask_flags2_tag, "Tag of this route\n" "Tag value\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[5]->arg, + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_reject_blackhole = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL); } @@ -924,8 +1044,11 @@ DEFUN (no_ip_route_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, - argv[5]->arg, NULL); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, + argv[idx_number]->arg, NULL); } DEFUN (no_ip_route_tag_distance, @@ -942,8 +1065,12 @@ DEFUN (no_ip_route_tag_distance, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, - argv[7]->arg, NULL); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + int idx_number_2 = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (no_ip_route_flags_distance, @@ -959,8 +1086,12 @@ DEFUN (no_ip_route_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, NULL, - argv[6]->arg, NULL); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (no_ip_route_flags_tag_distance, @@ -978,8 +1109,13 @@ DEFUN (no_ip_route_flags_tag_distance, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, argv[7]->arg, - argv[8]->arg, NULL); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (no_ip_route_flags_distance2, @@ -993,8 +1129,11 @@ DEFUN (no_ip_route_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, argv[4]->arg, NULL, - argv[5]->arg, NULL); + int idx_ipv4_prefixlen = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (no_ip_route_flags_tag_distance2, @@ -1010,8 +1149,12 @@ DEFUN (no_ip_route_flags_tag_distance2, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, argv[4]->arg, argv[6]->arg, - argv[7]->arg, NULL); + int idx_ipv4_prefixlen = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (no_ip_route_mask_distance, @@ -1027,8 +1170,12 @@ DEFUN (no_ip_route_mask_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, - argv[6]->arg, NULL); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, + argv[idx_number]->arg, NULL); } DEFUN (no_ip_route_mask_tag_distance, @@ -1046,8 +1193,13 @@ DEFUN (no_ip_route_mask_tag_distance, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, - argv[8]->arg, NULL); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_number = 7; + int idx_number_2 = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (no_ip_route_mask_flags_distance, @@ -1064,8 +1216,13 @@ DEFUN (no_ip_route_mask_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, NULL, - argv[7]->arg, NULL); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname = 5; + int idx_reject_blackhole = 6; + int idx_number = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (no_ip_route_mask_flags_tag_distance, @@ -1084,8 +1241,14 @@ DEFUN (no_ip_route_mask_flags_tag_distance, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg, - argv[9]->arg, NULL); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname = 5; + int idx_reject_blackhole = 6; + int idx_number = 8; + int idx_number_2 = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } DEFUN (no_ip_route_mask_flags_distance2, @@ -1100,8 +1263,12 @@ DEFUN (no_ip_route_mask_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, NULL, - argv[6]->arg, NULL); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, + argv[idx_number]->arg, NULL); } DEFUN (no_ip_route_mask_flags_tag_distance2, @@ -1118,8 +1285,13 @@ DEFUN (no_ip_route_mask_flags_tag_distance2, "Tag value\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg, - argv[8]->arg, NULL); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, + argv[idx_number_2]->arg, NULL); } /* Static route configuration. */ @@ -1134,7 +1306,10 @@ DEFUN (ip_route_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, NULL, argv[5]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_name = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (ip_route_tag_vrf, @@ -1150,7 +1325,11 @@ DEFUN (ip_route_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, NULL, argv[7]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_number = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ip_route_flags_vrf, @@ -1165,7 +1344,11 @@ DEFUN (ip_route_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[6]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_name = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (ip_route_flags_tag_vrf, @@ -1183,7 +1366,12 @@ DEFUN (ip_route_flags_tag_vrf, VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ip_route_flags2_vrf, @@ -1196,7 +1384,10 @@ DEFUN (ip_route_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, NULL, NULL, argv[5]->arg); + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_name = 5; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (ip_route_flags2_tag_vrf, @@ -1212,7 +1403,11 @@ DEFUN (ip_route_flags2_tag_vrf, VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, argv[5]->arg, NULL, argv[7]->arg); + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_number = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } /* Mask as A.B.C.D format. */ @@ -1228,7 +1423,11 @@ DEFUN (ip_route_mask_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, argv[6]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_name = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (ip_route_mask_tag_vrf, @@ -1246,7 +1445,12 @@ DEFUN (ip_route_mask_tag_vrf, VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ip_route_mask_flags_vrf, @@ -1262,7 +1466,12 @@ DEFUN (ip_route_mask_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[7]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (ip_route_mask_flags_tag_vrf, @@ -1281,7 +1490,13 @@ DEFUN (ip_route_mask_flags_tag_vrf, VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, NULL, argv[9]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ip_route_mask_flags2_vrf, @@ -1295,7 +1510,11 @@ DEFUN (ip_route_mask_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, argv[6]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_name = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (ip_route_mask_flags2_tag_vrf, @@ -1311,7 +1530,12 @@ DEFUN (ip_route_mask_flags2_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } /* Distance option value. */ @@ -1327,7 +1551,11 @@ DEFUN (ip_route_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, argv[4]->arg, argv[6]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_number = 4; + int idx_name = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ip_route_tag_distance_vrf, @@ -1345,7 +1573,12 @@ DEFUN (ip_route_tag_distance_vrf, VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, argv[6]->arg, argv[8]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname_null = 3; + int idx_number = 5; + int idx_number_2 = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (ip_route_flags_distance_vrf, @@ -1361,7 +1594,12 @@ DEFUN (ip_route_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ip_route_flags_tag_distance_vrf, @@ -1379,7 +1617,13 @@ DEFUN (ip_route_flags_tag_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, argv[6]->arg, argv[7]->arg, argv[9]->arg); + int idx_ipv4_prefixlen = 2; + int idx_ipv4_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (ip_route_flags_distance2_vrf, @@ -1393,7 +1637,11 @@ DEFUN (ip_route_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg); + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_number = 4; + int idx_name = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ip_route_flags_tag_distance2_vrf, @@ -1409,7 +1657,12 @@ DEFUN (ip_route_flags_tag_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, NULL, argv[3]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg); + int idx_ipv4_prefixlen = 2; + int idx_reject_blackhole = 3; + int idx_number = 5; + int idx_number_2 = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (ip_route_mask_distance_vrf, @@ -1425,7 +1678,12 @@ DEFUN (ip_route_mask_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ip_route_mask_tag_distance_vrf, @@ -1443,7 +1701,13 @@ DEFUN (ip_route_mask_tag_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, argv[9]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (ip_route_mask_flags_tag_distance_vrf, @@ -1462,7 +1726,14 @@ DEFUN (ip_route_mask_flags_tag_distance_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, argv[8]->arg, argv[10]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + int idx_name = 10; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } @@ -1480,7 +1751,13 @@ DEFUN (ip_route_mask_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[6]->arg, argv[8]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ip_route_mask_flags_distance2_vrf, @@ -1495,7 +1772,12 @@ DEFUN (ip_route_mask_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ip_route_mask_flags_tag_distance2_vrf, @@ -1512,7 +1794,13 @@ DEFUN (ip_route_mask_flags_tag_distance2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, argv[7]->arg, argv[9]->arg); + int idx_ipv4 = 2; + int idx_ipv4_2 = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_vrf, @@ -1527,7 +1815,10 @@ DEFUN (no_ip_route_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, NULL, argv[6]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_name = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_flags_vrf, @@ -1543,7 +1834,11 @@ DEFUN (no_ip_route_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[7]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_tag_vrf, @@ -1560,7 +1855,11 @@ DEFUN (no_ip_route_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_flags_tag_vrf, @@ -1578,7 +1877,12 @@ DEFUN (no_ip_route_flags_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, argv[7]->arg, NULL, argv[9]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_flags2_vrf, @@ -1592,7 +1896,10 @@ DEFUN (no_ip_route_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, argv[4]->arg, NULL, NULL, argv[6]->arg); + int idx_ipv4_prefixlen = 3; + int idx_reject_blackhole = 4; + int idx_name = 6; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_flags2_tag_vrf, @@ -1608,7 +1915,11 @@ DEFUN (no_ip_route_flags2_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, argv[4]->arg, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv4_prefixlen = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_vrf, @@ -1624,7 +1935,11 @@ DEFUN (no_ip_route_mask_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, NULL, argv[7]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags_vrf, @@ -1641,7 +1956,12 @@ DEFUN (no_ip_route_mask_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, NULL, NULL, argv[8]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname = 5; + int idx_reject_blackhole = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_tag_vrf, @@ -1659,7 +1979,12 @@ DEFUN (no_ip_route_mask_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, NULL, argv[9]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_number = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags_tag_vrf, @@ -1678,7 +2003,13 @@ DEFUN (no_ip_route_mask_flags_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg, NULL, argv[10]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname = 5; + int idx_reject_blackhole = 6; + int idx_number = 8; + int idx_name = 10; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags2_vrf, @@ -1693,7 +2024,11 @@ DEFUN (no_ip_route_mask_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, NULL, NULL, argv[7]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_reject_blackhole = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags2_tag_vrf, @@ -1710,7 +2045,12 @@ DEFUN (no_ip_route_mask_flags2_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg, NULL, argv[9]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } @@ -1727,7 +2067,11 @@ DEFUN (no_ip_route_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_tag_distance_vrf, @@ -1745,7 +2089,12 @@ DEFUN (no_ip_route_tag_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, argv[9]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname_null = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_flags_distance_vrf, @@ -1762,7 +2111,12 @@ DEFUN (no_ip_route_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, NULL, argv[6]->arg, argv[8]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_flags_tag_distance_vrf, @@ -1781,7 +2135,13 @@ DEFUN (no_ip_route_flags_tag_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, argv[7]->arg, argv[8]->arg,argv[10]->arg); + int idx_ipv4_prefixlen = 3; + int idx_ipv4_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + int idx_name = 10; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg,argv[idx_name]->arg); } DEFUN (no_ip_route_flags_distance2_vrf, @@ -1796,7 +2156,11 @@ DEFUN (no_ip_route_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv4_prefixlen = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + int idx_name = 7; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_flags_tag_distance2_vrf, @@ -1813,7 +2177,12 @@ DEFUN (no_ip_route_flags_tag_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, NULL, argv[4]->arg, argv[6]->arg , argv[7]->arg, argv[9]->arg); + int idx_ipv4_prefixlen = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4_prefixlen]->arg, NULL, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg , argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_distance_vrf, @@ -1830,7 +2199,12 @@ DEFUN (no_ip_route_mask_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[6]->arg, argv[8]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_tag_distance_vrf, @@ -1849,7 +2223,13 @@ DEFUN (no_ip_route_mask_tag_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg, argv[10]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname_null = 5; + int idx_number = 7; + int idx_number_2 = 8; + int idx_name = 10; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname_null]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags_distance_vrf, @@ -1867,7 +2247,13 @@ DEFUN (no_ip_route_mask_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, NULL, argv[7]->arg, argv[9]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname = 5; + int idx_reject_blackhole = 6; + int idx_number = 7; + int idx_name = 9; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags_tag_distance_vrf, @@ -1887,7 +2273,14 @@ DEFUN (no_ip_route_mask_flags_tag_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg, argv[9]->arg, argv[11]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_ipv4_ifname = 5; + int idx_reject_blackhole = 6; + int idx_number = 8; + int idx_number_2 = 9; + int idx_name = 11; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, argv[idx_ipv4_ifname]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags_distance2_vrf, @@ -1903,7 +2296,12 @@ DEFUN (no_ip_route_mask_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, NULL, argv[6]->arg, argv[8]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + int idx_name = 8; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ip_route_mask_flags_tag_distance2_vrf, @@ -1921,7 +2319,13 @@ DEFUN (no_ip_route_mask_flags_tag_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg, argv[8]->arg, argv[10]->arg); + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + int idx_name = 10; + return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } /* New RIB. Detailed information for IPv4 route. */ @@ -2442,12 +2846,13 @@ DEFUN (show_ip_route_vrf, "IP routing table\n" VRF_CMD_HELP_STR) { + int idx_json = 5; u_char uj = use_json(argc, argv); if (argc == 1 && uj) return do_show_ip_route (vty, NULL, SAFI_UNICAST, uj); else - return do_show_ip_route (vty, argv[5]->arg, SAFI_UNICAST, uj); + return do_show_ip_route (vty, argv[idx_json]->arg, SAFI_UNICAST, uj); } /* @@ -2626,6 +3031,7 @@ DEFUN (show_ip_route_tag, "Show only routes with tag\n" "Tag value\n") { + int idx_number = 4; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -2636,10 +3042,10 @@ DEFUN (show_ip_route_tag, if (argc > 1) { tag = atoi(argv[1]); - VRF_GET_ID (vrf_id, argv[4]->arg); + VRF_GET_ID (vrf_id, argv[idx_number]->arg); } else - tag = atoi(argv[4]->arg); + tag = atoi(argv[idx_number]->arg); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -2683,6 +3089,7 @@ DEFUN (show_ip_route_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Show route matching the specified Network/Mask pair only\n") { + int idx_ipv4_prefixlen = 3; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -2694,10 +3101,10 @@ DEFUN (show_ip_route_prefix_longer, if (argc > 1) { ret = str2prefix (argv[1], &p); - VRF_GET_ID (vrf_id, argv[3]->arg); + VRF_GET_ID (vrf_id, argv[idx_ipv4_prefixlen]->arg); } else - ret = str2prefix (argv[3]->arg, &p); + ret = str2prefix (argv[idx_ipv4_prefixlen]->arg, &p); if (! ret) { @@ -2847,13 +3254,14 @@ DEFUN (show_ip_route_ospf_instance, "Open Shortest Path First (OSPFv2)\n" "Instance ID\n") { + int idx_number = 4; struct route_table *table; struct route_node *rn; struct rib *rib; int first = 1; u_short instance = 0; - VTY_GET_INTEGER ("Instance", instance, argv[4]->arg); + VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT); if (! table) @@ -2892,6 +3300,7 @@ DEFUN (show_ip_route_addr, "IP routing table\n" "Network in the IP routing table to display\n") { + int idx_ipv4 = 3; int ret; struct prefix_ipv4 p; struct route_table *table; @@ -2900,11 +3309,11 @@ DEFUN (show_ip_route_addr, if (argc > 1) { - VRF_GET_ID (vrf_id, argv[3]->arg); + VRF_GET_ID (vrf_id, argv[idx_ipv4]->arg); ret = str2prefix_ipv4 (argv[1], &p); } else - ret = str2prefix_ipv4 (argv[3]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { @@ -2949,6 +3358,7 @@ DEFUN (show_ip_route_prefix, "IP routing table\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { + int idx_ipv4_prefixlen = 3; int ret; struct prefix_ipv4 p; struct route_table *table; @@ -2957,11 +3367,11 @@ DEFUN (show_ip_route_prefix, if (argc > 1) { - VRF_GET_ID (vrf_id, argv[3]->arg); + VRF_GET_ID (vrf_id, argv[idx_ipv4_prefixlen]->arg); ret = str2prefix_ipv4 (argv[1], &p); } else - ret = str2prefix_ipv4 (argv[3]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret <= 0) { @@ -3264,6 +3674,7 @@ DEFUN (show_ip_route_vrf_all_tag, "Show only routes with tag\n" "Tag value\n") { + int idx_number = 6; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -3273,8 +3684,8 @@ DEFUN (show_ip_route_vrf_all_tag, int vrf_header = 1; u_short tag = 0; - if (argv[6]->arg) - tag = atoi(argv[6]->arg); + if (argv[idx_number]->arg) + tag = atoi(argv[idx_number]->arg); for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) { @@ -3317,6 +3728,7 @@ DEFUN (show_ip_route_vrf_all_prefix_longer, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Show route matching the specified Network/Mask pair only\n") { + int idx_ipv4_prefixlen = 5; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -3327,7 +3739,7 @@ DEFUN (show_ip_route_vrf_all_prefix_longer, int first = 1; int vrf_header = 1; - ret = str2prefix (argv[5]->arg, &p); + ret = str2prefix (argv[idx_ipv4_prefixlen]->arg, &p); if (! ret) { vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); @@ -3482,6 +3894,7 @@ DEFUN (show_ip_route_vrf_all_addr, VRF_ALL_CMD_HELP_STR "Network in the IP routing table to display\n") { + int idx_ipv4 = 5; int ret; struct prefix_ipv4 p; struct route_table *table; @@ -3489,7 +3902,7 @@ DEFUN (show_ip_route_vrf_all_addr, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv4 (argv[5]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p); if (ret <= 0) { vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); @@ -3523,6 +3936,7 @@ DEFUN (show_ip_route_vrf_all_prefix, VRF_ALL_CMD_HELP_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { + int idx_ipv4_prefixlen = 5; int ret; struct prefix_ipv4 p; struct route_table *table; @@ -3530,7 +3944,7 @@ DEFUN (show_ip_route_vrf_all_prefix, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv4 (argv[5]->arg, &p); + ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p); if (ret <= 0) { vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); @@ -3789,7 +4203,9 @@ DEFUN (ipv6_route, "IPv6 gateway address\n" "IPv6 gateway interface name\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, NULL, NULL); } DEFUN (ipv6_route_tag, @@ -3803,7 +4219,10 @@ DEFUN (ipv6_route_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, argv[5]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_number = 5; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, NULL, NULL); } DEFUN (ipv6_route_flags, @@ -3817,7 +4236,10 @@ DEFUN (ipv6_route_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } DEFUN (ipv6_route_flags_tag, @@ -3833,7 +4255,11 @@ DEFUN (ipv6_route_flags_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } DEFUN (ipv6_route_ifname, @@ -3845,7 +4271,10 @@ DEFUN (ipv6_route_ifname, "IPv6 gateway address\n" "IPv6 gateway interface name\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, NULL, NULL); } DEFUN (ipv6_route_ifname_tag, ipv6_route_ifname_tag_cmd, @@ -3858,7 +4287,11 @@ DEFUN (ipv6_route_ifname_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_number = 6; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, NULL, NULL); } DEFUN (ipv6_route_ifname_flags, @@ -3872,7 +4305,11 @@ DEFUN (ipv6_route_ifname_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } DEFUN (ipv6_route_ifname_flags_tag, @@ -3888,7 +4325,12 @@ DEFUN (ipv6_route_ifname_flags_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } DEFUN (ipv6_route_pref, @@ -3901,7 +4343,10 @@ DEFUN (ipv6_route_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, NULL, argv[4]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_number = 4; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, argv[idx_number]->arg, NULL); } DEFUN (ipv6_route_pref_tag, @@ -3916,7 +4361,11 @@ DEFUN (ipv6_route_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, argv[5]->arg, argv[6]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_number = 5; + int idx_number_2 = 6; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (ipv6_route_flags_pref, @@ -3931,7 +4380,11 @@ DEFUN (ipv6_route_flags_pref, "Silently discard pkts when matched\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[5]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, NULL); } DEFUN (ipv6_route_flags_pref_tag, @@ -3948,7 +4401,12 @@ DEFUN (ipv6_route_flags_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, argv[7]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (ipv6_route_ifname_pref, @@ -3961,7 +4419,11 @@ DEFUN (ipv6_route_ifname_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[5]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_number = 5; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, argv[idx_number]->arg, NULL); } DEFUN (ipv6_route_ifname_pref_tag, @@ -3976,7 +4438,12 @@ DEFUN (ipv6_route_ifname_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_number = 6; + int idx_number_2 = 7; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (ipv6_route_ifname_flags_pref, @@ -3991,7 +4458,12 @@ DEFUN (ipv6_route_ifname_flags_pref, "Silently discard pkts when matched\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[6]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, NULL); } DEFUN (ipv6_route_ifname_flags_pref_tag, @@ -4008,7 +4480,13 @@ DEFUN (ipv6_route_ifname_flags_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, argv[8]->arg, NULL); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (no_ipv6_route, @@ -4021,7 +4499,9 @@ DEFUN (no_ipv6_route, "IPv6 gateway address\n" "IPv6 gateway interface name\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, NULL, NULL); } DEFUN (no_ipv6_route_tag, @@ -4036,7 +4516,10 @@ DEFUN (no_ipv6_route_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[6]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_number = 6; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, NULL, NULL); } DEFUN (no_ipv6_route_flags, @@ -4051,7 +4534,10 @@ DEFUN (no_ipv6_route_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } DEFUN (no_ipv6_route_flags_tag, @@ -4068,7 +4554,11 @@ DEFUN (no_ipv6_route_flags_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } DEFUN (no_ipv6_route_ifname, @@ -4081,7 +4571,10 @@ DEFUN (no_ipv6_route_ifname, "IPv6 gateway address\n" "IPv6 gateway interface name\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, NULL, NULL); } DEFUN (no_ipv6_route_ifname_tag, @@ -4096,7 +4589,11 @@ DEFUN (no_ipv6_route_ifname_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_number = 7; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, NULL, NULL); } DEFUN (no_ipv6_route_ifname_flags, @@ -4111,7 +4608,11 @@ DEFUN (no_ipv6_route_ifname_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, NULL, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, NULL); } DEFUN (no_ipv6_route_ifname_flags_tag, @@ -4128,7 +4629,12 @@ DEFUN (no_ipv6_route_ifname_flags_tag, "Set tag for this route\n" "Tag value\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg, NULL, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_number = 8; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, NULL); } DEFUN (no_ipv6_route_pref, @@ -4142,7 +4648,10 @@ DEFUN (no_ipv6_route_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, argv[5]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_number = 5; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, argv[idx_number]->arg, NULL); } DEFUN (no_ipv6_route_pref_tag, @@ -4158,7 +4667,11 @@ DEFUN (no_ipv6_route_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[6]->arg, argv[7]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_number = 6; + int idx_number_2 = 7; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (no_ipv6_route_flags_pref, @@ -4174,8 +4687,12 @@ DEFUN (no_ipv6_route_flags_pref, "Silently discard pkts when matched\n" "Distance value for this prefix\n") { - /* We do not care about argv[5]->arg */ - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, NULL, argv[6]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + /* We do not care about argv[idx_reject_blackhole]->arg */ + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, NULL); } DEFUN (no_ipv6_route_flags_pref_tag, @@ -4193,8 +4710,13 @@ DEFUN (no_ipv6_route_flags_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - /* We do not care about argv[5]->arg */ - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg, argv[8]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + /* We do not care about argv[idx_reject_blackhole]->arg */ + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (no_ipv6_route_ifname_pref, @@ -4208,7 +4730,11 @@ DEFUN (no_ipv6_route_ifname_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[6]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_number = 6; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, argv[idx_number]->arg, NULL); } DEFUN (no_ipv6_route_ifname_pref_tag, @@ -4224,7 +4750,12 @@ DEFUN (no_ipv6_route_ifname_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_number = 7; + int idx_number_2 = 8; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (no_ipv6_route_ifname_flags_pref, @@ -4240,7 +4771,12 @@ DEFUN (no_ipv6_route_ifname_flags_pref, "Silently discard pkts when matched\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, NULL, argv[7]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_number = 7; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, NULL); } DEFUN (no_ipv6_route_ifname_flags_pref_tag, @@ -4258,7 +4794,13 @@ DEFUN (no_ipv6_route_ifname_flags_pref_tag, "Tag value\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg, argv[9]->arg, NULL); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_number = 8; + int idx_number_2 = 9; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, NULL); } DEFUN (ipv6_route_vrf, @@ -4271,7 +4813,10 @@ DEFUN (ipv6_route_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, NULL, NULL, argv[5]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_name = 5; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_tag_vrf, @@ -4286,7 +4831,11 @@ DEFUN (ipv6_route_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_number = 5; + int idx_name = 7; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_flags_vrf, @@ -4301,7 +4850,11 @@ DEFUN (ipv6_route_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, argv[6]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_name = 6; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_flags_tag_vrf, @@ -4318,7 +4871,12 @@ DEFUN (ipv6_route_flags_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_name = 8; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_vrf, @@ -4331,7 +4889,11 @@ DEFUN (ipv6_route_ifname_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, argv[6]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_name = 6; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_tag_vrf, ipv6_route_ifname_tag_vrf_cmd, @@ -4345,7 +4907,12 @@ DEFUN (ipv6_route_ifname_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_number = 6; + int idx_name = 8; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_flags_vrf, @@ -4360,7 +4927,12 @@ DEFUN (ipv6_route_ifname_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[7]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_name = 7; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_flags_tag_vrf, @@ -4377,7 +4949,13 @@ DEFUN (ipv6_route_ifname_flags_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, NULL, argv[9]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_name = 9; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (ipv6_route_pref_vrf, @@ -4391,7 +4969,11 @@ DEFUN (ipv6_route_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, NULL, argv[4]->arg, argv[6]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_number = 4; + int idx_name = 6; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ipv6_route_pref_tag_vrf, @@ -4407,7 +4989,12 @@ DEFUN (ipv6_route_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, NULL, argv[5]->arg, argv[6]->arg, argv[8]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_number = 5; + int idx_number_2 = 6; + int idx_name = 8; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (ipv6_route_flags_pref_vrf, @@ -4423,7 +5010,12 @@ DEFUN (ipv6_route_flags_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 5; + int idx_name = 7; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ipv6_route_flags_pref_tag_vrf, @@ -4441,7 +5033,13 @@ DEFUN (ipv6_route_flags_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, NULL, argv[4]->arg, argv[6]->arg, argv[7]->arg, argv[9]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6_ifname = 3; + int idx_reject_blackhole = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_pref_vrf, @@ -4455,7 +5053,12 @@ DEFUN (ipv6_route_ifname_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_number = 5; + int idx_name = 7; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_pref_tag_vrf, @@ -4471,7 +5074,13 @@ DEFUN (ipv6_route_ifname_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, argv[9]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_flags_pref_vrf, @@ -4487,7 +5096,13 @@ DEFUN (ipv6_route_ifname_flags_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[6]->arg, argv[8]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + int idx_name = 8; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (ipv6_route_ifname_flags_pref_tag_vrf, @@ -4505,7 +5120,14 @@ DEFUN (ipv6_route_ifname_flags_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[7]->arg, argv[8]->arg, argv[10]->arg); + int idx_ipv6_prefixlen = 2; + int idx_ipv6 = 3; + int idx_interface = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + int idx_name = 10; + return static_ipv6_func (vty, 1, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_vrf, @@ -4519,7 +5141,10 @@ DEFUN (no_ipv6_route_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, NULL, argv[6]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_name = 6; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_tag_vrf, @@ -4535,7 +5160,11 @@ DEFUN (no_ipv6_route_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[6]->arg, NULL, argv[8]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_number = 6; + int idx_name = 8; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_flags_vrf, @@ -4551,7 +5180,11 @@ DEFUN (no_ipv6_route_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, NULL, NULL, argv[7]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_name = 7; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_flags_tag_vrf, @@ -4569,7 +5202,12 @@ DEFUN (no_ipv6_route_flags_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg, NULL, argv[9]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_name = 9; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_vrf, @@ -4583,7 +5221,11 @@ DEFUN (no_ipv6_route_ifname_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, NULL, argv[7]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_name = 7; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_tag_vrf, @@ -4599,7 +5241,12 @@ DEFUN (no_ipv6_route_ifname_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, NULL, argv[9]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_number = 7; + int idx_name = 9; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_flags_vrf, @@ -4615,7 +5262,12 @@ DEFUN (no_ipv6_route_ifname_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, NULL, NULL, argv[8]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_name = 8; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_flags_tag_vrf, @@ -4633,7 +5285,13 @@ DEFUN (no_ipv6_route_ifname_flags_tag_vrf, "Tag value\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg, NULL, argv[10]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_number = 8; + int idx_name = 10; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, NULL, argv[idx_name]->arg); } DEFUN (no_ipv6_route_pref_vrf, @@ -4648,7 +5306,11 @@ DEFUN (no_ipv6_route_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, argv[5]->arg, argv[7]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_number = 5; + int idx_name = 7; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_pref_tag_vrf, @@ -4665,7 +5327,12 @@ DEFUN (no_ipv6_route_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[6]->arg, argv[7]->arg, argv[9]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_number = 6; + int idx_number_2 = 7; + int idx_name = 9; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_flags_pref_vrf, @@ -4682,8 +5349,13 @@ DEFUN (no_ipv6_route_flags_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - /* We do not care about argv[5]->arg */ - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, NULL, argv[6]->arg, argv[8]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 6; + int idx_name = 8; + /* We do not care about argv[idx_reject_blackhole]->arg */ + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_flags_pref_tag_vrf, @@ -4702,8 +5374,14 @@ DEFUN (no_ipv6_route_flags_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - /* We do not care about argv[5]->arg */ - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, NULL, argv[5]->arg, argv[7]->arg, argv[8]->arg, argv[10]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6_ifname = 4; + int idx_reject_blackhole = 5; + int idx_number = 7; + int idx_number_2 = 8; + int idx_name = 10; + /* We do not care about argv[idx_reject_blackhole]->arg */ + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6_ifname]->arg, NULL, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_pref_vrf, @@ -4718,7 +5396,12 @@ DEFUN (no_ipv6_route_ifname_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[6]->arg, argv[8]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_number = 6; + int idx_name = 8; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_pref_tag_vrf, @@ -4735,7 +5418,13 @@ DEFUN (no_ipv6_route_ifname_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg, argv[10]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_number = 7; + int idx_number_2 = 8; + int idx_name = 10; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, NULL, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_flags_pref_vrf, @@ -4752,7 +5441,13 @@ DEFUN (no_ipv6_route_ifname_flags_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, NULL, argv[7]->arg, argv[9]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_number = 7; + int idx_name = 9; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, NULL, argv[idx_number]->arg, argv[idx_name]->arg); } DEFUN (no_ipv6_route_ifname_flags_pref_tag_vrf, @@ -4771,7 +5466,14 @@ DEFUN (no_ipv6_route_ifname_flags_pref_tag_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, argv[6]->arg, argv[8]->arg, argv[9]->arg, argv[11]->arg); + int idx_ipv6_prefixlen = 3; + int idx_ipv6 = 4; + int idx_interface = 5; + int idx_reject_blackhole = 6; + int idx_number = 8; + int idx_number_2 = 9; + int idx_name = 11; + return static_ipv6_func (vty, 0, argv[idx_ipv6_prefixlen]->arg, argv[idx_ipv6]->arg, argv[idx_interface]->arg, argv[idx_reject_blackhole]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_name]->arg); } /* @@ -4790,6 +5492,7 @@ DEFUN (show_ipv6_route, IP_STR "IPv6 routing table\n") { + int idx_json = 3; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -4801,14 +5504,14 @@ DEFUN (show_ipv6_route, json_object *json_prefix = NULL; u_char uj = use_json(argc, argv); - if (argc > 0 && argv[3]->arg && strcmp(argv[3]->arg, "json") != 0) + if (argc > 0 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0) { - if (!(zvrf = zebra_vrf_list_lookup_by_name (argv[3]->arg))) + if (!(zvrf = zebra_vrf_list_lookup_by_name (argv[idx_json]->arg))) { if (uj) vty_out (vty, "{}%s", VTY_NEWLINE); else - vty_out (vty, "vrf %s not defined%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "vrf %s not defined%s", argv[idx_json]->arg, VTY_NEWLINE); return CMD_SUCCESS; } @@ -4817,7 +5520,7 @@ DEFUN (show_ipv6_route, if (uj) vty_out (vty, "{}%s", VTY_NEWLINE); else - vty_out (vty, "vrf %s inactive%s", argv[3]->arg, VTY_NEWLINE); + vty_out (vty, "vrf %s inactive%s", argv[idx_json]->arg, VTY_NEWLINE); return CMD_SUCCESS; } else @@ -4898,6 +5601,7 @@ DEFUN (show_ipv6_route_tag, "Show only routes with tag\n" "Tag value\n") { + int idx_number = 4; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -4907,11 +5611,11 @@ DEFUN (show_ipv6_route_tag, if (argc > 1) { - VRF_GET_ID (vrf_id, argv[4]->arg); + VRF_GET_ID (vrf_id, argv[idx_number]->arg); tag = atoi(argv[1]); } else - tag = atoi(argv[4]->arg); + tag = atoi(argv[idx_number]->arg); table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); if (! table) @@ -4955,6 +5659,7 @@ DEFUN (show_ipv6_route_prefix_longer, "IPv6 prefix\n" "Show route matching the specified Network/Mask pair only\n") { + int idx_ipv6_prefixlen = 3; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -4965,11 +5670,11 @@ DEFUN (show_ipv6_route_prefix_longer, if (argc > 1) { - VRF_GET_ID (vrf_id, argv[3]->arg); + VRF_GET_ID (vrf_id, argv[idx_ipv6_prefixlen]->arg); ret = str2prefix (argv[1], &p); } else - ret = str2prefix (argv[3]->arg, &p); + ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &p); if (! ret) { @@ -5015,6 +5720,7 @@ DEFUN (show_ipv6_route_protocol, "IP routing table\n" QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) { + int idx_protocol = 3; int type; struct route_table *table; struct route_node *rn; @@ -5025,7 +5731,7 @@ DEFUN (show_ipv6_route_protocol, if ( argc >1 ) { VRF_GET_ID (vrf_id, argv[4]->arg); - type = proto_redistnum (AFI_IP6, argv[3]->arg); + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); } else type = proto_redistnum (AFI_IP6, argv[4]->arg); @@ -5074,6 +5780,7 @@ DEFUN (show_ipv6_route_addr, "IPv6 routing table\n" "IPv6 Address\n") { + int idx_ipv6 = 3; int ret; struct prefix_ipv6 p; struct route_table *table; @@ -5082,11 +5789,11 @@ DEFUN (show_ipv6_route_addr, if (argc > 1 ) { - VRF_GET_ID (vrf_id, argv[3]->arg); + VRF_GET_ID (vrf_id, argv[idx_ipv6]->arg); ret = str2prefix_ipv6 (argv[1], &p); } else - ret = str2prefix_ipv6 (argv[3]->arg, &p); + ret = str2prefix_ipv6 (argv[idx_ipv6]->arg, &p); if (ret <= 0) { @@ -5131,6 +5838,7 @@ DEFUN (show_ipv6_route_prefix, "IPv6 routing table\n" "IPv6 prefix\n") { + int idx_ipv6_prefixlen = 3; int ret; struct prefix_ipv6 p; struct route_table *table; @@ -5139,11 +5847,11 @@ DEFUN (show_ipv6_route_prefix, if (argc > 1) { - VRF_GET_ID (vrf_id, argv[3]->arg); + VRF_GET_ID (vrf_id, argv[idx_ipv6_prefixlen]->arg); ret = str2prefix_ipv6 (argv[1], &p); } else - ret = str2prefix_ipv6 (argv[3]->arg, &p); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, &p); if (ret <= 0) { @@ -5346,6 +6054,7 @@ DEFUN (show_ipv6_route_vrf_all_tag, "Show only routes with tag\n" "Tag value\n") { + int idx_number = 6; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -5355,8 +6064,8 @@ DEFUN (show_ipv6_route_vrf_all_tag, int vrf_header = 1; u_short tag = 0; - if (argv[6]->arg) - tag = atoi(argv[6]->arg); + if (argv[idx_number]->arg) + tag = atoi(argv[idx_number]->arg); for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) { @@ -5400,6 +6109,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer, "IPv6 prefix\n" "Show route matching the specified Network/Mask pair only\n") { + int idx_ipv6_prefixlen = 5; struct route_table *table; struct route_node *rn; struct rib *rib; @@ -5410,7 +6120,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer, int first = 1; int vrf_header = 1; - ret = str2prefix (argv[5]->arg, &p); + ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &p); if (! ret) { vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); @@ -5511,6 +6221,7 @@ DEFUN (show_ipv6_route_vrf_all_addr, VRF_ALL_CMD_HELP_STR "IPv6 Address\n") { + int idx_ipv6 = 5; int ret; struct prefix_ipv6 p; struct route_table *table; @@ -5518,7 +6229,7 @@ DEFUN (show_ipv6_route_vrf_all_addr, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv6 (argv[5]->arg, &p); + ret = str2prefix_ipv6 (argv[idx_ipv6]->arg, &p); if (ret <= 0) { vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE); @@ -5552,6 +6263,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix, VRF_ALL_CMD_HELP_STR "IPv6 prefix\n") { + int idx_ipv6_prefixlen = 5; int ret; struct prefix_ipv6 p; struct route_table *table; @@ -5559,7 +6271,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix, struct zebra_vrf *zvrf; vrf_iter_t iter; - ret = str2prefix_ipv6 (argv[5]->arg, &p); + ret = str2prefix_ipv6 (argv[idx_ipv6_prefixlen]->arg, &p); if (ret <= 0) { vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); @@ -5807,11 +6519,13 @@ DEFUN (ip_zebra_import_table_distance, "Distance for imported routes\n" "Default distance value\n") { + int idx_number = 2; + int idx_number_2 = 4; u_int32_t table_id = 0; int distance = ZEBRA_TABLE_DISTANCE_DEFAULT; if (argc) - VTY_GET_INTEGER("table", table_id, argv[2]->arg); + VTY_GET_INTEGER("table", table_id, argv[idx_number]->arg); if (!is_zebra_valid_kernel_table(table_id)) { @@ -5828,7 +6542,7 @@ DEFUN (ip_zebra_import_table_distance, } if (argc > 1) - VTY_GET_INTEGER_RANGE("distance", distance, argv[4]->arg, 1, 255); + VTY_GET_INTEGER_RANGE("distance", distance, argv[idx_number_2]->arg, 1, 255); return (zebra_import_table(AFI_IP, table_id, distance, NULL, 1)); } @@ -5855,12 +6569,15 @@ DEFUN (ip_zebra_import_table_distance_routemap, "route-map for filtering\n" "route-map name\n") { + int idx_number = 2; + int idx_number_2 = 4; + int idx_word = 6; u_int32_t table_id = 0; int distance = ZEBRA_TABLE_DISTANCE_DEFAULT; const char *rmap_name; if (argc) - VTY_GET_INTEGER("table", table_id, argv[2]->arg); + VTY_GET_INTEGER("table", table_id, argv[idx_number]->arg); if (!is_zebra_valid_kernel_table(table_id)) { @@ -5878,11 +6595,11 @@ DEFUN (ip_zebra_import_table_distance_routemap, if (argc > 2) { - VTY_GET_INTEGER_RANGE("distance", distance, argv[4]->arg, 1, 255); - rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[6]->arg); + VTY_GET_INTEGER_RANGE("distance", distance, argv[idx_number_2]->arg, 1, 255); + rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[idx_word]->arg); } else - rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[4]->arg); + rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[idx_number_2]->arg); return (zebra_import_table(AFI_IP, table_id, distance, rmap_name, 1)); } @@ -5905,10 +6622,11 @@ DEFUN (no_ip_zebra_import_table, "import routes from non-main kernel table\n" "kernel routing table id\n") { + int idx_number = 3; u_int32_t table_id = 0; if (argc) - VTY_GET_INTEGER("table", table_id, argv[3]->arg); + VTY_GET_INTEGER("table", table_id, argv[idx_number]->arg); if (!is_zebra_valid_kernel_table(table_id)) { |