]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Allow matching on enums:
authorPavel Machek <pavel@ucw.cz>
Thu, 1 Jun 2000 08:32:49 +0000 (08:32 +0000)
committerPavel Machek <pavel@ucw.cz>
Thu, 1 Jun 2000 08:32:49 +0000 (08:32 +0000)
        if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then {
                print "Failed in test";
                quitbird;
        }

filter/config.Y
filter/filter.c
filter/test.conf2

index 9d5dc43af4baab366e6bc450f5fa0c06d873da03..69454bc3a748328640b55937def9d6520c6b01c1 100644 (file)
@@ -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:
index f1a8f8fa5defaa2aeb179587a6eb2654d9a868a6..c6d7e4f11cb27f357ecf1ddb83920a0f001b5635 100644 (file)
@@ -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;
 }
 
index 055e49a5bd217e08eec044012ad8e237a61ebd85..60bdd9653f8fc474765cdbaa03551241e748d9f6 100644 (file)
@@ -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;