summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2000-06-01 10:32:49 +0200
committerPavel Machek <pavel@ucw.cz>2000-06-01 10:32:49 +0200
commit1895e81e0532f732f501036402bbdd1825885cfd (patch)
tree8f2c9e7b8bfb5b1b2e76657289a91af0146c9dd0
parent42542c56c23174bfaefb1b949b90ed72afbea8fd (diff)
downloadbird-1895e81e0532f732f501036402bbdd1825885cfd.tar
bird-1895e81e0532f732f501036402bbdd1825885cfd.zip
Allow matching on enums:
if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then { print "Failed in test"; quitbird; }
-rw-r--r--filter/config.Y1
-rw-r--r--filter/filter.c23
-rw-r--r--filter/test.conf24
3 files changed, 20 insertions, 8 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 9d5dc43..69454bc 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -226,6 +226,7 @@ set_atom:
| pair { $$.type = T_PAIR; $$.val.i = $1; }
| fipa { $$ = $1; }
| fprefix { $$ = $1; }
+ | ENUM { $$.type = $1 >> 16; $$.val.i = $1 & 0xffff; }
;
set_item:
diff --git a/filter/filter.c b/filter/filter.c
index f1a8f8f..c6d7e4f 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -143,14 +143,21 @@ val_in_range(struct f_val v1, struct f_val v2)
if (res != CMP_ERROR)
return res;
-
- if (((v1.type == T_INT) || ((v1.type == T_IP) || (v1.type == T_PREFIX)) && (v2.type == T_SET))) {
- struct f_tree *n;
- n = find_tree(v2.val.t, v1);
- if (!n)
- return 0;
- return !! (val_simple_in_range(v1, n->from)); /* We turn CMP_ERROR into compared ok, and that's fine */
- }
+
+ if (v2.type == T_SET)
+ switch (v1.type) {
+ case T_ENUM:
+ case T_INT:
+ case T_IP:
+ case T_PREFIX:
+ {
+ struct f_tree *n;
+ n = find_tree(v2.val.t, v1);
+ if (!n)
+ return 0;
+ return !! (val_simple_in_range(v1, n->from)); /* We turn CMP_ERROR into compared ok, and that's fine */
+ }
+ }
return CMP_ERROR;
}
diff --git a/filter/test.conf2 b/filter/test.conf2
index 055e49a..60bdd96 100644
--- a/filter/test.conf2
+++ b/filter/test.conf2
@@ -36,6 +36,10 @@ protocol static {
print scope;
scope = SCOPE_HOST;
print scope;
+ if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then {
+ print "Failed in test";
+ quitbird;
+ }
preference = 15;
print preference;