Statistics
| Branch: | Revision:

iof-bird-daemon / nest / config.Y @ cf98be7b

History | View | Annotate | Download (17.7 KB)

1
/*
2
 *	BIRD -- Core Configuration
3
 *
4
 *	(c) 1998--2000 Martin Mares <mj@ucw.cz>
5
 *      (c) 2004       Ondrej Filip <feela@network.cz>
6
 *
7
 *	Can be freely distributed and used under the terms of the GNU GPL.
8
 */
9

    
10
CF_HDR
11

    
12
#include "nest/rt-dev.h"
13
#include "nest/password.h"
14
#include "nest/cmds.h"
15
#include "lib/lists.h"
16

    
17
CF_DEFINES
18

    
19
static struct proto_config *this_proto;
20
static struct iface_patt *this_ipatt;
21
static struct iface_patt_node *this_ipn;
22
static struct roa_table_config *this_roa_table;
23
static list *this_p_list;
24
static struct password_item *this_p_item;
25
static int password_id;
26

    
27
static inline void
28
reset_passwords(void)
29
{
30
  this_p_list = NULL;
31
}
32

    
33
static inline list *
34
get_passwords(void)
35
{
36
  list *rv = this_p_list;
37
  this_p_list = NULL;
38
  return rv;
39
}
40

    
41
#define DIRECT_CFG ((struct rt_dev_config *) this_proto)
42

    
43
CF_DECLS
44

    
45
CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
46
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
47
CF_KEYWORDS(LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, REJECTED)
48
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
49
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE, ROA, MAX, FLUSH)
50
CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION, SORTED)
51
CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC)
52

    
53
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
54
	RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
55
CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE, UNDEFINED)
56
CF_ENUM(T_ENUM_RTC, RTC_, UNICAST, BROADCAST, MULTICAST, ANYCAST)
57
CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT, MULTIPATH)
58
CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID)
59

    
60
%type <i32> idval
61
%type <f> imexport
62
%type <r> rtable
63
%type <s> optsym
64
%type <ra> r_args
65
%type <ro> roa_args
66
%type <rot> roa_table_arg
67
%type <sd> sym_args
68
%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 limit_action tab_sorted
69
%type <ps> proto_patt proto_patt2
70
%type <g> limit_spec
71

    
72
CF_GRAMMAR
73

    
74
/* Setting of router ID */
75

    
76
CF_ADDTO(conf, rtrid)
77

    
78
rtrid: ROUTER ID idval ';' {
79
   new_config->router_id = $3;
80
   }
81
 ;
82

    
83
idval:
84
   NUM { $$ = $1; }
85
 | RTRID
86
 | IPA {
87
#ifndef IPV6
88
     $$ = ipa_to_u32($1);
89
#else
90
     cf_error("Router IDs must be entered as hexadecimal numbers or IPv4 addresses in IPv6 version");
91
#endif
92
   }
93
 ;
94

    
95

    
96
CF_ADDTO(conf, listen)
97

    
98
listen: LISTEN BGP listen_opts ';' ;
99

    
100
listen_opts:
101
   /* Nothing */
102
 | listen_opts listen_opt
103
 ;
104

    
105
listen_opt: 
106
   ADDRESS ipa { new_config->listen_bgp_addr = $2; }
107
 | PORT expr { new_config->listen_bgp_port = $2; }
108
 | V6ONLY { new_config->listen_bgp_flags = 0; }
109
 | DUAL { new_config->listen_bgp_flags = 1; }
110
 ;
111

    
112

    
113
/* Creation of routing tables */
114

    
115
tab_sorted:
116
          { $$ = 0; }
117
 | SORTED { $$ = 1; }
118
 ;
119

    
120
CF_ADDTO(conf, newtab)
121

    
122
newtab: TABLE SYM tab_sorted {
123
   struct rtable_config *cf;
124
   cf = rt_new_table($2);
125
   cf->sorted = $3;
126
   }
127
 ;
