From 0e5373fd823d174d0cdd7820fc94cdbe4b0db5a3 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Thu, 25 May 2000 12:33:42 +0000 Subject: Some more documentation, plus minor fixes. --- doc/bird.sgml | 120 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 44 deletions(-) (limited to 'doc') diff --git a/doc/bird.sgml b/doc/bird.sgml index 63f251a..674adce 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -45,7 +45,7 @@ License. Bird is designed to run on Unix and unix-like systems, it is primarily html) and dvi/postscript (generated from sgml using sgmltools). You should always edit master copy, it is slightly modified linuxdoc dtd. Anything in <descrip> tags is considered definition of configuration primitives, <cf> is fragment of configuration within normal text, <m> is -"meta" information -- something in config which is not keyword. +"meta" information within fragment of configuration -- something in config which is not keyword. Configuration @@ -71,9 +71,9 @@ protocol rip { } -

Everything on a line after # is a comment, whitespace is -ignored. If there's variable number of options, it is grouped using { -} brackets. +

Everything on a line after You can find example of more complicated configuration file in doc/bird.conf.example. @@ -108,7 +108,7 @@ ignored. If there's variable number of options, it is grouped using { table create new routing table. - eval evaluates give filter expression. It is basically mainly for testing. + eval evaluates given filter expression. It is used for testing. Per-protocol options @@ -154,20 +154,20 @@ ignored. If there's variable number of options, it is grouped using {

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

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

You can find sources of filters language in filter/ directory. filter/config.Y contains filter grammar, and basically translates source from user into tree of f_inst structures. These trees are later interpreted using code in filter/filter.c. Filters internally work with values/variables in struct f_val, which contains type of value and value. -

Filter basically looks like this: +

Filter basically gets the route, looks at its attributes and +modifies some of them if it wishes. At the end, it decides, whether to +pass change route through (using filter not_too_far @@ -186,12 +186,39 @@ int var; } -

As you can see, filter has a header, list of local variables, and body. Header consists of As you can see, filter has a header, list of local variables, and body. Header consists of +type name;, where each pair defines one local variable. Body consists of { statements }. Statements are terminated by { statements } construction, that is useful if you want to make bigger block of code conditional. +

Bird supports functions, so that you don't have to repeat same blocks of code over and +over. Functions can have zero or more parameters, and can have local variables. Function basically +looks like this: + + +function name () +int local_variable; +{ + local_variable = 5; +} + +function with_parameters (int parameter) +{ + print parameter; +} + + +

Unlike C, variables are declared after function line but before first {. You can not declare +variables in nested blocks. Functions are called like in C: name(); +with_parameters(5);. Function may return value using return +syntax. Returning value exits from current function (this is similar to C). + +

Filters are declared in similar way to functions, except they can not have explicit +parameters. They get route table entry as implicit parameter. Route table entry is passed implicitly +to any functions being called. Filter must terminate with either accept or reject statement. + Data types

Each variable and each value has certain type. Unlike C, filters distinguish between integers and @@ -211,7 +238,7 @@ booleans (that is to prevent you from shooting in the foot). ip address/px len. There are two special operators on prefix: + ipaddress/pxlen, or + ipaddress/netmask There are two special + operators on prefix: set int looks like [ 1, 2, 5..7 ]. As you can see, both simple values and ranges are permitted in @@ -236,8 +265,15 @@ booleans (that is to prevent you from shooting in the foot). Operations @@ -245,35 +281,8 @@ booleans (that is to prevent you from shooting in the foot).

Filter language supports common integer operations (+,-,*,/), parenthesis Functions - -

Bird supports functions, so that you don't have to repeat same blocks of code over and -over. Functions can have zero or more parameters, and can have local variables. Function basically -looks like this: - - -function name () -int local_variable; -{ - local_variable = 5; -} - -function with_parameters (int parameter) -{ - print parameter; -} - - -

Unlike C, variables are declared after function line but before first {. You can not declare -variables in nested blocks. Functions are called like in C: name(); -with_parameters(5);. Function may return value using return -syntax. Returning value exits from current function (this is similar to C). - -

Filters are declared in similar way to functions, except they can not have explicit -parameters. They get route table entry as implicit parameter. Route table entry is passed implicitly -to any functions being called. +is true if element is in given set or if ip address is inside given prefix. Operator Control structures @@ -301,6 +310,29 @@ case arg1 { if 1234 = i then printn "."; else { print "*** FAIL: if 1 else"; } +Route attributes + +

Filter is implicitly passed route, and it can access its attributes, just like it accesses variables. + + + defined( attribute + returns TRUE if given attribute is defined. Access to undefined attribute results in runtime error. + + + +

Plus, there are protocol-specific attributes, which are described in protocol sections. + Protocols Rip -- cgit v1.2.3