]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Documentation update and improvement of tests related to expressions in sets.
authorOndrej Filip <feela@network.cz>
Tue, 3 Aug 2010 15:35:34 +0000 (17:35 +0200)
committerOndrej Filip <feela@network.cz>
Tue, 3 Aug 2010 15:35:34 +0000 (17:35 +0200)
doc/bird.sgml
filter/test.conf

index 2f65f137a0ff8d3287fa34106b88be3db3dadf5c..8b2e8ee791e6790a466a61ae7bf763a70f9f8a05 100644 (file)
@@ -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 <cf>int set</cf> look like <cf>
          [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in
-         sets. For pair sets, expressions like <cf/(123,*)/ can be used to denote ranges (in
+         sets.
+         For pair sets, expressions like <cf/(123,*)/ can be used to denote ranges (in
          that case <cf/(123,0)..(123,65535)/). You can also use <cf/(123,5..100/ for range
          <cf/(123,5)..(123,100)/.
+         You can also use expressions for both, pair sets and int sets. However it must
+         be possible to evaluate these expressions before daemon boots. So you can use
+         only constants inside them. E.g.
+       <code>
+        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) ];
+       </code>
 
          Sets of prefixes are special: their literals does not allow ranges, but allows
          prefix patterns that are written as <cf><M>ipaddress</M>/<M>pxlen</M>{<M>low</M>,<M>high</M>}</cf>.
index 18121c4ef7d0d65d9a43aa5b8fb9b90920573774..c25f11aa8df9f567cf8673e7d997e830f03209e8 100644 (file)
@@ -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,