128

    
129
CF_ADDTO(conf, roa_table)
130

    
131
roa_table_start: ROA TABLE SYM {
132
  this_roa_table = roa_new_table_config($3);
133
};
134

    
135
roa_table_opts:
136
   /* empty */
137
 | roa_table_opts ROA prefix MAX NUM AS NUM ';' {
138
     roa_add_item_config(this_roa_table, $3.addr, $3.len, $5, $7);
139
   }
140
 ;
141

    
142
roa_table:
143
   roa_table_start
144
 | roa_table_start '{' roa_table_opts '}'
145
 ;
146

    
147
/* Definition of protocols */
148

    
149
CF_ADDTO(conf, proto)
150

    
151
proto_start:
152
   PROTOCOL { $$ = SYM_PROTO; }
153
 | TEMPLATE { $$ = SYM_TEMPLATE; }
154
 ;
155

    
156
proto_name:
157
   /* EMPTY */ {
158
     struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
159
     s->class = this_proto->class;
160
     s->def = this_proto;
161
     this_proto->name = s->name;
162
     }
163
 | SYM {
164
     cf_define_symbol($1, this_proto->class, this_proto);
165
     this_proto->name = $1->name;
166
   }
167
 | SYM FROM SYM {
168
     if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected");
169

    
170
     cf_define_symbol($1, this_proto->class, this_proto);
171
     this_proto->name = $1->name;
172

    
173
     proto_copy_config(this_proto, $3->def);
174
   }
175
 ;
176

    
177
proto_item:
178
   /* EMPTY */
179
 | PREFERENCE expr {
180
     if ($2 < 0 || $2 > 0xFFFF) cf_error("Invalid preference");
181
     this_proto->preference = $2;
182
   }
183
 | DISABLED bool { this_proto->disabled = $2; }
184
 | DEBUG debug_mask { this_proto->debug = $2; }
185
 | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
186
 | IMPORT imexport { this_proto->in_filter = $2; }
187
 | EXPORT imexport { this_proto->out_filter = $2; }
188
 | IMPORT LIMIT limit_spec { this_proto->in_limit = $3; }
189
 | EXPORT LIMIT limit_spec { this_proto->out_limit = $3; }
190
 | IMPORT KEEP REJECTED bool { this_proto->in_keep_rejected = $4; }
191
 | TABLE rtable { this_proto->table = $2; }
192
 | ROUTER ID idval { this_proto->router_id = $3; }
193
 | DESCRIPTION TEXT { this_proto->dsc = $2; }
194
 ;
195

    
196
imexport:
197
   FILTER filter { $$ = $2; }
198
 | where_filter
199
 | ALL { $$ = FILTER_ACCEPT; }
200
 | NONE { $$ = FILTER_REJECT; }
201
 ;
202

    
203
limit_action:
204
   /* default */ { $$ = PLA_DISABLE; }
205
 | ACTION WARN { $$ = PLA_WARN; }
206
 | ACTION BLOCK { $$ = PLA_BLOCK; }
207
 | ACTION RESTART { $$ = PLA_RESTART; }
208
 | ACTION DISABLE { $$ = PLA_DISABLE; }
209
 ;
210

    
211
limit_spec:
212
   expr limit_action {
213
     struct proto_limit *l = cfg_allocz(sizeof(struct proto_limit));
214
     l->limit = $1;
215
     l->action = $2;
216
     $$ = l;
217
   }
218
 ;
219

    
220
rtable:
221
   SYM {
222
     if ($1->class != SYM_TABLE) cf_error("Table name expected");
223
     $$ = $1->def;
224
   }
225
 ;
226

    
227
CF_ADDTO(conf, debug_default)
228

    
229
debug_default:
230
   DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
231
 | DEBUG COMMANDS expr { new_config->cli_debug = $3; }
232
 ;
