Statistics
| Branch: | Revision:

iof-bird-daemon / doc / bird.sgml @ bfd71178

History | View | Annotate | Download (13.5 KB)

1
<!doctype linuxdoc system>
2

    
3
<!--
4
	Bird documentation
5

    
6
    Look for "about this documenation" section to learn more.
7

    
8
    (set-fill-column 100)
9

    
10
    Copyright 1999,2000 Pavel Machek <pavel@ucw.cz>, distribute under GPL version 2 or later.
11

    
12
 -->
13

    
14
<article>
15

    
16
<title>Bird
17
<author>
18
Pavel Machek <tt/pavel@ucw.cz/
19

    
20
<date>2000
21
<abstract>
22
This document contains documentation for BIRD Internet Routing Daemon
23
</abstract>
24

    
25
<!-- Table of contents -->
26
<toc>
27

    
28
<!-- Begin the document -->
29

    
30
<sect>Introduction
31

    
32
<sect1>What is bird
33

    
34
<p><label id="intro"> You may wonder what 'bird' means. It is acronym of 'Basic Internet Routing
35
Daemon', and we think that's cool name. Its task is similar to what firmware of Cisco routers does,
36
or what gated (<HTMLURL URL="http://www.gated.org/">) or GNU zebra (<HTMLURL
37
URL="http://www.zebra.org/">) does. However, you can not run Cisco's firmware on "normal" computer
38
and gated is really hard to configure and comes under wrong license. Bird is being developed on
39
Charles University, Prague, and can be freely distributed under terms of GNU General Public
40
License. Bird is designed to run on unix and unix-like systems, it is primarily developed on Linux.
41

    
42
<sect1>About this documentation
43

    
44
<p>This documentation can have 4 forms: sgml (this is master copy), html, ascii text (generated from
45
html) and dvi/postscript (generated from sgml using sgmltools). You should always edit master copy,
46
it is slightly modified linuxdoc dtd.  Anything in &lt;descrip&gt; tags is considered definition of
47
configuration primitives, &lt;cf&gt; is fragment of configuartion within normal text, &lt;m&gt; is
48
"meta" information -- something in config which is not keyword.
49

    
50
<sect1>Configuration
51

    
52
<p>Bird is configured using text configuration file. At startup, bird reads <file/bird.conf/
53
(unless -c command line parameter is given). Really simple configuration file might look like this:
54

    
55
<cf><verb>
56

    
57
protocol kernel {
58
	persist;		# Don't remove routes on bird shutdown
59
	scan time 20;		# Scan kernel routing table every 20 seconds
60
	export all;		# Default is export none
61
}
62

    
63
protocol device {
64
	scan time 10;		# Scan interfaces every 10 seconds
65
}
66

    
67
protocol rip {
68
	export all;
69
	import all;
70
}
71
</verb></cf>
72

    
73
<p>Everything on a line after # is a comment, whitespace is
74
ignored. If there's variable number of options, it is grouped using {
75
} brackets. 
76

    
77
<p>You can find example of more complicated configuration file in <file>doc/bird.conf.example</file>.
78

    
79
<sect2>Global options
80
				
81
<descrip>
82
	<tag>log "<m/filename/"|syslog|stderr all|{ debug, trace, info,
83
	remote, warning, error, auth, fatal, bug }</tag> set logging of
84
	classes (either all or { error, trace } etc.) into selected
85
	destination. You may specify more than one <cf/log/ line to
86
	log to multiple destinations.
87
				  
88
	<tag>debug protocols all|off|{ states, routes, filters,
89
	interfaces, events, packets }</tag> set debugging options.
90

    
91
	<tag>filter <m/name/ { <m/commands/ }</tag> define filter. You can
92
	learn more about filters in next chapter.
93
 
94
	<tag>protocol rip|ospf|bgp <m/[name]/ { <m>protocol options</m> }</tag> define
95
	protocol instance, called name (or called something like rip5
96
	if you ommit name). You can learn more about
97
	configuring protocols in their own chapters.
98

    
99
	<tag>define constant = expression</tag> define constant. You can
100
	use it later in every place you could use simple integer.
101

    
102
	<tag>router id <m/num.num.num.num/</tag> set router
103
	id. Usually lowest IP address of router.
104

    
105
	<tag>table <m/name/</tag> create new routing table.
