]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripngd: add 'int idx_foo' argv index variables
authorDaniel Walton <dwalton@cumulusnetworks.com>
Fri, 23 Sep 2016 20:04:42 +0000 (20:04 +0000)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Fri, 23 Sep 2016 20:04:42 +0000 (20:04 +0000)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
ripngd/ripng_debug.c
ripngd/ripng_interface.c
ripngd/ripng_offset.c
ripngd/ripng_routemap.c
ripngd/ripng_zebra.c
ripngd/ripngd.c

index ecbba5b308d06184b5c9a5f4b428aa2cde4192b3..de5367261d7d6c0871c6fbf0ad1d70ecf184f3e5 100644 (file)
@@ -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;
index 930752abd0f2a62bdfd3413510e43459afcf64bc..9c434c8dfb91853c63d0b7da0b6c21509b1dc092 100644 (file)
@@ -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 *
index 46ca818c4613092e5b8ce45b04519c830366c41e..dcddf96ebfea0c039697ec235dc85b77f1ea93f0 100644 (file)
@@ -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
index 0910f94a7731b1ad31125f654be20cf697c0ad9a..9e2c35b38e781e0ef3e9f7dfc8beaaab75420cd2 100644 (file)
@@ -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);
 }
 
 /*
index e4552119545a3ecb7d1b6d07306bff3ddd66b875..a6dc20072d4ec38b5073a57390457431bdd5338c 100644 (file)
@@ -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;
 }
index 5e53d44b698bb194ffb946b1f253e5664e0fdf79..d3944c1c70d8dd9418f6c5c13fd37cb992bdaf9f 100644 (file)
@@ -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;