2 * This is an example configuration file.
3 * FIXME: add all examples from docs here.
10 define xyzzy = (120+10);
11 define '1a-a1' = (20+10);
14 function 'mkpair-a'(int a)
19 function mkpath(int a; int b)
21 return [= a b 3 2 1 =];
24 function callme(int arg1; int arg2)
29 printn "Function callme called arguments ", arg1, " and ", arg2, ":" ;
33 2: print "dva"; print "jeste jednou dva";
34 3 .. 5: print "tri az pet";
35 else: print "neco jineho";
41 print "fifteen called";
53 print "Testing path masks: ", pm1, " ", pm2;
54 p2 = prepend( + empty +, 1 );
55 p2 = prepend( p2, 2 );
56 p2 = prepend( p2, 3 );
57 p2 = prepend( p2, 4 );
58 print "Testing paths: ", p2;
59 print "Should be true: ", p2 ~ pm1, " ", p2 ~ pm2;
61 p2 = prepend( p2, 5 );
62 print "Should be false: ", p2 ~ pm1, " ", p2 ~ pm2;
63 print "Should be true: ", p2 ~ / ? 4 3 2 1 /, " ", p2, " ", / ? 4 3 2 1 /;
64 print "Should be true: ", p2 ~ [= * 4 3 * 1 =], " ", p2, " ", [= * 4 3 * 1 =];
65 print "Should be true: ", p2 ~ [= (3+2) (2*2) 3 2 1 =], " ", p2 ~ mkpath(5, 4);
66 print "Should be true: ", p2.len = 5, " ", p2.first = 5, " ", p2.last = 1;
69 pm1 = [= 1 2 * 3 4 5 =];
70 p2 = prepend( + empty +, 5 );
71 p2 = prepend( p2, 4 );
72 p2 = prepend( p2, 3 );
73 p2 = prepend( p2, 3 );
74 p2 = prepend( p2, 2 );
75 p2 = prepend( p2, 1 );
76 print "Should be true: ", p2 ~ pm1, " ", p2, " ", pm1;
81 print "Community list (1,2) (2,3) ", l;
82 print "Should be true: ", (2,3) ~ l;
83 l = delete( l, (2,3) );
84 print "Community list (1,2) ", l;
85 print "Should be false: ", (2,3) ~ l;
90 print "fifteen called";
95 define onetwo=1.2.3.4;
99 if source ~ [ RTS_BGP, RTS_STATIC ] then {
100 # ospf_metric1 = 65535;
101 # ospf_metric2 = 1000;
102 ospf_tag = 0x12345678;
109 if source ~ [ RTS_BGP, RTS_STATIC ] then {
110 # ospf_metric1 = 65535;
111 # ospf_metric2 = 1000;
112 ospf_tag = 0x12345678;
117 function test_pxset(prefix set pxs)
119 print " must be true: ", 10.0.0.0/8 ~ pxs, ",", 10.0.0.0/10 ~ pxs, ",", 10.0.0.0/12 ~ pxs, ",",
120 20.0.0.0/24 ~ pxs, ",", 20.0.40.0/24 ~ pxs, ",", 20.0.0.0/26 ~ pxs, ",",
121 20.0.100.0/26 ~ pxs, ",", 20.0.0.0/28 ~ pxs, ",", 20.0.255.0/28 ~ pxs;
122 print " must be false: ", 10.0.0.0/7 ~ pxs, ",", 10.0.0.0/13 ~ pxs, ",", 10.0.0.0/16 ~ pxs, ",",
123 20.0.0.0/16 ~ pxs, ",", 20.0.0.0/23 ~ pxs, ",", 20.0.0.0/29 ~ pxs, ",",
124 11.0.0.0/10 ~ pxs, ",", 20.1.0.0/26 ~ pxs;
127 function test_undef(int a)
132 print "Defined: ", a, " ", b, " ", defined(b);
148 print "1a-a1 = 30: ", '1a-a1';
149 print "Testing filter language:";
151 i = 12*100 + 60/2 + i;
153 print " arithmetics: 1234 = ", i;
154 printn " if statements ";
155 print "what happens here?";
157 if (i = 4) then { print "*** FAIL: if 0"; quitbird; } else printn ".";
158 # if !(i = 3) then { print "*** FAIL: if 0"; quitbird; } else printn ".";
159 if 1234 = i then printn "."; else { print "*** FAIL: if 1 else"; }
160 # if 1 <= 1 then printn "."; else { print "*** FAIL: test 3"; }
161 if 1234 < 1234 then { print "*** FAIL: test 4"; quitbird; } else print "ok";
162 is = [ 2, 3, 4, 7..11 ];
163 print " must be true: ", 1.2.0.0/16 ~ [ 1.0.0.0/8{ 15 , 17 } ];
164 print " data types; must be true: ", 1.2.3.4 = 1.2.3.4, ",", 1 ~ [1,2,3], ",", 5 ~ [1..20], ",", 10 ~ is, ",", 2 ~ [ 1, 2, 3 ], ",", 5 ~ [ 4 .. 7 ], ",", 1.2.3.4 ~ [ 1.2.3.3..1.2.3.5 ], ",", 1.2.3.4 ~ 1.0.0.0/8, ",", 1.0.0.0/8 ~ 1.0.0.0/8, ",", 1.0.0.0/8 ~ [ 1.0.0.0/8+ ];
165 print " must be true: ", true && true, ",", true || false, ",", ! false && ! false && true, ",", 1 < 2 && 1 != 3, ",", true && true && ! false;
167 print " must be true: ", defined(1), ",", defined(1.2.3.4), ",", 1 != 2, ",", 1 <= 2;
168 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;
170 is1 = [2, 3, 5, 8, 11, 15, 17, 19];
171 is2 = [19, 17, 15, 11, 8, 5, 3, 2];
172 is3 = [5, 17, 2, 11, 8, 15, 3, 19];
174 print " must be true: ", 2 ~ is1, " ", 2 ~ is2, " ", 2 ~ is3;
175 print " must be false: ", 4 ~ is1, " ", 4 ~ is2, " ", 4 ~ is3;
176 print " must be false: ", 10 ~ is1, " ", 10 ~ is2, " ", 10 ~ is3;
177 print " must be true: ", 15 ~ is1, " ", 15 ~ is2, " ", 15 ~ is3;
178 print " must be false: ", 18 ~ is1, " ", 18 ~ is2, " ", 18 ~ is3;
179 print " must be true: ", 19 ~ is1, " ", 19 ~ is2, " ", 19 ~ is3;
180 print " must be false: ", 20 ~ is1, " ", 20 ~ is2, " ", 20 ~ is3;
183 print "Testing prefixes: 1.2.0.0/18 = ", px;
184 print " must be true: ", 192.168.0.0/16 ~ 192.168.0.0/16, " ", 192.168.0.0/17 ~ 192.168.0.0/16, " ", 192.168.254.0/24 ~ 192.168.0.0/16;
185 print " must be false: ", 192.168.0.0/15 ~ 192.168.0.0/16, " ", 192.160.0.0/17 ~ 192.168.0.0/16;
188 print "Testing mask : 127.0.0.0 = ", p.mask(8);
191 print "Testing pairs: (1,2) = ", (1,2), " = ", pp, " = ", (1,1+1), " = ", 'mkpair-a'(2);
192 print " must be true: ", (1,2) = (1,1+1);
193 print "Testing enums: ", RTS_DUMMY, " ", RTS_STATIC;
196 print "Testing string: ", s, " true: ", s ~ "Hell*", " false: ", s ~ "ell*";
199 print "Testing bool: ", b, ", ", !b;
201 if ( b = true ) then print "Testing bool comparison b = true: ", b;
202 else { print "*** FAIL: TRUE test failed" ; quitbird; }
204 pxs = [ 1.2.0.0/16, 1.4.0.0/16+];
205 print "Testing prefix sets: ";
207 print " must be true: ", 1.2.0.0/16 ~ pxs, ",", 1.4.0.0/16 ~ pxs, ",", 1.4.0.0/18 ~ pxs, ",", 1.4.0.0/32 ~ pxs;
208 print " must be false: ", 1.1.0.0/16 ~ pxs, ",", 1.3.0.0/16 ~ pxs, ",", 1.2.0.0/15 ~ pxs, ",", 1.2.0.0/17 ~ pxs, ",",
209 1.2.0.0/32 ~ pxs, ",", 1.4.0.0/15 ~ pxs;
211 test_pxset([ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ]);
212 print "What will this do? ", [ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ];
214 print "Testing functions...";
223 print "Testing function calls: 15 = ", i;
227 print "1.2.3.4 = ", onetwo;
235 # print "*** FAIL: this is unreachable";
241 print "Heya, filtering route to ", net.ip, " prefixlen ", net.len, " source ", source;
242 print "This route was from ", from;
245 if rip_metric > 15 then {
246 reject "RIP Metric is more than infinity";
251 accept "ok I take that";