diff options
-rw-r--r-- | filter/config.Y | 1 | ||||
-rw-r--r-- | filter/filter.c | 25 | ||||
-rw-r--r-- | filter/filter.h | 1 | ||||
-rw-r--r-- | filter/test.conf | 1 |
4 files changed, 7 insertions, 21 deletions
diff --git a/filter/config.Y b/filter/config.Y index d515d17..0c2247d 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -313,6 +313,7 @@ switch_body: /* EMPTY */ { $$ = NULL; } bgp_one: NUM { $$ = $1; } + | '*' { $$ = PM_ANY; } ; bgp_path: diff --git a/filter/filter.c b/filter/filter.c index d8124b7..a20076f 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -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" ); -} diff --git a/filter/filter.h b/filter/filter.h index d634c86..e45b5f3 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -43,6 +43,7 @@ struct f_path_mask { struct f_path_mask *next; int val; }; +#define PM_ANY -1 struct f_val { int type; diff --git a/filter/test.conf b/filter/test.conf index 55cbf33..a31c7f2 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -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() |