mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 09:44:50 +00:00
lib/xref: add xrefs for install_element()
Combined with the DEFUN xrefs, this means we can extract the full CLI tree from a binary file. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
feb06e7a93
commit
01485adb9d
@ -277,7 +277,7 @@ const char *cmd_prompt(enum node_type node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Install a command into a 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;
|
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);
|
vector_set(cnode->cmd_vector, (void *)cmd);
|
||||||
|
|
||||||
if (ntype == VIEW_NODE)
|
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)
|
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)
|
void install_default(enum node_type node)
|
||||||
{
|
{
|
||||||
install_element(node, &config_exit_cmd);
|
_install_element(node, &config_exit_cmd);
|
||||||
install_element(node, &config_quit_cmd);
|
_install_element(node, &config_quit_cmd);
|
||||||
install_element(node, &config_end_cmd);
|
_install_element(node, &config_end_cmd);
|
||||||
install_element(node, &config_help_cmd);
|
_install_element(node, &config_help_cmd);
|
||||||
install_element(node, &config_list_cmd);
|
_install_element(node, &config_list_cmd);
|
||||||
install_element(node, &show_cli_graph_cmd);
|
_install_element(node, &show_cli_graph_cmd);
|
||||||
install_element(node, &find_cmd);
|
_install_element(node, &find_cmd);
|
||||||
|
|
||||||
install_element(node, &config_write_cmd);
|
_install_element(node, &config_write_cmd);
|
||||||
install_element(node, &show_running_config_cmd);
|
_install_element(node, &show_running_config_cmd);
|
||||||
|
|
||||||
install_element(node, &autocomplete_cmd);
|
_install_element(node, &autocomplete_cmd);
|
||||||
|
|
||||||
nb_cli_install_default(node);
|
nb_cli_install_default(node);
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,29 @@ struct cmd_node {
|
|||||||
/* Prototypes. */
|
/* Prototypes. */
|
||||||
extern void install_node(struct cmd_node *node);
|
extern void install_node(struct cmd_node *node);
|
||||||
extern void install_default(enum node_type);
|
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.
|
/* known issue with uninstall_element: changes to cmd_token->attr (i.e.
|
||||||
* deprecated/hidden) are not reversed. */
|
* deprecated/hidden) are not reversed. */
|
||||||
|
@ -1826,20 +1826,20 @@ static struct cmd_node nb_debug_node = {
|
|||||||
|
|
||||||
void nb_cli_install_default(int 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)
|
if (frr_get_cli_mode() != FRR_CLI_TRANSACTIONAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
install_element(node, &config_commit_cmd);
|
_install_element(node, &config_commit_cmd);
|
||||||
install_element(node, &config_commit_comment_cmd);
|
_install_element(node, &config_commit_comment_cmd);
|
||||||
install_element(node, &config_commit_check_cmd);
|
_install_element(node, &config_commit_check_cmd);
|
||||||
install_element(node, &config_update_cmd);
|
_install_element(node, &config_update_cmd);
|
||||||
install_element(node, &config_discard_cmd);
|
_install_element(node, &config_discard_cmd);
|
||||||
install_element(node, &show_config_running_cmd);
|
_install_element(node, &show_config_running_cmd);
|
||||||
install_element(node, &show_config_candidate_cmd);
|
_install_element(node, &show_config_candidate_cmd);
|
||||||
install_element(node, &show_config_compare_cmd);
|
_install_element(node, &show_config_compare_cmd);
|
||||||
install_element(node, &show_config_transaction_cmd);
|
_install_element(node, &show_config_transaction_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* YANG module autocomplete. */
|
/* YANG module autocomplete. */
|
||||||
|
@ -31,6 +31,7 @@ enum xref_type {
|
|||||||
XREFT_LOGMSG = 0x200,
|
XREFT_LOGMSG = 0x200,
|
||||||
|
|
||||||
XREFT_DEFUN = 0x300,
|
XREFT_DEFUN = 0x300,
|
||||||
|
XREFT_INSTALL_ELEMENT = 0x301,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* struct xref is the "const" part; struct xrefdata is the writable part. */
|
/* struct xref is the "const" part; struct xrefdata is the writable part. */
|
||||||
|
@ -3797,11 +3797,11 @@ DEFUN_HIDDEN(show_cli_graph_vtysh,
|
|||||||
|
|
||||||
static void vtysh_install_default(enum node_type node)
|
static void vtysh_install_default(enum node_type node)
|
||||||
{
|
{
|
||||||
install_element(node, &config_list_cmd);
|
_install_element(node, &config_list_cmd);
|
||||||
install_element(node, &find_cmd);
|
_install_element(node, &find_cmd);
|
||||||
install_element(node, &show_cli_graph_vtysh_cmd);
|
_install_element(node, &show_cli_graph_vtysh_cmd);
|
||||||
install_element(node, &vtysh_output_file_cmd);
|
_install_element(node, &vtysh_output_file_cmd);
|
||||||
install_element(node, &no_vtysh_output_file_cmd);
|
_install_element(node, &no_vtysh_output_file_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Making connection to protocol daemon. */
|
/* Making connection to protocol daemon. */
|
||||||
|
Loading…
Reference in New Issue
Block a user