summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-07-29 21:34:56 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-07-29 21:35:25 +0300
commit9da01b0b7b6bc9a5cc129f850ff4f459ec33eb49 (patch)
tree05933a71eadb8313ace4088f2cce576f43fc1a1a /lib/if.c
parent7543016dbc01093d5fbc7e94bbc9bc24344b3efc (diff)
*: cleanup interface node installation
The only difference in daemons' interface node definition is the config write function. No need to define the node in every daemon, just pass the callback as an argument to a library function and define the node there. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/if.c b/lib/if.c
index e37b4f55b0..6c57855ca1 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -1349,10 +1349,20 @@ static const struct cmd_variable_handler if_var_handlers[] = {
{.tokenname = "INTERFACE", .completions = if_autocomplete},
{.completions = NULL}};
-void if_cmd_init(void)
+static struct cmd_node interface_node = {
+ .name = "interface",
+ .node = INTERFACE_NODE,
+ .parent_node = CONFIG_NODE,
+ .prompt = "%s(config-if)# ",
+};
+
+void if_cmd_init(int (*config_write)(struct vty *))
{
cmd_variable_handler_register(if_var_handlers);
+ interface_node.config_write = config_write;
+ install_node(&interface_node);
+
install_element(CONFIG_NODE, &interface_cmd);
install_element(CONFIG_NODE, &no_interface_cmd);