From: Daniel Walton Date: Fri, 23 Sep 2016 20:04:42 +0000 (+0000) Subject: ripngd: add 'int idx_foo' argv index variables X-Git-Tag: frr-3.0-branchpoint~129^2~173^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=ab34a28ac64a24e5d736b3d90004d859a1ace1f3;p=matthieu%2Ffrr.git ripngd: add 'int idx_foo' argv index variables Signed-off-by: Daniel Walton --- diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index ecbba5b308..de5367261d 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 930752abd0..9c434c8dfb 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 46ca818c46..dcddf96ebf 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 0910f94a77..9e2c35b38e 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 e455211954..a6dc20072d 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 5e53d44b69..d3944c1c70 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;