summaryrefslogtreecommitdiffstats
path: root/filter/filter.c
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>1999-11-10 13:44:07 +0100
committerPavel Machek <pavel@ucw.cz>1999-11-10 13:44:07 +0100
commitf453665704cc8d946f86057e67151ef27419e280 (patch)
treea595188a4b3be8acf3b2f9c90fca57522578affe /filter/filter.c
parent6ba36f06ae10ea7efd60c30f8ef40d6143c69ef6 (diff)
downloadbird-f453665704cc8d946f86057e67151ef27419e280.tar
bird-f453665704cc8d946f86057e67151ef27419e280.zip
Enumerational types, defined keyword added.
Diffstat (limited to 'filter/filter.c')
-rw-r--r--filter/filter.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/filter/filter.c b/filter/filter.c
index 99d47bc..a6030ae 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -62,6 +62,7 @@ val_compare(struct f_val v1, struct f_val v2)
if (v1.type != v2.type)
return CMP_ERROR;
switch (v1.type) {
+ case T_ENUM:
case T_INT:
case T_PAIR:
if (v1.val.i == v2.val.i) return 0;
@@ -219,6 +220,11 @@ interpret(struct f_inst *what)
if (res.val.i == CMP_ERROR)
runtime( "~ applied on unknown type pair" );
break;
+ case 'de':
+ ONEARG;
+ res.type = T_BOOL;
+ res.val.i = (v1.type != T_VOID);
+ break;
/* Set to indirect value, a1 = variable, a2 = value */
case 's':
@@ -226,6 +232,7 @@ interpret(struct f_inst *what)
sym = what->a1.p;
switch (res.type = v2.type) {
case T_VOID: runtime( "Can not assign void values" );
+ case T_ENUM:
case T_INT:
case T_IP:
case T_PREFIX:
@@ -352,8 +359,16 @@ interpret(struct f_inst *what)
}
break;
case 'iM': /* IP.MASK(val) */
- TWOARGS_C;
- bug( "Should implement ip.mask\n" );
+ TWOARGS;
+ if (v2.type != T_INT)
+ runtime( "Can not use this type for mask.");
+ if (v1.type != T_IP)
+ runtime( "You can mask only IP addresses." );
+ {
+ ip_addr mask = ipa_mkmask(v2.val.i);
+ res.type = T_IP;
+ res.val.px.ip = ipa_and(mask, v1.val.px.ip);
+ }
break;
default:
bug( "Unknown instruction %d (%c)", what->code, what->code & 0xff);