#include "memory.h"
#include "log.h"
+#include "log_int.h"
#include <lib/version.h>
#include "thread.h"
#include "vector.h"
#include "vrf.h"
#include "command_match.h"
#include "qobj.h"
+#include "defaults.h"
DEFINE_MTYPE( LIB, HOST, "Host config")
DEFINE_MTYPE( LIB, STRVEC, "String vector")
return CMD_SUCCESS;
}
+/* "Set" version ... ignore version tags */
+DEFUN (frr_version_defaults,
+ frr_version_defaults_cmd,
+ "frr <version|defaults> LINE...",
+ "FRRouting 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,
show_commandtree_cmd,
"show commandtree [permutations]",
SHOW_STR
- "Show command tree\n")
+ "Show command tree\n"
+ "Permutations that we are interested in\n")
{
return cmd_list_cmds (vty, argc == 3);
}
+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,
"Write configuration to terminal\n")
{
int idx_type = 1;
- unsigned int i;
int fd, dirfd;
- struct cmd_node *node;
char *config_file, *slash;
char *config_file_tmp = NULL;
char *config_file_sav = NULL;
// if command was 'write terminal' or 'show running-config'
if (argc == 2 && (!strcmp(argv[idx_type]->text, "terminal") ||
!strcmp(argv[0]->text, "show")))
- {
- 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);
- }
- return CMD_SUCCESS;
- }
+ {
+ vty_write_config (vty);
+ return CMD_SUCCESS;
+ }
if (host.noconfig)
return CMD_SUCCESS;
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)
"Copy running config to... \n"
"Copy running config to startup config (same as write file)\n")
{
- return config_write (self, vty, argc, argv);
+ if (!host.noconfig)
+ vty_write_config (vty);
+ return CMD_SUCCESS;
}
/** -- **/
if ((level = level_match(argv[idx_log_level]->arg)) == ZLOG_DISABLED)
return CMD_ERR_NO_MATCH;
- zlog(NULL, level, "%s", ((message = argv_concat(argv, argc, idx_message)) ? message : ""));
+ zlog(level, "%s", ((message = argv_concat(argv, argc, idx_message)) ? message : ""));
if (message)
XFREE(MTYPE_TMP, message);
vty_out (vty, "%s", VTY_NEWLINE);
vty_out (vty, "Protocol name: %s%s",
- zlog_proto_names[zl->protocol], VTY_NEWLINE);
+ zl->protoname, VTY_NEWLINE);
vty_out (vty, "Record priority: %s%s",
(zl->record_priority ? "enabled" : "disabled"), VTY_NEWLINE);
vty_out (vty, "Timestamp precision: %d%s",
if (argc == idx_log_level)
{
- zlog_set_level (NULL, ZLOG_DEST_STDOUT, zlog_default->default_lvl);
+ zlog_set_level (ZLOG_DEST_STDOUT, zlog_default->default_lvl);
return CMD_SUCCESS;
}
int level;
if ((level = level_match(argv[idx_log_level]->arg)) == ZLOG_DISABLED)
return CMD_ERR_NO_MATCH;
- zlog_set_level (NULL, ZLOG_DEST_STDOUT, level);
+ zlog_set_level (ZLOG_DEST_STDOUT, level);
return CMD_SUCCESS;
}
"Cancel logging to stdout\n"
LOG_LEVEL_DESC)
{
- zlog_set_level (NULL, ZLOG_DEST_STDOUT, ZLOG_DISABLED);
+ zlog_set_level (ZLOG_DEST_STDOUT, ZLOG_DISABLED);
return CMD_SUCCESS;
}
if (argc == idx_log_level)
{
- zlog_set_level (NULL, ZLOG_DEST_MONITOR, zlog_default->default_lvl);
+ zlog_set_level (ZLOG_DEST_MONITOR, zlog_default->default_lvl);
return CMD_SUCCESS;
}
int level;
if ((level = level_match(argv[idx_log_level]->arg)) == ZLOG_DISABLED)
return CMD_ERR_NO_MATCH;
- zlog_set_level (NULL, ZLOG_DEST_MONITOR, level);
+ zlog_set_level (ZLOG_DEST_MONITOR, level);
return CMD_SUCCESS;
}
"Disable terminal line (monitor) logging\n"
LOG_LEVEL_DESC)
{
- zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
+ zlog_set_level (ZLOG_DEST_MONITOR, ZLOG_DISABLED);
return CMD_SUCCESS;
}
else
fullpath = fname;
- ret = zlog_set_file (NULL, fullpath, loglevel);
+ ret = zlog_set_file (fullpath, loglevel);
if (p)
XFREE (MTYPE_TMP, p);
"Logging file name\n"
"Logging level\n")
{
- zlog_reset_file (NULL);
+ zlog_reset_file ();
if (host.logfile)
XFREE (MTYPE_HOST, host.logfile);
int level;
if ((level = level_match (argv[idx_log_levels]->arg)) == ZLOG_DISABLED)
return CMD_ERR_NO_MATCH;
- zlog_set_level (NULL, ZLOG_DEST_SYSLOG, level);
+ zlog_set_level (ZLOG_DEST_SYSLOG, level);
return CMD_SUCCESS;
}
else
{
- zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl);
+ zlog_set_level (ZLOG_DEST_SYSLOG, zlog_default->default_lvl);
return CMD_SUCCESS;
}
}
LOG_FACILITY_DESC
LOG_LEVEL_DESC)
{
- zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
+ zlog_set_level (ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
return CMD_SUCCESS;
}
install_element (CONFIG_NODE, &hostname_cmd);
install_element (CONFIG_NODE, &no_hostname_cmd);
+ install_element (CONFIG_NODE, &frr_version_defaults_cmd);
if (terminal > 0)
{
vrf_install_commands ();
}
- srandom(time(NULL));
#ifdef DEV_BUILD
grammar_sandbox_init();