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;
47 %token END CLI_MARKER INVALID_TOKEN
48 %token GEQ LEQ NEQ AND OR
56 %type <i> expr bool pxlen
59 %type <px> prefix prefix_or_ipa
60 %type <t> text_or_none
62 %nonassoc PREFIX_DUMMY
63 %nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ AND OR PO PC
68 CF_KEYWORDS(DEFINE, ON, OFF, YES, NO)
72 /* Basic config file structure */
74 config: conf_entries END { return 0; }
75 | CLI_MARKER cli_cmd { return 0; }
85 /* Constant expressions */
89 | '(' term ')' { $$ = f_eval_int($2); }
90 | SYM { if ($1->class != SYM_NUMBER) cf_error("Number expected"); else $$ = $1->aux; }
93 CF_ADDTO(conf, definition)
95 DEFINE SYM '=' expr ';' {
96 cf_define_symbol($2, SYM_NUMBER, NULL);
99 | DEFINE SYM '=' IPA ';' {
100 cf_define_symbol($2, SYM_IPA, cfg_alloc(sizeof(ip_addr)));
101 *(ip_addr *)$2->def = $4;
113 | /* Silence means agreement */ { $$ = 1; }
116 /* Addresses, prefixes and netmasks */
121 if ($1->class != SYM_IPA) cf_error("IP address expected");
122 $$ = *(ip_addr *)$1->def;
128 if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix");
129 $$.addr = $1; $$.len = $2;
135 | ipa { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
140 if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2);
145 if ($$ < 0) cf_error("Invalid netmask %I", $2);
151 $$ = tm_parse_datetime($1);
153 cf_error("Invalid date and time");