]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: track version & "defaults" in configs 298/head
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 9 Mar 2017 18:00:19 +0000 (19:00 +0100)
committerChristian Franke <chris@opensourcerouting.org>
Tue, 28 Mar 2017 17:18:42 +0000 (19:18 +0200)
[CF]: Move default name to autoconf and update tests

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
14 files changed:
Makefile.am
bgpd/bgpd.c
bgpd/bgpd.h
configure.ac
defaults.h [new file with mode: 0644]
lib/command.c
lib/version.h.in
ospf6d/ospf6_top.c
ospfd/ospf_vty.c
ospfd/ospfd.c
tests/lib/cli/.gitignore [new file with mode: 0644]
tests/lib/cli/test_cli.refout [deleted file]
tests/lib/cli/test_cli.refout.in [new file with mode: 0644]
vtysh/vtysh_config.c

index 63dedeac06f9c7dbf0215ab55f4b3ee347e27d75..3e73bd0cdd13dbebc24aa60af88f0ba7e8a3c538 100644 (file)
@@ -16,3 +16,5 @@ EXTRA_DIST = aclocal.m4 SERVICES REPORTING-BUGS \
        tools/zebra.el tools/multiple-bgpd.sh
 
 ACLOCAL_AMFLAGS = -I m4
+
+noinst_HEADERS = defaults.h
index 5280731234217b148c522d9abbe1934cec1b4436..86133cd7637eca68269c6a85cbb41af0f0ea51e0 100644 (file)
@@ -2889,10 +2889,18 @@ bgp_create (as_t *as, const char *name, enum bgp_instance_type inst_type)
   bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
   bgp->dynamic_neighbors_limit = BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT;
   bgp->dynamic_neighbors_count = 0;
+#if DFLT_BGP_IMPORT_CHECK
   bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
+#endif
+#if DFLT_BGP_SHOW_HOSTNAME
   bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME);
+#endif
+#if DFLT_BGP_LOG_NEIGHBOR_CHANGES
   bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+#endif
+#if DFLT_BGP_DETERMINISTIC_MED
   bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
+#endif
   bgp->addpath_tx_id = BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE;
 
   bgp->as = *as;
@@ -7263,8 +7271,11 @@ bgp_config_write (struct vty *vty)
                  inet_ntoa (bgp->router_id_static), VTY_NEWLINE);
 
       /* BGP log-neighbor-changes. */
-      if (!bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
-       vty_out (vty, " no bgp log-neighbor-changes%s", VTY_NEWLINE);
+      if (!!bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)
+          != DFLT_BGP_LOG_NEIGHBOR_CHANGES)
+        vty_out (vty, " %sbgp log-neighbor-changes%s",
+                 bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES) ? "" : "no ",
+                 VTY_NEWLINE);
 
       /* BGP configuration. */
       if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED))
@@ -7280,8 +7291,11 @@ bgp_config_write (struct vty *vty)
                 bgp->default_local_pref, VTY_NEWLINE);
 
       /* BGP default show-hostname */
-      if (!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
-       vty_out (vty, " no bgp default show-hostname%s", VTY_NEWLINE);
+      if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)
+          != DFLT_BGP_SHOW_HOSTNAME)
+        vty_out (vty, " %sbgp default show-hostname%s",
+                 bgp_flag_check (bgp, BGP_FLAG_SHOW_HOSTNAME) ? "" : "no ",
+                 VTY_NEWLINE);
 
       /* BGP default subgroup-pkt-queue-max. */
       if (bgp->default_subgroup_pkt_queue_max != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX)
@@ -7324,8 +7338,11 @@ bgp_config_write (struct vty *vty)
        vty_out (vty, " bgp enforce-first-as%s", VTY_NEWLINE);
 
       /* BGP deterministic-med. */
-      if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
-        vty_out (vty, " no bgp deterministic-med%s", VTY_NEWLINE);
+      if (!!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
+          != DFLT_BGP_DETERMINISTIC_MED)
+        vty_out (vty, " %sbgp deterministic-med%s",
+                 bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) ? "" : "no ",
+                 VTY_NEWLINE);
 
       /* BGP update-delay. */
       bgp_config_write_update_delay (vty, bgp);
@@ -7397,8 +7414,11 @@ bgp_config_write (struct vty *vty)
        }
 
       /* BGP network import check. */
