diff --git a/doc/bird.sgml b/doc/bird.sgml index 2f65f137..8b2e8ee7 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -706,9 +706,21 @@ incompatible with each other (that is to prevent you from shooting in the foot). Filters recognize four types of sets. Sets are similar to strings: you can pass them around but you can't modify them. Literals of type int set look like [ 1, 2, 5..7 ]. As you can see, both simple values and ranges are permitted in - sets. For pair sets, expressions like + define one=1; + int set odds; + pair set ps; + + odds = [ one, (2+1), (6-one), (2*2*2-1), 9, 11 ]; + ps = [ (1,(one+one)), (3,4)..(4,8), (5,*), (6,3..6) ]; + Sets of prefixes are special: their literals does not allow ranges, but allows prefix patterns that are written as ipaddress/pxlen{low,high}. diff --git a/filter/test.conf b/filter/test.conf index 18121c4e..c25f11aa 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -183,11 +183,12 @@ string s; print " must be true: ", defined(1), ",", defined(1.2.3.4), ",", 1 != 2, ",", 1 <= 2; print " data types: must be false: ", 1 ~ [ 2, 3, 4 ], ",", 5 ~ is, ",", 1.2.3.4 ~ [ 1.2.3.3, 1.2.3.5 ], ",", (1,2) > (2,2), ",", (1,1) > (1,1), ",", 1.0.0.0/9 ~ [ 1.0.0.0/8- ], ",", 1.2.0.0/17 ~ [ 1.0.0.0/8{ 15 , 16 } ], ",", true && false; - is1 = [2, 3, 5, 8, 11, 15, 17, 19]; + is1 = [one, (2+1), (6-one), 8, 11, 15, 17, 19]; is2 = [19, 17, 15, 11, 8, 5, 3, 2]; is3 = [5, 17, 2, 11, 8, 15, 3, 19]; - print " must be true: ", 2 ~ is1, " ", 2 ~ is2, " ", 2 ~ is3; + print " must be true: ", 1 ~ is1, " ", 3 ~ is1, " ", 5 ~ is1; + print " must be true: ", (one+2) ~ is1, " ", 2 ~ is2, " ", 2 ~ is3; print " must be false: ", 4 ~ is1, " ", 4 ~ is2, " ", 4 ~ is3; print " must be false: ", 10 ~ is1, " ", 10 ~ is2, " ", 10 ~ is3; print " must be true: ", 15 ~ is1, " ", 15 ~ is2, " ", 15 ~ is3; @@ -210,9 +211,9 @@ string s; ", true: ", RTS_STATIC ~ [RTS_STATIC, RTS_DEVICE], ", false: ", RTS_BGP ~ [RTS_STATIC, RTS_DEVICE]; - ps = [(1,2), (3,4)..(4,8), (5,*)]; - print "Testing pair set, true: ", pp ~ ps, " ", (3,5) ~ ps, " ", (4,1) ~ ps, " ", (5,4) ~ ps, " ", (5,65535) ~ ps; - print "Testing pair set, false: ", (3,3) ~ ps, " ", (4,9) ~ ps, " ", (4,65535) ~ ps, " ", (6,0) ~ ps ; + ps = [(1,(one+one)), (3,4)..(4,8), (5,*), (6,3..6)]; + print "Testing pair set, true: ", pp ~ ps, " ", (3,5) ~ ps, " ", (4,1) ~ ps, " ", (5,4) ~ ps, " ", (5,65535) ~ ps, " ", (6,4) ~ ps; + print "Testing pair set, false: ", (3,3) ~ ps, " ", (4,9) ~ ps, " ", (4,65535) ~ ps, " ", (6,2) ~ ps, " ", (6,(6+one)) ~ ps, " ", ((one+6),2) ~ ps ; qq = 1.2.3.4; print "Testinq quad: 1.2.3.4 = ", qq,