diff options
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 91 |
1 files changed, 53 insertions, 38 deletions
diff --git a/lib/command.c b/lib/command.c index c9b261cf2a..919e27ada4 100644 --- a/lib/command.c +++ b/lib/command.c @@ -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) { |
