Statistics
| Branch: | Revision:

iof-bird-daemon / nest / config.Y @ 26c09e1d

History | View | Annotate | Download (9.22 KB)

1 da877822 Martin Mares
/*
2
 *	BIRD -- Core Configuration
3
 *
4 4b87e256 Martin Mares
 *	(c) 1998--2000 Martin Mares <mj@ucw.cz>
5 da877822 Martin Mares
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8
9
CF_HDR
10
11 50d8424a Martin Mares
#include "nest/rt-dev.h"
12 1a2ded45 Pavel Machek
#include "nest/password.h"
13 4b87e256 Martin Mares
#include "nest/cmds.h"
14 50d8424a Martin Mares
15 2edb31b0 Martin Mares
CF_DEFINES
16
17
static struct proto_config *this_proto;
18
static struct iface_patt *this_ipatt;
19
20 da877822 Martin Mares
CF_DECLS
21
22 7e5f5ffd Martin Mares
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
23 96d8e3bf Martin Mares
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
24 6a9f28b0 Martin Mares
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
25 4761efdb Martin Mares
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS)
26 da877822 Martin Mares
27 7d509304 Martin Mares
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
28 beaf86e1 Martin Mares
	RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE)
29 26c09e1d Pavel Machek
CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE)
30
CF_ENUM(T_ENUM_RTC, RTC_, UNICAST, BROADCAST, MULTICAST, ANYCAST)
31
CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT)
32 7d509304 Martin Mares
33 dce26783 Martin Mares
%type <i32> idval
34 5056c559 Martin Mares
%type <f> imexport
35 0e02abfd Martin Mares
%type <r> rtable
36 1a2ded45 Pavel Machek
%type <p> password_list password_begin
37 ae97b946 Martin Mares
%type <s> optsym
38 730f2e2c Martin Mares
%type <ra> r_args
39 ce1da96e Martin Mares
%type <i> echo_mask echo_size debug_mask debug_list debug_flag import_or_proto
40 f14a4bec Martin Mares
%type <t> proto_patt
41 da877822 Martin Mares
42
CF_GRAMMAR
43
44 c74c0e3c Martin Mares
/* Setting of router ID */
45
46 da877822 Martin Mares
CF_ADDTO(conf, rtrid)
47 0e02abfd Martin Mares
48 7f400d1c Martin Mares
rtrid: ROUTER ID idval ';' {
49 31b3e1bb Martin Mares
   new_config->router_id = $3;
50 c74c0e3c Martin Mares
   }
51 da877822 Martin Mares
 ;
52
53
idval:
54 dce26783 Martin Mares
   NUM { $$ = $1; }
55
 | RTRID
56
 | IPA {
57
#ifndef IPV6
58
     $$ = ipa_to_u32($1);
59
#else
60 e79671a7 Martin Mares
     cf_error("Router IDs must be entered as hexadecimal numbers or IPv4 addresses in IPv6 version");
61 dce26783 Martin Mares
#endif
62
   }
63 da877822 Martin Mares
 ;
64
65 0e02abfd Martin Mares
/* Creation of routing tables */
66
67
CF_ADDTO(conf, newtab)
68
69
newtab: TABLE SYM {
70 b9626ec6 Martin Mares
   rt_new_table($2);
71 0e02abfd Martin Mares
   }
72
 ;
73
74 c74c0e3c Martin Mares
/* Definition of protocols */
75
76
CF_ADDTO(conf, proto)
77
78
proto_start: PROTOCOL
79
80
proto_name:
81
   /* EMPTY */ {
82 d272fe22 Martin Mares
     struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
83 c74c0e3c Martin Mares
     s->class = SYM_PROTO;
84
     s->def = this_proto;
85
     this_proto->name = s->name;
86
     }
87
 | SYM {
88 0e02abfd Martin Mares
     cf_define_symbol($1, SYM_PROTO, this_proto);
89 c74c0e3c Martin Mares
     this_proto->name = $1->name;
90
   }
91
 ;
92
93
proto_item:
94
   /* EMPTY */
95 0b62c3a7 Martin Mares
 | PREFERENCE expr {
96 c74c0e3c Martin Mares
     if ($2 < 0 || $2 > 255) cf_error("Invalid preference");
97
     this_proto->preference = $2;
98
   }
99 bd5d0d62 Martin Mares
 | DISABLED { this_proto->disabled = 1; }
100 96d8e3bf Martin Mares
 | DEBUG debug_mask { this_proto->debug = $2; }
101 5056c559 Martin Mares
 | IMPORT imexport { this_proto->in_filter = $2; }
102
 | EXPORT imexport { this_proto->out_filter = $2; }
103 0e02abfd Martin Mares
 | TABLE rtable { this_proto->table = $2; }
104 5056c559 Martin Mares
 ;
105
106
imexport:
107
   FILTER filter { $$ = $2; }
108 f8809249 Martin Mares
 | where_filter
109 5056c559 Martin Mares
 | ALL { $$ = FILTER_ACCEPT; }
110
 | NONE { $$ = FILTER_REJECT; }
111 c74c0e3c Martin Mares
 ;
112
113 0e02abfd Martin Mares
rtable:
114
   SYM {
115
     if ($1->class != SYM_TABLE) cf_error("Table name expected");
116
     $$ = $1->def;
117
   }
118
 ;
119
120 f30b86f9 Martin Mares
CF_ADDTO(conf, debug_default)
121
122
debug_default:
123
   DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
124 4761efdb Martin Mares
 | DEBUG COMMANDS expr { new_config->cli_debug = $3; }
125 f30b86f9 Martin Mares
 ;
126
127 8edf2361 Martin Mares
/* Interface patterns */
128
129
iface_patt:
130
   TEXT { this_ipatt->pattern = $1; this_ipatt->prefix = IPA_NONE; this_ipatt->pxlen = 0; }
131 758458be Martin Mares
 | prefix { this_ipatt->pattern = NULL; this_ipatt->prefix = $1.addr; this_ipatt->pxlen = $1.len; }
132
 | TEXT prefix { this_ipatt->pattern = $1; this_ipatt->prefix = $2.addr; this_ipatt->pxlen = $2.len; }
133 8edf2361 Martin Mares
 ;
134
135 7e5f5ffd Martin Mares
/* Direct device route protocol */
136 50d8424a Martin Mares
137
CF_ADDTO(proto, dev_proto '}')
138
139 7e5f5ffd Martin Mares
dev_proto_start: proto_start DIRECT {
140
     struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config));
141
     this_proto = &p->c;
142
     p->c.preference = DEF_PREF_DIRECT;
143
     init_list(&p->iface_list);
144 50d8424a Martin Mares
   }
145
 ;
146
147
dev_proto:
148 7e5f5ffd Martin Mares
   dev_proto_start proto_name '{'
149 50d8424a Martin Mares
 | dev_proto proto_item ';'
150
 | dev_proto dev_iface_list ';'
151
 ;
152
153 8edf2361 Martin Mares
dev_iface_entry_init:
154
   /* EMPTY */ {
155
     struct rt_dev_config *p = (void *) this_proto;
156
     struct iface_patt *k = cfg_allocz(sizeof(struct iface_patt));
157
     add_tail(&p->iface_list, &k->n);
158
     this_ipatt = k;
159 50d8424a Martin Mares
   }
160
 ;
161
162 8edf2361 Martin Mares
dev_iface_entry:
163
   dev_iface_entry_init iface_patt
164
 ;
165
166
dev_iface_list:
167
   INTERFACE dev_iface_entry
168
 | dev_iface_list ',' dev_iface_entry
169
 ;
170
171 96d8e3bf Martin Mares
/* Debug flags */
172
173
debug_mask:
174
   ALL { $$ = ~0; }
175
 | OFF { $$ = 0; }
176
 | '{' debug_list '}' { $$ = $2; }
177
 ;
178
179
debug_list:
180
   debug_flag
181
 | debug_list ',' debug_flag { $$ = $1 | $3; }
182
 ;
183
184
debug_flag:
185
   STATES	{ $$ = D_STATES; }
186
 | ROUTES	{ $$ = D_ROUTES; }
187
 | FILTERS	{ $$ = D_FILTERS; }
188 6a9f28b0 Martin Mares
 | INTERFACES	{ $$ = D_IFACES; }
189 96d8e3bf Martin Mares
 | EVENTS	{ $$ = D_EVENTS; }
190
 | PACKETS	{ $$ = D_PACKETS; }
191
 ;
192
193 8edf2361 Martin Mares
/* Password lists */
194
195 1a2ded45 Pavel Machek
password_begin: 
196
   PASSWORD TEXT {
197
     last_password_item = cfg_alloc(sizeof (struct password_item));
198
     last_password_item->password = $2;
199
     last_password_item->from = 0;
200 f0474f20 Martin Mares
     last_password_item->to = TIME_INFINITY;
201 1a2ded45 Pavel Machek
     last_password_item->id = 0;
202
     last_password_item->next = NULL;
203
     $$=last_password_item;
204
   }
205
 ;
206
207
password_items:
208
   /* empty */ { } 
209 858a7177 Pavel Machek
 | FROM datetime password_items { last_password_item->from = $2; }
210
 | TO datetime password_items { last_password_item->to = $2; }
211 900d5470 Pavel Machek
 | PASSIVE datetime password_items { last_password_item->passive = $2; }
212 e3f2d5fc Martin Mares
 | ID expr password_items { last_password_item->id = $2; }
213 1a2ded45 Pavel Machek
 ;
214
215
password_list: 
216
   /* empty */ { $$ = NULL; } 
217 858a7177 Pavel Machek
 | password_begin password_items ';' password_list {
218 ac40c888 Pavel Machek
     $1->next = $4;
219
     $$ = $1;
220 1a2ded45 Pavel Machek
   }
221
 ;
222
223 bc2fb680 Martin Mares
/* Core commands */
224
225 fae0396e Martin Mares
CF_CLI_HELP(SHOW, ..., [[Show status information]])
226 ae97b946 Martin Mares
227 4b87e256 Martin Mares
CF_CLI(SHOW STATUS,,, [[Show router status]])
228
{ cmd_show_status(); }
229 ae97b946 Martin Mares
230
CF_CLI(SHOW PROTOCOLS, optsym, [<name>], [[Show routing protocols]])
231 0d3e6bce Martin Mares
{ proto_show($3, 0); } ;
232
233 28e01f85 Martin Mares
CF_CLI(SHOW PROTOCOLS ALL, optsym, [<name>], [[Show routing protocol details]])
234 0d3e6bce Martin Mares
{ proto_show($4, 1); } ;
235 ae97b946 Martin Mares
236 730f2e2c Martin Mares
optsym:
237
   SYM
238
 | /* empty */ { $$ = NULL; }
239
 ;
240
241 ae97b946 Martin Mares
CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
242
{ if_show(); } ;
243
244
CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
245
{ if_show_summary(); } ;
246
247 23693958 Martin Mares
CF_CLI(SHOW ROUTE, r_args, [<prefix>] [table <t>] [filter <f>] [all] [primary] [(import|protocol) <p>] [stats], [[Show routing table]])
248 730f2e2c Martin Mares
{ rt_show($3); } ;
249
250
r_args:
251
   /* empty */ {
252
     $$ = cfg_allocz(sizeof(struct rt_show_data));
253
     $$->pxlen = 256;
254
     $$->filter = FILTER_ACCEPT;
255
     $$->table = config->master_rtc->table;
256
   }
257 758458be Martin Mares
 | r_args prefix {
258 730f2e2c Martin Mares
     $$ = $1;
259
     if ($$->pxlen != 256) cf_error("Only one prefix expected");
260 758458be Martin Mares
     $$->prefix = $2.addr;
261
     $$->pxlen = $2.len;
262 730f2e2c Martin Mares
   }
263 9449c91a Martin Mares
 | r_args FOR prefix_or_ipa {
264
     $$ = $1;
265
     if ($$->pxlen != 256) cf_error("Only one prefix expected");
266
     $$->prefix = $3.addr;
267
     $$->pxlen = $3.len;
268
     $$->show_for = 1;
269
   }
270 730f2e2c Martin Mares
 | r_args TABLE SYM {
271
     $$ = $1;
272
     if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name);
273
     $$->table = ((struct rtable_config *)$3->def)->table;
274
   }
275
 | r_args FILTER filter {
276
     $$ = $1;
277 430da60f Martin Mares
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
278 730f2e2c Martin Mares
     $$->filter = $3;
279
   }
280 430da60f Martin Mares
 | r_args where_filter {
281
     $$ = $1;
282
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
283
     $$->filter = $2;
284
   }
285 730f2e2c Martin Mares
 | r_args ALL {
286
     $$ = $1;
287
     $$->verbose = 1;
288
   }
289 ce1da96e Martin Mares
 | r_args PRIMARY {
290
     $$ = $1;
291
     $$->primary_only = 1;
292
   }
293
 | r_args import_or_proto SYM {
294
     struct proto_config *c = (struct proto_config *) $3->def;
295
     $$ = $1;
296
     if ($$->import_mode) cf_error("Protocol specified twice");
297
     if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
298
     $$->import_mode = $2;
299
     $$->primary_only = 1;
300
     $$->import_protocol = c->proto;
301
     $$->running_on_config = c->proto->cf->global;
302
   }
303 23693958 Martin Mares
 | r_args STATS {
304
     $$ = $1;
305
     $$->stats = 1;
306
   }
307 33a368ad Martin Mares
 | r_args COUNT {
308
     $$ = $1;
309
     $$->stats = 2;
310
   }
311 ce1da96e Martin Mares
 ;
312
313
import_or_proto:
314
   IMPORT { $$ = 1; }
315
 | PROTOCOL { $$ = 2; }
316 730f2e2c Martin Mares
 ;
317
318 4b87e256 Martin Mares
CF_CLI(SHOW SYMBOLS, optsym, [<symbol>], [[Show all known symbolic names]])
319
{ cmd_show_symbols($3); } ;
320
321 96d8e3bf Martin Mares
CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
322
CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
323 34350a52 Martin Mares
{ rdump(&root_pool); cli_msg(0, ""); } ;
324 96d8e3bf Martin Mares
CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
325 34350a52 Martin Mares
{ sk_dump_all(); cli_msg(0, ""); } ;
326 96d8e3bf Martin Mares
CF_CLI(DUMP INTERFACES,,, [[Dump interface information]])
327 34350a52 Martin Mares
{ if_dump_all(); cli_msg(0, ""); } ;
328 96d8e3bf Martin Mares
CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
329 34350a52 Martin Mares
{ neigh_dump_all(); cli_msg(0, ""); } ;
330 96d8e3bf Martin Mares
CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
331 34350a52 Martin Mares
{ rta_dump_all(); cli_msg(0, ""); } ;
332 96d8e3bf Martin Mares
CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
333 34350a52 Martin Mares
{ rt_dump_all(); cli_msg(0, ""); } ;
334 96d8e3bf Martin Mares
CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
335 34350a52 Martin Mares
{ protos_dump_all(); cli_msg(0, ""); } ;
336
337
CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Configure echoing of log messages]]) {
338
  cli_set_log_echo(this_cli, $2, $3);
339
  cli_msg(0, "");
340
} ;
341
342
echo_mask:
343
   ALL { $$ = ~0; }
344
 | OFF { $$ = 0; }
345
 | NUM
346
 ;
347
348
echo_size:
349
   /* empty */ { $$ = 4096; }
350
 | NUM {
351
     if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
352
     $$ = $1;
353
   }
354
 ;
355 bc2fb680 Martin Mares
356 f14a4bec Martin Mares
CF_CLI(DISABLE, proto_patt, <protocol> | <pattern> | all, [[Disable protocol]])
357
{ proto_xxable($2, 0); } ;
358
CF_CLI(ENABLE, proto_patt, <protocol> | <pattern> | all, [[Enable protocol]])
359
{ proto_xxable($2, 1); } ;
360
CF_CLI(RESTART, proto_patt, <protocol> | <pattern> | all, [[Restart protocol]])
361
{ proto_xxable($2, 2); } ;
362
363 96d8e3bf Martin Mares
CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging]])
364
CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging]])
365
{ proto_debug($2, $3); }
366
367 f14a4bec Martin Mares
proto_patt:
368
   SYM { $$ = $1->name; }
369
 | ALL { $$ = "*"; }
370
 | TEXT
371
 ;
372
373 da877822 Martin Mares
CF_CODE
374
375
CF_END