From 17b08668a198b03e932662889eb415515d44d5e2 Mon Sep 17 00:00:00 2001 From: Katerina Kubecova Date: Thu, 7 Dec 2023 13:42:23 +0100 Subject: [PATCH] cmds.c, cbor_cmds.c (, config.Y): 'show symbols constant', 'show symbols variable' work --- nest/cbor_cmds.c | 13 ++++++++----- nest/cmds.c | 10 ++++++++-- nest/config.Y | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/nest/cbor_cmds.c b/nest/cbor_cmds.c index 858b7716..8bd69b28 100644 --- a/nest/cbor_cmds.c +++ b/nest/cbor_cmds.c @@ -116,8 +116,8 @@ cmd_show_status_cbor(byte *tbuf, uint capacity, struct linpool *lp) int parse_show_symbols_arg(struct argument *argument) { - char *params[] = {"table", "filter", "function", "protocol", "template"}; - int param_vals[] = {SYM_TABLE, SYM_FILTER, SYM_FUNCTION, SYM_PROTO, SYM_TEMPLATE}; // defined in conf.h + char *params[] = {"table", "filter", "function", "protocol", "template", "constant", "variable"}; + int param_vals[] = {SYM_TABLE, SYM_FILTER, SYM_FUNCTION, SYM_PROTO, SYM_TEMPLATE, SYM_CONSTANT, SYM_VARIABLE}; // defined in conf.h for (size_t j = 0; j < sizeof(params)/sizeof(char*); j++) { if (compare_str(argument->arg, argument->len, params[j])) @@ -167,7 +167,6 @@ cmd_show_symbols_cbor(byte *tbuf, uint capacity, struct arg_list *args, struct l cbor_string_string(w, "type", "symbol not known"); return w->pt; } - else { cbor_add_string(w, "table"); @@ -177,8 +176,12 @@ cmd_show_symbols_cbor(byte *tbuf, uint capacity, struct arg_list *args, struct l { if (!sym->scope->active) continue; - - if (show_type != SYM_VOID && (sym->class != show_type)) + if (show_type == SYM_VARIABLE || show_type == SYM_CONSTANT) + { + if (!(show_type == (int)(sym->class & 0xffffff00))) + continue; + } + else if (show_type != SYM_VOID && (sym->class != show_type)) continue; cbor_open_block_with_length(w, 2); diff --git a/nest/cmds.c b/nest/cmds.c index d49bbc53..77fc33b2 100644 --- a/nest/cmds.c +++ b/nest/cmds.c @@ -47,6 +47,7 @@ cmd_show_status(void) void cmd_show_symbols(struct sym_show_data *sd) { + cli_msg(-1010, "%i %x", sd->type, sd->type); if (sd->sym) cli_msg(1010, "%-8s\t%s", sd->sym->name, cf_symbol_class_name(sd->sym)); else @@ -57,10 +58,15 @@ cmd_show_symbols(struct sym_show_data *sd) if (!sym->scope->active) continue; - if (sd->type && (sym->class != sd->type)) + if (sd->type == SYM_VARIABLE || sd->type == SYM_CONSTANT) + { + if (!(sd->type == (int)(sym->class & 0xffffff00))) + continue; + } + else if (sd->type && (sym->class != sd->type)) continue; - cli_msg(-1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym)); + cli_msg(-1010, "%-8s\t%s %x %i", sym->name, cf_symbol_class_name(sym), sym->class, sym->class); } HASH_WALK_END; diff --git a/nest/config.Y b/nest/config.Y index 6832a57a..3d294ecc 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -114,7 +114,7 @@ proto_postconfig(void) CF_DECLS CF_KEYWORDS(ROUTER, ID, HOSTNAME, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) -CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, STATES, ROUTES, FILTERS) +CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, STATES, ROUTES, FILTERS, CONSTANT, VARIABLE) CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS) CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED, RPKI) CF_KEYWORDS(PASSWORD, KEY, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, CHANNELS, INTERFACES) @@ -836,7 +836,7 @@ channel_arg: ; CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]]) -CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|], [[Show all known symbolic names]]) +CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|constant|variable|], [[Show all known symbolic names]]) { cmd_show_symbols($3); } ; sym_args: @@ -848,6 +848,8 @@ sym_args: | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; } | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; } | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; } + | sym_args CONSTANT { $$ = $1; $$->type = SYM_CONSTANT; } + | sym_args VARIABLE { $$ = $1; $$->type = SYM_VARIABLE; } | sym_args CF_SYM_KNOWN { $$ = $1; $$->sym = $2; } ;