aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty/command.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-25 13:23:53 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-26 15:00:52 +0800
commit50cfb780d229919fbe6b49fde627becdd3cd3d97 (patch)
tree15aaa7acc1f881222d3e63dc82599d8e38cdbd66 /src/vty/command.c
parent5ea4498c28b456ade17a92bc9aab85de9502ba00 (diff)
vty: Move the assumption of the config nodes into a function
Move the assumption that something is a child of the CONFIG_NODE into a new function. The next step will be to use something else for that.
Diffstat (limited to 'src/vty/command.c')
-rw-r--r--src/vty/command.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index 598e63cc..bec28a0d 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -139,6 +139,12 @@ static int cmp_desc(const void *p, const void *q)
return strcmp(a->cmd, b->cmd);
}
+static int is_config(struct vty *vty)
+{
+ /* Assume that everything above CONFIG_NODE is a config node */
+ return vty->node > CONFIG_NODE;
+}
+
/* Sort each node's command element according to command string. */
void sort_node()
{
@@ -1947,9 +1953,9 @@ cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd,
if (vtysh)
return saved_ret;
- /* This assumes all nodes above CONFIG_NODE are childs of CONFIG_NODE */
+ /* Go to parent for config nodes to attempt to find the right command */
while (ret != CMD_SUCCESS && ret != CMD_WARNING
- && vty->node > CONFIG_NODE) {
+ && is_config(vty)) {
vty_go_parent(vty);
ret = cmd_execute_command_real(vline, vty, cmd);
tried = 1;
@@ -2097,7 +2103,7 @@ int config_from_file(struct vty *vty, FILE * fp)
/* Try again with setting node to CONFIG_NODE */
while (ret != CMD_SUCCESS && ret != CMD_WARNING
&& ret != CMD_ERR_NOTHING_TODO
- && vty->node != CONFIG_NODE) {
+ && vty->node != CONFIG_NODE && is_config(vty)) {
vty_go_parent(vty);
ret = cmd_execute_command_strict(vline, vty, NULL);
}