From 7f6c87da2f5a78a76c3bc019d31c6473f3eb9487 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 28 Sep 2020 13:03:49 +0700 Subject: vty/command: reflect global attributes in the XML reference Given that commands with either/both of the following attributes: - CMD_ATTR_DEPRECATED, - CMD_ATTR_HIDDEN, never end up in the XML reference, only CMD_ATTR_IMMEDIATE would be reflected for commands taking effect immediately as follows: Change-Id: I8476c1163c23a9a52641987acf3df0b8c49d8f7b Related: SYS#4937 --- src/vty/command.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/vty/command.c b/src/vty/command.c index bad26888..30c39a72 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -622,6 +622,13 @@ static char *xml_escape(const char *inp) typedef int (*print_func_t)(void *data, const char *fmt, ...); +static const struct value_string cmd_attr_desc[] = { + { CMD_ATTR_DEPRECATED, "This command is deprecated" }, + { CMD_ATTR_HIDDEN, "This command is hidden" }, + { CMD_ATTR_IMMEDIATE, "This command applies immediately" }, + { 0, NULL } +}; + /* * Write one cmd_element as XML via a print_func_t. */ @@ -632,6 +639,25 @@ static int vty_dump_element(struct cmd_element *cmd, print_func_t print_func, vo print_func(data, " %s", xml_string, newline); + /* Print global attributes and their description */ + if (cmd->attr != 0x00) { /* ... if at least one flag is set */ + print_func(data, " %s", newline); + + for (i = 0; i < ARRAY_SIZE(cmd_attr_desc) - 1; i++) { + char *xml_att_desc; + + if (~cmd->attr & cmd_attr_desc[i].value) + continue; + + xml_att_desc = xml_escape(cmd_attr_desc[i].str); + print_func(data, " %s", + xml_att_desc, newline); + talloc_free(xml_att_desc); + } + + print_func(data, " %s", newline); + } + /* Print application specific attributes and their description */ if (cmd->usrattr != 0x00) { /* ... if at least one flag is set */ print_func(data, " %s", newline); -- cgit v1.2.3