summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_vty.c269
1 files changed, 76 insertions, 193 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 6dd49a06..101f6765 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -8210,57 +8210,16 @@ ALIAS (show_bgp_instance_rsclient_summary,
/* Redistribute VTY commands. */
-/* Utility function to convert user input route type string to route
- type. */
-static int
-bgp_str2route_type (int afi, const char *str)
-{
- if (! str)
- return 0;
-
- if (afi == AFI_IP)
- {
- if (strncmp (str, "k", 1) == 0)
- return ZEBRA_ROUTE_KERNEL;
- else if (strncmp (str, "c", 1) == 0)
- return ZEBRA_ROUTE_CONNECT;
- else if (strncmp (str, "s", 1) == 0)
- return ZEBRA_ROUTE_STATIC;
- else if (strncmp (str, "r", 1) == 0)
- return ZEBRA_ROUTE_RIP;
- else if (strncmp (str, "o", 1) == 0)
- return ZEBRA_ROUTE_OSPF;
- }
- if (afi == AFI_IP6)
- {
- if (strncmp (str, "k", 1) == 0)
- return ZEBRA_ROUTE_KERNEL;
- else if (strncmp (str, "c", 1) == 0)
- return ZEBRA_ROUTE_CONNECT;
- else if (strncmp (str, "s", 1) == 0)
- return ZEBRA_ROUTE_STATIC;
- else if (strncmp (str, "r", 1) == 0)
- return ZEBRA_ROUTE_RIPNG;
- else if (strncmp (str, "o", 1) == 0)
- return ZEBRA_ROUTE_OSPF6;
- }
- return 0;
-}
-
DEFUN (bgp_redistribute_ipv4,
bgp_redistribute_ipv4_cmd,
- "redistribute (connected|kernel|ospf|rip|static)",
+ "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n")
+ QUAGGA_IP_REDIST_HELP_STR_BGPD)
{
int type;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8270,20 +8229,16 @@ DEFUN (bgp_redistribute_ipv4,
DEFUN (bgp_redistribute_ipv4_rmap,
bgp_redistribute_ipv4_rmap_cmd,
- "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
+ "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n")
{
int type;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8295,21 +8250,17 @@ DEFUN (bgp_redistribute_ipv4_rmap,
DEFUN (bgp_redistribute_ipv4_metric,
bgp_redistribute_ipv4_metric_cmd,
- "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
+ "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n")
{
int type;
u_int32_t metric;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8322,13 +8273,9 @@ DEFUN (bgp_redistribute_ipv4_metric,
DEFUN (bgp_redistribute_ipv4_rmap_metric,
bgp_redistribute_ipv4_rmap_metric_cmd,
- "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
+ "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n"
"Metric for redistributed routes\n"
@@ -8337,8 +8284,8 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
int type;
u_int32_t metric;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8352,13 +8299,9 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
DEFUN (bgp_redistribute_ipv4_metric_rmap,
bgp_redistribute_ipv4_metric_rmap_cmd,
- "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
+ "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n"
"Route map reference\n"
@@ -8367,8 +8310,8 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
int type;
u_int32_t metric;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8382,19 +8325,15 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
DEFUN (no_bgp_redistribute_ipv4,
no_bgp_redistribute_ipv4_cmd,
- "no redistribute (connected|kernel|ospf|rip|static)",
+ "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n")
+ QUAGGA_IP_REDIST_HELP_STR_BGPD)
{
int type;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8405,21 +8344,17 @@ DEFUN (no_bgp_redistribute_ipv4,
DEFUN (no_bgp_redistribute_ipv4_rmap,
no_bgp_redistribute_ipv4_rmap_cmd,
- "no redistribute (connected|kernel|ospf|rip|static) route-map WORD",
+ "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n")
{
int type;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8431,21 +8366,17 @@ DEFUN (no_bgp_redistribute_ipv4_rmap,
DEFUN (no_bgp_redistribute_ipv4_metric,
no_bgp_redistribute_ipv4_metric_cmd,
- "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
+ "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n")
{
int type;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8457,14 +8388,10 @@ DEFUN (no_bgp_redistribute_ipv4_metric,
DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
no_bgp_redistribute_ipv4_rmap_metric_cmd,
- "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
+ "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n"
"Metric for redistributed routes\n"
@@ -8472,8 +8399,8 @@ DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
{
int type;
- type = bgp_str2route_type (AFI_IP, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8486,14 +8413,10 @@ DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
no_bgp_redistribute_ipv4_metric_rmap_cmd,
- "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
+ "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPF)\n"
- "Routing Information Protocol (RIP)\n"
- "Static routes\n"
+ QUAGGA_IP_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n"
"Route map reference\n"
@@ -8502,18 +8425,14 @@ ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
#ifdef HAVE_IPV6
DEFUN (bgp_redistribute_ipv6,
bgp_redistribute_ipv6_cmd,
- "redistribute (connected|kernel|ospf6|ripng|static)",
+ "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n")
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD)
{
int type;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8524,20 +8443,16 @@ DEFUN (bgp_redistribute_ipv6,
DEFUN (bgp_redistribute_ipv6_rmap,
bgp_redistribute_ipv6_rmap_cmd,
- "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
+ "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n")
{
int type;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8549,21 +8464,17 @@ DEFUN (bgp_redistribute_ipv6_rmap,
DEFUN (bgp_redistribute_ipv6_metric,
bgp_redistribute_ipv6_metric_cmd,
- "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
+ "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n")
{
int type;
u_int32_t metric;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8576,13 +8487,9 @@ DEFUN (bgp_redistribute_ipv6_metric,
DEFUN (bgp_redistribute_ipv6_rmap_metric,
bgp_redistribute_ipv6_rmap_metric_cmd,
- "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
+ "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n"
"Metric for redistributed routes\n"
@@ -8591,8 +8498,8 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
int type;
u_int32_t metric;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8606,13 +8513,9 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
DEFUN (bgp_redistribute_ipv6_metric_rmap,
bgp_redistribute_ipv6_metric_rmap_cmd,
- "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
+ "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n"
"Route map reference\n"
@@ -8621,8 +8524,8 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
int type;
u_int32_t metric;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8636,19 +8539,15 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
DEFUN (no_bgp_redistribute_ipv6,
no_bgp_redistribute_ipv6_cmd,
- "no redistribute (connected|kernel|ospf6|ripng|static)",
+ "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n")
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD)
{
int type;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8659,21 +8558,17 @@ DEFUN (no_bgp_redistribute_ipv6,
DEFUN (no_bgp_redistribute_ipv6_rmap,
no_bgp_redistribute_ipv6_rmap_cmd,
- "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
+ "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n")
{
int type;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8685,21 +8580,17 @@ DEFUN (no_bgp_redistribute_ipv6_rmap,
DEFUN (no_bgp_redistribute_ipv6_metric,
no_bgp_redistribute_ipv6_metric_cmd,
- "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
+ "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n")
{
int type;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8711,14 +8602,10 @@ DEFUN (no_bgp_redistribute_ipv6_metric,
DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
no_bgp_redistribute_ipv6_rmap_metric_cmd,
- "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
+ "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Route map reference\n"
"Pointer to route-map entries\n"
"Metric for redistributed routes\n"
@@ -8726,8 +8613,8 @@ DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
{
int type;
- type = bgp_str2route_type (AFI_IP6, argv[0]);
- if (! type)
+ type = proto_redistnum (AFI_IP6, argv[0]);
+ if (type < 0 || type == ZEBRA_ROUTE_BGP)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -8740,14 +8627,10 @@ DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
no_bgp_redistribute_ipv6_metric_rmap_cmd,
- "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
+ "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
NO_STR
"Redistribute information from another routing protocol\n"
- "Connected\n"
- "Kernel routes\n"
- "Open Shurtest Path First (OSPFv3)\n"
- "Routing Information Protocol (RIPng)\n"
- "Static routes\n"
+ QUAGGA_IP6_REDIST_HELP_STR_BGPD
"Metric for redistributed routes\n"
"Default metric\n"
"Route map reference\n"