233

    
234
/* MRTDUMP PROTOCOLS is in systep/unix/config.Y */
235

    
236
/* Interface patterns */
237

    
238
iface_patt_node_init:
239
   /* EMPTY */ {
240
     struct iface_patt_node *ipn = cfg_allocz(sizeof(struct iface_patt_node));
241
     add_tail(&this_ipatt->ipn_list, NODE ipn);
242
     this_ipn = ipn;
243
   }
244
 ;
245

    
246
iface_patt_node_body:
247
   TEXT { this_ipn->pattern = $1; this_ipn->prefix = IPA_NONE; this_ipn->pxlen = 0; }
248
 | prefix_or_ipa { this_ipn->pattern = NULL; this_ipn->prefix = $1.addr; this_ipn->pxlen = $1.len; }
249
 | TEXT prefix_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2.addr; this_ipn->pxlen = $2.len; }
250
 ;
251

    
252
iface_negate:
253
       { this_ipn->positive = 1; }
254
 | '-' { this_ipn->positive = 0; }
255
 ;
256

    
257
iface_patt_node:
258
   iface_patt_node_init iface_negate iface_patt_node_body 
259
 ;
260

    
261

    
262
iface_patt_list:
263
   iface_patt_node
264
 | iface_patt_list ',' iface_patt_node
265
 ;
266

    
267

    
268
/* Direct device route protocol */
269

    
270
CF_ADDTO(proto, dev_proto '}')
271

    
272
dev_proto_start: proto_start DIRECT {
273
     this_proto = proto_config_new(&proto_device, sizeof(struct rt_dev_config), $1);
274
     init_list(&DIRECT_CFG->iface_list);
275
   }
276
 ;
277

    
278
dev_proto:
279
   dev_proto_start proto_name '{'
280
 | dev_proto proto_item ';'
281
 | dev_proto dev_iface_patt ';'
282
 ;
283

    
284
dev_iface_init:
285
   /* EMPTY */ {
286
     this_ipatt = cfg_allocz(sizeof(struct iface_patt));
287
     add_tail(&DIRECT_CFG->iface_list, NODE this_ipatt);
288
     init_list(&this_ipatt->ipn_list);
289
   }
290
 ;
291

    
292
dev_iface_patt:
293
   INTERFACE dev_iface_init iface_patt_list
294
 ;
295

    
296
/* Debug flags */
297

    
298
debug_mask:
299
   ALL { $$ = ~0; }
300
 | OFF { $$ = 0; }
301
 | '{' debug_list '}' { $$ = $2; }
302
 ;
303

    
304
debug_list:
305
   debug_flag
306
 | debug_list ',' debug_flag { $$ = $1 | $3; }
307
 ;
308

    
309
debug_flag:
310
   STATES	{ $$ = D_STATES; }
311
 | ROUTES	{ $$ = D_ROUTES; }
312
 | FILTERS	{ $$ = D_FILTERS; }
313
 | INTERFACES	{ $$ = D_IFACES; }
314
 | EVENTS	{ $$ = D_EVENTS; }
315
 | PACKETS	{ $$ = D_PACKETS; }
316
 ;
317

    
318
/* MRTDump flags */
319

    
320
mrtdump_mask:
321
   ALL { $$ = ~0; }
322
 | OFF { $$ = 0; }
323
 | '{' mrtdump_list '}' { $$ = $2; }
324
 ;
325

    
326
mrtdump_list:
327
   mrtdump_flag
328
 | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; }
329
 ;
330

    
331
mrtdump_flag:
332
   STATES	{ $$ = MD_STATES; }
333
 | MESSAGES	{ $$ = MD_MESSAGES; }
334
 ;
335

    
336
/* Password lists */
337

    
338
password_list:
339
   PASSWORDS '{' password_items '}'
340
 | password_item
341
;
342

    
343
password_items: 
344
    /* empty */
345
  | password_item ';' password_items
346
;
347

    
348
password_item:
349
    password_item_begin '{' password_item_params '}'
350
  | password_item_begin
