This patch removes an assertion of node > CONFIG_NODE and changes the function to handle all nodes properly. For the sake of completeness, the generic exit command implementation is extended to work properly with all nodes, too. --- src/vty/command.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/vty/command.c b/src/vty/command.c index 7f76ced..38a32cf 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> #define _XOPEN_SOURCE #include <unistd.h> -#include <assert.h> #include <ctype.h> #include <time.h> #include <sys/time.h> @@ -1884,21 +1883,31 @@ char **cmd_complete_command(vector vline, struct vty *vty, int *status) }
/* return parent node */ -/* MUST eventually converge on CONFIG_NODE */ +/* + * MUST eventually converge either on CONFIG_NODE for every config node or + * on CONFIG_ENABLE for every other user defined node. + */ enum node_type vty_go_parent(struct vty *vty) { - assert(vty->node > CONFIG_NODE); - switch (vty->node) { + case AUTH_NODE: + case VIEW_NODE: + case ENABLE_NODE: case CONFIG_NODE: break;
+ case AUTH_ENABLE_NODE: + vty->node = VIEW_NODE; + break; + case CFG_LOG_NODE: case VTY_NODE: vty->node = CONFIG_NODE; break;
default: + if (vty->node > CONFIG_NODE); + if (host.app_info->go_parent_cb) host.app_info->go_parent_cb(vty); else @@ -2267,6 +2276,7 @@ gDEFUN(config_exit, config_exit_cmd, "exit", "Exit current mode and down to previous mode\n") { switch (vty->node) { + case AUTH_NODE: case VIEW_NODE: case ENABLE_NODE: if (0) //vty_shell (vty))