summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLou Berger <lberger@labn.net>2016-01-12 13:41:48 -0500
committerPaul Jakma <paul.jakma@hpe.com>2016-02-26 14:11:41 +0000
commitf9ec4190f1eaf2dba355a9808bca8d7148bc8a55 (patch)
treede588e9501d2f43c347356fe346c409d6a33c6fd
parent9248b61f54955e56212f3ae4c8a7ab704f7ad01c (diff)
downloadquagga-f9ec4190f1eaf2dba355a9808bca8d7148bc8a55.tar.bz2
quagga-f9ec4190f1eaf2dba355a9808bca8d7148bc8a55.tar.xz
lib: add "show commandtree" CLI command
Signed-off-by: Lou Berger <lberger@labn.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r--lib/command.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/command.c b/lib/command.c
index 73a8a804..aee7d06a 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -4056,6 +4056,37 @@ DEFUN (no_banner_motd,
return CMD_SUCCESS;
}
+DEFUN (show_commandtree,
+ show_commandtree_cmd,
+ "show commandtree",
+ NO_STR
+ "Show command tree\n")
+{
+ /* TBD */
+ vector cmd_vector;
+ unsigned int i;
+
+ vty_out (vty, "Current node id: %d%s", vty->node, VTY_NEWLINE);
+
+ /* vector of all commands installed at this node */
+ cmd_vector = vector_copy (cmd_node_vector (cmdvec, vty->node));
+
+ /* loop over all commands at this node */
+ for (i = 0; i < vector_active(cmd_vector); ++i)
+ {
+ struct cmd_element *cmd_element;
+
+ /* A cmd_element (seems to be) is an individual command */
+ if ((cmd_element = vector_slot (cmd_vector, i)) == NULL)
+ continue;
+
+ vty_out (vty, " %s%s", cmd_element->string, VTY_NEWLINE);
+ }
+
+ vector_free (cmd_vector);
+ return CMD_SUCCESS;
+}
+
/* Set config filename. Called from vty.c */
void
host_config_set (char *filename)
@@ -4124,6 +4155,7 @@ cmd_init (int terminal)
install_element (VIEW_NODE, &config_terminal_length_cmd);
install_element (VIEW_NODE, &config_terminal_no_length_cmd);
install_element (VIEW_NODE, &show_logging_cmd);
+ install_element (VIEW_NODE, &show_commandtree_cmd);
install_element (VIEW_NODE, &echo_cmd);
install_element (RESTRICTED_NODE, &config_list_cmd);
@@ -4133,6 +4165,7 @@ cmd_init (int terminal)
install_element (RESTRICTED_NODE, &config_enable_cmd);
install_element (RESTRICTED_NODE, &config_terminal_length_cmd);
install_element (RESTRICTED_NODE, &config_terminal_no_length_cmd);
+ install_element (RESTRICTED_NODE, &show_commandtree_cmd);
install_element (RESTRICTED_NODE, &echo_cmd);
}
@@ -4145,6 +4178,7 @@ cmd_init (int terminal)
}
install_element (ENABLE_NODE, &show_startup_config_cmd);
install_element (ENABLE_NODE, &show_version_cmd);
+ install_element (ENABLE_NODE, &show_commandtree_cmd);
if (terminal)
{
@@ -4207,6 +4241,7 @@ cmd_init (int terminal)
install_element (VIEW_NODE, &show_work_queues_cmd);
install_element (ENABLE_NODE, &show_work_queues_cmd);
}
+ install_element (CONFIG_NODE, &show_commandtree_cmd);
srandom(time(NULL));
}