summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-03-14 12:43:10 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2009-03-14 12:43:10 +0100
commitcf1860349182503523975fb8084d514407a75fb4 (patch)
tree24fbf737c0204f763ae0a29705706d4786308c3d /filter
parentf16ad72ed76c398f081b97b09d56f4b199822464 (diff)
downloadbird-cf1860349182503523975fb8084d514407a75fb4.tar
bird-cf1860349182503523975fb8084d514407a75fb4.zip
New syntax for bgp_path
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y2
-rw-r--r--filter/filter.c6
-rw-r--r--filter/test.conf25
3 files changed, 22 insertions, 11 deletions
diff --git a/filter/config.Y b/filter/config.Y
index fa2453d..688464d 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -268,7 +268,7 @@ switch_body: /* EMPTY */ { $$ = NULL; }
/* CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT; $$->a2.i = $3; } */
bgp_path:
- '|' bgp_path_tail1 '|' { $$ = $2; }
+ PO bgp_path_tail1 PC { $$ = $2; }
| '/' bgp_path_tail2 '/' { $$ = $2; }
| OR { $$ = NULL; } /* special case because of || is a different token */
;
diff --git a/filter/filter.c b/filter/filter.c
index 785a087..623ab29 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -83,9 +83,9 @@ pm_format(struct f_path_mask *p, byte *buf, unsigned int size)
}
if (p->any)
- buf += bsprintf(buf, "* ");
+ buf += bsprintf(buf, " *");
else
- buf += bsprintf(buf, "%u ", p->val);
+ buf += bsprintf(buf, " %u", p->val);
p = p->next;
}
@@ -252,7 +252,7 @@ val_print(struct f_val v)
case T_ENUM: PRINTF( "(enum %x)%d", v.type, v.val.i ); break;
case T_PATH: as_path_format(v.val.ad, buf2, 1020); PRINTF( "(path %s)", buf2 ); break;
case T_CLIST: int_set_format(v.val.ad, 1, buf2, 1020); PRINTF( "(clist %s)", buf2 ); break;
- case T_PATH_MASK: pm_format(v.val.path_mask, buf2, 1020); PRINTF( "(pathmask %s)", buf2 ); break;
+ case T_PATH_MASK: pm_format(v.val.path_mask, buf2, 1020); PRINTF( "(pathmask%s)", buf2 ); break;
default: PRINTF( "[unknown type %x]", v.type );
#undef PRINTF
}
diff --git a/filter/test.conf b/filter/test.conf
index 73a6519..96859e5 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -31,24 +31,35 @@ function fifteen()
}
function paths()
-bgpmask p;
+bgpmask pm1;
+bgpmask pm2;
bgppath p2;
clist l;
{
- p = / 4 3 2 1 /;
- print "Testing path masks: ", p;
+ pm1 = / 4 3 2 1 /;
+ pm2 = [= 4 3 2 1 =];
+ print "Testing path masks: ", pm1, " ", pm2;
p2 = prepend( + empty +, 1 );
p2 = prepend( p2, 2 );
p2 = prepend( p2, 3 );
p2 = prepend( p2, 4 );
print "Testing paths: ", p2;
- print "Should be true: ", p2 ~ p;
+ print "Should be true: ", p2 ~ pm1, " ", p2 ~ pm2;
print "4 = ", p2.len;
p2 = prepend( p2, 5 );
- print "Should be false: ", p2 ~ p;
- print "Should be true: ", p2 ~ / ? 4 3 2 1 /, p2, / ? 4 3 2 1 /;
- print "Should be true: ", p2 ~ / ? 4 3 ? 1 /, p2, / ? 4 3 ? 1 /;
+ print "Should be false: ", p2 ~ pm1, " ", p2 ~ pm2;
+ print "Should be true: ", p2 ~ / ? 4 3 2 1 /, " ", p2, " ", / ? 4 3 2 1 /;
+ print "Should be true: ", p2 ~ [= * 4 3 * 1 =], " ", p2, " ", [= * 4 3 * 1 =];
print "5 = ", p2.len;
+
+ pm1 = [= 1 2 * 3 4 5 =];
+ p2 = prepend( + empty +, 5 );
+ p2 = prepend( p2, 4 );
+ p2 = prepend( p2, 3 );
+ p2 = prepend( p2, 3 );
+ p2 = prepend( p2, 2 );
+ p2 = prepend( p2, 1 );
+ print "Should be true: ", p2 ~ pm1, " ", p2, " ", pm1;
l = - empty -;
l = add( l, (1,2) );