summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/command.c24
-rw-r--r--lib/command.h24
-rw-r--r--lib/northbound_cli.c20
-rw-r--r--lib/xref.h1
-rw-r--r--vtysh/vtysh.c10
5 files changed, 51 insertions, 28 deletions
diff --git a/lib/command.c b/lib/command.c
index b34fa7ff3e..6a4d504b2f 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -277,7 +277,7 @@ const char *cmd_prompt(enum node_type node)
}
/* Install a command into a node. */
-void install_element(enum node_type ntype, const struct cmd_element *cmd)
+void _install_element(enum node_type ntype, const struct cmd_element *cmd)
{
struct cmd_node *cnode;
@@ -323,7 +323,7 @@ void install_element(enum node_type ntype, const struct cmd_element *cmd)
vector_set(cnode->cmd_vector, (void *)cmd);
if (ntype == VIEW_NODE)
- install_element(ENABLE_NODE, cmd);
+ _install_element(ENABLE_NODE, cmd);
}
void uninstall_element(enum node_type ntype, const struct cmd_element *cmd)
@@ -2344,18 +2344,18 @@ const char *host_config_get(void)
void install_default(enum node_type node)
{
- install_element(node, &config_exit_cmd);
- install_element(node, &config_quit_cmd);
- install_element(node, &config_end_cmd);
- install_element(node, &config_help_cmd);
- install_element(node, &config_list_cmd);
- install_element(node, &show_cli_graph_cmd);
- install_element(node, &find_cmd);
+ _install_element(node, &config_exit_cmd);
+ _install_element(node, &config_quit_cmd);
+ _install_element(node, &config_end_cmd);
+ _install_element(node, &config_help_cmd);
+ _install_element(node, &config_list_cmd);
+ _install_element(node, &show_cli_graph_cmd);
+ _install_element(node, &find_cmd);
- install_element(node, &config_write_cmd);
- install_element(node, &show_running_config_cmd);
+ _install_element(node, &config_write_cmd);
+ _install_element(node, &show_running_config_cmd);
- install_element(node, &autocomplete_cmd);
+ _install_element(node, &autocomplete_cmd);
nb_cli_install_default(node);
}
diff --git a/lib/command.h b/lib/command.h
index 6acaa450c2..71abb20b05 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -488,7 +488,29 @@ struct cmd_node {
/* Prototypes. */
extern void install_node(struct cmd_node *node);
extern void install_default(enum node_type);
-extern void install_element(enum node_type, const struct cmd_element *);
+
+struct xref_install_element {
+ struct xref xref;
+
+ const struct cmd_element *cmd_element;
+ enum node_type node_type;
+};
+
+#ifndef VTYSH_EXTRACT_PL
+#define install_element(node_type_, cmd_element_) do { \
+ static const struct xref_install_element _xref \
+ __attribute__((used)) = { \
+ .xref = XREF_INIT(XREFT_INSTALL_ELEMENT, NULL, \
+ __func__), \
+ .cmd_element = cmd_element_, \
+ .node_type = node_type_, \
+ }; \
+ XREF_LINK(_xref.xref); \
+ _install_element(node_type_, cmd_element_); \
+ } while (0)
+#endif
+
+extern void _install_element(enum node_type, const struct cmd_element *);
/* known issue with uninstall_element: changes to cmd_token->attr (i.e.
* deprecated/hidden) are not reversed. */
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 853f643472..ad7dad5cb2 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -1826,20 +1826,20 @@ static struct cmd_node nb_debug_node = {
void nb_cli_install_default(int node)
{
- install_element(node, &show_config_candidate_section_cmd);
+ _install_element(node, &show_config_candidate_section_cmd);
if (frr_get_cli_mode() != FRR_CLI_TRANSACTIONAL)
return;
- install_element(node, &config_commit_cmd);
- install_element(node, &config_commit_comment_cmd);
- install_element(node, &config_commit_check_cmd);
- install_element(node, &config_update_cmd);
- install_element(node, &config_discard_cmd);
- install_element(node, &show_config_running_cmd);
- install_element(node, &show_config_candidate_cmd);
- install_element(node, &show_config_compare_cmd);
- install_element(node, &show_config_transaction_cmd);
+ _install_element(node, &config_commit_cmd);
+ _install_element(node, &config_commit_comment_cmd);
+ _install_element(node, &config_commit_check_cmd);
+ _install_element(node, &config_update_cmd);
+ _install_element(node, &config_discard_cmd);
+ _install_element(node, &show_config_running_cmd);
+ _install_element(node, &show_config_candidate_cmd);
+ _install_element(node, &show_config_compare_cmd);
+ _install_element(node, &show_config_transaction_cmd);
}
/* YANG module autocomplete. */
diff --git a/lib/xref.h b/lib/xref.h
index 29c68820fd..11796bc4f8 100644
--- a/lib/xref.h
+++ b/lib/xref.h
@@ -31,6 +31,7 @@ enum xref_type {
XREFT_LOGMSG = 0x200,
XREFT_DEFUN = 0x300,
+ XREFT_INSTALL_ELEMENT = 0x301,
};
/* struct xref is the "const" part; struct xrefdata is the writable part. */
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index a6f9f39a4c..efb6b28acc 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -3797,11 +3797,11 @@ DEFUN_HIDDEN(show_cli_graph_vtysh,
static void vtysh_install_default(enum node_type node)
{
- install_element(node, &config_list_cmd);
- install_element(node, &find_cmd);
- install_element(node, &show_cli_graph_vtysh_cmd);
- install_element(node, &vtysh_output_file_cmd);
- install_element(node, &no_vtysh_output_file_cmd);
+ _install_element(node, &config_list_cmd);
+ _install_element(node, &find_cmd);
+ _install_element(node, &show_cli_graph_vtysh_cmd);
+ _install_element(node, &vtysh_output_file_cmd);
+ _install_element(node, &no_vtysh_output_file_cmd);
}
/* Making connection to protocol daemon. */