Commit 84ac62d3 authored by Maria Matejka's avatar Maria Matejka
Browse files

Filter: CLI command to dump all the linearized filters

parent 0206c070
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -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);
	    }
	  }
	}
    }
  }
}
+4 −2
Original line number Diff line number Diff line
@@ -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 */

+2 −0
Original line number Diff line number Diff line
@@ -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)); } ;