#include "log.h"
#include "zclient.h"
#include <lib/json.h>
+#include "defaults.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_asbr.h"
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
- UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
return CMD_SUCCESS;
}
VTY_NEWLINE, VTY_NEWLINE);
}
- if (argc == (iface_argv + 1))
+ if (argc == iface_argv)
{
/* Show All Interfaces.*/
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
}
}
}
- else if (argv[iface_argv] && strcmp(argv[iface_argv]->arg, "json") == 0)
- {
- if (!use_json)
- {
- json = json_object_new_object();
- json_interface_sub = json_object_new_object ();
- use_json = 1;
- }
- /* Show All Interfaces. */
- for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
- {
- if (ospf_oi_count(ifp))
- {
- show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
- if (use_json)
- json_object_object_add(json, ifp->name, json_interface_sub);
- }
- }
- }
else
{
/* Interface name is specified. */
if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
return CMD_SUCCESS;
- return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj);
+ if (uj)
+ argc--;
+
+ return show_ip_ospf_interface_common(vty, ospf, argc, argv, 4, uj);
}
DEFUN (show_ip_ospf_instance_interface,
if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
return CMD_SUCCESS;
- return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj);
+ if (uj)
+ argc--;
+
+ return show_ip_ospf_interface_common(vty, ospf, argc, argv, 5, uj);
}
static void
DEFUN (ospf_distance,
ospf_distance_cmd,
"distance (1-255)",
- "Define an administrative distance\n"
+ "Administrative distance\n"
"OSPF Administrative distance\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
no_ospf_distance_cmd,
"no distance (1-255)",
NO_STR
- "Define an administrative distance\n"
+ "Administrative distance\n"
"OSPF Administrative distance\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
DEFUN (no_ospf_distance_ospf,
no_ospf_distance_ospf_cmd,
- "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
+ "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
NO_STR
- "Define an administrative distance\n"
- "OSPF Administrative distance\n"
+ "Administrative distance\n"
+ "OSPF administrative distance\n"
"Intra-area routes\n"
"Distance for intra-area routes\n"
"Inter-area routes\n"
"Distance for external routes\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
- int idx_area_distance = 3;
-
- if (!ospf)
- return CMD_SUCCESS;
-
- if (argc < 3)
- return CMD_WARNING;
+ int idx = 0;
if (!ospf)
return CMD_SUCCESS;
- if (argv[idx_area_distance]->arg != NULL)
- ospf->distance_intra = 0;
-
- if (argv[1] != NULL)
- ospf->distance_inter = 0;
-
- if (argv[2] != NULL)
+ if (argv_find (argv, argc, "intra-area", &idx) || argc == 3)
+ idx = ospf->distance_intra = 0;
+ if (argv_find (argv, argc, "inter-area", &idx) || argc == 3)
+ idx = ospf->distance_inter = 0;
+ if (argv_find (argv, argc, "external", &idx) || argc == 3)
ospf->distance_external = 0;
- if (argv[idx_area_distance]->arg || 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;
-
return CMD_SUCCESS;
}
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"
+ "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
+ "Administrative distance\n"
+ "OSPF administrative distance\n"
"Intra-area routes\n"
"Distance for intra-area routes\n"
"Inter-area routes\n"
"Distance for external routes\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
- int idx_area_distance = 2;
-
- if (argc < 3) /* should not happen */
- return CMD_WARNING;
-
- if (!argv[idx_area_distance]->arg && !argv[1] && !argv[2])
- {
- vty_out(vty, "%% Command incomplete. (Arguments required)%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- if (strcmp (argv[idx_area_distance]->text, "intra") == 0)
- ospf->distance_intra = atoi(argv[idx_area_distance+1]->arg);
-
- if (strcmp (argv[idx_area_distance]->text, "inter") == 0)
- ospf->distance_inter = atoi(argv[idx_area_distance+1]->arg);
+ int idx = 0;
- if (strcmp (argv[idx_area_distance]->text, "external") == 0)
- ospf->distance_external = atoi(argv[idx_area_distance+1]->arg);
+ if (argv_find (argv, argc, "intra-area", &idx))
+ ospf->distance_intra = atoi(argv[idx + 1]->arg);
+ idx = 0;
+ if (argv_find (argv, argc, "inter-area", &idx))
+ ospf->distance_inter = atoi(argv[idx + 1]->arg);
+ idx = 0;
+ if (argv_find (argv, argc, "external", &idx))
+ ospf->distance_external = atoi(argv[idx + 1]->arg);
return CMD_SUCCESS;
}
{
if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE);
+ else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES)
+ vty_out(vty, " log-adjacency-changes%s", VTY_NEWLINE);
}
- else
+ else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES)
{
vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE);
}