This patch removes the local 'end' and 'exit' implementations and uses the generic ones provided by libosmocore instead, which are enabled automatically when vty_install_default() is used. --- src/e1_input_vty.c | 2 ++ src/ipa_proxy.c | 26 +------------------------- 2 files changed, 3 insertions(+), 25 deletions(-)
diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index b6e1438..faaebd8 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -276,6 +276,8 @@ int e1inp_vty_init(void) { install_element(CONFIG_NODE, &cfg_e1inp_cmd); install_node(&e1inp_node, e1inp_config_write); + + vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); diff --git a/src/ipa_proxy.c b/src/ipa_proxy.c index 74cf427..a394b8c 100644 --- a/src/ipa_proxy.c +++ b/src/ipa_proxy.c @@ -644,28 +644,6 @@ static int ipa_cfg_write(struct vty *vty) return CMD_SUCCESS; }
-DEFUN(ournode_exit, - ournode_exit_cmd, "exit", "Exit current mode and down to previous mode\n") -{ - switch (vty->node) { - case L_IPA_NODE: - vty->node = CONFIG_NODE; - vty->index = NULL; - break; - } - return CMD_SUCCESS; -} - -DEFUN(ournode_end, - ournode_end_cmd, "end", "End current mode and change to enable mode.\n") -{ - switch (vty->node) { - case L_IPA_NODE: - break; - } - return CMD_SUCCESS; -} - void ipa_proxy_vty_init(void) { tall_ipa_proxy_ctx = @@ -681,9 +659,7 @@ void ipa_proxy_vty_init(void)
install_element(CONFIG_NODE, &ipa_cfg_cmd); install_node(&ipa_node, ipa_cfg_write); - install_default(L_IPA_NODE); - install_element(L_IPA_NODE, &ournode_exit_cmd); - install_element(L_IPA_NODE, &ournode_end_cmd); + vty_install_default(L_IPA_NODE); install_element(L_IPA_NODE, &ipa_instance_cfg_add_cmd); install_element(L_IPA_NODE, &ipa_route_cfg_add_cmd); }
Ensures a single blank after the '#'. Use (config-foo) instead (foo) for config nodes. --- src/e1_input_vty.c | 2 +- src/ipa_proxy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index faaebd8..d99c853 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -268,7 +268,7 @@ DEFUN(show_e1ts,
struct cmd_node e1inp_node = { L_E1INP_NODE, - "%s(e1_input)#", + "%s(config-e1_input)# ", 1, };
diff --git a/src/ipa_proxy.c b/src/ipa_proxy.c index a394b8c..30840ef 100644 --- a/src/ipa_proxy.c +++ b/src/ipa_proxy.c @@ -612,7 +612,7 @@ DEFUN(ipa_instance_cfg_add, ipa_instance_cfg_add_cmd,
struct cmd_node ipa_node = { L_IPA_NODE, - "%s(ipa)#", + "%s(config-ipa)# ", 1, };
This was basically a link to configure/ipa which is not cleanly supported by the current VTY framework.
The test program uses the default implementation for go_parent_cb/vty_go_parent() and is_config_node, since config-ipa is a top level config node which is assumed by default. --- src/ipa_proxy.c | 8 -------- tests/ipa_proxy_test.c | 22 ---------------------- 2 files changed, 30 deletions(-)
diff --git a/src/ipa_proxy.c b/src/ipa_proxy.c index 30840ef..0c177a2 100644 --- a/src/ipa_proxy.c +++ b/src/ipa_proxy.c @@ -208,13 +208,6 @@ ipa_sock_src_accept_cb(struct ipa_server_link *link, int fd) /* * VTY commands for IPA */ -DEFUN(ipa_proxy, ipa_cmd, "ipa", "Configure the ipaccess proxy") -{ - vty->index = NULL; - vty->node = L_IPA_NODE; - return CMD_SUCCESS; -} - static int __ipa_instance_add(struct vty *vty, int argc, const char *argv[]) { struct ipa_proxy_instance *ipi; @@ -649,7 +642,6 @@ void ipa_proxy_vty_init(void) tall_ipa_proxy_ctx = talloc_named_const(libosmo_abis_ctx, 1, "ipa_proxy");
- install_element(ENABLE_NODE, &ipa_cmd); install_element(ENABLE_NODE, &ipa_instance_add_cmd); install_element(ENABLE_NODE, &ipa_instance_del_cmd); install_element(ENABLE_NODE, &ipa_instance_show_cmd); diff --git a/tests/ipa_proxy_test.c b/tests/ipa_proxy_test.c index 2ed30ff..8f4533c 100644 --- a/tests/ipa_proxy_test.c +++ b/tests/ipa_proxy_test.c @@ -28,31 +28,9 @@ const struct log_info ipa_proxy_test_log_info = { .num_cat = ARRAY_SIZE(ipa_proxy_test_cat), };
-static int bsc_vty_is_config_node(struct vty *vty, int node) -{ - switch(node) { - case L_IPA_NODE: - return 1; - break; - } - return 0; -} - -static enum node_type bsc_vty_go_parent(struct vty *vty) -{ - switch (vty->node) { - case L_IPA_NODE: - vty->node = VIEW_NODE; - break; - } - return vty->node; -} - static struct vty_app_info vty_info = { .name = "ipa-proxy-test", .version = "1.0", - .go_parent_cb = bsc_vty_go_parent, - .is_config_node = bsc_vty_is_config_node, };
#define IPA_PROXY_TEST_TELNET_PORT 4260