]> git.ipfire.org Git - thirdparty/bird.git/blame - nest/config.Y
Pruned the TODO list.
[thirdparty/bird.git] / nest / config.Y
CommitLineData
da877822
MM
1/*
2 * BIRD -- Core Configuration
3 *
31b3e1bb 4 * (c) 1998--1999 Martin Mares <mj@ucw.cz>
da877822
MM
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9CF_HDR
10
31b3e1bb 11static struct proto_config *this_proto;
8edf2361 12static struct iface_patt *this_ipatt;
c74c0e3c 13
50d8424a 14#include "nest/rt-dev.h"
1a2ded45 15#include "nest/password.h"
50d8424a 16
da877822
MM
17CF_DECLS
18
7e5f5ffd 19CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
0e02abfd 20CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE)
900d5470 21CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID)
da877822
MM
22
23%type <i> idval
5056c559 24%type <f> imexport
0e02abfd 25%type <r> rtable
1a2ded45 26%type <p> password_list password_begin
da877822
MM
27
28CF_GRAMMAR
29
c74c0e3c
MM
30/* Setting of router ID */
31
da877822 32CF_ADDTO(conf, rtrid)
0e02abfd 33
7f400d1c 34rtrid: ROUTER ID idval ';' {
31b3e1bb 35 new_config->router_id = $3;
c74c0e3c 36 }
da877822
MM
37 ;
38
39idval:
40 NUM
41 | IPA { $$ = ipa_to_u32($1); }
42 ;
43
0e02abfd
MM
44/* Creation of routing tables */
45
46CF_ADDTO(conf, newtab)
47
48newtab: TABLE SYM {
49 struct rtable_config *c = cfg_allocz(sizeof(struct rtable_config));
50 struct symbol *s = $2;
51 cf_define_symbol(s, SYM_TABLE, c);
52 c->name = s->name;
53 add_tail(&new_config->tables, &c->n);
54 }
55 ;
56
c74c0e3c
MM
57/* Definition of protocols */
58
59CF_ADDTO(conf, proto)
60
61proto_start: PROTOCOL
62
63proto_name:
64 /* EMPTY */ {
7e5f5ffd 65 struct symbol *s = cf_default_name(this_proto->proto->name, &this_proto->proto->name_counter);
c74c0e3c
MM
66 s->class = SYM_PROTO;
67 s->def = this_proto;
68 this_proto->name = s->name;
69 }
70 | SYM {
0e02abfd 71 cf_define_symbol($1, SYM_PROTO, this_proto);
c74c0e3c
MM
72 this_proto->name = $1->name;
73 }
74 ;
75
76proto_item:
77 /* EMPTY */
0b62c3a7 78 | PREFERENCE expr {
c74c0e3c
MM
79 if ($2 < 0 || $2 > 255) cf_error("Invalid preference");
80 this_proto->preference = $2;
81 }
bd5d0d62
MM
82 | DISABLED { this_proto->disabled = 1; }
83 | DEBUG expr { this_proto->debug = $2; }
84 | DEBUG ALL { this_proto->debug = ~0; }
85 | DEBUG OFF { this_proto->debug = 0; }
5056c559
MM
86 | IMPORT imexport { this_proto->in_filter = $2; }
87 | EXPORT imexport { this_proto->out_filter = $2; }
0e02abfd 88 | TABLE rtable { this_proto->table = $2; }
5056c559
MM
89 ;
90
91imexport:
92 FILTER filter { $$ = $2; }
93 | ALL { $$ = FILTER_ACCEPT; }
94 | NONE { $$ = FILTER_REJECT; }
c74c0e3c
MM
95 ;
96
0e02abfd
MM
97rtable:
98 SYM {
99 if ($1->class != SYM_TABLE) cf_error("Table name expected");
100 $$ = $1->def;
101 }
102 ;
103
8edf2361
MM
104/* Interface patterns */
105
106iface_patt:
107 TEXT { this_ipatt->pattern = $1; this_ipatt->prefix = IPA_NONE; this_ipatt->pxlen = 0; }
108 | IPA pxlen { this_ipatt->pattern = NULL; this_ipatt->prefix = $1; this_ipatt->pxlen = $2; }
109 | TEXT IPA pxlen { this_ipatt->pattern = $1; this_ipatt->prefix = $2; this_ipatt->pxlen = $3; }
110 ;
111
7e5f5ffd 112/* Direct device route protocol */
50d8424a
MM
113
114CF_ADDTO(proto, dev_proto '}')
115
7e5f5ffd
MM
116dev_proto_start: proto_start DIRECT {
117 struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config));
7e5f5ffd
MM
118 this_proto = &p->c;
119 p->c.preference = DEF_PREF_DIRECT;
120 init_list(&p->iface_list);
50d8424a
MM
121 }
122 ;
123
124dev_proto:
7e5f5ffd 125 dev_proto_start proto_name '{'
50d8424a
MM
126 | dev_proto proto_item ';'
127 | dev_proto dev_iface_list ';'
128 ;
129
8edf2361
MM
130dev_iface_entry_init:
131 /* EMPTY */ {
132 struct rt_dev_config *p = (void *) this_proto;
133 struct iface_patt *k = cfg_allocz(sizeof(struct iface_patt));
134 add_tail(&p->iface_list, &k->n);
135 this_ipatt = k;
50d8424a 136 }
50d8424a
MM
137 ;
138
8edf2361
MM
139dev_iface_entry:
140 dev_iface_entry_init iface_patt
141 ;
142
143dev_iface_list:
144 INTERFACE dev_iface_entry
145 | dev_iface_list ',' dev_iface_entry
146 ;
147
148/* Password lists */
149
1a2ded45
PM
150password_begin:
151 PASSWORD TEXT {
152 last_password_item = cfg_alloc(sizeof (struct password_item));
153 last_password_item->password = $2;
154 last_password_item->from = 0;
155 last_password_item->to = ~0;
156 last_password_item->id = 0;
157 last_password_item->next = NULL;
158 $$=last_password_item;
159 }
160 ;
161
162password_items:
163 /* empty */ { }
858a7177
PM
164 | FROM datetime password_items { last_password_item->from = $2; }
165 | TO datetime password_items { last_password_item->to = $2; }
900d5470 166 | PASSIVE datetime password_items { last_password_item->passive = $2; }
858a7177 167 | ID NUM password_items { last_password_item->id = $2; }
1a2ded45
PM
168 ;
169
170password_list:
171 /* empty */ { $$ = NULL; }
858a7177
PM
172 | password_begin password_items ';' password_list {
173 last_password_item->next = $4;
174 $$ = last_password_item;
1a2ded45
PM
175 }
176 ;
177
da877822
MM
178CF_CODE
179
180CF_END