351
;
352

    
353
password_item_begin:
354
   PASSWORD TEXT {
355
     if (!this_p_list) {
356
     	this_p_list = cfg_alloc(sizeof(list));
357
     	init_list(this_p_list);
358
        password_id = 1;
359
     }
360
     this_p_item = cfg_alloc(sizeof (struct password_item));
361
     this_p_item->password = $2;
362
     this_p_item->genfrom = 0;
363
     this_p_item->gento = TIME_INFINITY;
364
     this_p_item->accfrom = 0;
365
     this_p_item->accto = TIME_INFINITY;
366
     this_p_item->id = password_id++;
367
     add_tail(this_p_list, &this_p_item->n);
368
   }
369
;
370

    
371
password_item_params:
372
   /* empty */ { } 
373
 | GENERATE FROM datetime ';' password_item_params { this_p_item->genfrom = $3; }
374
 | GENERATE TO datetime ';' password_item_params { this_p_item->gento = $3; }
375
 | ACCEPT FROM datetime ';' password_item_params { this_p_item->accfrom = $3; }
376
 | ACCEPT TO datetime ';' password_item_params { this_p_item->accto = $3; }
377
 | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 <= 0) cf_error("Password ID has to be greated than zero."); }
378
 ;
379

    
380

    
381

    
382
/* Core commands */
383
CF_CLI_HELP(SHOW, ..., [[Show status information]])
384

    
385
CF_CLI(SHOW STATUS,,, [[Show router status]])
386
{ cmd_show_status(); } ;
387

    
388
CF_CLI(SHOW MEMORY,,, [[Show memory usage]])
389
{ cmd_show_memory(); } ;
390

    
391
CF_CLI(SHOW PROTOCOLS, proto_patt2, [<protocol> | \"<pattern>\"], [[Show routing protocols]])
392
{ proto_apply_cmd($3, proto_cmd_show, 0, 0); } ;
393

    
394
CF_CLI(SHOW PROTOCOLS ALL, proto_patt2, [<protocol> | \"<pattern>\"], [[Show routing protocol details]])
395
{ proto_apply_cmd($4, proto_cmd_show, 0, 1); } ;
396

    
397
optsym:
398
   SYM
399
 | /* empty */ { $$ = NULL; }
400
 ;
401

    
402
CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
403
{ if_show(); } ;
404

    
405
CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
406
{ if_show_summary(); } ;
407

    
408
CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
409
CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [rejected] [(export|preexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
410
{ rt_show($3); } ;
411

    
412
r_args:
413
   /* empty */ {
414
     $$ = cfg_allocz(sizeof(struct rt_show_data));
415
     $$->pxlen = 256;
416
     $$->filter = FILTER_ACCEPT;
417
     $$->table = config->master_rtc->table;
418
   }
419
 | r_args prefix {
420
     $$ = $1;
421
     if ($$->pxlen != 256) cf_error("Only one prefix expected");
422
     $$->prefix = $2.addr;
423
     $$->pxlen = $2.len;
424
   }
425
 | r_args FOR prefix_or_ipa {
426
     $$ = $1;
427
     if ($$->pxlen != 256) cf_error("Only one prefix expected");
428
     $$->prefix = $3.addr;
429
     $$->pxlen = $3.len;
430
     $$->show_for = 1;
431
   }
432
 | r_args TABLE SYM {
433
     $$ = $1;
434
     if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name);
435
     $$->table = ((struct rtable_config *)$3->def)->table;
436
   }
437
 | r_args FILTER filter {
438
     $$ = $1;
439
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
440
     $$->filter = $3;
441
   }
442
 | r_args where_filter {
443
     $$ = $1;
444
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
445
     $$->filter = $2;
446
   }
447
 | r_args ALL {
448
     $$ = $1;
449
     $$->verbose = 1;
450
   }
451
 | r_args PRIMARY {
452
     $$ = $1;
453
     $$->primary_only = 1;
454
   }
455
 | r_args REJECTED {
456
     $$ = $1;
457
     $$->rejected = 1;
458
   }
459
 | r_args export_or_preexport SYM {
460
     struct proto_config *c = (struct proto_config *) $3->def;
461
     $$ = $1;
462
     if ($$->export_mode) cf_error("Protocol specified twice");
463
     if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
464
     $$->export_mode = $2;
465
     $$->primary_only = 1;
466
     $$->export_protocol = c->proto;
467
     $$->running_on_config = c->proto->cf->global;
468
   }
469
 | r_args PROTOCOL SYM {
470
     struct proto_config *c = (struct proto_config *) $3->def;
471
     $$ = $1;
472
     if ($$->show_protocol) cf_error("Protocol specified twice");
473
     if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
474
     $$->show_protocol = c->proto;
475
     $$->running_on_config = c->proto->cf->global;
476
   }
477
 | r_args STATS {
478
     $$ = $1;
479
     $$->stats = 1;
480
   }
481
 | r_args COUNT {
482
     $$ = $1;
483
     $$->stats = 2;
484
   }
485
 ;
486

    
487
export_or_preexport:
488
   PREEXPORT { $$ = 1; }
489
 | EXPORT { $$ = 2; }
490
 ;
491

    
492

    
493
CF_CLI_HELP(SHOW ROA, ..., [[Show ROA table]])
494
CF_CLI(SHOW ROA, roa_args, [<prefix> | in <prefix> | for <prefix>] [as <num>] [table <t>], [[Show ROA table]])
495
{ roa_show($3); } ;
496

    
497
roa_args:
498
   /* empty */ {
499
     $$ = cfg_allocz(sizeof(struct roa_show_data));
500
     $$->mode = ROA_SHOW_ALL;
501
     $$->table = roa_table_default;
502
     if (roa_table_default == NULL)
503
       cf_error("No ROA table defined");
504
   }
505
 | roa_args roa_mode prefix {
506
     $$ = $1;
507
     if ($$->mode != ROA_SHOW_ALL) cf_error("Only one prefix expected");
508
     $$->prefix = $3.addr;
509
     $$->pxlen = $3.len;
510
     $$->mode = $2;
511
   }
512
 | roa_args AS NUM {
513
     $$ = $1;
514
     $$->asn = $3;
515
   }
516
 | roa_args TABLE SYM {
517
     $$ = $1;
518
     if ($3->class != SYM_ROA) cf_error("%s is not a ROA table", $3->name);
519
     $$->table = ((struct roa_table_config *)$3->def)->table;
520
   }
521
 ;
522

    
523
roa_mode:
524
       { $$ = ROA_SHOW_PX; }
525
 | IN  { $$ = ROA_SHOW_IN; }
526
 | FOR { $$ = ROA_SHOW_FOR; }
527
 ;
528

    
529

    
530
CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]])
531
CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|roa|<symbol>], [[Show all known symbolic names]])
532
{ cmd_show_symbols($3); } ;
533

    
534
sym_args:
535
   /* empty */ {
536
     $$ = cfg_allocz(sizeof(struct sym_show_data));
537
   }
