diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2010-09-17 14:40:56 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2010-09-17 14:40:56 +0200 |
commit | 8f553d57cb44c8797d456a27adfb6637aa1bd1c6 (patch) | |
tree | f3d908122b9f00bbf49ade0e839ff43e5ea04f27 /src/shared/libosmocore/src/vty/command.c | |
parent | 66d8352a24a0dae83605b7e31c0e0427365ce1ac (diff) | |
parent | af5ee34c353ea2868a4b04b227bc1b511e1ac42b (diff) |
Merge commit 'af5ee34c353ea2868a4b04b227bc1b511e1ac42b'
Diffstat (limited to 'src/shared/libosmocore/src/vty/command.c')
-rw-r--r-- | src/shared/libosmocore/src/vty/command.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/shared/libosmocore/src/vty/command.c b/src/shared/libosmocore/src/vty/command.c index 598e63cc..7525df65 100644 --- a/src/shared/libosmocore/src/vty/command.c +++ b/src/shared/libosmocore/src/vty/command.c @@ -139,6 +139,18 @@ static int cmp_desc(const void *p, const void *q) return strcmp(a->cmd, b->cmd); } +static int is_config(struct vty *vty) +{ + if (vty->node <= CONFIG_NODE) + return 0; + else if (vty->node > CONFIG_NODE && vty->node < _LAST_OSMOVTY_NODE) + return 1; + else if (host.app_info->is_config_node) + return host.app_info->is_config_node(vty, vty->node); + else + return vty->node > CONFIG_NODE; +} + /* Sort each node's command element according to command string. */ void sort_node() { @@ -1947,9 +1959,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 +2109,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); } |