Statistics
| Branch: | Revision:

iof-bird-daemon / filter / test.conf @ 9a09a64b

History | View | Annotate | Download (3.52 KB)

1
/*
2
 *	This is an example configuration file.
3
 */
4

    
5
# Yet another comment
6

    
7
router id 62.168.0.1;
8

    
9
define xyzzy = (120+10);
10

    
11
function callme(int arg1; int arg2)
12
int local1;
13
int local2;
14
int i;
15
{
16
	printn "Function callme called arguments ", arg1, " and ", arg2, ":" ;
17
	i = arg2;
18

    
19
	case arg1 {
20
	2: print "dva"; print "jeste jednou dva";
21
	3 .. 5: print "tri az pet";
22
	else: print "neco jineho";
23
	}	
24
}
25

    
26
function fifteen()
27
{
28
	print "fifteen called";
29
	return 15;
30
}
31

    
32
function paths()
33
bgpmask p;
34
bgppath p2;
35
clist l;
36
{
37
	p = / 4 3 2 1 /;
38
	print "Testing path masks: ", p;
39
	p2 = prepend( + empty +, 1 );
40
	p2 = prepend( p2, 2 );
41
	p2 = prepend( p2, 3 );
42
	p2 = prepend( p2, 4 );
43
	print "Testing paths: ", p2;
44
	print "Should be true: ", p2 ~ p;
45
	print "4 = ", p2.len;
46
	p2 = prepend( p2, 5 );
47
	print "Should be false: ", p2 ~ p;
48
	print "Should be true: ", p2 ~ / ? 4 3 2 1 /, p2, / ? 4 3 2 1 /;
49
	print "Should be true: ", p2 ~ / ? 4 3 ? 1 /, p2, / ? 4 3 ? 1 /;
50
	print "5 = ", p2.len;
51

    
52
	l = - empty -;
53
	l = add( l, (1,2) );
54
	l = add( l, (2,3) );
55
	print "Community list (1,2) (2,3) ", l;
56
	print "Should be true: ", (2,3) ~ l;
57
	l = delete( l, (2,3) );
58
	print "Community list (1,2) ", l;
59
	print "Should be false: ", (2,3) ~ l;
60
}
61

    
62
function bla()
63
{
64
	print "fifteen called";
65
	return 15;
66
}
67

    
68
define four=4;
69
define onetwo=1.2.3.4;
70

    
71
function __startup() 
72
int i;
73
prefix px;
74
ip p;
75
{ 
76
	print "Testing filter language:";
77
	i = four; 
78
	i = 12*100 + 60/2 + i; 
79
	i = ( i + 0 );
80
	print "  arithmetics: 1234 = ", i;
81
	printn "  if statements ";
82
	print "what happens here?";
83
	printn ".";
84
	if (i = 4) then { print "*** FAIL: if 0"; quitbird; } else printn ".";
85
#	if !(i = 3) then { print "*** FAIL: if 0"; quitbird; } else printn ".";
86
	if 1234 = i then printn "."; else { print "*** FAIL: if 1 else"; }
87
#	if 1 <= 1 then printn "."; else { print "*** FAIL: test 3"; }
88
	if 1234 < 1234 then { print "*** FAIL: test 4"; quitbird; } else print "ok";
89
	print "  must be true: ", 1.2.0.0/16 ~ [ 1.0.0.0/8{ 15 , 17 } ];
90
	print "  data types; must be true: ", 1.2.3.4 = 1.2.3.4, ",", 1 ~ [1,2,3], ",", 5 ~ [1..20], ",", 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+ ];
91

    
92
#	print "  must be true: ", defined(1), ",", defined(1.2.3.4), ",", 1 != 2, ",", 1 <= 2;
93
	print "  data types: must be false: ", 1 ~ [ 2, 3, 4 ], ",", 5 ~ [ 2, 3, 4, 7..11 ], ",", 1.2.3.4 ~ [ 1.2.3.3, 1.2.3.5 ], ",", (1,2) > (2,2), ",", (1,1) > (1,1), ",", 1.0.0.0/8 ~ [ 1.0.0.0/8- ], ",", 1.2.0.0/17 ~ [ 1.0.0.0/8{ 15 , 16 } ];
94

    
95
	px = 1.2.0.0/18;
96
	print "Testing prefixes: 1.2.0.0/18 = ", px;
97
	p = 127.1.2.3;
98
	print "Testing mask : 127.0.0.0 = ", p.mask(8);
99
	print "Testing pairs: (1,2) = ", (1,2);
100
	print "Testing enums: ", RTS_DUMMY, " ", RTS_STATIC;
101

    
102
	print "What will this do? ", [ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ];
103

    
104
	print "Testing functions...";
105
#	callme ( 1, 2 );
106
	callme ( 2, 2 );
107
	callme ( 2, 2 );
108
	callme ( 3, 2 );
109
	callme ( 4, 2 );
110
	callme ( 7, 2 );
111

    
112
	i = fifteen();
113
	print "Testing function calls: 15 = ", i;
114

    
115
	paths();
116

    
117
	print "1.2.3.4 = ", onetwo;
118

    
119
	print "done";
120
	quitbird;
121
#	print "*** FAIL: this is unreachable"; 
122
}
123

    
124
function __test1()
125
{
126
	print bgp_path ~ / 65000 /;
127
}
128

    
129
function __test2()
130
{
131
	print bgp_path ~ / 65000 /;
132
}
133

    
134
filter testf 
135
int j; 
136
{ 
137
	print "Heya, filtering route to ", net.ip, " prefixlen ", net.len, " source ", source;
138
	print "This route was from ", from;
139
	j = 7;
140
	j = 17;
141
	if rip_metric > 15 then {
142
 		reject "RIP Metric is more than infinity";
143
	}
144
	rip_metric = 14;
145
	unset(rip_metric);
146
		
147
	accept "ok I take that";
148
}
149

    
150
eval __startup();