summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMaria Matejka <mq@jmq.cz>2019-07-03 08:13:07 +0200
committerMaria Matejka <mq@jmq.cz>2019-07-03 08:27:56 +0200
commit84ac62d3967f5294f4dc208b803a273a101744a8 (patch)
tree411eb271d89924466c2d77476f503a6d62927389 /filter
parent0206c070ace90c48a806a74fac52ba6e6ff9858b (diff)
Filter: CLI command to dump all the linearized filters
Diffstat (limited to 'filter')
-rw-r--r--filter/filter.c38
-rw-r--r--filter/filter.h6
2 files changed, 42 insertions, 2 deletions
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 */