-      if (!bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
-       vty_out (vty, " no bgp network import-check%s", VTY_NEWLINE);
+      if (!!bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)
+          != DFLT_BGP_IMPORT_CHECK)
+        vty_out (vty, " %sbgp network import-check%s",
+                 bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK) ? "" : "no ",
+                 VTY_NEWLINE);
 
       /* BGP flag dampening. */
       if (CHECK_FLAG (bgp->af_flags[AFI_IP][SAFI_UNICAST],
index 510082fdc2f182e34ccc989cfca987c26bafcd9d..f1e5d7b0ad894e277b9dbf766344172b1e1bcb1e 100644 (file)
@@ -29,6 +29,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "sockunion.h"
 #include "routemap.h"
 #include "linklist.h"
+#include "defaults.h"
 #include "bgp_memory.h"
 
 #define BGP_MAX_HOSTNAME 64    /* Linux max, is larger than most other sys */
@@ -1052,12 +1053,13 @@ struct bgp_nlri
 #define BGP_EVENTS_MAX                          15
 
 /* BGP timers default value.  */
+/* note: the DFLT_ ones depend on compile-time "defaults" selection */
 #define BGP_INIT_START_TIMER                     1
-#define BGP_DEFAULT_HOLDTIME                     9
-#define BGP_DEFAULT_KEEPALIVE                    3
+#define BGP_DEFAULT_HOLDTIME                      DFLT_BGP_HOLDTIME
+#define BGP_DEFAULT_KEEPALIVE                     DFLT_BGP_KEEPALIVE
 #define BGP_DEFAULT_EBGP_ROUTEADV                0
 #define BGP_DEFAULT_IBGP_ROUTEADV                0
-#define BGP_DEFAULT_CONNECT_RETRY               10
+#define BGP_DEFAULT_CONNECT_RETRY                 DFLT_BGP_TIMERS_CONNECT
 
 /* BGP default local preference.  */
 #define BGP_DEFAULT_LOCAL_PREF                 100
index 6ff64d086ab0c1d6f7fc44c00f0c35d0d1ff7203..9fc3cb72f32d09353f67af2e1b6146ecfa18b668 100755 (executable)
@@ -346,7 +346,12 @@ AC_SUBST(MPLS_METHOD)
 
 if test "${enable_cumulus}" = "yes" ; then
   AC_DEFINE(HAVE_CUMULUS,,Compile Special Cumulus Code in)
+  DFLT_NAME="datacenter"
+else
+  DFLT_NAME="traditional"
 fi
+AC_SUBST(DFLT_NAME)
+AC_DEFINE_UNQUOTED(DFLT_NAME,["$DFLT_NAME"], Name of the configuration default set)
 
 if test "${enable_shell_access}" = "yes"; then
    AC_DEFINE(HAVE_SHELL_ACCESS,,Allow user to use ssh/telnet/bash)
@@ -1599,6 +1604,7 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile
          snapcraft/Makefile
          snapcraft/snapcraft.yaml
          lib/version.h
+         tests/lib/cli/test_cli.refout
          doc/defines.texi
          doc/bgpd.8
          doc/isisd.8
diff --git a/defaults.h b/defaults.h
new file mode 100644 (file)
index 0000000..e43fb2a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * FRR switchable defaults.
+ * Copyright (C) 2017  David Lamparter for NetDEF, Inc.
+ *
+ * This file is part of FreeRangeRouting (FRR).
+ *
+ * FRR is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2, or (at your option) any later version.
+ *
+ * FRR is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of 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 FRR; see the file COPYING.  If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _FRR_DEFAULTS_H
+#define _FRR_DEFAULTS_H
+
+#include "config.h"
+
+#ifdef HAVE_CUMULUS
+
+#define DFLT_BGP_IMPORT_CHECK                  1
+#define DFLT_BGP_TIMERS_CONNECT                        10
+#define DFLT_BGP_HOLDTIME                      9
+#define DFLT_BGP_KEEPALIVE                     3
+#define DFLT_BGP_LOG_NEIGHBOR_CHANGES          1
+#define DFLT_BGP_SHOW_HOSTNAME                 1
+#define DFLT_BGP_DETERMINISTIC_MED             1
+
+#define DFLT_OSPF_LOG_ADJACENCY_CHANGES                1
+#define DFLT_OSPF6_LOG_ADJACENCY_CHANGES       1
+
+#else /* !HAVE_CUMULUS */
+
+#define DFLT_BGP_IMPORT_CHECK                  0
+#define DFLT_BGP_TIMERS_CONNECT                        120
+#define DFLT_BGP_HOLDTIME                      180
+#define DFLT_BGP_KEEPALIVE                     60
+#define DFLT_BGP_LOG_NEIGHBOR_CHANGES          0
+#define DFLT_BGP_SHOW_HOSTNAME                 0
+#define DFLT_BGP_DETERMINISTIC_MED             0
+
+#define DFLT_OSPF_LOG_ADJACENCY_CHANGES                0
+#define DFLT_OSPF6_LOG_ADJACENCY_CHANGES       0
+
+#endif /* !HAVE_CUMULUS */
+
+#endif /* _FRR_DEFAULTS_H */
index c9b261cf2a7fcdb6de7377e6961da40ca4ac3d39..919e27ada456d82f07d5257a17dccfe20bce4dc4 100644 (file)
@@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA.  */
 #include "workqueue.h"
 #include "vrf.h"
 #include "qobj.h"
+#include "defaults.h"
 
 DEFINE_MTYPE(       LIB, HOST,       "Host config")
 DEFINE_MTYPE(       LIB, STRVEC,     "String vector")
@@ -3082,6 +3083,23 @@ DEFUN (show_version,
   return CMD_SUCCESS;
 }
 
+/* "Set" version ... ignore version tags */
+DEFUN (frr_version_defaults,
+       frr_version_defaults_cmd,
+       "frr (version|defaults) .LINE",
+       "FreeRangeRouting global parameters\n"
+       "version configuration was written by\n"
+       "set of configuration defaults used\n"
+       "version string\n")
+{
+  if (vty->type == VTY_TERM || vty->type == VTY_SHELL)
+    /* only print this when the user tries to do run it */
+    vty_out (vty, "%% NOTE: This command currently does nothing.%s"
+             "%% It is written to the configuration for future reference.%s",
+             VTY_NEWLINE, VTY_NEWLINE);
+  return CMD_SUCCESS;
+}
+
 /* Help display function for all node. */
 DEFUN (config_help,
        config_help_cmd,
@@ -3125,6 +3143,37 @@ DEFUN (config_list,
   return CMD_SUCCESS;
 }
 
+static void
+vty_write_config (struct vty *vty)
+{
+  size_t i;
+  struct cmd_node *node;
+
+  if (vty->type == VTY_TERM)
+    {
+      vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE,
+               VTY_NEWLINE);
+      vty_out (vty, "!%s", VTY_NEWLINE);
+    }
+
+  vty_out (vty, "frr version %s%s", FRR_VER_SHORT, VTY_NEWLINE);
+  vty_out (vty, "frr defaults %s%s", DFLT_NAME, VTY_NEWLINE);
+  vty_out (vty, "!%s", VTY_NEWLINE);
+
+  for (i = 0; i < vector_active (cmdvec); i++)
+    if ((node = vector_slot (cmdvec, i)) && node->func
+        && (node->vtysh || vty->type != VTY_SHELL))
+      {
+        if ((*node->func) (vty))
+          vty_out (vty, "!%s", VTY_NEWLINE);
+      }
+
+  if (vty->type == VTY_TERM)
+    {
+      vty_out (vty, "end%s",VTY_NEWLINE);
+    }
+}
+
 /* Write current configuration into file. */
 DEFUN (config_write_file, 
        config_write_file_cmd,
@@ -3132,9 +3181,7 @@ DEFUN (config_write_file,
        "Write running configuration to memory, network, or terminal\n"
        "Write to configuration file\n")
 {
-  unsigned int i;
   int fd, dirfd;
-  struct cmd_node *node;
   char *config_file, *slash;
   char *config_file_tmp = NULL;
   char *config_file_sav = NULL;
@@ -3205,13 +3252,7 @@ DEFUN (config_write_file,
   vty_out (file_vty, "!\n! Zebra configuration saved from vty\n!   ");
   vty_time_print (file_vty, 1);
   vty_out (file_vty, "!\n");
-
-  for (i = 0; i < vector_active (cmdvec); i++)
-    if ((node = vector_slot (cmdvec, i)) && node->func)
-      {
-       if ((*node->func) (file_vty))
-         vty_out (file_vty, "!\n");
-      }
+  vty_write_config (file_vty);
   vty_close (file_vty);
 
   if (stat(config_file, &conf_stat) >= 0)
@@ -3277,35 +3318,8 @@ DEFUN (config_write_terminal,
        "Write running configuration to memory, network, or terminal\n"
        "Write to terminal\n")
 {
-  unsigned int i;
-  struct cmd_node *node;
-
-  if (host.noconfig)
-    return CMD_SUCCESS;
-
-  if (vty->type == VTY_SHELL_SERV)
-    {
-      for (i = 0; i < vector_active (cmdvec); i++)
-       if ((node = vector_slot (cmdvec, i)) && node->func && node->vtysh)
-         {
-           if ((*node->func) (vty))
-             vty_out (vty, "!%s", VTY_NEWLINE);
-         }
-    }
-  else
-    {
-      vty_out (vty, "%sCurrent configuration:%s", VTY_NEWLINE,
-              VTY_NEWLINE);
-      vty_out (vty, "!%s", VTY_NEWLINE);
-
-      for (i = 0; i < vector_active (cmdvec); i++)
-       if ((node = vector_slot (cmdvec, i)) && node->func)
-         {
-           if ((*node->func) (vty))
-             vty_out (vty, "!%s", VTY_NEWLINE);
-         }
-      vty_out (vty, "end%s",VTY_NEWLINE);
-    }
+  if (!host.noconfig)
+    vty_write_config (vty);
   return CMD_SUCCESS;
 }
 
@@ -4301,6 +4315,7 @@ cmd_init (int terminal)
   
   install_element (CONFIG_NODE, &hostname_cmd);
   install_element (CONFIG_NODE, &no_hostname_cmd);
+  install_element (CONFIG_NODE, &frr_version_defaults_cmd);
 
   if (terminal > 0)
     {
index adc82781892b2ee3e77ad71df0736e8e68dba6d7..6c78bd0544f1d0459fe8271bc462fd0a80b48b64 100644 (file)
@@ -41,6 +41,7 @@
 
 #define FRR_FULL_NAME   "FreeRangeRouting"
 #define FRR_VERSION     "@PACKAGE_VERSION@" GIT_SUFFIX
+#define FRR_VER_SHORT   "@PACKAGE_VERSION@"
 #define FRR_BUG_ADDRESS "@PACKAGE_BUGREPORT@"
 #define FRR_COPYRIGHT   "Copyright 1996-2005 Kunihiro Ishiguro, et al."
 #define FRR_CONFIG_ARGS "@CONFIG_ARGS@"
index 3d632b644ed43003bcf7fd36960e57d37cf36d28..f2d14ef09cdaebc8c96b3dba0adc53dbd166617e 100644 (file)
@@ -29,6 +29,7 @@
 #include "table.h"
 #include "thread.h"
 #include "command.h"
+#include "defaults.h"
 
 #include "ospf6_proto.h"
 #include "ospf6_message.h"
@@ -158,7 +159,9 @@ ospf6_create (void)
   o->distance_table = route_table_init ();
 
   /* Enable "log-adjacency-changes" */
+#if DFLT_OSPF6_LOG_ADJACENCY_CHANGES
   SET_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
+#endif
 
   return o;
 }
@@ -1132,8 +1135,10 @@ config_write_ospf6 (struct vty *vty)
     {
       if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
         vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE);
+      else if (!DFLT_OSPF6_LOG_ADJACENCY_CHANGES)
+        vty_out(vty, " log-adjacency-changes%s", VTY_NEWLINE);
     }
-  else
+  else if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES)
     {
       vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE);
     }
index 2c3aaa68086134423641d55b12517bbd0df79cc2..5faf2850d9bcab2249a2f67e25e24020ce02ee6d 100644 (file)
@@ -33,6 +33,7 @@
 #include "plist.h"
 #include "log.h"
 #include "zclient.h"
+#include "defaults.h"
 
 #include "ospfd/ospfd.h"
 #include "ospfd/ospf_asbr.h"
@@ -9873,8 +9874,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);
         }
