ip_addr a;
struct symbol *s;
char *t;
- struct f_inst *x;
+ struct f_inst *x;
+ struct filter *f;
}
%token END
CF_HDR
#include "nest/bird.h"
-#include "filter/filter.h"
#include "lib/resource.h"
#include "lib/socket.h"
#include "lib/timer.h"
%type <x> term
%type <x> block
%type <x> cmds
+%type <f> filter filter_body
CF_GRAMMAR
}
;
-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:
}
int
-f_run(struct symbol *filter, struct rte *rtein, struct rte **rteout)
+f_run(struct filter *filter, struct rte *rtein, struct rte **rteout)
{
struct f_inst *inst;
struct f_val res;
debug( "Running filter `%s'...", filter->name );
- inst = filter->def;
+ inst = filter->root;
res = interpret(inst);
if (res.type != T_RETURN)
return F_ERROR;
/*
- * BIRD Internet Routing Daemon -- Configuration File Handling
+ * BIRD Internet Routing Daemon -- Filters
*
- * (c) 1998 Martin Mares <mj@ucw.cz>
+ * (c) 1999 Pavel Machek <pavel@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
} val;
};
+struct filter {
+ char *name;
+ struct f_inst *root;
+};
+
void filters_postconfig(void);
struct f_inst *f_new_inst(void);
+int f_run(struct filter *filter, struct rte *rtein, struct rte **rteout);
+
#define F_ACCEPT 1
#define F_REJECT 2
#define F_MODIFY 3
#define T_PX 11 /* prefix */
#define T_INTLIST 12
-
#endif