diff --git a/filter/filter.c b/filter/filter.c index ed0b21bc..d9c98872 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -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); + } + } + } + } + } +} diff --git a/filter/filter.h b/filter/filter.h index 36b63e7c..9d997efb 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -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 */ diff --git a/nest/config.Y b/nest/config.Y index 430c9f29..e97b8fb3 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -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, , [[Evaluate an expression]]) { cmd_eval(f_linearize($2)); } ;