summaryrefslogtreecommitdiffstats
path: root/lib/lib_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lib_vty.c')
-rw-r--r--lib/lib_vty.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/lib_vty.c b/lib/lib_vty.c
index 932b46501..787da08e2 100644
--- a/lib/lib_vty.c
+++ b/lib/lib_vty.c
@@ -35,6 +35,7 @@
#include "log.h"
#include "memory.h"
#include "module.h"
+#include "defaults.h"
#include "lib_vty.h"
/* Looking up memory status from vty interface. */
@@ -177,8 +178,60 @@ DEFUN_NOSH (show_modules,
return CMD_SUCCESS;
}
+DEFUN (frr_defaults,
+ frr_defaults_cmd,
+ "frr defaults PROFILE...",
+ "FRRouting global parameters\n"
+ "set of configuration defaults used\n"
+ "profile string\n")
+{
+ char *profile = argv_concat(argv, argc, 2);
+ int rv = CMD_SUCCESS;
+
+ if (!frr_defaults_profile_valid(profile)) {
+ vty_out(vty, "%% WARNING: profile %s is not known in this version\n",
+ profile);
+ rv = CMD_WARNING;
+ }
+ frr_defaults_profile_set(profile);
+ XFREE(MTYPE_TMP, profile);
+ return rv;
+}
+
+DEFUN (frr_version,
+ frr_version_cmd,
+ "frr version VERSION...",
+ "FRRouting global parameters\n"
+ "version configuration was written by\n"
+ "version string\n")
+{
+ char *version = argv_concat(argv, argc, 2);
+
+ frr_defaults_version_set(version);
+ XFREE(MTYPE_TMP, version);
+ return CMD_SUCCESS;
+}
+
+static void defaults_autocomplete(vector comps, struct cmd_token *token)
+{
+ const char **p;
+
+ for (p = frr_defaults_profiles; *p; p++)
+ vector_set(comps, XSTRDUP(MTYPE_COMPLETION, *p));
+}
+
+static const struct cmd_variable_handler default_var_handlers[] = {
+ {.tokenname = "PROFILE", .completions = defaults_autocomplete},
+ {.completions = NULL},
+};
+
void lib_cmd_init(void)
{
+ cmd_variable_handler_register(default_var_handlers);
+
+ install_element(CONFIG_NODE, &frr_defaults_cmd);
+ install_element(CONFIG_NODE, &frr_version_cmd);
+
install_element(VIEW_NODE, &show_memory_cmd);
install_element(VIEW_NODE, &show_modules_cmd);
}