]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_vty.c
Merge branch 'stable/3.0'
[mirror_frr.git] / ospfd / ospf_vty.c
index caf1b0c6683d84af71e5feb941eae5064870a26f..99c8368a5ffbaa5639224363a3d648abaa37ad85 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with GNU Zebra; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.  
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -989,15 +988,15 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
        "Use null authentication\n" \
        "Use message-digest authentication\n"
 
-#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
+#define VLINK_HELPSTR_TIME_PARAM \
        "Time between HELLO packets\n" \
+       "Seconds\n" \
        "Time between retransmitting lost link state advertisements\n" \
+       "Seconds\n" \
        "Link state transmit delay\n" \
-       "Interval time after which a neighbor is declared down\n"
-
-#define VLINK_HELPSTR_TIME_PARAM \
-       VLINK_HELPSTR_TIME_PARAM_NOSECS \
-       "Seconds\n"
+       "Seconds\n" \
+       "Interval time after which a neighbor is declared down\n" \
+       "Seconds\n" \
 
 #define VLINK_HELPSTR_AUTH_SIMPLE \
        "Authentication password (key)\n" \
@@ -1130,59 +1129,6 @@ DEFUN (ospf_area_vlink,
 
 }
 
-DEFUN (ospf_area_vlink_intervals,
-       ospf_area_vlink_intervals_cmd,
-       "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
-       "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "]]]",
-       VLINK_HELPSTR_IPADDR
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM)
-{
-  VTY_DECLVAR_CONTEXT(ospf, ospf);
-  struct ospf_vl_config_data vl_config;
-  int ret = 0;
-
-  ospf_vl_config_data_init(&vl_config, vty);
-
-  char *area_id   = argv[1]->arg;
-  char *router_id = argv[3]->arg;
-
-  ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt);
-  if (ret < 0)
-    {
-      vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-
-  ret = inet_aton (router_id, &vl_config.vl_peer);
-  if (! ret)
-    {
-      vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-  for (unsigned int i = 0; i < 4; i++)
-    {
-      int idx = 0;
-      if (argv_find (argv, argc, "hello-interval", &idx))
-        vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10);
-      else if (argv_find (argv, argc, "retransmit-interval", &idx))
-        vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10);
-      else if (argv_find (argv, argc, "transmit-delay", &idx))
-        vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10);
-      else if (argv_find (argv, argc, "dead-interval", &idx))
-        vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10);
-    }
-
-  /* Action configuration */
-  return ospf_vl_set (ospf, &vl_config);
-}
-
 DEFUN (no_ospf_area_vlink,
        no_ospf_area_vlink_cmd,
        "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
@@ -1293,19 +1239,56 @@ DEFUN (no_ospf_area_vlink,
   return ospf_vl_set (ospf, &vl_config);
 }
 
+DEFUN (ospf_area_vlink_intervals,
+       ospf_area_vlink_intervals_cmd,
+       "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
+       VLINK_HELPSTR_IPADDR
+       VLINK_HELPSTR_TIME_PARAM)
+{
+  VTY_DECLVAR_CONTEXT(ospf, ospf);
+  struct ospf_vl_config_data vl_config;
+  int ret = 0;
+
+  ospf_vl_config_data_init(&vl_config, vty);
+
+  char *area_id   = argv[1]->arg;
+  char *router_id = argv[3]->arg;
+
+  ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt);
+  if (ret < 0)
+    {
+      vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  ret = inet_aton (router_id, &vl_config.vl_peer);
+  if (! ret)
+    {
+      vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  for (int idx = 4; idx < argc; idx++)
+    {
+      if (strmatch (argv[idx]->text, "hello-interval"))
+        vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10);
+      else if (strmatch (argv[idx]->text, "retransmit-interval"))
+        vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10);
+      else if (strmatch (argv[idx]->text, "transmit-delay"))
+        vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10);
+      else if (strmatch (argv[idx]->text, "dead-interval"))
+        vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10);
+    }
+
+  /* Action configuration */
+  return ospf_vl_set (ospf, &vl_config);
+}
+
 DEFUN (no_ospf_area_vlink_intervals,
        no_ospf_area_vlink_intervals_cmd,
-       "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
-       "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
-       "]]]",
+       "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
        NO_STR
        VLINK_HELPSTR_IPADDR
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
-       VLINK_HELPSTR_TIME_PARAM
        VLINK_HELPSTR_TIME_PARAM)
 {
   VTY_DECLVAR_CONTEXT(ospf, ospf);
@@ -1331,16 +1314,15 @@ DEFUN (no_ospf_area_vlink_intervals,
       return CMD_WARNING;
     }
 
-  for (unsigned int i = 0; i < 4; i++)
+  for (int idx = 5; idx < argc; idx++)
     {
-      int idx = 0;
-      if (argv_find (argv, argc, "hello-interval", &idx))
+      if (strmatch (argv[idx]->text, "hello-interval"))
         vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
-      else if (argv_find (argv, argc, "retransmit-interval", &idx))
+      else if (strmatch (argv[idx]->text, "retransmit-interval"))
         vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
-      else if (argv_find (argv, argc, "transmit-delay", &idx))
+      else if (strmatch (argv[idx]->text, "transmit-delay"))
         vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
-      else if (argv_find (argv, argc, "dead-interval", &idx))
+      else if (strmatch (argv[idx]->text, "dead-interval"))
         vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
     }
 
@@ -2223,7 +2205,7 @@ DEFUN (ospf_timers_min_ls_interval,
   int idx_number = 4;
   unsigned int interval;
 
-  if (argc != 1)
+  if (argc < 5)
     {
       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -2265,7 +2247,7 @@ DEFUN (ospf_timers_min_ls_arrival,
   int idx_number = 3;
   unsigned int arrival;
 
-  if (argc != 1)
+  if (argc < 4)
     {
       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -2310,7 +2292,7 @@ DEFUN (ospf_timers_throttle_spf,
   int idx_number_3 = 5;
   unsigned int delay, hold, max;
   
-  if (argc != 3)
+  if (argc < 6)
     {
       vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -2353,7 +2335,7 @@ DEFUN (ospf_timers_lsa,
   int idx_number = 3;
   unsigned int minarrival;
 
-  if (argc != 1)
+  if (argc < 4)
     {
       vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
       return CMD_WARNING;
@@ -3553,7 +3535,6 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
   if (use_json)
     {
       json = json_object_new_object();
-      json_interface_sub = json_object_new_object();
     }
 
   if (ospf->instance)
@@ -3572,7 +3553,11 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
         {
           if (ospf_oi_count(ifp))
             {
+              if (use_json)
+                json_interface_sub = json_object_new_object();
+
               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);
             }
@@ -3590,7 +3575,11 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
         }
       else
         {
+          if (use_json)
+            json_interface_sub = json_object_new_object();
+
           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);
         }
@@ -6473,6 +6462,7 @@ DEFUN (no_ip_ospf_hello_interval,
   int idx = 0;
   struct in_addr addr;
   struct ospf_if_params *params;
+
   params = IF_DEF_PARAMS (ifp);
 
   if (argv_find (argv, argc, "A.B.C.D", &idx))
@@ -9099,7 +9089,7 @@ DEFUN (clear_ip_ospf_interface,
     }
   else /* Interface name is specified. */
     {
-      if ((ifp = if_lookup_by_name (argv[idx_ifname]->text, VRF_DEFAULT)) == NULL)
+      if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT)) == NULL)
         vty_out (vty, "No such interface name%s", VTY_NEWLINE);
       else
         ospf_interface_clear(ifp);