]> git.puffer.fish Git - mirror/frr.git/commitdiff
ripd, ripngd: cli refactor
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 27 Sep 2016 00:10:31 +0000 (00:10 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 27 Sep 2016 00:10:31 +0000 (00:10 +0000)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
ripd/rip_interface.c
ripd/ripd.c
ripngd/ripng_zebra.c
ripngd/ripngd.c

index 036edeac8b7126a2e47a7fbf1b639e1cc90b84bc..d6686399c2e5b5e7684c08dfe87f15d78cb7f487 100644 (file)
@@ -1398,26 +1398,16 @@ DEFUN (ip_rip_receive_version_2,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no ip rip receive version (1|2)",
- *     NO_STR
- *     IP_STR
- *     "Routing Information Protocol\n"
- *     "Advertisement reception\n"
- *     "Version control\n"
- *     "Version 1\n"
- *     "Version 2\n"
- *
- */
 DEFUN (no_ip_rip_receive_version,
        no_ip_rip_receive_version_cmd,
-       "no ip rip receive version",
+       "no ip rip receive version [(1-1)|(2-2)]",
        NO_STR
        IP_STR
        "Routing Information Protocol\n"
        "Advertisement reception\n"
-       "Version control\n")
+       "Version control\n"
+       "Version 1\n"
+       "Version 2\n")
 {
   struct interface *ifp;
   struct rip_interface *ri;
@@ -1503,26 +1493,16 @@ DEFUN (ip_rip_send_version_2,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no ip rip send version (1|2)",
- *     NO_STR
- *     IP_STR
- *     "Routing Information Protocol\n"
- *     "Advertisement transmission\n"
- *     "Version control\n"
- *     "Version 1\n"
- *     "Version 2\n"
- *
- */
 DEFUN (no_ip_rip_send_version,
        no_ip_rip_send_version_cmd,
-       "no ip rip send version",
+       "no ip rip send version [(1-1)|(2-2)]",
        NO_STR
        IP_STR
        "Routing Information Protocol\n"
        "Advertisement transmission\n"
-       "Version control\n")
+       "Version control\n"
+       "Version 1\n"
+       "Version 2\n")
 {
   struct interface *ifp;
   struct rip_interface *ri;
@@ -1535,31 +1515,21 @@ DEFUN (no_ip_rip_send_version,
 }
 
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
- *     IP_STR
- *     "Routing Information Protocol\n"
- *     "Authentication control\n"
- *     "Authentication mode\n"
- *     "Keyed message digest\n"
- *     "Clear text authentication\n"
- *     "MD5 authentication data length\n"
- *     "RFC compatible\n"
- *     "Old ripd compatible\n"
- *
- */
 DEFUN (ip_rip_authentication_mode,
        ip_rip_authentication_mode_cmd,
-       "ip rip authentication mode <md5|text>",
+       "ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]",
        IP_STR
        "Routing Information Protocol\n"
        "Authentication control\n"
        "Authentication mode\n"
        "Keyed message digest\n"
-       "Clear text authentication\n")
+       "Clear text authentication\n"
+       "MD5 authentication data length\n"
+       "RFC compatible\n"
+       "Old ripd compatible\n")
 {
-  int idx_encryption = 4;
+  char *cryptmode = argv[4]->text;
+  char *authlen = (argc > 5) ? argv[6]->text : NULL;
   struct interface *ifp;
   struct rip_interface *ri;
   int auth_type;
@@ -1567,79 +1537,47 @@ DEFUN (ip_rip_authentication_mode,
   ifp = (struct interface *)vty->index;
   ri = ifp->info;
 
-  if ( (argc < 1) || (argc > 2) )
-    {
-      vty_out (vty, "incorrect argument count%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-    
-  if (strncmp ("md5", argv[idx_encryption]->arg, strlen (argv[idx_encryption]->arg)) == 0)
+  if (strmatch ("md5", cryptmode))
     auth_type = RIP_AUTH_MD5;
-  else if (strncmp ("text", argv[idx_encryption]->arg, strlen (argv[idx_encryption]->arg)) == 0)
+  else {
+    assert (strmatch ("text", cryptmode));
     auth_type = RIP_AUTH_SIMPLE_PASSWORD;
-  else
-    {
-      vty_out (vty, "mode should be md5 or text%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
+  }
 
-  if (argc == 1)
-    {
-      ri->auth_type = auth_type;
-      return CMD_SUCCESS;
-    }
+  ri->auth_type = auth_type;
 
-  if ( (argc == 2) && (auth_type != RIP_AUTH_MD5) )
+  if (argc > 5)
+  {
+    if (auth_type != RIP_AUTH_MD5)
     {
       vty_out (vty, "auth length argument only valid for md5%s", VTY_NEWLINE);
       return CMD_WARNING;
     }
+    if (strmatch ("rfc", authlen))
+      ri->md5_auth_len = RIP_AUTH_MD5_SIZE;
+    else
+    {
+      assert (strmatch ("old-ripd", authlen));
+      ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
+    }
+  }
 
-  if (strncmp ("r", argv[6]->arg, 1) == 0)
-    ri->md5_auth_len = RIP_AUTH_MD5_SIZE;
-  else if (strncmp ("o", argv[6]->arg, 1) == 0)
-    ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
-  else 
-    return CMD_WARNING;
-    
-  ri->auth_type = auth_type;
-  
   return CMD_SUCCESS;
 }
 
-
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no ip rip authentication mode (md5|text)",
- *     NO_STR
- *     IP_STR
- *     "Routing Information Protocol\n"
- *     "Authentication control\n"
- *     "Authentication mode\n"
- *     "Keyed message digest\n"
- *     "Clear text authentication\n"
- *
- * "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
- *     NO_STR
- *     IP_STR
- *     "Routing Information Protocol\n"
- *     "Authentication control\n"
- *     "Authentication mode\n"
- *     "Keyed message digest\n"
- *     "Clear text authentication\n"
- *     "MD5 authentication data length\n"
- *     "RFC compatible\n"
- *     "Old ripd compatible\n"
- *
- */
 DEFUN (no_ip_rip_authentication_mode,
        no_ip_rip_authentication_mode_cmd,
-       "no ip rip authentication mode",
+       "no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]",
        NO_STR
        IP_STR
        "Routing Information Protocol\n"
        "Authentication control\n"
-       "Authentication mode\n")
+       "Authentication mode\n"
+       "Keyed message digest\n"
+       "Clear text authentication\n"
+       "MD5 authentication data length\n"
+       "RFC compatible\n"
+       "Old ripd compatible\n")
 {
   struct interface *ifp;
   struct rip_interface *ri;
@@ -1653,8 +1591,6 @@ DEFUN (no_ip_rip_authentication_mode,
   return CMD_SUCCESS;
 }
 
-
-
 DEFUN (ip_rip_authentication_string,
        ip_rip_authentication_string_cmd,
        "ip rip authentication string LINE",
@@ -1692,24 +1628,14 @@ DEFUN (ip_rip_authentication_string,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no ip rip authentication string LINE",
- *     NO_STR
- *     IP_STR
- *     "Routing Information Protocol\n"
- *     "Authentication control\n"
- *     "Authentication string\n"
- *     "Authentication string\n"
- *
- */
 DEFUN (no_ip_rip_authentication_string,
        no_ip_rip_authentication_string_cmd,
-       "no ip rip authentication string",
+       "no ip rip authentication string [LINE]",
        NO_STR
        IP_STR
        "Routing Information Protocol\n"
        "Authentication control\n"
+       "Authentication string\n"
        "Authentication string\n")
 {
   struct interface *ifp;
@@ -1758,25 +1684,15 @@ DEFUN (ip_rip_authentication_key_chain,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no ip rip authentication key-chain LINE",
- *     NO_STR
- *     IP_STR
- *     "Routing Information Protocol\n"
- *     "Authentication control\n"
- *     "Authentication key-chain\n"
- *     "name of key-chain\n"
- *
- */
 DEFUN (no_ip_rip_authentication_key_chain,
        no_ip_rip_authentication_key_chain_cmd,
-       "no ip rip authentication key-chain",
+       "no ip rip authentication key-chain [LINE]",
        NO_STR
        IP_STR
        "Routing Information Protocol\n"
        "Authentication control\n"
-       "Authentication key-chain\n")
+       "Authentication key-chain\n"
+       "name of key-chain\n")
 {
   struct interface *ifp;
   struct rip_interface *ri;
@@ -1871,10 +1787,10 @@ DEFUN (no_ip_rip_split_horizon_poisoned_reverse,
 
   switch( ri->split_horizon )
   {
-       case RIP_SPLIT_HORIZON_POISONED_REVERSE:
-               ri->split_horizon = RIP_SPLIT_HORIZON;
-       default:
-               break;
+     case RIP_SPLIT_HORIZON_POISONED_REVERSE:
+       ri->split_horizon = RIP_SPLIT_HORIZON;
+     default:
+       break;
   }
 
   return CMD_SUCCESS;
@@ -1887,18 +1803,15 @@ DEFUN (rip_passive_interface,
        "Interface name\n"
        "default for all interfaces\n")
 {
-  int idx_ifname = 1;
-  const char *ifname = argv[idx_ifname]->arg;
-
-  if (!strcmp(ifname,"default")) {
+  if (argv[1]->type == WORD_TKN) { // user passed 'default'
     passive_default = 1;
     rip_passive_nondefault_clean();
     return CMD_SUCCESS;
   }
   if (passive_default)
-    return rip_passive_nondefault_unset (vty, ifname);
+    return rip_passive_nondefault_unset (vty, argv[1]->arg);
   else
-    return rip_passive_nondefault_set (vty, ifname);
+    return rip_passive_nondefault_set (vty, argv[1]->arg);
 }
 
 DEFUN (no_rip_passive_interface,
@@ -1909,18 +1822,15 @@ DEFUN (no_rip_passive_interface,
        "Interface name\n"
        "default for all interfaces\n")
 {
-  int idx_ifname = 2;
-  const char *ifname = argv[idx_ifname]->arg;
-
-  if (!strcmp(ifname,"default")) {
+  if (argv[2]->type == WORD_TKN) {
     passive_default = 0;
     rip_passive_nondefault_clean();
     return CMD_SUCCESS;
   }
   if (passive_default)
-    return rip_passive_nondefault_set (vty, ifname);
+    return rip_passive_nondefault_set (vty, argv[2]->arg);
   else
-    return rip_passive_nondefault_unset (vty, ifname);
+    return rip_passive_nondefault_unset (vty, argv[2]->arg);
 }
 
 /* Write rip configuration of each interface. */
index a7f35de276453eb4633c4d1d6da934bb141ca66f..c5d928ba6d72caffc8ef18fbeffcd33451586da2 100644 (file)
@@ -2963,19 +2963,12 @@ DEFUN (rip_version,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no version <1-2>",
- *     NO_STR
- *     "Set routing protocol version\n"
- *     "version\n"
- *
- */
 DEFUN (no_rip_version,
        no_rip_version_cmd,
-       "no version",
+       "no version [(1-2)]",
        NO_STR
-       "Set routing protocol version\n")
+       "Set routing protocol version\n"
+       "Version\n")
 {
   /* Set RIP version to the default. */
   rip->version_send = RI_RIP_VERSION_2;
@@ -3091,17 +3084,9 @@ DEFUN (rip_default_metric,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no default-metric <1-16>",
- *     NO_STR
- *     "Set a metric of redistribute routes\n"
- *     "Default metric\n"
- *
- */
 DEFUN (no_rip_default_metric,
        no_rip_default_metric_cmd,
-       "no default-metric",
+       "no default-metric [(1-16)]",
        NO_STR
        "Set a metric of redistribute routes\n"
        "Default metric\n")
@@ -3166,23 +3151,15 @@ DEFUN (rip_timers,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no timers basic <0-65535> <0-65535> <0-65535>",
- *     NO_STR
- *     "Adjust routing timers\n"
- *     "Basic routing protocol update timers\n"
- *     "Routing table update timer value in second. Default is 30.\n"
- *     "Routing information timeout timer. Default is 180.\n"
- *     "Garbage collection timer. Default is 120.\n"
- *
- */
 DEFUN (no_rip_timers,
        no_rip_timers_cmd,
-       "no timers basic",
+       "no timers basic [(0-65535) (0-65535) (0-65535)]",
        NO_STR
        "Adjust routing timers\n"
-       "Basic routing protocol update timers\n")
+       "Basic routing protocol update timers\n"
+       "Routing table update timer value in second. Default is 30.\n"
+       "Routing information timeout timer. Default is 180.\n"
+       "Garbage collection timer. Default is 120.\n")
 {
   /* Set each timer value to the default. */
   rip->update_time = RIP_UPDATE_TIMER_DEFAULT;
index 07c51ca6d2ec5b69db1d7a1870a98759a2f0998f..c8527539f82014185b65aa5790951dc078be26d7 100644 (file)
@@ -345,44 +345,23 @@ DEFUN (ripng_redistribute_type,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no redistribute <kernel|connected|static|ospf6|isis|bgp|table> metric <0-16> route-map WORD",
- *     NO_STR
- *     "Redistribute\n"
- *     QUAGGA_REDIST_HELP_STR_RIPNGD
- *     "Route map reference\n"
- *     "Pointer to route-map entries\n"
- *
- * "no redistribute <kernel|connected|static|ospf6|isis|bgp|table> metric <0-16>",
- *     NO_STR
- *     "Redistribute\n"
- *     QUAGGA_REDIST_HELP_STR_RIPNGD
- *     "Metric\n"
- *     "Metric value\n"
- *
- * "no redistribute <kernel|connected|static|ospf6|isis|bgp|table> route-map WORD",
- *     NO_STR
- *     "Redistribute\n"
- *     QUAGGA_REDIST_HELP_STR_RIPNGD
- *     "Route map reference\n"
- *     "Pointer to route-map entries\n"
- *
- */
 DEFUN (no_ripng_redistribute_type,
        no_ripng_redistribute_type_cmd,
-       "no redistribute <kernel|connected|static|ospf6|isis|bgp|table>",
+       "no redistribute <kernel|connected|static|ospf6|isis|bgp|table> [metric (0-16)] [route-map WORD]",
        NO_STR
        "Redistribute\n"
-       QUAGGA_REDIST_HELP_STR_RIPNGD)
+       QUAGGA_REDIST_HELP_STR_RIPNGD
+       "Metric\n"
+       "Metric value\n"
+       "Route map reference\n"
+       "Pointer to route-map entries\n")
 {
   int type;
-
-  type = proto_redistnum(AFI_IP6, argv[3]->arg);
+  type = proto_redistnum(AFI_IP6, argv[2]->text);
 
   if (type < 0)
     {
-      vty_out(vty, "Invalid type %s%s", argv[3]->arg, VTY_NEWLINE);
+      vty_out(vty, "Invalid type %s%s", argv[2]->text, VTY_NEWLINE);
       return CMD_WARNING;
     }
 
@@ -406,11 +385,11 @@ DEFUN (ripng_redistribute_type_metric,
   int metric;
 
   metric = atoi (argv[idx_number]->arg);
-  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
+  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
 
   if (type < 0)
     {
-      vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE);
+      vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
       return CMD_WARNING;
     }
 
@@ -433,15 +412,15 @@ DEFUN (ripng_redistribute_type_routemap,
   int idx_word = 3;
   int type;
 
-  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
+  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
 
   if (type < 0)
     {
-      vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE);
+      vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
       return CMD_WARNING;
     }
 
-  ripng_redistribute_routemap_set (type, argv[idx_word]->arg);
+  ripng_redistribute_routemap_set (type, argv[idx_word]->text);
   zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0,
                         VRF_DEFAULT);
  return CMD_SUCCESS;
@@ -464,17 +443,17 @@ DEFUN (ripng_redistribute_type_metric_routemap,
   int type;
   int metric;
 
-  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
+  type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
   metric = atoi (argv[idx_number]->arg);
 
   if (type < 0)
     {
-      vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, VTY_NEWLINE);
+      vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
       return CMD_WARNING;
     }
 
   ripng_redistribute_metric_set (type, metric);
-  ripng_redistribute_routemap_set (type, argv[idx_word]->arg);
+  ripng_redistribute_routemap_set (type, argv[idx_word]->text);
   zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
   return CMD_SUCCESS;
 }
index d3944c1c70d8dd9418f6c5c13fd37cb992bdaf9f..78a92a497e0391441f2903fc4fa635e2fcf8a271 100644 (file)
@@ -2405,17 +2405,9 @@ DEFUN (ripng_default_metric,
   return CMD_SUCCESS;
 }
 
-/*
- * CHECK ME - The following ALIASes need to be implemented in this DEFUN
- * "no default-metric <1-16>",
- *     NO_STR
- *     "Set a metric of redistribute routes\n"
- *     "Default metric\n"
- *
- */
 DEFUN (no_ripng_default_metric,
        no_ripng_default_metric_cmd,
-       "no default-metric",
+       "no default-metric [(1-16)]",
        NO_STR
        "Set a metric of redistribute routes\n"
        "Default metric\n")