Filter: CLI command to dump all the linearized filters
This commit is contained in:
parent
0206c070ac
commit
84ac62d396
3 changed files with 44 additions and 2 deletions
|
@ -482,3 +482,41 @@ filter_commit(struct config *new, struct config *old)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void filters_dump_all(void)
|
||||
{
|
||||
struct symbol *sym;
|
||||
WALK_LIST(sym, config->symbols) {
|
||||
switch (sym->class) {
|
||||
case SYM_FILTER:
|
||||
debug("Named filter %s:\n", sym->name);
|
||||
f_dump_line(sym->filter->root, 1);
|
||||
break;
|
||||
case SYM_FUNCTION:
|
||||
debug("Function %s:\n", sym->name);
|
||||
f_dump_line(sym->function, 1);
|
||||
break;
|
||||
case SYM_PROTO:
|
||||
{
|
||||
debug("Protocol %s:\n", sym->name);
|
||||
struct channel *c;
|
||||
WALK_LIST(c, sym->proto->proto->channels) {
|
||||
debug(" Channel %s (%s) IMPORT", c->name, net_label[c->net_type]);
|
||||
if (c->in_filter == FILTER_ACCEPT)
|
||||
debug(" ALL\n");
|
||||
else if (c->in_filter == FILTER_REJECT)
|
||||
debug(" NONE\n");
|
||||
else if (c->in_filter == FILTER_UNDEF)
|
||||
debug(" UNDEF\n");
|
||||
else if (c->in_filter->sym) {
|
||||
ASSERT(c->in_filter->sym->filter == c->in_filter);
|
||||
debug(" named filter %s\n", c->in_filter->sym->name);
|
||||
} else {
|
||||
debug("\n");
|
||||
f_dump_line(c->in_filter->root, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,11 @@ int f_same(const struct f_line *f1, const struct f_line *f2);
|
|||
|
||||
void filter_commit(struct config *new, struct config *old);
|
||||
|
||||
void filters_dump_all(void);
|
||||
|
||||
#define FILTER_ACCEPT NULL
|
||||
#define FILTER_REJECT ((void *) 1)
|
||||
#define FILTER_UNDEF ((void *) 2) /* Used in BGP */
|
||||
#define FILTER_REJECT ((struct filter *) 1)
|
||||
#define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */
|
||||
|
||||
#define FF_SILENT 2 /* Silent filter execution */
|
||||
|
||||
|
|
|
@ -731,6 +731,8 @@ CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
|
|||
{ rt_dump_all(); cli_msg(0, ""); } ;
|
||||
CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
|
||||
{ protos_dump_all(); cli_msg(0, ""); } ;
|
||||
CF_CLI(DUMP FILTER ALL,,, [[Dump all filters in linearized form]])
|
||||
{ filters_dump_all(); cli_msg(0, ""); } ;
|
||||
|
||||
CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]])
|
||||
{ cmd_eval(f_linearize($2)); } ;
|
||||
|
|
Loading…
Reference in a new issue