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.
13 #include "nest/bird.h"
14 #include "conf/conf.h"
15 #include "lib/resource.h"
16 #include "lib/socket.h"
17 #include "lib/timer.h"
18 #include "lib/string.h"
19 #include "nest/protocol.h"
20 #include "nest/iface.h"
21 #include "nest/route.h"
23 #include "filter/filter.h"
25 /* FIXME: Turn on YYERROR_VERBOSE and work around lots of bison bugs? */
30 check_u16(unsigned val)
33 cf_error("Value %d out of range (0-65535)", val);
44 struct rtable_config *r;
46 struct f_dynamic_attr fda;
47 struct f_static_attr fsa;
52 struct f_path_mask *h;
53 struct password_item *p;
54 struct rt_show_data *ra;
55 struct roa_show_data *ro;
56 struct sym_show_data *sd;
57 struct lsadb_show_data *ld;
58 struct mrt_dump_data *md;
60 struct roa_table *rot;
65 struct timeformat *tf;
68 %token END CLI_MARKER INVALID_TOKEN ELSECOL DDOT
69 %token GEQ LEQ NEQ AND OR
76 %type <iface> ipa_scope
78 %type <i> expr bool pxlen
82 %type <px> prefix prefix_or_ipa
83 %type <t> text opttext
84 %type <t> text_or_none
86 %nonassoc PREFIX_DUMMY
88 %nonassoc '=' '<' '>' '~' GEQ LEQ NEQ NMA PO PC
94 CF_KEYWORDS(DEFINE, ON, OFF, YES, NO, S, MS, US, PORT)
98 /* Basic config file structure */
100 config: conf_entries END { return 0; }
101 | CLI_MARKER cli_cmd { return 0; }
112 /* Constant expressions */
114 CF_ADDTO(conf, definition)
116 DEFINE SYM '=' term ';' {
117 struct f_val *val = cfg_alloc(sizeof(struct f_val));
118 *val = f_eval($4, cfg_mem);
119 if (val->type == T_RETURN) cf_error("Runtime error");
120 cf_define_symbol($2, SYM_CONSTANT | val->type, val);
126 | '(' term ')' { $$ = f_eval_int($2); }
128 if ($1->class != (SYM_CONSTANT | T_INT)) cf_error("Number expected");
129 $$ = SYM_VAL($1).i; }
134 expr S { $$ = (u32) $1 * 1000000; }
135 | expr MS { $$ = (u32) $1 * 1000; }
136 | expr US { $$ = (u32) $1 * 1; }
139 /* expr_u16: expr { check_u16($1); $$ = $1; }; */
149 | /* Silence means agreement */ { $$ = 1; }
152 /* Addresses, prefixes and netmasks */
157 if ($1->class != (SYM_CONSTANT | T_IP)) cf_error("IP address expected");
158 $$ = SYM_VAL($1).px.ip;
163 /* empty */ { $$ = NULL; }
164 | '%' SYM { $$ = if_get_by_name($2->name); }
169 if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix");
170 $$.addr = $1; $$.len = $2;
176 | ipa { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
181 if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2);
185 $$ = ipa_masklen($2);
186 if ($$ < 0) cf_error("Invalid netmask %I", $2);
192 $$ = tm_parse_datetime($1);
194 cf_error("Invalid date and time");
201 if ($1->class != (SYM_CONSTANT | T_STRING)) cf_error("String expected");
208 | /* empty */ { $$ = NULL; }