diff options
author | Martin Mares <mj@ucw.cz> | 1999-03-17 15:29:39 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-03-17 15:29:39 +0100 |
commit | e0f2e42f4f420f7bbdda3d4656c9dda585f1297a (patch) | |
tree | b3db9ed1f4bd5af7bd05c509beb60aca3b6fda7a /filter/config.Y | |
parent | c612a3be310069b9fbbcfef931bb546d536a716f (diff) | |
download | bird-e0f2e42f4f420f7bbdda3d4656c9dda585f1297a.tar bird-e0f2e42f4f420f7bbdda3d4656c9dda585f1297a.zip |
A couple of filter tweaks:
o Introduced struct filter which serves as an external reference
to filter. Using struct symbol for this is unwise since it doesn't
allow extra information attached to the filter and it also forces
all filters to be named.
o Implemented config rule 'filter' which matches either named filter
or an embedded unnamed filter (`{ <filter> }').
o Fixed totally bogus comment at the top of filter.h.
o Added a missing prototype for f_run() to filter.h.
Diffstat (limited to 'filter/config.Y')
-rw-r--r-- | filter/config.Y | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/filter/config.Y b/filter/config.Y index 3577b19..6d51dc7 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -9,7 +9,6 @@ CF_HDR #include "nest/bird.h" -#include "filter/filter.h" #include "lib/resource.h" #include "lib/socket.h" #include "lib/timer.h" @@ -25,6 +24,7 @@ CF_KEYWORDS(FUNCTION, FILTER, PRINTDEBUG, INT, PRINT, CONST, VAR, PUTS, IF, %type <x> term %type <x> block %type <x> cmds +%type <f> filter filter_body CF_GRAMMAR @@ -41,16 +41,34 @@ function: } ; -CF_ADDTO(conf, filter) -filter: - FILTER SYM '{' cmds '}' { +CF_ADDTO(conf, filter_def) +filter_def: + FILTER SYM filter_body { if ($2->class != SYM_VOID) cf_error("Symbol already defined" ); $2->class = SYM_FILTER; - $2->def = $4; + $2->def = $3; + $3->name = $2->name; printf( "We have new filter defined (%s)\n", $2->name ) } ; +filter_body: + '{' cmds '}' { + struct filter *f = cfg_alloc(sizeof(struct filter)); + f->name = NULL; + f->root = $2; + $$ = f; + } + ; + +filter: + SYM { + if ($1->class != SYM_FILTER) cf_error("No such filter"); + $$ = $1->def; + } + | filter_body + ; + /* Programs */ cmds: |