ospfd/ospf_vty.c: use keyword cmd style
Use the new keyword command style for:
- default-information originate
- distance ospf
- redistribute
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 5e5a0b0..1489b20 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -5787,11 +5787,10 @@
"OSPF interface commands\n"
"Link state transmit delay\n")
-
-DEFUN (ospf_redistribute_source_metric_type,
- ospf_redistribute_source_metric_type_routemap_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD
- " metric <0-16777214> metric-type (1|2) route-map WORD",
+DEFUN (ospf_redistribute_source,
+ ospf_redistribute_source_cmd,
+ "redistribute " QUAGGA_REDIST_STR_OSPFD
+ " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
REDIST_STR
QUAGGA_REDIST_HELP_STR_OSPFD
"Metric for redistributed routes\n"
@@ -5807,84 +5806,25 @@
int type = -1;
int metric = -1;
+ if (argc < 4)
+ return CMD_WARNING; /* should not happen */
+
/* Get distribute source. */
source = proto_redistnum(AFI_IP, argv[0]);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
/* Get metric value. */
- if (argc >= 2)
+ if (argv[1] != NULL)
if (!str2metric (argv[1], &metric))
return CMD_WARNING;
/* Get metric type. */
- if (argc >= 3)
+ if (argv[2] != NULL)
if (!str2metric_type (argv[2], &type))
return CMD_WARNING;
- if (argc == 4)
- ospf_routemap_set (ospf, source, argv[3]);
- else
- ospf_routemap_unset (ospf, source);
-
- return ospf_redistribute_set (ospf, source, type, metric);
-}
-
-ALIAS (ospf_redistribute_source_metric_type,
- ospf_redistribute_source_metric_type_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD
- " metric <0-16777214> metric-type (1|2)",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "Metric for redistributed routes\n"
- "OSPF default metric\n"
- "OSPF exterior metric type for redistributed routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n")
-
-ALIAS (ospf_redistribute_source_metric_type,
- ospf_redistribute_source_metric_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "Metric for redistributed routes\n"
- "OSPF default metric\n")
-
-DEFUN (ospf_redistribute_source_type_metric,
- ospf_redistribute_source_type_metric_routemap_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD
- " metric-type (1|2) metric <0-16777214> route-map WORD",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "OSPF exterior metric type for redistributed routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "Metric for redistributed routes\n"
- "OSPF default metric\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int source;
- int type = -1;
- int metric = -1;
-
- /* Get distribute source. */
- source = proto_redistnum(AFI_IP, argv[0]);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
- return CMD_WARNING;
-
- /* Get metric value. */
- if (argc >= 2)
- if (!str2metric_type (argv[1], &type))
- return CMD_WARNING;
-
- /* Get metric type. */
- if (argc >= 3)
- if (!str2metric (argv[2], &metric))
- return CMD_WARNING;
-
- if (argc == 4)
+ if (argv[3] != NULL)
ospf_routemap_set (ospf, source, argv[3]);
else
ospf_routemap_unset (ospf, source);
@@ -5892,124 +5832,6 @@
return ospf_redistribute_set (ospf, source, type, metric);
}
-ALIAS (ospf_redistribute_source_type_metric,
- ospf_redistribute_source_type_metric_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD
- " metric-type (1|2) metric <0-16777214>",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "OSPF exterior metric type for redistributed routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "Metric for redistributed routes\n"
- "OSPF default metric\n")
-
-ALIAS (ospf_redistribute_source_type_metric,
- ospf_redistribute_source_type_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "OSPF exterior metric type for redistributed routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n")
-
-ALIAS (ospf_redistribute_source_type_metric,
- ospf_redistribute_source_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD,
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD)
-
-DEFUN (ospf_redistribute_source_metric_routemap,
- ospf_redistribute_source_metric_routemap_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD
- " metric <0-16777214> route-map WORD",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "Metric for redistributed routes\n"
- "OSPF default metric\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int source;
- int metric = -1;
-
- /* Get distribute source. */
- source = proto_redistnum(AFI_IP, argv[0]);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
- return CMD_WARNING;
-
- /* Get metric value. */
- if (argc >= 2)
- if (!str2metric (argv[1], &metric))
- return CMD_WARNING;
-
- if (argc == 3)
- ospf_routemap_set (ospf, source, argv[2]);
- else
- ospf_routemap_unset (ospf, source);
-
- return ospf_redistribute_set (ospf, source, -1, metric);
-}
-
-DEFUN (ospf_redistribute_source_type_routemap,
- ospf_redistribute_source_type_routemap_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD
- " metric-type (1|2) route-map WORD",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "OSPF exterior metric type for redistributed routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int source;
- int type = -1;
-
- /* Get distribute source. */
- source = proto_redistnum(AFI_IP, argv[0]);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
- return CMD_WARNING;
-
- /* Get metric value. */
- if (argc >= 2)
- if (!str2metric_type (argv[1], &type))
- return CMD_WARNING;
-
- if (argc == 3)
- ospf_routemap_set (ospf, source, argv[2]);
- else
- ospf_routemap_unset (ospf, source);
-
- return ospf_redistribute_set (ospf, source, type, -1);
-}
-
-DEFUN (ospf_redistribute_source_routemap,
- ospf_redistribute_source_routemap_cmd,
- "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
- REDIST_STR
- QUAGGA_REDIST_HELP_STR_OSPFD
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int source;
-
- /* Get distribute source. */
- source = proto_redistnum(AFI_IP, argv[0]);
- if (source < 0 || source == ZEBRA_ROUTE_OSPF)
- return CMD_WARNING;
-
- if (argc == 2)
- ospf_routemap_set (ospf, source, argv[1]);
- else
- ospf_routemap_unset (ospf, source);
-
- return ospf_redistribute_set (ospf, source, -1, -1);
-}
-
DEFUN (no_ospf_redistribute_source,
no_ospf_redistribute_source_cmd,
"no redistribute " QUAGGA_REDIST_STR_OSPFD,
@@ -6067,399 +5889,52 @@
}
/* Default information originate. */
-DEFUN (ospf_default_information_originate_metric_type_routemap,
- ospf_default_information_originate_metric_type_routemap_cmd,
- "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "OSPF default metric\n"
- "OSPF metric\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int type = -1;
- int metric = -1;
-
- /* Get metric value. */
- if (argc >= 1)
- if (!str2metric (argv[0], &metric))
- return CMD_WARNING;
-
- /* Get metric type. */
- if (argc >= 2)
- if (!str2metric_type (argv[1], &type))
- return CMD_WARNING;
-
- if (argc == 3)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
- type, metric);
-}
-
-ALIAS (ospf_default_information_originate_metric_type_routemap,
- ospf_default_information_originate_metric_type_cmd,
- "default-information originate metric <0-16777214> metric-type (1|2)",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "OSPF default metric\n"
- "OSPF metric\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n")
-
-ALIAS (ospf_default_information_originate_metric_type_routemap,
- ospf_default_information_originate_metric_cmd,
- "default-information originate metric <0-16777214>",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "OSPF default metric\n"
- "OSPF metric\n")
-
-ALIAS (ospf_default_information_originate_metric_type_routemap,
+DEFUN (ospf_default_information_originate,
ospf_default_information_originate_cmd,
- "default-information originate",
- "Control distribution of default information\n"
- "Distribute a default route\n")
-
-/* Default information originate. */
-DEFUN (ospf_default_information_originate_metric_routemap,
- ospf_default_information_originate_metric_routemap_cmd,
- "default-information originate metric <0-16777214> route-map WORD",
+ "default-information originate "
+ "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
"Control distribution of default information\n"
"Distribute a default route\n"
+ "Always advertise default route\n"
"OSPF default metric\n"
"OSPF metric\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int metric = -1;
-
- /* Get metric value. */
- if (argc >= 1)
- if (!str2metric (argv[0], &metric))
- return CMD_WARNING;
-
- if (argc == 2)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
- -1, metric);
-}
-
-/* Default information originate. */
-DEFUN (ospf_default_information_originate_routemap,
- ospf_default_information_originate_routemap_cmd,
- "default-information originate route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
-
- if (argc == 1)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
-}
-
-DEFUN (ospf_default_information_originate_type_metric_routemap,
- ospf_default_information_originate_type_metric_routemap_cmd,
- "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
"OSPF metric type for default routes\n"
"Set OSPF External Type 1 metrics\n"
"Set OSPF External Type 2 metrics\n"
- "OSPF default metric\n"
- "OSPF metric\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
struct ospf *ospf = vty->index;
+ int default_originate = DEFAULT_ORIGINATE_ZEBRA;
int type = -1;
int metric = -1;
- /* Get metric type. */
- if (argc >= 1)
- if (!str2metric_type (argv[0], &type))
- return CMD_WARNING;
+ if (argc < 4)
+ return CMD_WARNING; /* this should not happen */
+
+ /* Check whether "always" was specified */
+ if (argv[0] != NULL)
+ default_originate = DEFAULT_ORIGINATE_ALWAYS;
/* Get metric value. */
- if (argc >= 2)
+ if (argv[1] != NULL)
if (!str2metric (argv[1], &metric))
return CMD_WARNING;
- if (argc == 3)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
+ /* Get metric type. */
+ if (argv[2] != NULL)
+ if (!str2metric_type (argv[2], &type))
+ return CMD_WARNING;
+
+ if (argv[3] != NULL)
+ ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
else
ospf_routemap_unset (ospf, DEFAULT_ROUTE);
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
+ return ospf_redistribute_default_set (ospf, default_originate,
type, metric);
}
-ALIAS (ospf_default_information_originate_type_metric_routemap,
- ospf_default_information_originate_type_metric_cmd,
- "default-information originate metric-type (1|2) metric <0-16777214>",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "OSPF default metric\n"
- "OSPF metric\n")
-
-ALIAS (ospf_default_information_originate_type_metric_routemap,
- ospf_default_information_originate_type_cmd,
- "default-information originate metric-type (1|2)",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n")
-
-DEFUN (ospf_default_information_originate_type_routemap,
- ospf_default_information_originate_type_routemap_cmd,
- "default-information originate metric-type (1|2) route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int type = -1;
-
- /* Get metric type. */
- if (argc >= 1)
- if (!str2metric_type (argv[0], &type))
- return CMD_WARNING;
-
- if (argc == 2)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
- type, -1);
-}
-
-DEFUN (ospf_default_information_originate_always_metric_type_routemap,
- ospf_default_information_originate_always_metric_type_routemap_cmd,
- "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF default metric\n"
- "OSPF metric\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int type = -1;
- int metric = -1;
-
- /* Get metric value. */
- if (argc >= 1)
- if (!str2metric (argv[0], &metric))
- return CMD_WARNING;
-
- /* Get metric type. */
- if (argc >= 2)
- if (!str2metric_type (argv[1], &type))
- return CMD_WARNING;
-
- if (argc == 3)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
- type, metric);
-}
-
-ALIAS (ospf_default_information_originate_always_metric_type_routemap,
- ospf_default_information_originate_always_metric_type_cmd,
- "default-information originate always metric <0-16777214> metric-type (1|2)",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF default metric\n"
- "OSPF metric\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n")
-
-ALIAS (ospf_default_information_originate_always_metric_type_routemap,
- ospf_default_information_originate_always_metric_cmd,
- "default-information originate always metric <0-16777214>",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF default metric\n"
- "OSPF metric\n"
- "OSPF metric type for default routes\n")
-
-ALIAS (ospf_default_information_originate_always_metric_type_routemap,
- ospf_default_information_originate_always_cmd,
- "default-information originate always",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n")
-
-DEFUN (ospf_default_information_originate_always_metric_routemap,
- ospf_default_information_originate_always_metric_routemap_cmd,
- "default-information originate always metric <0-16777214> route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF default metric\n"
- "OSPF metric\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int metric = -1;
-
- /* Get metric value. */
- if (argc >= 1)
- if (!str2metric (argv[0], &metric))
- return CMD_WARNING;
-
- if (argc == 2)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
- -1, metric);
-}
-
-DEFUN (ospf_default_information_originate_always_routemap,
- ospf_default_information_originate_always_routemap_cmd,
- "default-information originate always route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
-
- if (argc == 1)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
-}
-
-DEFUN (ospf_default_information_originate_always_type_metric_routemap,
- ospf_default_information_originate_always_type_metric_routemap_cmd,
- "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "OSPF default metric\n"
- "OSPF metric\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int type = -1;
- int metric = -1;
-
- /* Get metric type. */
- if (argc >= 1)
- if (!str2metric_type (argv[0], &type))
- return CMD_WARNING;
-
- /* Get metric value. */
- if (argc >= 2)
- if (!str2metric (argv[1], &metric))
- return CMD_WARNING;
-
- if (argc == 3)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
- type, metric);
-}
-
-ALIAS (ospf_default_information_originate_always_type_metric_routemap,
- ospf_default_information_originate_always_type_metric_cmd,
- "default-information originate always metric-type (1|2) metric <0-16777214>",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "OSPF default metric\n"
- "OSPF metric\n")
-
-ALIAS (ospf_default_information_originate_always_type_metric_routemap,
- ospf_default_information_originate_always_type_cmd,
- "default-information originate always metric-type (1|2)",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n")
-
-DEFUN (ospf_default_information_originate_always_type_routemap,
- ospf_default_information_originate_always_type_routemap_cmd,
- "default-information originate always metric-type (1|2) route-map WORD",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Always advertise default route\n"
- "OSPF metric type for default routes\n"
- "Set OSPF External Type 1 metrics\n"
- "Set OSPF External Type 2 metrics\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
-{
- struct ospf *ospf = vty->index;
- int type = -1;
-
- /* Get metric type. */
- if (argc >= 1)
- if (!str2metric_type (argv[0], &type))
- return CMD_WARNING;
-
- if (argc == 2)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
- else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
-
- return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
- type, -1);
-}
-
DEFUN (no_ospf_default_information_originate,
no_ospf_default_information_originate_cmd,
"no default-information originate",
@@ -6552,14 +6027,33 @@
DEFUN (no_ospf_distance_ospf,
no_ospf_distance_ospf_cmd,
- "no distance ospf",
+ "no distance ospf {intra-area|inter-area|external}",
NO_STR
"Define an administrative distance\n"
"OSPF Administrative distance\n"
- "OSPF Distance\n")
+ "OSPF Distance\n"
+ "Intra-area routes\n"
+ "Inter-area routes\n"
+ "External routes\n")
{
struct ospf *ospf = vty->index;
+ if (argc < 3)
+ return CMD_WARNING;
+
+ if (argv[0] != NULL)
+ ospf->distance_intra = 0;
+
+ if (argv[1] != NULL)
+ ospf->distance_inter = 0;
+
+ if (argv[2] != NULL)
+ ospf->distance_external = 0;
+
+ if (argv[0] || argv[1] || argv[2])
+ return CMD_SUCCESS;
+
+ /* If no arguments are given, clear all distance information */
ospf->distance_intra = 0;
ospf->distance_inter = 0;
ospf->distance_external = 0;
@@ -6567,60 +6061,10 @@
return CMD_SUCCESS;
}
-DEFUN (ospf_distance_ospf_intra,
- ospf_distance_ospf_intra_cmd,
- "distance ospf intra-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_intra = atoi (argv[0]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_intra_inter,
- ospf_distance_ospf_intra_inter_cmd,
- "distance ospf intra-area <1-255> inter-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_intra = atoi (argv[0]);
- ospf->distance_inter = atoi (argv[1]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_intra_external,
- ospf_distance_ospf_intra_external_cmd,
- "distance ospf intra-area <1-255> external <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n"
- "External routes\n"
- "Distance for external routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_intra = atoi (argv[0]);
- ospf->distance_external = atoi (argv[1]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_intra_inter_external,
- ospf_distance_ospf_intra_inter_external_cmd,
- "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
+DEFUN (ospf_distance_ospf,
+ ospf_distance_ospf_cmd,
+ "distance ospf "
+ "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
"Define an administrative distance\n"
"OSPF Administrative distance\n"
"Intra-area routes\n"
@@ -6632,216 +6076,24 @@
{
struct ospf *ospf = vty->index;
- ospf->distance_intra = atoi (argv[0]);
- ospf->distance_inter = atoi (argv[1]);
- ospf->distance_external = atoi (argv[2]);
+ if (argc < 3) /* should not happen */
+ return CMD_WARNING;
- return CMD_SUCCESS;
-}
+ if (!argv[0] && !argv[1] && !argv[2])
+ {
+ vty_out(vty, "%% Command incomplete. (Arguments required)%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
-DEFUN (ospf_distance_ospf_intra_external_inter,
- ospf_distance_ospf_intra_external_inter_cmd,
- "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n"
- "External routes\n"
- "Distance for external routes\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n")
-{
- struct ospf *ospf = vty->index;
+ if (argv[0] != NULL)
+ ospf->distance_intra = atoi(argv[0]);
- ospf->distance_intra = atoi (argv[0]);
- ospf->distance_external = atoi (argv[1]);
- ospf->distance_inter = atoi (argv[2]);
+ if (argv[1] != NULL)
+ ospf->distance_inter = atoi(argv[1]);
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_inter,
- ospf_distance_ospf_inter_cmd,
- "distance ospf inter-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_inter = atoi (argv[0]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_inter_intra,
- ospf_distance_ospf_inter_intra_cmd,
- "distance ospf inter-area <1-255> intra-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_inter = atoi (argv[0]);
- ospf->distance_intra = atoi (argv[1]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_inter_external,
- ospf_distance_ospf_inter_external_cmd,
- "distance ospf inter-area <1-255> external <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n"
- "External routes\n"
- "Distance for external routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_inter = atoi (argv[0]);
- ospf->distance_external = atoi (argv[1]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_inter_intra_external,
- ospf_distance_ospf_inter_intra_external_cmd,
- "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n"
- "External routes\n"
- "Distance for external routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_inter = atoi (argv[0]);
- ospf->distance_intra = atoi (argv[1]);
- ospf->distance_external = atoi (argv[2]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_inter_external_intra,
- ospf_distance_ospf_inter_external_intra_cmd,
- "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n"
- "External routes\n"
- "Distance for external routes\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_inter = atoi (argv[0]);
- ospf->distance_external = atoi (argv[1]);
- ospf->distance_intra = atoi (argv[2]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_external,
- ospf_distance_ospf_external_cmd,
- "distance ospf external <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "External routes\n"
- "Distance for external routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_external = atoi (argv[0]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_external_intra,
- ospf_distance_ospf_external_intra_cmd,
- "distance ospf external <1-255> intra-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "External routes\n"
- "Distance for external routes\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_external = atoi (argv[0]);
- ospf->distance_intra = atoi (argv[1]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_external_inter,
- ospf_distance_ospf_external_inter_cmd,
- "distance ospf external <1-255> inter-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "External routes\n"
- "Distance for external routes\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_external = atoi (argv[0]);
- ospf->distance_inter = atoi (argv[1]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_external_intra_inter,
- ospf_distance_ospf_external_intra_inter_cmd,
- "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "External routes\n"
- "Distance for external routes\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_external = atoi (argv[0]);
- ospf->distance_intra = atoi (argv[1]);
- ospf->distance_inter = atoi (argv[2]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ospf_distance_ospf_external_inter_intra,
- ospf_distance_ospf_external_inter_intra_cmd,
- "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
- "External routes\n"
- "Distance for external routes\n"
- "Inter-area routes\n"
- "Distance for inter-area routes\n"
- "Intra-area routes\n"
- "Distance for intra-area routes\n")
-{
- struct ospf *ospf = vty->index;
-
- ospf->distance_external = atoi (argv[0]);
- ospf->distance_inter = atoi (argv[1]);
- ospf->distance_intra = atoi (argv[2]);
+ if (argv[2] != NULL)
+ ospf->distance_external = atoi(argv[2]);
return CMD_SUCCESS;
}
@@ -8268,63 +7520,13 @@
static void
ospf_vty_zebra_init (void)
{
- install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
- install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
- install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
- install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
- install_element (OSPF_NODE,
- &ospf_redistribute_source_metric_type_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_redistribute_source_type_metric_routemap_cmd);
- install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
- install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
- install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
-
install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_metric_type_cmd);
- install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_type_metric_cmd);
- install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_metric_type_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_metric_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_type_metric_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_type_cmd);
-
- install_element (OSPF_NODE,
- &ospf_default_information_originate_metric_type_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_metric_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_type_metric_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_type_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_metric_type_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_metric_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_type_metric_routemap_cmd);
- install_element (OSPF_NODE,
- &ospf_default_information_originate_always_type_routemap_cmd);
-
install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
install_element (OSPF_NODE, &ospf_default_metric_cmd);
@@ -8334,21 +7536,7 @@
install_element (OSPF_NODE, &ospf_distance_cmd);
install_element (OSPF_NODE, &no_ospf_distance_cmd);
install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
- install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
+ install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
#if 0
install_element (OSPF_NODE, &ospf_distance_source_cmd);
install_element (OSPF_NODE, &no_ospf_distance_source_cmd);