538
 | sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; }
539
 | sym_args FUNCTION { $$ = $1; $$->type = SYM_FUNCTION; }
540
 | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
541
 | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; }
542
 | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; }
543
 | sym_args ROA { $$ = $1; $$->type = SYM_ROA; }
544
 | sym_args SYM { $$ = $1; $$->sym = $2; }
545
 ;
546

    
547

    
548
roa_table_arg:
549
   /* empty */ { 
550
     if (roa_table_default == NULL)
551
       cf_error("No ROA table defined");
552
     $$ = roa_table_default;
553
   }
554
 | TABLE SYM {
555
     if ($2->class != SYM_ROA)
556
       cf_error("%s is not a ROA table", $2->name);
557
     $$ = ((struct roa_table_config *)$2->def)->table;
558
   }
559
 ;
560

    
561
CF_CLI_HELP(ADD, roa ..., [[Add ROA record]])
562
CF_CLI(ADD ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Add ROA record]])
563
{
564
  if (! cli_access_restricted())
565
    { roa_add_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
566
};
567

    
568
CF_CLI_HELP(DELETE, roa ..., [[Delete ROA record]])
569
CF_CLI(DELETE ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Delete ROA record]])
570
{
571
  if (! cli_access_restricted())
572
    { roa_delete_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
573
};
574

    
575
CF_CLI_HELP(FLUSH, roa [table <name>], [[Removes all dynamic ROA records]])
576
CF_CLI(FLUSH ROA, roa_table_arg, [table <name>], [[Removes all dynamic ROA records]])
577
{
578
  if (! cli_access_restricted())
579
    { roa_flush($3, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
580
};
581

    
582

    
583
CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
584
CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
585
{ rdump(&root_pool); cli_msg(0, ""); } ;
586
CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
587
{ sk_dump_all(); cli_msg(0, ""); } ;
588
CF_CLI(DUMP INTERFACES,,, [[Dump interface information]])
589
{ if_dump_all(); cli_msg(0, ""); } ;
590
CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
591
{ neigh_dump_all(); cli_msg(0, ""); } ;
592
CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
593
{ rta_dump_all(); cli_msg(0, ""); } ;
594
CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
595
{ rt_dump_all(); cli_msg(0, ""); } ;
596
CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
597
{ protos_dump_all(); cli_msg(0, ""); } ;
598

    
599
CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Configure echoing of log messages]]) {
600
  cli_set_log_echo(this_cli, $2, $3);
601
  cli_msg(0, "");
602
} ;
603

    
604
echo_mask:
605
   ALL { $$ = ~0; }
