diff options
author | Daniel Walton <dwalton@cumulusnetworks.com> | 2016-09-23 22:06:40 +0200 |
---|---|---|
committer | Daniel Walton <dwalton@cumulusnetworks.com> | 2016-09-23 22:06:40 +0200 |
commit | 80fa0c69e86e8bbb81e6459c70bdfe1a622795c8 (patch) | |
tree | c7529068c0fd2223d4d8ef50786043d81dc81414 | |
parent | ripngd: add 'int idx_foo' argv index variables (diff) | |
download | frr-80fa0c69e86e8bbb81e6459c70bdfe1a622795c8.tar.xz frr-80fa0c69e86e8bbb81e6459c70bdfe1a622795c8.zip |
ripd: add 'int idx_foo' argv index variables
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
-rw-r--r-- | ripd/rip_debug.c | 10 | ||||
-rw-r--r-- | ripd/rip_interface.c | 49 | ||||
-rw-r--r-- | ripd/rip_offset.c | 22 | ||||
-rw-r--r-- | ripd/rip_routemap.c | 32 | ||||
-rw-r--r-- | ripd/rip_zebra.c | 56 | ||||
-rw-r--r-- | ripd/ripd.c | 48 | ||||
-rwxr-xr-x | tools/argv_translator.py | 9 |
7 files changed, 149 insertions, 77 deletions
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/tools/argv_translator.py b/tools/argv_translator.py index c874e0e4b..b637cf69f 100755 --- a/tools/argv_translator.py +++ b/tools/argv_translator.py @@ -292,10 +292,10 @@ def get_token_index_variable_name(line_number, token): elif token == 'both|send|receive' or token == 'send|recv': return 'idx_send_recv' - elif token == 'both|extended|standard': + elif token == 'both|extended|standard' or token == '1|2': return 'idx_type' - elif token == 'A.B.C.D|WORD': + 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': @@ -316,9 +316,12 @@ def get_token_index_variable_name(line_number, token): elif token == 'ipv4|ipv6' or token == 'ip|ipv6': return 'idx_afi' - elif token == 'md5|clear' or token == 'null|message-digest': + 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' |