2 * BIRD -- Configuration Parser Top
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
11 #include "nest/bird.h"
12 #include "conf/conf.h"
13 #include "lib/resource.h"
14 #include "lib/socket.h"
15 #include "lib/timer.h"
16 #include "lib/string.h"
17 #include "nest/protocol.h"
18 #include "nest/iface.h"
19 #include "nest/route.h"
21 #include "filter/filter.h"
23 /* FIXME: Turn on YYERROR_VERBOSE and work around lots of bison bugs? */
33 struct rtable_config *r;
39 struct f_path_mask *h;
40 struct password_item *p;
41 struct rt_show_data *ra;
46 struct timeformat *tf;
49 %token END CLI_MARKER INVALID_TOKEN
50 %token GEQ LEQ NEQ AND OR
58 %type <i> expr bool pxlen
61 %type <px> prefix prefix_or_ipa
62 %type <t> text_or_none
64 %nonassoc PREFIX_DUMMY
66 %nonassoc '=' '<' '>' '~' GEQ LEQ NEQ PO PC
72 CF_KEYWORDS(DEFINE, ON, OFF, YES, NO)
76 /* Basic config file structure */
78 config: conf_entries END { return 0; }
79 | CLI_MARKER cli_cmd { return 0; }
89 /* Constant expressions */
93 | '(' term ')' { $$ = f_eval_int($2); }
94 | SYM { if ($1->class != SYM_NUMBER) cf_error("Number expected"); else $$ = $1->aux; }
97 CF_ADDTO(conf, definition)
99 DEFINE SYM '=' expr ';' {
100 cf_define_symbol($2, SYM_NUMBER, NULL);
103 | DEFINE SYM '=' IPA ';' {
104 cf_define_symbol($2, SYM_IPA, cfg_alloc(sizeof(ip_addr)));
105 *(ip_addr *)$2->def = $4;
117 | /* Silence means agreement */ { $$ = 1; }
120 /* Addresses, prefixes and netmasks */
125 if ($1->class != SYM_IPA) cf_error("IP address expected");
126 $$ = *(ip_addr *)$1->def;
132 if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix");
133 $$.addr = $1; $$.len = $2;
139 | ipa { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
144 if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2);
149 if ($$ < 0) cf_error("Invalid netmask %I", $2);
155 $$ = tm_parse_datetime($1);
157 cf_error("Invalid date and time");