106
</descrip>
107

    
108
<sect2>Per-protocol options
109

    
110
<p>FIXME - document preference, disabled, debug, import, export, table; see nest/config.Y
111

    
112

    
113
<sect>Filters
114

    
115
<sect1>Introduction
116

    
117
<p>Bird contains rather simple programming language. (No, it can not yet read mail :-). There are
118
two objects in this language: filters and functions. Filters are called by bird core when route is
119
being passed between protocol and main routing table, and filters may call functions. Functions may
120
call other functions but recursion is not allowed. Filter language contains control structures such
121
as if's and switches, but it allows no loops. Filters are
122
interpretted. Filter using many features can be found in <file>filter/test.conf</file>. 
123

    
124
<p>There's one strange thing with filter language: it does not permit you to create loops. There's
125
no equivalent of while() or for() command, and recursive functions are not permitted.
126

    
127
<p>You can find sources of filters language in
128
<file>filter/</file> directory. <file>filter/config.Y</file> contains
129
filter gramar, and basically translates source from user into tree of
130
<cf>f_inst</cf> structures. These trees are later interpreted using
131
code in <file>filter/filter.c</file>. Filters internally work with
132
values/variables in <code>struct f_val</code>, which contains type of
133
value and value.
134

    
135
<p>Filter basically looks like this:
136

    
137
<cf><verb>
138
filter not_too_far
139
int var;
140
{
141
	if defined( rip_metric ) then
142
		var = rip_metric;
143
	else {
144
		var = 1;
145
		rip_metric = 1;
146
	}
147
	if rip_metric &gt; 10 then
148
		reject "RIP metric is too big";
149
	else
150
		accept "ok";
151
}
152
</verb></cf>
153

    
154
<p>As you can see, filter has a header, list of local variables, and body. Header consists of <cf/filter/ keyword, followed by (unique) name of filter. List of local variables consists of
155
pairs <cf><M>type name</M>;</cf>, where each pair defines one local variable. Body consists of
156
<cf> { <M>statments</M> }</cf>. Statements are terminated by <cf/;/. You can group
157
several statments into one by <cf>{ <M>statments</M> }</cf> construction, that is usefull if
158
you want to make bigger block of code conditional.
159

    
160
<sect1>Data types
161

    
162
<p>Each variable and each value has certain type. Unlike C, filters distinguish between integers and
163
booleans (that is to prevent you from shooting in the foot).
164

    
165
<descrip>
166
	<tag/bool/ this is boolean type, it can have only two values,
167
	  <cf/TRUE/ and <cf/FALSE/. Boolean is not compatible with
168
	  integer and is the only type you can use in if statments.
169

    
170
	<tag/int/ this is common integer, you can expect it to store
171
	  signed values from -2000000000 to +2000000000.
172

    
173
	<tag/pair/ this is pair of two short integers. Each component
174
	  can have values from 0 to 65535. Constant of this type is
175
	  written as <cf/(1234,5678)/.
176

    
177
	<tag/string/ this is string of characters. There are no ways to modify strings in filters. You can
178
	  pass them between functions, assign to variable of type string, print such variables, but
179
	  you can not concatenate two strings (for example). String constants are written as <cf/
180
	  "This is string constant"/.
181

    
182
	<tag/ip/ this type can hold single ip address. Depending on version of bird you are using, it
183
	  can be ipv4 or ipv6 address. Ipv4 addresses addresses are written (as you would expect) as
184
	  <cf/1.2.3.4/. You can apply special operator <cf>.mask(<M>num</M>)</cf>
185
	  on values of type ip. It masks out all but first <cf><M>num</M></cf> bits from ip
186
	  address. So <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
187

    
188
	<tag/prefix/ this type can hold ip address, prefix len
189
	  pair. Prefixes are written as <cf><M>ip address</M>/<M>px
190
	  len</M></cf>. There are two special operators on prefix:
191
	  <cf/.ip/, which separates ip address from the pair, and
192
	  <cf/.len/, which separates prefix len from the pair.
193

    
194
	<tag/set int|ip|prefix|pair/
195
	  filters know four types of sets. Sets are similar to strings: you can pass them around
196
	  but you can not modify them. Constant of type <cf>set int</cf> looks like <cf>
