]> git.ipfire.org Git - thirdparty/bird.git/blame - conf/confbase.Y
SYM_STAT is gone.
[thirdparty/bird.git] / conf / confbase.Y
CommitLineData
f142750d
MM
1/*
2 * BIRD -- Configuration Parser Top
3 *
c9b66706 4 * (c) 1998--1999 Martin Mares <mj@ucw.cz>
f142750d
MM
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9CF_HDR
10
11#include "nest/bird.h"
12#include "conf/conf.h"
c74c0e3c
MM
13#include "lib/resource.h"
14#include "lib/socket.h"
15#include "lib/timer.h"
16#include "nest/protocol.h"
50d8424a 17#include "nest/iface.h"
166b9c49 18#include "nest/route.h"
bc2fb680 19#include "nest/cli.h"
b9d70dc8 20#include "filter/filter.h"
f142750d 21
bc2fb680
MM
22#define cli_msg(x...) cli_printf(this_cli, x)
23
f142750d
MM
24CF_DECLS
25
26%union {
27 int i;
dce26783 28 u32 i32;
f142750d
MM
29 ip_addr a;
30 struct symbol *s;
31 char *t;
0e02abfd 32 struct rtable_config *r;
e0f2e42f
MM
33 struct f_inst *x;
34 struct filter *f;
38506f71
PM
35 struct f_tree *e;
36 struct f_val v;
9d79fec8 37 struct password_item *p;
f142750d
MM
38}
39
bc2fb680 40%token END CLI_MARKER
f142750d 41%token <i> NUM
dce26783 42%token <i32> RTRID
f142750d
MM
43%token <a> IPA
44%token <s> SYM
45%token <t> TEXT
46
9d79fec8 47%type <i> expr bool pxlen datetime
0b62c3a7 48
f4536657 49%nonassoc '=' '<' '>' '~' '.'
0b62c3a7
MM
50%left '+' '-'
51%left '*' '/' '%'
23b1539b 52%left '!'
0b62c3a7 53
166b9c49 54CF_KEYWORDS(DEFINE, ON, OFF, YES, NO)
0b62c3a7 55
f142750d
MM
56CF_GRAMMAR
57
0b62c3a7
MM
58/* Basic config file structure */
59
bc2fb680
MM
60config: conf_entries END { return 0; }
61 | CLI_MARKER cli_cmd END { return 0; }
f142750d
MM
62 ;
63
64conf_entries:
65 /* EMPTY */
7f400d1c 66 | conf_entries conf
f142750d
MM
67 ;
68
7f400d1c 69CF_ADDTO(conf, ';')
f142750d 70
72380a34 71/* Constant expressions */
0b62c3a7 72
c9b66706 73expr:
0b62c3a7 74 NUM
c9b66706
MM
75 | expr '+' expr { $$ = $1 + $3; }
76 | expr '-' expr { $$ = $1 - $3; }
77 | expr '*' expr { $$ = $1 * $3; }
78 | expr '/' expr { if ($3) $$ = $1 / $3; else cf_error("Division by zero"); }
79 | expr '%' expr { if ($3) $$ = $1 % $3; else cf_error("Division by zero"); }
80 | '(' expr ')' { $$ = $2; }
0b62c3a7
MM
81 | SYM { if ($1->class != SYM_NUMBER) cf_error("Number expected"); else $$ = $1->aux; }
82 ;
83
84CF_ADDTO(conf, definition)
85definition:
7f400d1c 86 DEFINE SYM '=' expr ';' {
0e02abfd 87 cf_define_symbol($2, SYM_NUMBER, NULL);
0b62c3a7
MM
88 $2->aux = $4;
89 }
90 ;
91
166b9c49
MM
92/* Switches */
93
94bool:
c9b66706 95 expr {$$ = !!$1; }
166b9c49
MM
96 | ON { $$ = 1; }
97 | YES { $$ = 1; }
98 | OFF { $$ = 0; }
99 | NO { $$ = 0; }
100 | /* Silence means agreement */ { $$ = 1; }
101 ;
102
89d2355d
MM
103/* Prefixes and netmasks */
104
105pxlen:
106 '/' NUM {
107 if ($2 < 0 || $2 > 32) cf_error("Invalid prefix length %d", $2);
108 $$ = $2;
109 }
110 | ':' IPA {
111 $$ = ipa_mklen($2);
112 if ($$ < 0) cf_error("Invalid netmask %I", $2);
113 }
114 ;
115
9d79fec8
PM
116datetime: /* Return seconds from epoch, FIXME we want be more user friendly */
117 NUM { $$ = $1; }
118 ;
119
f142750d
MM
120CF_CODE
121
122CF_END