0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-08 12:18:42 +00:00

cmds.c, cbor_cmds.c (, config.Y): 'show symbols constant', 'show symbols variable' work

This commit is contained in:
Katerina Kubecova 2023-12-07 13:42:23 +01:00
parent c200b7972b
commit 17b08668a1
3 changed files with 20 additions and 9 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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|<symbol>], [[Show all known symbolic names]])
CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|constant|variable|<symbol>], [[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; }
;