197
	  [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in
198
	  sets. Sets of prefixes are special: you can specify which prefixes should match them by
199
	  using <cf>[ 1.0.0.0/8+, 2.0.0.0/8-, 3.0.0.0/8{5,6} ]</cf>. 3.0.0.0/8{5,6} matches
200
	  prefixes 3.X.X.X, whose prefixlength is 5 to 6. 3.0.0.0/8+ is shorthand for 3.0.0.0/{0,8},
201
	  3.0.0.0/8- is shorthand for 3.0.0.0/{0,7}.
202

    
203
	<tag/enum/
204
	  enumerational types are halfway-internal in the bird. You can not define your own
205
	  variable of enumerational type, but some pre-defined variables are of enumerational
206
	  type. Enumerational types are incompatible with each other, again, its for your
207
	  protection.
208
</descrip>
209

    
210
<sect1>Operations
211

    
212
<p>Filter language supports common integer operations (+,-,*,/), parenthesis (a*(b+c)), comparation
213
(a=b, a!=b, a&lt;b, a&gt;=b). Special operators include ~ for "in" operation. In operation can be
214
used on element and set of that elements, or on ip and prefix, or on prefix and prefix. Its result
215
is true if element is in given set or if ip adress is inside given prefix.
216

    
217
<sect1>Functions
218

    
219
<p>Bird supports functions, so that you don't have to repeat same blocks of code over and
220
over. Functions can have zero or more parameters, and can have local variables. Function basically
221
looks like this:
222

    
223
<cf><verb>
224
function name ()
225
int local_variable;
226
{
227
	local_variable = 5;
228
}
229

    
230
function with_parameters (int parameter)
231
{
232
	print parameter;
233
}
234
</verb></cf>
235

    
236
<p>Unlike C, variables are declared after function line but before first {. You can not declare
237
variables in nested blocks. Functions are called like in C: <cf>name(); with_parameters(5);</cf>.
238

    
239
<p>Filters are declared in similar way to functions, except they can not have explicit
240
parameters. They get route table entry as implicit parameter.
241

    
242
<sect1>Control structures
243

    
244
<p>Filters support two control structures: if/then/else and
245
case. Syntax of if/then/else is <cf>if <M>expression</M> then
246
<M>command</M>; else <M>command</M>;</cf> and you can use <cf>{
247
<M>command_1</M>; <M>command_2</M>; <M>...</M> }</cf> instead of one
248
or both commands. <cf>else</cf> clause may be ommited. Case is
249
used like this:
250

    
251
<cf><verb>
252
        case <M>argument</M> {
253
        2: print "dva"; print "jeste jednou dva";
254
        3 .. 5: print "tri az pet";
255
        else: print "neco jineho";
256
        }
257
</verb></cf>
258

    
259
where <M>argument</M> is any argument that can be on the left side of ~ operator, and anything that
260
could be member of set is allowed before :. Multiple commands are allowed without {} grouping. If
261
argument matches neither of : clauses, else: clause is used. (Case is actually implemented as set
262
matching, internally.)
263

    
264
<sect>Protocols
265

    
266
<sect1>Rip
267

    
268
<sect2>Introduction
269

    
270
<p>Rip protocol (sometimes called Rest In Pieces) is simple protocol, where each router broadcasts
271
distances to all networks he can reach. When router hears distance to other network, it increments
272
it and broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some network goes
273
unreachable, routers keep telling each other that distance is old distance plus 1 (actually, plus
274
interface metric, which is usually one). After some time, distance reaches infinity (that's 15 in
275
rip) and all routers know that network is unreachable. Rip tries to minimize situations where
276
counting to infinity is neccessary, because it is slow. Due to infinity being 16, you can not use
277
rip on networks where maximal distance is bigger than 15 hosts. You can read more about rip at <HTMLURL
278
URL="http://www.ietf.org/html.charters/rip-charter.html">.
279

    
280
<sect2>Configuration
281

    
282
<p>In addition to options generic to other protocols, rip supports following options:
283

    
284
<descrip>
285
	<tag/authentication none|password|md5/ selects authenticaion method to use. None means that
286
	  packets are not authenticated at all, password means that plaintext password is embedded
287
	  into each packet, and md5 means that packets are authenticated using md5 cryptographics
288
	  hash. If you set authentication to non-none, it is good idea to add <cf>passwords { }</cf>
289
	  section.
290
</descrip>
291

    
292
<p>There are two options that can be specified per-interface. First is <cf>metric</cf>, with
293
default one.  Second is <cf>mode broadcast|quiet|nolisten|version1</cf>, it selects mode for
294
rip to work in. If nothing is specified, rip runs in multicasts mode. <cf>version1</cf> is
295
currently equivalent to <cf>broadcast</cf>, and it makes rip talk at broadcast address even
296
through multicast mode is possible. <cf>quiet</cf> option means that rip will not transmit
297
periodic messages onto this interface and <cf>nolisten</cf> means that rip will talk to this
298
interface but not listen on it.
299

    
300
<p>Following options generally override specified behaviour from rfc. If you use any of these
301
options, bird will no longer be rfc-compatible, which means it will not be able to talk to anything
302
other than equally (mis-)configured bird. I warned you.
303

    
304
<descrip>
305
	<tag>port <M>number</M></tag>
306
	  selects IP port to operate on, default 520. (This is usefull when testing bird, if you
307
	  set this to address &gt;1024, you will not need to run bird with uid==0).
308

    
309
	<tag>infinity <M>number</M></tag>
310
	  select value of infinity, default 16. Bigger values will make protocol convergence
311
	  even slower.
312

    
313
	<tag>period <M>number</M>
314
	  </tag>specifies number of seconds between periodic updates. Default is 30 seconds. Lower
315
	  number will mean faster convergence but bigger network load.
316

    
317
	<tag>timeouttime <M>number</M>
318
	  </tag>specifies how old route has to be to be considered unreachable. Default is 4*period.
319

    
320
	<tag>garbagetime <M>number</M>
321
	  </tag>specifies how old route has to be to be discarded. Default is 10*period.
322
</descrip>
323

    
324
<p>In addition, rip defines two filter variables, both of type it. <cf>rip_metric</cf> is rip
325
metric of current route, <cf>rip_tag</cf> is tag of current route.
326

    
327
<cf><verb>
328

    
329
protocol rip MyRIP_test {
330
        debug all;
331
        port 1520;
332
        period 7;
333
        garbagetime 60;
334
        interface "*";
335
        honour neighbour;
336
        passwords { password "ahoj" from 0 to 10;
337
                password "nazdar" from 10;
338
        }
339
        authentication none;
340
        import filter { print "importing"; accept; };
341
        export filter { print "exporting"; accept; };
342
}
343
</verb></cf>
344

    
345
</article>