]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_vty.c
Merge pull request #410 from dslicenc/rdnbrd-vrr
[mirror_frr.git] / ospfd / ospf_vty.c
index c51e176c7434280fafc3a866c6875f0fb61f0095..b4c456e0aa8532a62d09bb3ef2ee4be3d417dae3 100644 (file)
@@ -34,6 +34,7 @@
 #include "log.h"
 #include "zclient.h"
 #include <lib/json.h>
+#include "defaults.h"
 
 #include "ospfd/ospfd.h"
 #include "ospfd/ospf_asbr.h"
@@ -2137,7 +2138,6 @@ DEFUN (no_ospf_log_adjacency_changes_detail,
 {
   VTY_DECLVAR_CONTEXT(ospf, ospf);
 
-  UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
   UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
   return CMD_SUCCESS;
 }
@@ -3557,7 +3557,7 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
                  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))
@@ -3570,25 +3570,6 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
             }
         }
     }
-  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. */
@@ -3634,7 +3615,10 @@ DEFUN (show_ip_ospf_interface,
   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,
@@ -3657,7 +3641,10 @@ 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
@@ -7458,7 +7445,7 @@ DEFUN (no_ospf_default_metric,
 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);
@@ -7473,7 +7460,7 @@ DEFUN (no_ospf_distance,
        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);
@@ -7485,10 +7472,10 @@ DEFUN (no_ospf_distance,
 
 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"
@@ -7497,42 +7484,26 @@ DEFUN (no_ospf_distance_ospf,
        "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"
@@ -7541,26 +7512,16 @@ DEFUN (ospf_distance_ospf,
        "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;
 }
@@ -8832,8 +8793,10 @@ ospf_config_write (struct vty *vty)
        {
          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);
         }