diff options
author | Pavel Machek <pavel@ucw.cz> | 1999-11-18 15:29:10 +0100 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 1999-11-18 15:29:10 +0100 |
commit | f31156ca217226ad110cc46e6365d70e64c527e0 (patch) | |
tree | 497dbe2635cffc3cd98fbcbe9ff52d3cfd7a585d /filter | |
parent | c7b43f33ae8d583ead531d76ed81f1b5deb507f3 (diff) | |
download | bird-f31156ca217226ad110cc46e6365d70e64c527e0.tar bird-f31156ca217226ad110cc46e6365d70e64c527e0.zip |
Filters: first parts of extended attributes being read-write. It can
not actually work since I do not do rta/rte cow, yet.
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 8 | ||||
-rw-r--r-- | filter/filter.c | 28 |
2 files changed, 34 insertions, 2 deletions
diff --git a/filter/config.Y b/filter/config.Y index 0a14856..a24b157 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -27,7 +27,7 @@ CF_HDR CF_DECLS -CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST, +CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST, UNSET, ACCEPT, REJECT, ERROR, QUITBIRD, INT, BOOL, IP, PREFIX, PAIR, SET, STRING, IF, THEN, ELSE, CASE, @@ -360,7 +360,11 @@ cmd: | RTA '.' any_dynamic '=' term ';' { $$ = $3; $$->code = 'eS'; - + $$->a1.p = $5; + } + | UNSET '(' RTA '.' any_dynamic ')' ';' { + $$ = $5; + $$->code = 'eD'; } | break_command print_list ';' { $$ = f_new_inst(); $$->code = 'p,'; $$->a1.p = $2; $$->a2.i = $1; } | SYM '(' var_list ')' ';' { diff --git a/filter/filter.c b/filter/filter.c index 458b876..36830bd 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -159,6 +159,7 @@ val_print(struct f_val v) } static struct rte **f_rte; +static struct linpool *f_pool; static struct f_val interpret(struct f_inst *what); @@ -332,6 +333,32 @@ interpret(struct f_inst *what) } } break; + case 'eS': + ONEARG; + if (v1.type != what->aux) + runtime("Wrong type when setting dynamic attribute\n"); + + /* This willl only work if it is not already there! */ + { + struct ea_list *l = lp_alloc(f_pool, sizeof(struct ea_list) + sizeof(eattr)); + + l->next = NULL; + l->flags = EALF_SORTED; + l->count = 1; + l->attrs[0].id = what->a2.i; + l->attrs[0].flags = 0; + switch (what->aux) { + case T_INT: + l->attrs[0].type = EAF_TYPE_INT | EAF_INLINE; + l->attrs[0].u.data = v1.val.i; + break; + } + /* FIXME: need to do copy on write of rte + rta + insert at the beggining */ + } + + case 'eD': /*FIXME: unset: implement me */ + die("Implement me!!!" ); + break; case 'cp': /* Convert prefix to ... */ ONEARG; if (v1.type != T_PREFIX) @@ -392,6 +419,7 @@ f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struc debug( "Running filter `%s'...", filter->name ); f_rte = rte; + f_pool = tmp_pool; inst = filter->root; res = interpret(inst); if (res.type != T_RETURN) |