aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-09-06 16:52:00 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-09-08 10:49:52 +0200
commit0c987bd83b2b23f3f125c74f4a653c2fd2ae8c92 (patch)
tree0b87b424c5a44bc5f6d4655bc5987084270621fd /src
parent7eed0538ae79394a10ac9667a798237457ac2373 (diff)
vty: Add vty_install_default() and use for the vty nodes
This adds the vty_install_default() function that is basically the install_default() function plus the registration of the commands 'exit' and 'end'. The latter is only provided in subnodes of ENABLED_NODE and CONFIG_NONE. The VTY test program is extended to check these commands. Ticket: OW#952
Diffstat (limited to 'src')
-rw-r--r--src/vty/command.c18
-rw-r--r--src/vty/logging_vty.c3
-rw-r--r--src/vty/vty.c2
3 files changed, 16 insertions, 7 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index 3892dddd..df2ffeab 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -3302,6 +3302,18 @@ void install_default(enum node_type node)
install_element(node, &show_running_config_cmd);
}
+void vty_install_default(enum node_type node)
+{
+ install_default(node);
+
+ install_element(node, &config_exit_cmd);
+
+ if (node >= CONFIG_NODE) {
+ /* It's not a top node. */
+ install_element(node, &config_end_cmd);
+ }
+}
+
/**
* \brief Write the current running config to a given file
* \param[in] vty the vty of the code
@@ -3380,8 +3392,7 @@ void cmd_init(int terminal)
}
if (terminal) {
- install_element(ENABLE_NODE, &config_exit_cmd);
- install_default(ENABLE_NODE);
+ vty_install_default(ENABLE_NODE);
install_element(ENABLE_NODE, &config_disable_cmd);
install_element(ENABLE_NODE, &config_terminal_cmd);
install_element (ENABLE_NODE, &copy_runningconfig_startupconfig_cmd);
@@ -3395,8 +3406,7 @@ void cmd_init(int terminal)
install_element(ENABLE_NODE, &config_terminal_no_length_cmd);
install_element(ENABLE_NODE, &echo_cmd);
- install_default(CONFIG_NODE);
- install_element(CONFIG_NODE, &config_exit_cmd);
+ vty_install_default(CONFIG_NODE);
}
install_element(CONFIG_NODE, &hostname_cmd);
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index e17c7a8a..64e49d7e 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -677,8 +677,7 @@ void logging_vty_add_cmds(const struct log_info *cat)
install_element_ve(&show_alarms_cmd);
install_node(&cfg_log_node, config_write_log);
- install_default(CFG_LOG_NODE);
- install_element(CFG_LOG_NODE, &config_end_cmd);
+ vty_install_default(CFG_LOG_NODE);
install_element(CFG_LOG_NODE, &logging_fltr_all_cmd);
install_element(CFG_LOG_NODE, &logging_use_clr_cmd);
install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd);
diff --git a/src/vty/vty.c b/src/vty/vty.c
index 696766a9..8bfc35cd 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -1753,7 +1753,7 @@ void vty_init(struct vty_app_info *app_info)
install_element(ENABLE_NODE, &terminal_monitor_cmd);
install_element(ENABLE_NODE, &terminal_no_monitor_cmd);
- install_default(VTY_NODE);
+ vty_install_default(VTY_NODE);
install_element(VTY_NODE, &vty_login_cmd);
install_element(VTY_NODE, &no_vty_login_cmd);
}