<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/20440">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty/command: add CMD_ATTR_LIB_COMMAND and install() API wrappers<br><br>This new attribute would allow to distinguish commands provided<br>by libraries from commands registered by the application itself,<br>so vty_dump_element() would print proper description for the<br>library specific attributes.<br><br>All VTY commands defined by the libraries need to use the new API:<br><br>  - install_lib_element(), and<br>  - install_lib_element_ve,<br><br>instead of the old functions (respectively):<br><br>  - install_element(), and<br>  - install_element_ve().<br><br>See https://lists.osmocom.org/pipermail/openbsc/2020-October/013278.html.<br><br>Change-Id: I8baf31ace93c536421893c2aa4e3d9d298dcbcc6<br>Related: SYS#4937<br>---<br>M include/osmocom/vty/command.h<br>M src/vty/command.c<br>2 files changed, 21 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/40/20440/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h</span><br><span>index 43ad3da..25890a4 100644</span><br><span>--- a/include/osmocom/vty/command.h</span><br><span>+++ b/include/osmocom/vty/command.h</span><br><span>@@ -138,6 +138,7 @@</span><br><span>        CMD_ATTR_DEPRECATED     = (1 << 0),</span><br><span>    CMD_ATTR_HIDDEN         = (1 << 1),</span><br><span>    CMD_ATTR_IMMEDIATE      = (1 << 2),</span><br><span style="color: hsl(120, 100%, 40%);">+     CMD_ATTR_LIB_COMMAND    = (1 << 3),</span><br><span> };</span><br><span> </span><br><span> /*! Structure of a command element */</span><br><span>@@ -396,7 +397,9 @@</span><br><span> void install_node(struct cmd_node *, int (*)(struct vty *));</span><br><span> void install_default(int node_type) OSMO_DEPRECATED("Now happens implicitly with install_node()");</span><br><span> void install_element(int node_type, struct cmd_element *);</span><br><span style="color: hsl(120, 100%, 40%);">+void install_lib_element(int node_type, struct cmd_element *);</span><br><span> void install_element_ve(struct cmd_element *cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+void install_lib_element_ve(struct cmd_element *cmd);</span><br><span> void sort_node(void);</span><br><span> </span><br><span> void vty_install_default(int node_type) OSMO_DEPRECATED("Now happens implicitly with install_node()");</span><br><span>diff --git a/src/vty/command.c b/src/vty/command.c</span><br><span>index 30c39a7..b96c268 100644</span><br><span>--- a/src/vty/command.c</span><br><span>+++ b/src/vty/command.c</span><br><span>@@ -626,6 +626,7 @@</span><br><span>         { CMD_ATTR_DEPRECATED,          "This command is deprecated" },</span><br><span>    { CMD_ATTR_HIDDEN,              "This command is hidden" },</span><br><span>        { CMD_ATTR_IMMEDIATE,           "This command applies immediately" },</span><br><span style="color: hsl(120, 100%, 40%);">+       /* CMD_ATTR_LIB_COMMAND is intentionally skipped */</span><br><span>  { 0, NULL }</span><br><span> };</span><br><span> </span><br><span>@@ -859,6 +860,16 @@</span><br><span>         cmd->cmdsize = cmd_cmdsize(cmd->strvec);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Install a library command into a node</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] ntype Node Type</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] cmd element to be installed</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void install_lib_element(int ntype, struct cmd_element *cmd)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  cmd->attr |= CMD_ATTR_LIB_COMMAND;</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element(ntype, cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Install a command into VIEW and ENABLE node */</span><br><span> void install_element_ve(struct cmd_element *cmd)</span><br><span> {</span><br><span>@@ -866,6 +877,13 @@</span><br><span>       install_element(ENABLE_NODE, cmd);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Install a library command into VIEW and ENABLE node */</span><br><span style="color: hsl(120, 100%, 40%);">+void install_lib_element_ve(struct cmd_element *cmd)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       cmd->attr |= CMD_ATTR_LIB_COMMAND;</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element_ve(cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #ifdef VTY_CRYPT_PW</span><br><span> static unsigned char itoa64[] =</span><br><span>     "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/20440">change 20440</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/20440"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I8baf31ace93c536421893c2aa4e3d9d298dcbcc6 </div>
<div style="display:none"> Gerrit-Change-Number: 20440 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>