]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: argv->arg grab bag 754/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 27 Jun 2017 17:42:43 +0000 (17:42 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 27 Jun 2017 17:46:42 +0000 (17:46 +0000)
* Pass ->text to functions that now do full string matching
* Remove cases for l2vpn and evpn where they cannot occur

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_route.c
bgpd/bgp_vty.c
bgpd/bgp_vty.h

index a9e4c0d508bf3e13c5b5cb4c725ed6293d670e45..a68d8e128fbe751ce333f075ef9a4ed6c5a23bd4 100644 (file)
@@ -8463,7 +8463,7 @@ DEFUN (show_ip_bgp_large_community_list,
   {
     afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
     if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
-      safi = bgp_vty_safi_from_arg (argv[idx]->text);
+      safi = bgp_vty_safi_from_str (argv[idx]->text);
   }
 
   int uj = use_json (argc, argv);
@@ -8508,7 +8508,7 @@ DEFUN (show_ip_bgp_large_community,
   {
     afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
     if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
-      safi = bgp_vty_safi_from_arg (argv[idx]->text);
+      safi = bgp_vty_safi_from_str (argv[idx]->text);
   }
 
   int uj = use_json (argc, argv);
index e4d7d152c30351d22911919cac05f9d18451ec72..3c53df10a0b1b74238f29c4b4662b72c97ff0936 100644 (file)
@@ -166,33 +166,25 @@ bgp_node_safi (struct vty *vty)
   return safi;
 }
 
-/* supports <ipv4|ipv6> */
+/**
+ * Converts an AFI in string form to afi_t
+ *
+ * @param afi string, one of
+ *  - "ipv4"
+ *  - "ipv6"
+ * @return the corresponding afi_t
+ */
 afi_t
-bgp_vty_afi_from_arg(const char *afi_str)
+bgp_vty_afi_from_str(const char *afi_str)
 {
-  afi_t afi = AFI_MAX;       /* unknown */
-  if (!strcmp(afi_str, "ipv4")) {
+  afi_t afi = AFI_MAX; /* unknown */
+  if (strmatch(afi_str, "ipv4"))
     afi = AFI_IP;
-    }
-  else if (!strcmp(afi_str, "ipv6")) {
+  else if (strmatch(afi_str, "ipv6"))
     afi = AFI_IP6;
-  }
-  else if (!strcmp(afi_str, "l2vpn")) {
-    afi = AFI_L2VPN;
-  }
   return afi;
 }
 
-int
-bgp_parse_afi(const char *str, afi_t *afi)
-{
-  *afi = bgp_vty_afi_from_arg(str);
-  if (*afi != AFI_MAX)
-    return 0;
-  else
-    return -1;
-}
-
 int
 argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi)
 {
@@ -214,7 +206,7 @@ argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *af
 
 /* supports <unicast|multicast|vpn|labeled-unicast> */
 safi_t
-bgp_vty_safi_from_arg(const char *safi_str)
+bgp_vty_safi_from_str(const char *safi_str)
 {
   safi_t safi = SAFI_MAX;       /* unknown */
   if (strmatch (safi_str, "multicast"))
@@ -256,12 +248,6 @@ argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t
       if (safi)
         *safi = SAFI_MPLS_VPN;
     }
-  else if (argv_find (argv, argc, "evpn", index))
-    {
-      ret = 1;
-      if (safi)
-        *safi = SAFI_EVPN;
-    }
   return ret;
 }
 
@@ -6225,7 +6211,7 @@ DEFUN_NOSH (address_family_ipv4_safi,
 
   if (argc == 3)
     {
-      safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg);
+      safi_t safi = bgp_vty_safi_from_str (argv[2]->text);
       vty->node = bgp_node_type(AFI_IP, safi);
     }
   else
@@ -6243,7 +6229,7 @@ DEFUN_NOSH (address_family_ipv6_safi,
 {
   if (argc == 3)
     {
-      safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg);
+      safi_t safi = bgp_vty_safi_from_str (argv[2]->text);
       vty->node = bgp_node_type(AFI_IP6, safi);
     }
   else
@@ -6531,7 +6517,7 @@ DEFUN (clear_bgp_ipv6_safi_prefix,
   int idx_safi = 3;
   int idx_ipv6_prefixlen = 5;
   return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6,
-                           bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL);
+                           bgp_vty_safi_from_str(argv[idx_safi]->text), NULL);
 }
 
 DEFUN (clear_bgp_instance_ipv6_safi_prefix,
@@ -6550,7 +6536,7 @@ DEFUN (clear_bgp_instance_ipv6_safi_prefix,
   int idx_safi = 5;
   int idx_ipv6_prefixlen = 7;
   return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6,
-                           bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL);
+                           bgp_vty_safi_from_str(argv[idx_safi]->text), NULL);
 }
 
 DEFUN (show_bgp_views,
@@ -9665,8 +9651,8 @@ DEFUN (show_bgp_updgrps_afi_adj,
   int idx_safi = 3;
   int idx_type = 5;
   show_bgp_updgrps_adj_info_aux(vty, NULL,
-                                bgp_vty_afi_from_arg(argv[idx_afi]->arg),
-                                bgp_vty_safi_from_arg(argv[idx_safi]->arg),
+                                bgp_vty_afi_from_str(argv[idx_afi]->text),
+                                bgp_vty_safi_from_str(argv[idx_safi]->text),
                                 argv[idx_type]->arg, 0);
   return CMD_SUCCESS;
 }
@@ -9776,8 +9762,8 @@ DEFUN (show_bgp_updgrps_afi_adj_s,
   VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg);
 
   show_bgp_updgrps_adj_info_aux(vty, NULL, 
-                                bgp_vty_afi_from_arg(argv[idx_afi]->arg),
-                                bgp_vty_safi_from_arg(argv[idx_safi]->arg),
+                                bgp_vty_afi_from_str(argv[idx_afi]->text),
+                                bgp_vty_safi_from_str(argv[idx_safi]->text),
                                 argv[idx_type]->arg, subgrp_id);
   return CMD_SUCCESS;
 }
index 1bb9cfb7120c8391fd84b98162cd7bd0ddcec163..fcef4ccc0101bc2bc10b9d3fccbbf4e83a5a2910 100644 (file)
@@ -48,14 +48,11 @@ extern int bgp_vty_return (struct vty *vty, int ret);
 extern struct peer *
 peer_and_group_lookup_vty (struct vty *vty, const char *peer_str);
 
-extern int
-bgp_parse_afi(const char *str, afi_t *afi);
-
 extern afi_t
-bgp_vty_afi_from_arg(const char *afi_str);
+bgp_vty_afi_from_str(const char *afi_str);
 
 extern safi_t
-bgp_vty_safi_from_arg(const char *safi_str);
+bgp_vty_safi_from_str(const char *safi_str);
 
 extern int
 argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi);