summaryrefslogtreecommitdiffstats
path: root/filter/filter.c
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>1999-10-12 08:27:42 +0200
committerPavel Machek <pavel@ucw.cz>1999-10-12 08:27:42 +0200
commitd3dd620b96c5960207b9321b416423b8130a4df7 (patch)
tree984834ecea383ef4a3b6b6e76c487cb6d187e886 /filter/filter.c
parentc79ec2ec1962394f1550afa10a8b396f0e4dfc52 (diff)
downloadbird-d3dd620b96c5960207b9321b416423b8130a4df7.tar
bird-d3dd620b96c5960207b9321b416423b8130a4df7.zip
Filters: permit variables of prefix types, cleanup around
variables. TODO list added, hopefully complete. Use new features of filters in bird.conf
Diffstat (limited to 'filter/filter.c')
-rw-r--r--filter/filter.c28
1 files changed, 18 insertions, 10 deletions
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);
}