index b83093db3c982377ed9ccd981c2ea79e4c65d407..53b81c6248a3e5f7c65cf4032db4843dff8304f1 100644 (file)
@@ -35,6 +35,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "plist.h"
 #include "sockopt.h"
 #include "bfd.h"
+#include "defaults.h"
 
 #include "ospfd/ospfd.h"
 #include "ospfd/ospf_network.h"
@@ -291,7 +292,9 @@ ospf_new (u_short instance)
   new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
   
   /* Enable "log-adjacency-changes" */
+#if DFLT_OSPF_LOG_ADJACENCY_CHANGES
   SET_FLAG(new->config, OSPF_LOG_ADJACENCY_CHANGES);
+#endif
   return new;
 }
 
diff --git a/tests/lib/cli/.gitignore b/tests/lib/cli/.gitignore
new file mode 100644 (file)
index 0000000..682e95f
--- /dev/null
@@ -0,0 +1 @@
+/test_cli.refout
diff --git a/tests/lib/cli/test_cli.refout b/tests/lib/cli/test_cli.refout
deleted file mode 100644 (file)
index 7da5494..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-test# echo this is a  test message\r
-this is a test message\r
-test# echo  foo bla  \r
-  MESSAGE  The message to echo\r
-  <cr>     \r
-test# echo  foo bla    baz\r
-foo bla baz\r
-test# echo\r
-% Command incomplete.\r
-test# \r
-test# arg ipv4 1.2.3.4\r
-cmd0 with 1 args.\r
-[00]: 1.2.3.4\r
-test# arg ipv4 1.2.\r
-  A.B.C.D  02\r
-test# arg ipv4 1.2.3.4\r
-cmd0 with 1 args.\r
-[00]: 1.2.3.4\r
-test# arg ipv4 1.2.3\r
-cmd0 with 1 args.\r
-[00]: 1.2.3\r
-test# arg ipv4 1.2.3.4.5\r
-% [NONE] Unknown command: arg ipv4 1.2.3.4.5\r
-test# arg ipv4 1.a.3.4\r
-% [NONE] Unknown command: arg ipv4 1.a.3.4\r
-test# arg ipv4 blah\r
-% [NONE] Unknown command: arg ipv4 blah\r
-test# \r
-test# arg ipv4m 1.2.3.0/24\r
-cmd1 with 1 args.\r
-[00]: 1.2.3.0/24\r
-test# arg ipv4m 1.2.\r
-  A.B.C.D/M  02\r
-test# arg ipv4m 1.2.3.0/24\r
-cmd1 with 1 args.\r
-[00]: 1.2.3.0/24\r
-test# arg ipv4m 1.2.3/9\r
-% [NONE] Unknown command: arg ipv4m 1.2.3/9\r
-test# arg ipv4m 1.2.3.4.5/6\r
-% [NONE] Unknown command: arg ipv4m 1.2.3.4.5/6\r
-test# arg ipv4m 1.a.3.4\r
-% [NONE] Unknown command: arg ipv4m 1.a.3.4\r
-test# arg ipv4m blah\r
-% [NONE] Unknown command: arg ipv4m blah\r
-test# arg ipv4m 1.2.3.0/999\r
-% [NONE] Unknown command: arg ipv4m 1.2.3.0/999\r
-test# arg ipv4m 1.2.3.0/a9\r
-% [NONE] Unknown command: arg ipv4m 1.2.3.0/a9\r
-test# arg ipv4m 1.2.3.0/9a\r
-% [NONE] Unknown command: arg ipv4m 1.2.3.0/9a\r
-test# \r
-test# arg ipv6 de4d:b33f::cafe\r
-cmd2 with 1 args.\r
-[00]: de4d:b33f::cafe\r
-test# arg ipv6 de4d:b3\r
-% There is no matched command.\r
-test# arg ipv6 de4d:b33f::caf\r
-  X:X::X:X  02\r
-test# arg ipv6 de4d:b33f::cafe\r
-cmd2 with 1 args.\r
-[00]: de4d:b33f::cafe\r
-test# arg ipv6 de4d:b3\r
-test# arg ipv6 de4d:b33f::caf\r
-  X:X::X:X  02\r
-test# arg ipv6 de4d:b33f::cafe\r
-cmd2 with 1 args.\r
-[00]: de4d:b33f::cafe\r
-test# arg ipv6 de4d:b33f:z::cafe\r
-% [NONE] Unknown command: arg ipv6 de4d:b33f:z::cafe\r
-test# arg ipv6 de4d:b33f:cafe:\r
-% [NONE] Unknown command: arg ipv6 de4d:b33f:cafe:\r
-test# arg ipv6 ::\r
-cmd2 with 1 args.\r
-[00]: ::\r
-test# arg ipv6 ::/\r
-% [NONE] Unknown command: arg ipv6 ::/\r
-test# arg ipv6 1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0\r
-% [NONE] Unknown command: arg ipv6 1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0\r
-test# arg ipv6 12::34::56\r
-% [NONE] Unknown command: arg ipv6 12::34::56\r
-test# arg ipv6m dead:beef:cafe::/64\r
-cmd3 with 1 args.\r
-[00]: dead:beef:cafe::/64\r
-test# arg ipv6m dead:be\r
-  X:X::X:X/M  02\r
-test# arg ipv6m dead:beef:cafe:\r
-  X:X::X:X/M  02\r
-test# arg ipv6m dead:beef:cafe::/64\r
-cmd3 with 1 args.\r
-[00]: dead:beef:cafe::/64\r
-test# \r
-test# arg range 4\r
-% [NONE] Unknown command: arg range 4\r
-test# arg range 5\r
-cmd4 with 1 args.\r
-[00]: 5\r
-test# arg range 9\r
-  <5-15>  02\r
-test# arg range 9\r
-cmd4 with 1 args.\r
-[00]: 9\r
-test# arg range 15\r
-cmd4 with 1 args.\r
-[00]: 15\r
-test# arg range 16\r
-% [NONE] Unknown command: arg range 16\r
-test# arg range -1\r
-% [NONE] Unknown command: arg range -1\r
-test# arg range 99999999999999999999999999999999999999999\r
-% [NONE] Unknown command: arg range 99999999999999999999999999999999999999999\r
-test# \r
-test# arg \r
-  ipv4   01\r
-  ipv4m  01\r
-  ipv6   01\r
-  ipv6m  01\r
-  range  01\r
-test# arg \r
-% Command incomplete.\r
-test# \r
-test# pa\r
-test# pa\b\bpat \r
-% Command incomplete.\r
-test# pat \r
-a          b          c          d          e          f          \r
-test# pat \r
-% Command incomplete.\r
-test# \r
-test# pat a\r
-% Command incomplete.\r
-test# pat a a\r
-cmd5 with 1 args.\r
-[00]: a\r
-test# pat a \r
-  a  02\r
-  b  03\r
-test# pat a b\r
-cmd5 with 1 args.\r
-[00]: b\r
-test# pat a c\r
-% There is no matched command.\r
-test# pat a c\r
-% [NONE] Unknown command: pat a c\r
-test# pat a a x\r
-% [NONE] Unknown command: pat a a x\r
-test# \r
-test# pat b\r
-% Command incomplete.\r
-test# pat b \r
-  a  02\r
-test# pat b a\r
-cmd6 with 1 args.\r
-[00]: a\r
-test# pat b x\r
-% [NONE] Unknown command: pat b x\r
-test# pat b x y\r
-% [NONE] Unknown command: pat b x y\r
-test# \r
-test# pat c a\r
-% Command incomplete.\r
-test# pat c a 1.2.3.4\r
-cmd7 with 2 args.\r
-[00]: a\r
-[01]: 1.2.3.4\r
-test# pat c b 2.3.4\r
-cmd7 with 2 args.\r
-[00]: b\r
-[01]: 2.3.4\r
-test# pat c c \r
-  A.B.C.D  05\r
-test# pat c c x\r
-% [NONE] Unknown command: pat c c x\r
-test# \r
-test# pat d\r
-cmd8 with 3 args.\r
-[00]: (null)\r
-[01]: (null)\r
-[02]: (null)\r
-test# pat d \r
-bar        baz        foo        \r
-test# pat d \r
-cmd8 with 3 args.\r
-[00]: (null)\r
-[01]: (null)\r
-[02]: (null)\r
-test# pat d foo 1.2.3.4\r
-cmd8 with 3 args.\r
-[00]: 1.2.3.4\r
-[01]: (null)\r
-[02]: (null)\r
-test# pat d foo\r
-% Command incomplete.\r
-test# pat d noooo\r
-% [NONE] Unknown command: pat d noooo\r
-test# pat d bar 1::2\r
-cmd8 with 3 args.\r
-[00]: (null)\r
-[01]: 1::2\r
-[02]: (null)\r
-test# pat d bar 1::2 foo 3.4.5.6\r
-cmd8 with 3 args.\r
-[00]: 3.4.5.6\r
-[01]: 1::2\r
-[02]: (null)\r
-test# pat d ba\r
-  bar  04\r
-  baz  06\r
-test# pat d baz\r
-cmd8 with 3 args.\r
-[00]: (null)\r
-[01]: (null)\r
-[02]: baz\r
-test# pat d foo 3.4.5.6 baz\r
-cmd8 with 3 args.\r
-[00]: 3.4.5.6\r
-[01]: (null)\r
-[02]: baz\r
-test# \r
-test# pat e\r
-% Command incomplete.\r
-test# pat e f\r
-% Command incomplete.\r
-test# pat e f g\r
-% Command incomplete.\r
-test# pat e 1.2.3.4\r
-% Command incomplete.\r
-test# \r
-test# pat f\r
-cmd10 with 0 args.\r
-test# pat f foo\r
-cmd10 with 1 args.\r
-[00]: foo\r
-test# pat f key\r
-cmd10 with 1 args.\r
-[00]: key\r
-test# \r
-test# alt a \r
-test# alt a a\r
-  WORD  02\r
-test# alt a ab\r
-cmd11 with 1 args.\r
-[00]: ab\r
-test# alt a 1\r
-test# alt a 1.2\r
-  A.B.C.D  02\r
-  WORD     02\r
-test# alt a 1.2.3.4\r
-cmd12 with 1 args.\r
-[00]: 1.2.3.4\r
-test# alt a 1\r
-test# alt a 1:2\r
-  WORD  02\r
-test# alt a 1:2\r
-test# alt a 1:2::\r
-  WORD      02\r
-  X:X::X:X  02\r
-test# alt a 1:2::3\r
-cmd13 with 1 args.\r
-[00]: 1:2::3\r
-test# \r
-test# conf t\r
-test(config)# do pat d baz\r
-cmd8 with 3 args.\r
-[00]: (null)\r
-[01]: (null)\r
-[02]: baz\r
-test(config)# exit\r
-test# \r
-test# show run\r
-\r
-Current configuration:\r
-!\r
-hostname test\r
-!\r
-!\r
-line vty\r
-!\r
-end\r
-test# conf t\r
-test(config)# hostname foohost\r
-foohost(config)# do show run\r
-\r
-Current configuration:\r
-!\r
-hostname foohost\r
-!\r
-!\r
-line vty\r
-!\r
-end\r
-foohost(config)# 
-end.
diff --git a/tests/lib/cli/test_cli.refout.in b/tests/lib/cli/test_cli.refout.in
new file mode 100644 (file)
index 0000000..26f7f09
--- /dev/null
@@ -0,0 +1,298 @@
+test# echo this is a  test message\r
+this is a test message\r
+test# echo  foo bla  \r
+  MESSAGE  The message to echo\r
+  <cr>     \r
+test# echo  foo bla    baz\r
+foo bla baz\r
+test# echo\r
+% Command incomplete.\r
+test# \r
+test# arg ipv4 1.2.3.4\r
+cmd0 with 1 args.\r
+[00]: 1.2.3.4\r
+test# arg ipv4 1.2.\r
+  A.B.C.D  02\r
+test# arg ipv4 1.2.3.4\r
+cmd0 with 1 args.\r
+[00]: 1.2.3.4\r
+test# arg ipv4 1.2.3\r
+cmd0 with 1 args.\r
+[00]: 1.2.3\r
+test# arg ipv4 1.2.3.4.5\r
+% [NONE] Unknown command: arg ipv4 1.2.3.4.5\r
+test# arg ipv4 1.a.3.4\r
+% [NONE] Unknown command: arg ipv4 1.a.3.4\r
+test# arg ipv4 blah\r
+% [NONE] Unknown command: arg ipv4 blah\r
+test# \r
+test# arg ipv4m 1.2.3.0/24\r
+cmd1 with 1 args.\r
+[00]: 1.2.3.0/24\r
+test# arg ipv4m 1.2.\r
+  A.B.C.D/M  02\r
+test# arg ipv4m 1.2.3.0/24\r
+cmd1 with 1 args.\r
+[00]: 1.2.3.0/24\r
+test# arg ipv4m 1.2.3/9\r
+% [NONE] Unknown command: arg ipv4m 1.2.3/9\r
+test# arg ipv4m 1.2.3.4.5/6\r
+% [NONE] Unknown command: arg ipv4m 1.2.3.4.5/6\r
+test# arg ipv4m 1.a.3.4\r
+% [NONE] Unknown command: arg ipv4m 1.a.3.4\r
+test# arg ipv4m blah\r
+% [NONE] Unknown command: arg ipv4m blah\r
+test# arg ipv4m 1.2.3.0/999\r
+% [NONE] Unknown command: arg ipv4m 1.2.3.0/999\r
+test# arg ipv4m 1.2.3.0/a9\r
+% [NONE] Unknown command: arg ipv4m 1.2.3.0/a9\r
+test# arg ipv4m 1.2.3.0/9a\r
+% [NONE] Unknown command: arg ipv4m 1.2.3.0/9a\r
+test# \r
+test# arg ipv6 de4d:b33f::cafe\r
+cmd2 with 1 args.\r
+[00]: de4d:b33f::cafe\r
+test# arg ipv6 de4d:b3\r
+% There is no matched command.\r
+test# arg ipv6 de4d:b33f::caf\r
+  X:X::X:X  02\r
+test# arg ipv6 de4d:b33f::cafe\r
+cmd2 with 1 args.\r
+[00]: de4d:b33f::cafe\r
+test# arg ipv6 de4d:b3\r
+test# arg ipv6 de4d:b33f::caf\r
+  X:X::X:X  02\r
+test# arg ipv6 de4d:b33f::cafe\r
+cmd2 with 1 args.\r
+[00]: de4d:b33f::cafe\r
+test# arg ipv6 de4d:b33f:z::cafe\r
+% [NONE] Unknown command: arg ipv6 de4d:b33f:z::cafe\r
+test# arg ipv6 de4d:b33f:cafe:\r
+% [NONE] Unknown command: arg ipv6 de4d:b33f:cafe:\r
+test# arg ipv6 ::\r
+cmd2 with 1 args.\r
+[00]: ::\r
+test# arg ipv6 ::/\r
+% [NONE] Unknown command: arg ipv6 ::/\r
+test# arg ipv6 1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0\r
+% [NONE] Unknown command: arg ipv6 1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0:1:2:3:4:5:6:7:8:9:0\r
+test# arg ipv6 12::34::56\r
+% [NONE] Unknown command: arg ipv6 12::34::56\r
+test# arg ipv6m dead:beef:cafe::/64\r
+cmd3 with 1 args.\r
+[00]: dead:beef:cafe::/64\r
+test# arg ipv6m dead:be\r
+  X:X::X:X/M  02\r
+test# arg ipv6m dead:beef:cafe:\r
+  X:X::X:X/M  02\r
+test# arg ipv6m dead:beef:cafe::/64\r
+cmd3 with 1 args.\r
+[00]: dead:beef:cafe::/64\r
+test# \r
+test# arg range 4\r
+% [NONE] Unknown command: arg range 4\r
+test# arg range 5\r
+cmd4 with 1 args.\r
+[00]: 5\r
+test# arg range 9\r
+  <5-15>  02\r
+test# arg range 9\r
+cmd4 with 1 args.\r
+[00]: 9\r
+test# arg range 15\r
+cmd4 with 1 args.\r
+[00]: 15\r
+test# arg range 16\r
+% [NONE] Unknown command: arg range 16\r
+test# arg range -1\r
+% [NONE] Unknown command: arg range -1\r
+test# arg range 99999999999999999999999999999999999999999\r
+% [NONE] Unknown command: arg range 99999999999999999999999999999999999999999\r
+test# \r
+test# arg \r
+  ipv4   01\r
+  ipv4m  01\r
+  ipv6   01\r
+  ipv6m  01\r
+  range  01\r
+test# arg \r
+% Command incomplete.\r
+test# \r
+test# pa\r
+test# pa\b\bpat \r
+% Command incomplete.\r
+test# pat \r
+a          b          c          d          e          f          \r
+test# pat \r
+% Command incomplete.\r
+test# \r
+test# pat a\r
+% Command incomplete.\r
+test# pat a a\r
+cmd5 with 1 args.\r
+[00]: a\r
+test# pat a \r
+  a  02\r
+  b  03\r
+test# pat a b\r
+cmd5 with 1 args.\r
+[00]: b\r
+test# pat a c\r
+% There is no matched command.\r
+test# pat a c\r
+% [NONE] Unknown command: pat a c\r
+test# pat a a x\r
+% [NONE] Unknown command: pat a a x\r
+test# \r
+test# pat b\r
+% Command incomplete.\r
+test# pat b \r
+  a  02\r
+test# pat b a\r
+cmd6 with 1 args.\r
+[00]: a\r
+test# pat b x\r
+% [NONE] Unknown command: pat b x\r
+test# pat b x y\r
+% [NONE] Unknown command: pat b x y\r
+test# \r
+test# pat c a\r
+% Command incomplete.\r
+test# pat c a 1.2.3.4\r
+cmd7 with 2 args.\r
+[00]: a\r
+[01]: 1.2.3.4\r
+test# pat c b 2.3.4\r
+cmd7 with 2 args.\r
+[00]: b\r
+[01]: 2.3.4\r
+test# pat c c \r
+  A.B.C.D  05\r
+test# pat c c x\r
+% [NONE] Unknown command: pat c c x\r
+test# \r
+test# pat d\r
+cmd8 with 3 args.\r
+[00]: (null)\r
+[01]: (null)\r
+[02]: (null)\r
+test# pat d \r
+bar        baz        foo        \r
+test# pat d \r
+cmd8 with 3 args.\r
+[00]: (null)\r
+[01]: (null)\r
+[02]: (null)\r
+test# pat d foo 1.2.3.4\r
+cmd8 with 3 args.\r
+[00]: 1.2.3.4\r
+[01]: (null)\r
+[02]: (null)\r
+test# pat d foo\r
+% Command incomplete.\r
+test# pat d noooo\r
+% [NONE] Unknown command: pat d noooo\r
+test# pat d bar 1::2\r
+cmd8 with 3 args.\r
+[00]: (null)\r
+[01]: 1::2\r
+[02]: (null)\r
+test# pat d bar 1::2 foo 3.4.5.6\r
+cmd8 with 3 args.\r
+[00]: 3.4.5.6\r
+[01]: 1::2\r
+[02]: (null)\r
+test# pat d ba\r
+  bar  04\r
+  baz  06\r
+test# pat d baz\r
+cmd8 with 3 args.\r
+[00]: (null)\r
+[01]: (null)\r
+[02]: baz\r
+test# pat d foo 3.4.5.6 baz\r
+cmd8 with 3 args.\r
+[00]: 3.4.5.6\r
+[01]: (null)\r
+[02]: baz\r
+test# \r
+test# pat e\r
+% Command incomplete.\r
+test# pat e f\r
+% Command incomplete.\r
+test# pat e f g\r
+% Command incomplete.\r
+test# pat e 1.2.3.4\r
+% Command incomplete.\r
+test# \r
+test# pat f\r
+cmd10 with 0 args.\r
+test# pat f foo\r
+cmd10 with 1 args.\r
+[00]: foo\r
+test# pat f key\r
+cmd10 with 1 args.\r
+[00]: key\r
+test# \r
+test# alt a \r
+test# alt a a\r
+  WORD  02\r
+test# alt a ab\r
+cmd11 with 1 args.\r
+[00]: ab\r
+test# alt a 1\r
+test# alt a 1.2\r
+  A.B.C.D  02\r
+  WORD     02\r
+test# alt a 1.2.3.4\r
+cmd12 with 1 args.\r
+[00]: 1.2.3.4\r
+test# alt a 1\r
+test# alt a 1:2\r
+  WORD  02\r
+test# alt a 1:2\r
+test# alt a 1:2::\r
+  WORD      02\r
+  X:X::X:X  02\r
+test# alt a 1:2::3\r
+cmd13 with 1 args.\r
+[00]: 1:2::3\r
+test# \r
+test# conf t\r
+test(config)# do pat d baz\r
+cmd8 with 3 args.\r
+[00]: (null)\r
+[01]: (null)\r
+[02]: baz\r
+test(config)# exit\r
+test# \r
+test# show run\r
+\r
+Current configuration:\r
+!\r
+frr version @PACKAGE_VERSION@\r
+frr defaults @DFLT_NAME@\r
+!\r
+hostname test\r
+!\r
+!\r
+line vty\r
+!\r
+end\r
+test# conf t\r
+test(config)# hostname foohost\r
+foohost(config)# do show run\r
+\r
+Current configuration:\r
+!\r
+frr version @PACKAGE_VERSION@\r
+frr defaults @DFLT_NAME@\r
+!\r
+hostname foohost\r
+!\r
+!\r
+line vty\r
+!\r
+end\r
+foohost(config)# 
+end.
index e60e9c091fdf0796301650504395e8c82f72b800..94c4042dd4b8e79914b219aca88a694575516145 100644 (file)
@@ -274,6 +274,7 @@ vtysh_config_parse_line (const char *line)
        {
          if (strncmp (line, "log", strlen ("log")) == 0
              || strncmp (line, "hostname", strlen ("hostname")) == 0
+             || strncmp (line, "frr", strlen ("frr")) == 0
             )
            config_add_line_uniq (config_top, line);
          else