From d3dd620b96c5960207b9321b416423b8130a4df7 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Tue, 12 Oct 1999 06:27:42 +0000 Subject: Filters: permit variables of prefix types, cleanup around variables. TODO list added, hopefully complete. Use new features of filters in bird.conf --- filter/filter.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'filter/filter.c') diff --git a/filter/filter.c b/filter/filter.c index d317fcc..f6b2d4b 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -58,6 +58,7 @@ val_compare(struct f_val v1, struct f_val v2) return CMP_ERROR; switch (v1.type) { case T_INT: + case T_PAIR: if (v1.val.i == v2.val.i) return 0; if (v1.val.i < v2.val.i) return -1; return 1; @@ -209,31 +210,32 @@ interpret(struct f_inst *what) runtime( "~ applied on unknown type pair" ); break; - /* Set to consant, a1 = type, a2 = value */ + /* Set to indirect value, a1 = variable, a2 = value */ case 's': ARG(v2, a2.p); sym = what->a1.p; switch (res.type = v2.type) { case T_VOID: runtime( "Can not assign void values" ); case T_INT: - if (sym->class != (SYM_VARIABLE | T_INT)) + case T_IP: + case T_PREFIX: + case T_PAIR: + if (sym->class != (SYM_VARIABLE | v2.type)) runtime( "Variable of bad type" ); - sym->aux = v2.val.i; + * (struct f_val *) sym->aux2 = v2; break; + default: + bug( "Set to invalid type\n" ); } break; - case 'c': + case 'c': /* integer (or simple type) constant */ res.type = what->a1.i; - res.val.i = (int) what->a2.p; + res.val.i = what->a2.i; break; case 'C': res = * ((struct f_val *) what->a1.p); break; - case 'i': - res.type = what->a1.i; - res.val.i = * ((int *) what->a2.p); - break; case 'p': ONEARG; val_print(v1); @@ -253,7 +255,8 @@ interpret(struct f_inst *what) break; case 'p,': ONEARG; - printf( "\n" ); + if (what->a2.i != F_NONL) + printf( "\n" ); switch (what->a2.i) { case F_QUITBIRD: @@ -265,6 +268,7 @@ interpret(struct f_inst *what) res.type = T_RETURN; res.val.i = what->a1.i; break; + case F_NONL: case F_NOP: break; default: @@ -309,6 +313,10 @@ interpret(struct f_inst *what) ONEARG; interpret_switch(what->a2.p, v1); break; + case 'iM': /* IP.MASK(val) */ + TWOARGS_C; + bug( "Should implement ip.mask\n" ); + break; default: bug( "Unknown instruction %d (%c)", what->code, what->code & 0xff); } -- cgit v1.2.3