606
 | OFF { $$ = 0; }
607
 | NUM
608
 ;
609

    
610
echo_size:
611
   /* empty */ { $$ = 4096; }
612
 | NUM {
613
     if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
614
     $$ = $1;
615
   }
616
 ;
617

    
618
CF_CLI(DISABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Disable protocol]])
619
{ proto_apply_cmd($2, proto_cmd_disable, 1, 0); } ;
620
CF_CLI(ENABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Enable protocol]])
621
{ proto_apply_cmd($2, proto_cmd_enable, 1, 0); } ;
622
CF_CLI(RESTART, proto_patt, <protocol> | \"<pattern>\" | all, [[Restart protocol]])
623
{ proto_apply_cmd($2, proto_cmd_restart, 1, 0); } ;
624
CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
625
{ proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ;
626
CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
627
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ;
628
CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
629
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ;
630

    
631
CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]])
632
CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | interfaces | events | packets }), [[Control protocol debugging via BIRD logs]])
633
{ proto_apply_cmd($2, proto_cmd_debug, 1, $3); } ;
634

    
635
CF_CLI_HELP(MRTDUMP, ..., [[Control protocol debugging via MRTdump files]])
636
CF_CLI(MRTDUMP, proto_patt mrtdump_mask, (<protocol> | <pattern> | all) (all | off | { states | messages }), [[Control protocol debugging via MRTdump format]])
637
{ proto_apply_cmd($2, proto_cmd_mrtdump, 1, $3); } ;
638

    
639
CF_CLI(RESTRICT,,,[[Restrict current CLI session to safe commands]])
640
{ this_cli->restricted = 1; cli_msg(16, "Access restricted"); } ;
641

    
642
proto_patt:
643
   SYM  { $$.ptr = $1; $$.patt = 0; }
644
 | ALL  { $$.ptr = NULL; $$.patt = 1; }
645
 | TEXT { $$.ptr = $1; $$.patt = 1; }
646
 ;
647

    
648
proto_patt2:
649
   SYM  { $$.ptr = $1; $$.patt = 0; }
650
 |      { $$.ptr = NULL; $$.patt = 1; }
651
 | TEXT { $$.ptr = $1; $$.patt = 1; }
652
 ;
653

    
654
CF_ADDTO(dynamic_attr, IGP_METRIC
655
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); })
656

    
657

    
658
CF_CODE
659

    
660
CF_END