aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-07 13:53:38 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-07 14:17:02 +0700
commitf1fc9d3af5262402ac4bcf3da0be631fded70eae (patch)
tree323962e44435b0fd101d3cc803d960a224585b0c
parentef4c597b4aea28611e1c7fa74464a1b189c45f35 (diff)
vty: fix vty_dump_element(): do not print empty <attributes>
Some attributes like CMD_ATTR_LIB_COMMAND are not being printed to the XML VTY reference (despite being set), so we should not print empty "<attributes scope='global'></attributes>". Change-Id: Ie7e53b080c10564bfef6f0e8ddeb470e46fad387 Related: SYS#4937
-rw-r--r--src/vty/command.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index d71f686f..4952567d 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -631,6 +631,10 @@ static const struct value_string cmd_attr_desc[] = {
{ 0, NULL }
};
+/* Public attributes (to be printed in the VTY / XML reference) */
+#define CMD_ATTR_PUBLIC_MASK \
+ (CMD_ATTR_IMMEDIATE | CMD_ATTR_NODE_EXIT)
+
/* Get a flag character for a global VTY command attribute */
static char cmd_attr_get_flag(unsigned int attr)
{
@@ -670,7 +674,7 @@ static int vty_dump_element(struct cmd_element *cmd, print_func_t print_func, vo
print_func(data, " <command id='%s'>%s", xml_string, newline);
/* Print global attributes and their description */
- if (cmd->attr != 0x00) { /* ... if at least one flag is set */
+ if (cmd->attr & CMD_ATTR_PUBLIC_MASK) { /* ... only public ones */
print_func(data, " <attributes scope='global'>%s", newline);
for (i = 0; i < ARRAY_SIZE(cmd_attr_desc) - 1; i++) {