]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Path matching now actually works, including / * 1 2 3 * /.
authorPavel Machek <pavel@ucw.cz>
Mon, 17 Apr 2000 10:50:03 +0000 (10:50 +0000)
committerPavel Machek <pavel@ucw.cz>
Mon, 17 Apr 2000 10:50:03 +0000 (10:50 +0000)
filter/config.Y
filter/filter.c
filter/filter.h
filter/test.conf

index d515d17b6fef905a4d3e5260ad2002c6cc541f2c..0c2247dc633389da547bf41db33422c307556dc4 100644 (file)
@@ -313,6 +313,7 @@ switch_body: /* EMPTY */ { $$ = NULL; }
 
 bgp_one:
    NUM { $$ = $1; }
+ | '*' { $$ = PM_ANY; }
  ;
 
 bgp_path: 
index d8124b79fb9aeaffedac90d1843df7eeafc453e7..a20076f4631bf56654eda83cef37dfc703cd24a4 100644 (file)
@@ -592,7 +592,6 @@ filters_postconfig(void)
       die( "Startup function resulted in error." );
     debug( "done\n" );
   }
-  self_test();
 } 
 
 int
@@ -674,11 +673,8 @@ path_format(u8 *p, int len)
 #undef PRINTF
 #undef COMMA
 
-#define PM_END -1
-#define PM_ASTERIX -2
-
 #define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \
-                      asterix = (mask->val == PM_ASTERIX); \
+                      asterix = (mask->val == PM_ANY); \
                        if (asterix) { mask = mask->next; if (!mask) { return 1; } } \
                       } while(0)
 
@@ -690,6 +686,9 @@ path_match(u8 *p, int len, struct f_path_mask *mask)
   u8 *q = p+len;
   u8 *next;
 
+  asterix = (mask->val == PM_ANY);
+  if (asterix) { mask = mask->next; if (!mask) { return 1; } }
+
   while (p<q) {
     switch (*p++) {
     case 1:    /* This is a set */
@@ -789,19 +788,3 @@ adata_empty(struct linpool *pool)
   res->length = 0;
   return res;
 }
-
-void
-self_test(void)
-{
-  char path1[] = { 2, 5, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1 };
-  char path2[] = { 2, 5, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 1, 5, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1 };
-  s32 match[] = { 5, PM_ASTERIX, 2, PM_ASTERIX, 1, 3, PM_END };
-
-  DBG( "Filters self-testing:\n" );
-  DBG( "%s\n", path_format(path1, sizeof(path1)) );
-  DBG( "%s\n", path_format(path2, sizeof(path2)) );
-  DBG( "5, 6 = %d, %d\n", path_getlen(path1, sizeof(path1)), path_getlen(path2, sizeof(path2)) );
-//  DBG( "%d\n", path_match(path1, sizeof(path1), match));
-//  DBG( "%d\n", path_match(path2, sizeof(path2), match));
-//  die( "okay" );
-}
index d634c86755a84ea3ed538e313366f390446018b6..e45b5f3c2592226fb143a0a65ceabace35f4ae4a 100644 (file)
@@ -43,6 +43,7 @@ struct f_path_mask {
   struct f_path_mask *next;
   int val;
 };
+#define PM_ANY -1
 
 struct f_val {
   int type;
index 55cbf3368e6ed730b8a3b1a68024aaf5060a2f6f..a31c7f2dc9ffe23e6d4d3f9c30df518f1324896e 100644 (file)
@@ -43,6 +43,7 @@ bgppath p2;
        print "Should be true: ", p2 ~ p;
        p2 = prepend( p2, 5 );
        print "Should be false: ", p2 ~ p;
+       print "Should be true: ", p2 ~ / * 4 3 2 1 /, p2, / * 4 3 2 1 /;
 }
 
 function startup()