diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2020-10-06 00:22:06 +0700 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2020-10-06 00:22:06 +0700 |
commit | 99d5c2d721ed3b4b12e32fcd4ad1770359825ef1 (patch) | |
tree | 80efc283e1b573b7670dbd8026a363ba7e36603e /src/vty | |
parent | ceb3b394404540684f448d8edb43a9550f044def (diff) |
vty/command: add CMD_ATTR_LIB_COMMAND and install() API wrappers
This new attribute would allow to distinguish commands provided
by libraries from commands registered by the application itself,
so vty_dump_element() would print proper description for the
library specific attributes.
All VTY commands defined by the libraries need to use the new API:
- install_lib_element(), and
- install_lib_element_ve,
instead of the old functions (respectively):
- install_element(), and
- install_element_ve().
See https://lists.osmocom.org/pipermail/openbsc/2020-October/013278.html.
Change-Id: I8baf31ace93c536421893c2aa4e3d9d298dcbcc6
Related: SYS#4937
Diffstat (limited to 'src/vty')
-rw-r--r-- | src/vty/command.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vty/command.c b/src/vty/command.c index b472f6d0..398c716c 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -627,6 +627,7 @@ static const struct value_string cmd_attr_desc[] = { { CMD_ATTR_HIDDEN, "This command is hidden" }, { CMD_ATTR_IMMEDIATE, "This command applies immediately" }, { CMD_ATTR_NODE_EXIT, "This command applies on VTY node exit" }, + /* CMD_ATTR_LIB_COMMAND is intentionally skipped */ { 0, NULL } }; @@ -860,6 +861,16 @@ void install_element(int ntype, struct cmd_element *cmd) cmd->cmdsize = cmd_cmdsize(cmd->strvec); } +/*! Install a library command into a node + * \param[in] ntype Node Type + * \param[in] cmd element to be installed + */ +void install_lib_element(int ntype, struct cmd_element *cmd) +{ + cmd->attr |= CMD_ATTR_LIB_COMMAND; + install_element(ntype, cmd); +} + /* Install a command into VIEW and ENABLE node */ void install_element_ve(struct cmd_element *cmd) { @@ -867,6 +878,13 @@ void install_element_ve(struct cmd_element *cmd) install_element(ENABLE_NODE, cmd); } +/* Install a library command into VIEW and ENABLE node */ +void install_lib_element_ve(struct cmd_element *cmd) +{ + cmd->attr |= CMD_ATTR_LIB_COMMAND; + install_element_ve(cmd); +} + #ifdef VTY_CRYPT_PW static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |