]> git.ipfire.org Git - thirdparty/bird.git/blame - nest/config.Y
Some minor changes to CLI.
[thirdparty/bird.git] / nest / config.Y
CommitLineData
da877822
MM
1/*
2 * BIRD -- Core Configuration
3 *
4b87e256 4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
bc956fca 5 * (c) 2004 Ondrej Filip <feela@network.cz>
da877822
MM
6 *
7 * Can be freely distributed and used under the terms of the GNU GPL.
8 */
9
10CF_HDR
11
50d8424a 12#include "nest/rt-dev.h"
1a2ded45 13#include "nest/password.h"
4b87e256 14#include "nest/cmds.h"
5236fb03 15#include "lib/lists.h"
50d8424a 16
2edb31b0
MM
17CF_DEFINES
18
19static struct proto_config *this_proto;
20static struct iface_patt *this_ipatt;
20e94fb8 21static struct iface_patt_node *this_ipn;
af582c48 22static struct roa_table_config *this_roa_table;
5236fb03
OF
23static list *this_p_list;
24static struct password_item *this_p_item;
b21f68b4
OZ
25static int password_id;
26
024c310b
OZ
27static inline void
28reset_passwords(void)
29{
a7f23f58 30 this_p_list = NULL;
024c310b
OZ
31}
32
33static inline list *
b21f68b4
OZ
34get_passwords(void)
35{
36 list *rv = this_p_list;
37 this_p_list = NULL;
38 return rv;
39}
40
a7f23f58 41#define DIRECT_CFG ((struct rt_dev_config *) this_proto)
2edb31b0 42
da877822
MM
43CF_DECLS
44
a7f23f58 45CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
96d8e3bf 46CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
6a9f28b0 47CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
c47d037e 48CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE, ROA, MAX, FLUSH)
fcf5a4f4 49CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION)
ba5e5940 50CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC)
da877822 51
7d509304 52CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
98ac6176 53 RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
bf6d91dc 54CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE, UNDEFINED)
26c09e1d 55CF_ENUM(T_ENUM_RTC, RTC_, UNICAST, BROADCAST, MULTICAST, ANYCAST)
7e95c05d 56CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT, MULTIPATH)
af582c48 57CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID)
7d509304 58
dce26783 59%type <i32> idval
5056c559 60%type <f> imexport
0e02abfd 61%type <r> rtable
ae97b946 62%type <s> optsym
730f2e2c 63%type <ra> r_args
af582c48
OZ
64%type <ro> roa_args
65%type <rot> roa_table_arg
0f808c06 66%type <sd> sym_args
af582c48 67%type <i> proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_or_preexport roa_mode
e304fd4b 68%type <ps> proto_patt proto_patt2
da877822
MM
69
70CF_GRAMMAR
71
c74c0e3c
MM
72/* Setting of router ID */
73
da877822 74CF_ADDTO(conf, rtrid)
0e02abfd 75
7f400d1c 76rtrid: ROUTER ID idval ';' {
31b3e1bb 77 new_config->router_id = $3;
c74c0e3c 78 }
da877822
MM
79 ;
80
81idval:
dce26783
MM
82 NUM { $$ = $1; }
83 | RTRID
84 | IPA {
85#ifndef IPV6
86 $$ = ipa_to_u32($1);
87#else
e79671a7 88 cf_error("Router IDs must be entered as hexadecimal numbers or IPv4 addresses in IPv6 version");
dce26783
MM
89#endif
90 }
da877822
MM
91 ;
92
789772ed 93
d72cdff4 94CF_ADDTO(conf, listen)
789772ed 95
d72cdff4 96listen: LISTEN BGP listen_opts ';' ;
789772ed 97
d72cdff4 98listen_opts:
789772ed 99 /* Nothing */
d72cdff4 100 | listen_opts listen_opt
789772ed
OZ
101 ;
102
d72cdff4
OZ
103listen_opt:
104 ADDRESS ipa { new_config->listen_bgp_addr = $2; }
105 | PORT expr { new_config->listen_bgp_port = $2; }
fcf5a4f4
OZ
106 | V6ONLY { new_config->listen_bgp_flags = 0; }
107 | DUAL { new_config->listen_bgp_flags = 1; }
789772ed
OZ
108 ;
109
110
0e02abfd
MM
111/* Creation of routing tables */
112
113CF_ADDTO(conf, newtab)
114
115newtab: TABLE SYM {
b9626ec6 116 rt_new_table($2);
0e02abfd
MM
117 }
118 ;
119
af582c48
OZ
120CF_ADDTO(conf, roa_table)
121
122roa_table_start: ROA TABLE SYM {
123 this_roa_table = roa_new_table_config($3);
124};
125
126roa_table_opts:
127 /* empty */
128 | roa_table_opts ROA prefix MAX NUM AS NUM ';' {
129 roa_add_item_config(this_roa_table, $3.addr, $3.len, $5, $7);
130 }
131 ;
132
133roa_table:
134 roa_table_start
135 | roa_table_start '{' roa_table_opts '}'
136 ;
137
c74c0e3c
MM
138/* Definition of protocols */
139
140CF_ADDTO(conf, proto)
141
a7f23f58
OZ
142proto_start:
143 PROTOCOL { $$ = SYM_PROTO; }
144 | TEMPLATE { $$ = SYM_TEMPLATE; }
de10a974 145 ;
c74c0e3c
MM
146
147proto_name:
148 /* EMPTY */ {
d272fe22 149 struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
a7f23f58 150 s->class = this_proto->class;
c74c0e3c
MM
151 s->def = this_proto;
152 this_proto->name = s->name;
153 }
154 | SYM {
a7f23f58 155 cf_define_symbol($1, this_proto->class, this_proto);
c74c0e3c
MM
156 this_proto->name = $1->name;
157 }
a7f23f58
OZ
158 | SYM FROM SYM {
159 if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected");
160
161 cf_define_symbol($1, this_proto->class, this_proto);
162 this_proto->name = $1->name;
163
164 proto_copy_config(this_proto, $3->def);
165 }
c74c0e3c
MM
166 ;
167
168proto_item:
169 /* EMPTY */
0b62c3a7 170 | PREFERENCE expr {
f4c6ca8c 171 if ($2 < 0 || $2 > 0xFFFF) cf_error("Invalid preference");
c74c0e3c
MM
172 this_proto->preference = $2;
173 }
ca77641d 174 | DISABLED bool { this_proto->disabled = $2; }
96d8e3bf 175 | DEBUG debug_mask { this_proto->debug = $2; }
cf31112f 176 | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
5056c559
MM
177 | IMPORT imexport { this_proto->in_filter = $2; }
178 | EXPORT imexport { this_proto->out_filter = $2; }
0e02abfd 179 | TABLE rtable { this_proto->table = $2; }
4cdd0784 180 | ROUTER ID idval { this_proto->router_id = $3; }
3f9b7bfe 181 | DESCRIPTION TEXT { this_proto->dsc = $2; }
5056c559
MM
182 ;
183
184imexport:
185 FILTER filter { $$ = $2; }
f8809249 186 | where_filter
5056c559
MM
187 | ALL { $$ = FILTER_ACCEPT; }
188 | NONE { $$ = FILTER_REJECT; }
c74c0e3c
MM
189 ;
190
0e02abfd
MM
191rtable:
192 SYM {
193 if ($1->class != SYM_TABLE) cf_error("Table name expected");
194 $$ = $1->def;
195 }
196 ;
197
f30b86f9
MM
198CF_ADDTO(conf, debug_default)
199
200debug_default:
201 DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
4761efdb 202 | DEBUG COMMANDS expr { new_config->cli_debug = $3; }
f30b86f9
MM
203 ;
204
cf31112f
OZ
205/* MRTDUMP PROTOCOLS is in systep/unix/config.Y */
206
8edf2361
MM
207/* Interface patterns */
208
20e94fb8
OZ
209iface_patt_node_init:
210 /* EMPTY */ {
211 struct iface_patt_node *ipn = cfg_allocz(sizeof(struct iface_patt_node));
212 add_tail(&this_ipatt->ipn_list, NODE ipn);
213 this_ipn = ipn;
214 }
215 ;
216
217iface_patt_node_body:
218 TEXT { this_ipn->pattern = $1; this_ipn->prefix = IPA_NONE; this_ipn->pxlen = 0; }
5d53b807
OZ
219 | prefix_or_ipa { this_ipn->pattern = NULL; this_ipn->prefix = $1.addr; this_ipn->pxlen = $1.len; }
220 | TEXT prefix_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2.addr; this_ipn->pxlen = $2.len; }
20e94fb8
OZ
221 ;
222
223iface_negate:
224 { this_ipn->positive = 1; }
225 | '-' { this_ipn->positive = 0; }
226 ;
227
228iface_patt_node:
229 iface_patt_node_init iface_negate iface_patt_node_body
230 ;
231
232
233iface_patt_list:
234 iface_patt_node
235 | iface_patt_list ',' iface_patt_node
8edf2361
MM
236 ;
237
20e94fb8 238
7e5f5ffd 239/* Direct device route protocol */
50d8424a
MM
240
241CF_ADDTO(proto, dev_proto '}')
242
7e5f5ffd 243dev_proto_start: proto_start DIRECT {
a7f23f58 244 this_proto = proto_config_new(&proto_device, sizeof(struct rt_dev_config), $1);
a7f23f58 245 init_list(&DIRECT_CFG->iface_list);
50d8424a
MM
246 }
247 ;
248
249dev_proto:
7e5f5ffd 250 dev_proto_start proto_name '{'
50d8424a 251 | dev_proto proto_item ';'
20e94fb8 252 | dev_proto dev_iface_patt ';'
50d8424a
MM
253 ;
254
20e94fb8 255dev_iface_init:
8edf2361 256 /* EMPTY */ {
20e94fb8 257 this_ipatt = cfg_allocz(sizeof(struct iface_patt));
a7f23f58 258 add_tail(&DIRECT_CFG->iface_list, NODE this_ipatt);
20e94fb8 259 init_list(&this_ipatt->ipn_list);
50d8424a 260 }
50d8424a
MM
261 ;
262
20e94fb8
OZ
263dev_iface_patt:
264 INTERFACE dev_iface_init iface_patt_list
8edf2361
MM
265 ;
266
96d8e3bf
MM
267/* Debug flags */
268
269debug_mask:
270 ALL { $$ = ~0; }
271 | OFF { $$ = 0; }
272 | '{' debug_list '}' { $$ = $2; }
273 ;
274
275debug_list:
276 debug_flag
277 | debug_list ',' debug_flag { $$ = $1 | $3; }
278 ;
279
280debug_flag:
281 STATES { $$ = D_STATES; }
282 | ROUTES { $$ = D_ROUTES; }
283 | FILTERS { $$ = D_FILTERS; }
6a9f28b0 284 | INTERFACES { $$ = D_IFACES; }
96d8e3bf
MM
285 | EVENTS { $$ = D_EVENTS; }
286 | PACKETS { $$ = D_PACKETS; }
287 ;
288
cf31112f
OZ
289/* MRTDump flags */
290
291mrtdump_mask:
292 ALL { $$ = ~0; }
293 | OFF { $$ = 0; }
294 | '{' mrtdump_list '}' { $$ = $2; }
295 ;
296
297mrtdump_list:
298 mrtdump_flag
299 | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; }
300 ;
301
302mrtdump_flag:
303 STATES { $$ = MD_STATES; }
304 | MESSAGES { $$ = MD_MESSAGES; }
305 ;
306
8edf2361
MM
307/* Password lists */
308
b21f68b4
OZ
309password_list:
310 PASSWORDS '{' password_items '}'
311 | password_item
312;
313
5236fb03
OF
314password_items:
315 /* empty */
316 | password_item ';' password_items
317;
318
319password_item:
320 password_item_begin '{' password_item_params '}'
321 | password_item_begin
322;
323
324password_item_begin:
1a2ded45 325 PASSWORD TEXT {
b21f68b4
OZ
326 if (!this_p_list) {
327 this_p_list = cfg_alloc(sizeof(list));
328 init_list(this_p_list);
329 password_id = 1;
330 }
5236fb03
OF
331 this_p_item = cfg_alloc(sizeof (struct password_item));
332 this_p_item->password = $2;
333 this_p_item->genfrom = 0;
334 this_p_item->gento = TIME_INFINITY;
335 this_p_item->accfrom = 0;
336 this_p_item->accto = TIME_INFINITY;
b21f68b4 337 this_p_item->id = password_id++;
5236fb03 338 add_tail(this_p_list, &this_p_item->n);
1a2ded45 339 }
5236fb03 340;
1a2ded45 341
5236fb03 342password_item_params:
1a2ded45 343 /* empty */ { }
5236fb03
OF
344 | GENERATE FROM datetime ';' password_item_params { this_p_item->genfrom = $3; }
345 | GENERATE TO datetime ';' password_item_params { this_p_item->gento = $3; }
346 | ACCEPT FROM datetime ';' password_item_params { this_p_item->accfrom = $3; }
347 | ACCEPT TO datetime ';' password_item_params { this_p_item->accto = $3; }
bc956fca 348 | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 <= 0) cf_error("Password ID has to be greated than zero."); }
1a2ded45
PM
349 ;
350
1a2ded45 351
87d7fd97 352
bc2fb680 353/* Core commands */
fae0396e 354CF_CLI_HELP(SHOW, ..., [[Show status information]])
ae97b946 355
4b87e256 356CF_CLI(SHOW STATUS,,, [[Show router status]])
de10a974 357{ cmd_show_status(); } ;
ae97b946 358
acb60628
OZ
359CF_CLI(SHOW MEMORY,,, [[Show memory usage]])
360{ cmd_show_memory(); } ;
361
e304fd4b 362CF_CLI(SHOW PROTOCOLS, proto_patt2, [<protocol> | \"<pattern>\"], [[Show routing protocols]])
e0a45fb4 363{ proto_apply_cmd($3, proto_cmd_show, 0, 0); } ;
0d3e6bce 364
e304fd4b 365CF_CLI(SHOW PROTOCOLS ALL, proto_patt2, [<protocol> | \"<pattern>\"], [[Show routing protocol details]])
e0a45fb4 366{ proto_apply_cmd($4, proto_cmd_show, 0, 1); } ;
ae97b946 367
730f2e2c
MM
368optsym:
369 SYM
370 | /* empty */ { $$ = NULL; }
371 ;
372
ae97b946
MM
373CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
374{ if_show(); } ;
375
376CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
377{ if_show_summary(); } ;
378
c47d037e 379CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
ea2ae6dd 380CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [(export|preexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
730f2e2c
MM
381{ rt_show($3); } ;
382
383r_args:
384 /* empty */ {
385 $$ = cfg_allocz(sizeof(struct rt_show_data));
386 $$->pxlen = 256;
387 $$->filter = FILTER_ACCEPT;
388 $$->table = config->master_rtc->table;
389 }
758458be 390 | r_args prefix {
730f2e2c
MM
391 $$ = $1;
392 if ($$->pxlen != 256) cf_error("Only one prefix expected");
758458be
MM
393 $$->prefix = $2.addr;
394 $$->pxlen = $2.len;
730f2e2c 395 }
9449c91a
MM
396 | r_args FOR prefix_or_ipa {
397 $$ = $1;
398 if ($$->pxlen != 256) cf_error("Only one prefix expected");
399 $$->prefix = $3.addr;
400 $$->pxlen = $3.len;
401 $$->show_for = 1;
402 }
730f2e2c
MM
403 | r_args TABLE SYM {
404 $$ = $1;
405 if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name);
406 $$->table = ((struct rtable_config *)$3->def)->table;
407 }
408 | r_args FILTER filter {
409 $$ = $1;
430da60f 410 if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
730f2e2c
MM
411 $$->filter = $3;
412 }
430da60f
MM
413 | r_args where_filter {
414 $$ = $1;
415 if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
416 $$->filter = $2;
417 }
730f2e2c
MM
418 | r_args ALL {
419 $$ = $1;
420 $$->verbose = 1;
421 }
ce1da96e
MM
422 | r_args PRIMARY {
423 $$ = $1;
424 $$->primary_only = 1;
425 }
ea2ae6dd 426 | r_args export_or_preexport SYM {
ce1da96e
MM
427 struct proto_config *c = (struct proto_config *) $3->def;
428 $$ = $1;
ea2ae6dd 429 if ($$->export_mode) cf_error("Protocol specified twice");
ce1da96e 430 if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
ea2ae6dd 431 $$->export_mode = $2;
ce1da96e 432 $$->primary_only = 1;
ea2ae6dd 433 $$->export_protocol = c->proto;
ce1da96e
MM
434 $$->running_on_config = c->proto->cf->global;
435 }
4d176e14
OF
436 | r_args PROTOCOL SYM {
437 struct proto_config *c = (struct proto_config *) $3->def;
438 $$ = $1;
439 if ($$->show_protocol) cf_error("Protocol specified twice");
440 if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
441 $$->show_protocol = c->proto;
442 $$->running_on_config = c->proto->cf->global;
ce1da96e 443 }
23693958
MM
444 | r_args STATS {
445 $$ = $1;
446 $$->stats = 1;
447 }
33a368ad
MM
448 | r_args COUNT {
449 $$ = $1;
450 $$->stats = 2;
451 }
ce1da96e
MM
452 ;
453
ea2ae6dd
OZ
454export_or_preexport:
455 PREEXPORT { $$ = 1; }
456 | EXPORT { $$ = 2; }
730f2e2c
MM
457 ;
458
af582c48 459
c47d037e
OZ
460CF_CLI_HELP(SHOW ROA, ..., [[Show ROA table]])
461CF_CLI(SHOW ROA, roa_args, [<prefix> | in <prefix> | for <prefix>] [as <num>] [table <t>], [[Show ROA table]])
af582c48
OZ
462{ roa_show($3); } ;
463
464roa_args:
465 /* empty */ {
466 $$ = cfg_allocz(sizeof(struct roa_show_data));
467 $$->mode = ROA_SHOW_ALL;
468 $$->table = roa_table_default;
469 if (roa_table_default == NULL)
470 cf_error("No ROA table defined");
471 }
472 | roa_args roa_mode prefix {
473 $$ = $1;
474 if ($$->mode != ROA_SHOW_ALL) cf_error("Only one prefix expected");
475 $$->prefix = $3.addr;
476 $$->pxlen = $3.len;
477 $$->mode = $2;
478 }
479 | roa_args AS NUM {
480 $$ = $1;
481 $$->asn = $3;
482 }
483 | roa_args TABLE SYM {
484 $$ = $1;
485 if ($3->class != SYM_ROA) cf_error("%s is not a ROA table", $3->name);
486 $$->table = ((struct roa_table_config *)$3->def)->table;
487 }
488 ;
489
490roa_mode:
491 { $$ = ROA_SHOW_PX; }
492 | IN { $$ = ROA_SHOW_IN; }
493 | FOR { $$ = ROA_SHOW_FOR; }
494 ;
495
496
c47d037e 497CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]])
af582c48 498CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|roa|<symbol>], [[Show all known symbolic names]])
4b87e256
MM
499{ cmd_show_symbols($3); } ;
500
0f808c06
OZ
501sym_args:
502 /* empty */ {
503 $$ = cfg_allocz(sizeof(struct sym_show_data));
504 }
505 | sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; }
506 | sym_args FUNCTION { $$ = $1; $$->type = SYM_FUNCTION; }
507 | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
508 | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; }
509 | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; }
af582c48 510 | sym_args ROA { $$ = $1; $$->type = SYM_ROA; }
0f808c06
OZ
511 | sym_args SYM { $$ = $1; $$->sym = $2; }
512 ;
513
af582c48
OZ
514
515roa_table_arg:
516 /* empty */ {
517 if (roa_table_default == NULL)
518 cf_error("No ROA table defined");
519 $$ = roa_table_default;
520 }
521 | TABLE SYM {
522 if ($2->class != SYM_ROA)
523 cf_error("%s is not a ROA table", $2->name);
524 $$ = ((struct roa_table_config *)$2->def)->table;
525 }
526 ;
527
c47d037e 528CF_CLI_HELP(ADD, roa ..., [[Add ROA record]])
af582c48 529CF_CLI(ADD ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Add ROA record]])
c47d037e
OZ
530{
531 if (! cli_access_restricted())
532 { roa_add_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
533};
af582c48 534
c47d037e 535CF_CLI_HELP(DELETE, roa ..., [[Delete ROA record]])
af582c48 536CF_CLI(DELETE ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Delete ROA record]])
c47d037e
OZ
537{
538 if (! cli_access_restricted())
539 { roa_delete_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
540};
af582c48 541
c47d037e 542CF_CLI_HELP(FLUSH, roa [table <name>], [[Removes all dynamic ROA records]])
af582c48 543CF_CLI(FLUSH ROA, roa_table_arg, [table <name>], [[Removes all dynamic ROA records]])
c47d037e
OZ
544{
545 if (! cli_access_restricted())
546 { roa_flush($3, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
547};
af582c48
OZ
548
549
96d8e3bf
MM
550CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
551CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
34350a52 552{ rdump(&root_pool); cli_msg(0, ""); } ;
96d8e3bf 553CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
34350a52 554{ sk_dump_all(); cli_msg(0, ""); } ;
96d8e3bf 555CF_CLI(DUMP INTERFACES,,, [[Dump interface information]])
34350a52 556{ if_dump_all(); cli_msg(0, ""); } ;
96d8e3bf 557CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
34350a52 558{ neigh_dump_all(); cli_msg(0, ""); } ;
96d8e3bf 559CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
34350a52 560{ rta_dump_all(); cli_msg(0, ""); } ;
96d8e3bf 561CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
34350a52 562{ rt_dump_all(); cli_msg(0, ""); } ;
96d8e3bf 563CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
34350a52
MM
564{ protos_dump_all(); cli_msg(0, ""); } ;
565
566CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Configure echoing of log messages]]) {
567 cli_set_log_echo(this_cli, $2, $3);
568 cli_msg(0, "");
569} ;
570
571echo_mask:
572 ALL { $$ = ~0; }
573 | OFF { $$ = 0; }
574 | NUM
575 ;
576
577echo_size:
578 /* empty */ { $$ = 4096; }
579 | NUM {
580 if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
581 $$ = $1;
582 }
583 ;
bc2fb680 584
49569a8b 585CF_CLI(DISABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Disable protocol]])
e0a45fb4 586{ proto_apply_cmd($2, proto_cmd_disable, 1, 0); } ;
49569a8b 587CF_CLI(ENABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Enable protocol]])
e0a45fb4 588{ proto_apply_cmd($2, proto_cmd_enable, 1, 0); } ;
49569a8b 589CF_CLI(RESTART, proto_patt, <protocol> | \"<pattern>\" | all, [[Restart protocol]])
e0a45fb4 590{ proto_apply_cmd($2, proto_cmd_restart, 1, 0); } ;
bf47fe4b 591CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
e0a45fb4 592{ proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ;
8a7fb885 593CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
e0a45fb4 594{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ;
8a7fb885 595CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
e0a45fb4 596{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ;
f14a4bec 597
cf31112f 598CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]])
353729f5 599CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | interfaces | events | packets }), [[Control protocol debugging via BIRD logs]])
e0a45fb4 600{ proto_apply_cmd($2, proto_cmd_debug, 1, $3); } ;
cf31112f
OZ
601
602CF_CLI_HELP(MRTDUMP, ..., [[Control protocol debugging via MRTdump files]])
603CF_CLI(MRTDUMP, proto_patt mrtdump_mask, (<protocol> | <pattern> | all) (all | off | { states | messages }), [[Control protocol debugging via MRTdump format]])
e0a45fb4
OZ
604{ proto_apply_cmd($2, proto_cmd_mrtdump, 1, $3); } ;
605
606CF_CLI(RESTRICT,,,[[Restrict current CLI session to safe commands]])
607{ this_cli->restricted = 1; cli_msg(16, "Access restricted"); } ;
96d8e3bf 608
f14a4bec 609proto_patt:
e304fd4b
OZ
610 SYM { $$.ptr = $1; $$.patt = 0; }
611 | ALL { $$.ptr = NULL; $$.patt = 1; }
612 | TEXT { $$.ptr = $1; $$.patt = 1; }
f14a4bec
MM
613 ;
614
e304fd4b
OZ
615proto_patt2:
616 SYM { $$.ptr = $1; $$.patt = 0; }
617 | { $$.ptr = NULL; $$.patt = 1; }
618 | TEXT { $$.ptr = $1; $$.patt = 1; }
619 ;
620
ba5e5940
OZ
621CF_ADDTO(dynamic_attr, IGP_METRIC
622 { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); })
623
e304fd4b 624
da877822
MM
625CF_CODE
626
627CF_END