Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (18.1 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 channel_config *this_channel;
21
static struct iface_patt *this_ipatt;
22
static struct iface_patt_node *this_ipn;
23
/* static struct roa_table_config *this_roa_table; */
24
static list *this_p_list;
25
static struct password_item *this_p_item;
26
static int password_id;
27

    
28
static void
29
iface_patt_check(void)
30
{
31
  struct iface_patt_node *pn;
32

    
33
  WALK_LIST(pn, this_ipatt->ipn_list)
34
    if (!pn->pattern || pn->prefix.type)
35
      cf_error("Interface name/mask expected, not IP prefix");
36
}
37

    
38

    
39
static inline void
40
reset_passwords(void)
41
{
42
  this_p_list = NULL;
43
}
44

    
45
static inline list *
46
get_passwords(void)
47
{
48
  list *rv = this_p_list;
49
  this_p_list = NULL;
50
  return rv;
51
}
52

    
53
static void
54
proto_postconfig(void)
55
{
56
  CALL(this_proto->protocol->postconfig, this_proto);
57
  this_channel = NULL;
58
  this_proto = NULL;
59
}
60

    
61

    
62
#define DIRECT_CFG ((struct rt_dev_config *) this_proto)
63

    
64
CF_DECLS
65

    
66
CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
67
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
68
CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6)
69
CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED)
70
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
71
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, NOEXPORT, GENERATE) /* ,ROA */
72
CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION, SORTED)
73
CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP)
74
CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS)
75

    
76
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
77
	RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
78
CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE, UNDEFINED)
79
CF_ENUM(T_ENUM_RTC, RTC_, UNICAST, BROADCAST, MULTICAST, ANYCAST)
80
CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT, MULTIPATH)
81
CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID)
82

    
83
%type <i32> idval
84
%type <f> imexport
85
%type <r> rtable
86
%type <s> optsym
87
%type <ra> r_args
88
%type <sd> sym_args
89
%type <i> proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_mode limit_action net_type table_sorted tos
90
%type <ps> proto_patt proto_patt2
91
%type <cc> channel_start proto_channel
92
%type <cl> limit_spec
93

    
94
CF_GRAMMAR
95

    
96
/* Setting of router ID */
97

    
98
CF_ADDTO(conf, rtrid)
99

    
100
rtrid:
101
   ROUTER ID idval ';' { new_config->router_id = $3; }
102
 | ROUTER ID FROM iface_patt ';' { new_config->router_id_from = this_ipatt; }
103
 ;
104

    
105
idval:
106
   NUM { $$ = $1; }
107
 | '(' term ')' { $$ = f_eval_int($2); }
108
 | IP4 { $$ = ip4_to_u32($1); }
109
 | SYM {
110
     if ($1->class == (SYM_CONSTANT | T_INT) || $1->class == (SYM_CONSTANT | T_QUAD))
111
       $$ = SYM_VAL($1).i;
112
     else if (($1->class == (SYM_CONSTANT | T_IP)) && ipa_is_ip4(SYM_VAL($1).ip))
113
       $$ = ipa_to_u32(SYM_VAL($1).ip);
114
     else
115
       cf_error("Number of IPv4 address constant expected");
116
   }
117
 ;
118

    
119

    
120
CF_ADDTO(conf, listen)
121

    
122
listen: LISTEN BGP listen_opts ';' ;
123

    
124
listen_opts:
125
   /* Nothing */
126
 | listen_opts listen_opt
127
 ;
128

    
129
listen_opt:
130
   ADDRESS ipa { new_config->listen_bgp_addr = $2; }
131
 | PORT expr { new_config->listen_bgp_port = $2; }
132
 | V6ONLY { new_config->listen_bgp_flags = 0; }
133
 | DUAL { new_config->listen_bgp_flags = 1; }
134
 ;
135

    
136

    
137
CF_ADDTO(conf, gr_opts)
138

    
139
gr_opts: GRACEFUL RESTART WAIT expr ';' { new_config->gr_wait = $4; } ;
140

    
141

    
142
/* Network types (for tables, channels) */
143

    
144
net_type:
145
   IPV4 { $$ = NET_IP4; }
146
 | IPV6 { $$ = NET_IP6; }
147
 | VPN4 { $$ = NET_VPN4; }
148
 | VPN6 { $$ = NET_VPN6; }
149
 | ROA4 { $$ = NET_ROA4; }
150
 | ROA6 { $$ = NET_ROA6; }
151
 ;
152

    
153

    
154
/* Creation of routing tables */
155

    
156
CF_ADDTO(conf, table)
157

    
158
table_sorted:
159
          { $$ = 0; }
160
 | SORTED { $$ = 1; }
161
 ;
162

    
163
table: net_type TABLE SYM table_sorted {
164
   struct rtable_config *cf;
165
   cf = rt_new_table($3, $1);
166
   cf->sorted = $4;
167
   }
168
 ;
169

    
170

    
171
/* Definition of protocols */
172

    
173
CF_ADDTO(conf, proto { proto_postconfig(); })
174

    
175
proto_start:
176
   PROTOCOL { $$ = SYM_PROTO; }
177
 | TEMPLATE { $$ = SYM_TEMPLATE; }
178
 ;
179

    
180
proto_name:
181
   /* EMPTY */ {
182
     struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
183
     s->class = this_proto->class;
184
     s->def = this_proto;
185
     this_proto->name = s->name;
186
     }
187
 | SYM {
188
     cf_define_symbol($1, this_proto->class, this_proto);
189
     this_proto->name = $1->name;
190
   }
191
 | FROM SYM {
192
     struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
193
     s->class = this_proto->class;
194
     s->def = this_proto;
195
     this_proto->name = s->name;
196

    
197
     if (($2->class != SYM_TEMPLATE) && ($2->class != SYM_PROTO)) cf_error("Template or protocol name expected");
198
     proto_copy_config(this_proto, $2->def);
199
   }
200
 | SYM FROM SYM {
201
     cf_define_symbol($1, this_proto->class, this_proto);
202
     this_proto->name = $1->name;
203

    
204
     if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected");
205
     proto_copy_config(this_proto, $3->def);
206
   }
207
 ;
208

    
209
proto_item:
210
   /* EMPTY */
211
 | DISABLED bool { this_proto->disabled = $2; }
212
 | DEBUG debug_mask { this_proto->debug = $2; }
213
 | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
214
 | ROUTER ID idval { this_proto->router_id = $3; }
215
 | DESCRIPTION text { this_proto->dsc = $2; }
216
 ;
217

    
218

    
219
channel_start: net_type
220
{
221
  $$ = this_channel = channel_config_new(NULL, $1, this_proto);
222
};
223

    
224
channel_item:
225
   TABLE rtable {
226
     if (this_channel->net_type && ($2->addr_type != this_channel->net_type))
227
       cf_error("Incompatible table type");
228
     this_channel->table = $2;
229
   }
230
 | IMPORT imexport { this_channel->in_filter = $2; }
231
 | EXPORT imexport { this_channel->out_filter = $2; }
232
 | RECEIVE LIMIT limit_spec { this_channel->rx_limit = $3; }
233
 | IMPORT LIMIT limit_spec { this_channel->in_limit = $3; }
234
 | EXPORT LIMIT limit_spec { this_channel->out_limit = $3; }
235
 | PREFERENCE expr { this_channel->preference = $2; check_u16($2); }
236
 | IMPORT KEEP FILTERED bool { this_channel->in_keep_filtered = $4; }
237
 ;
238

    
239
channel_opts:
240
   /* empty */
241
 | channel_opts channel_item ';'
242
 ;
243

    
244
channel_opt_list:
245
   /* empty */
246
 | '{' channel_opts '}'
247
 ;
248

    
249
channel_end:
250
{
251
  if (!this_channel->table)
252
    cf_error("Routing table not specified");
253

    
254
  this_channel = NULL;
255
};
256

    
257
proto_channel: channel_start channel_opt_list channel_end;
258

    
259

    
260
rtable:
261
   SYM {
262
     if ($1->class != SYM_TABLE) cf_error("Table expected");
263
     $$ = $1->def;
264
   }
265
 ;
266

    
267
imexport:
268
   FILTER filter { $$ = $2; }
269
 | where_filter
270
 | ALL { $$ = FILTER_ACCEPT; }
271
 | NONE { $$ = FILTER_REJECT; }
272
 ;
273

    
274
limit_action:
275
   /* default */ { $$ = PLA_DISABLE; }
276
 | ACTION WARN { $$ = PLA_WARN; }
277
 | ACTION BLOCK { $$ = PLA_BLOCK; }
278
 | ACTION RESTART { $$ = PLA_RESTART; }
279
 | ACTION DISABLE { $$ = PLA_DISABLE; }
280
 ;
281

    
282
limit_spec:
283
   expr limit_action { $$ = (struct channel_limit){ .limit = $1, $$.action = $2 }; }
284
 | OFF { $$ = (struct channel_limit){}; }
285
 ;
286

    
287
CF_ADDTO(conf, debug_default)
288

    
289
debug_default:
290
   DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
291
 | DEBUG COMMANDS expr { new_config->cli_debug = $3; }
292
 ;
293

    
294
/* MRTDUMP PROTOCOLS is in systep/unix/config.Y */
295

    
296
/* Interface patterns */
297

    
298
iface_patt_node_init:
299
   /* EMPTY */ {
300
     struct iface_patt_node *ipn = cfg_allocz(sizeof(struct iface_patt_node));
301
     add_tail(&this_ipatt->ipn_list, NODE ipn);
302
     this_ipn = ipn;
303
   }
304
 ;
305

    
306
iface_patt_node_body:
307
   TEXT { this_ipn->pattern = $1; /* this_ipn->prefix stays zero */ }
308
 | opttext net_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2; }
309
 ;
310

    
311
iface_negate:
312
       { this_ipn->positive = 1; }
313
 | '-' { this_ipn->positive = 0; }
314
 ;
315

    
316
iface_patt_node:
317
   iface_patt_node_init iface_negate iface_patt_node_body
318
 ;
319

    
320

    
321
iface_patt_list:
322
   iface_patt_node
323
 | iface_patt_list ',' iface_patt_node
324
 ;
325

    
326
/* For name/mask-only iface patterns */
327
iface_patt_list_nopx: iface_patt_list { iface_patt_check(); }
328

    
329
iface_patt_init: {
330
   /* Generic this_ipatt init */
331
   this_ipatt = cfg_allocz(sizeof(struct iface_patt));
332
   init_list(&this_ipatt->ipn_list);
333
 }
334
 ;
335

    
336
iface_patt:
337
   iface_patt_init iface_patt_list
338
 ;
339

    
340
tos:
341
   CLASS expr { $$ = $2 & 0xfc;        if (($2 < 0) || ($2 > 255)) cf_error("TX class must be in range 0-255"); }
342
 | DSCP expr  { $$ = ($2 & 0x3f) << 2; if (($2 < 0) || ($2 > 63))  cf_error("TX DSCP must be in range 0-63"); }
343
 ;
344

    
345
/* Direct device route protocol */
346

    
347
CF_ADDTO(proto, dev_proto '}')
348

    
349
dev_proto_start: proto_start DIRECT {
350
     this_proto = proto_config_new(&proto_device, $1);
351
     init_list(&DIRECT_CFG->iface_list);
352
   }
353
 ;
354

    
355
dev_proto:
356
   dev_proto_start proto_name '{'
357
 | dev_proto proto_item ';'
358
 | dev_proto proto_channel ';'
359
 | dev_proto dev_iface_patt ';'
360
 ;
361

    
362
dev_iface_init:
363
   /* EMPTY */ {
364
     this_ipatt = cfg_allocz(sizeof(struct iface_patt));
365
     add_tail(&DIRECT_CFG->iface_list, NODE this_ipatt);
366
     init_list(&this_ipatt->ipn_list);
367
   }
368
 ;
369

    
370
dev_iface_patt:
371
   INTERFACE dev_iface_init iface_patt_list
372
 ;
373

    
374
/* Debug flags */
375

    
376
debug_mask:
377
   ALL { $$ = ~0; }
378
 | OFF { $$ = 0; }
379
 | '{' debug_list '}' { $$ = $2; }
380
 ;
381

    
382
debug_list:
383
   debug_flag
384
 | debug_list ',' debug_flag { $$ = $1 | $3; }
385
 ;
386

    
387
debug_flag:
388
   STATES	{ $$ = D_STATES; }
389
 | ROUTES	{ $$ = D_ROUTES; }
390
 | FILTERS	{ $$ = D_FILTERS; }
391
 | INTERFACES	{ $$ = D_IFACES; }
392
 | EVENTS	{ $$ = D_EVENTS; }
393
 | PACKETS	{ $$ = D_PACKETS; }
394
 ;
395

    
396
/* MRTDump flags */
397

    
398
mrtdump_mask:
399
   ALL { $$ = ~0; }
400
 | OFF { $$ = 0; }
401
 | '{' mrtdump_list '}' { $$ = $2; }
402
 ;
403

    
404
mrtdump_list:
405
   mrtdump_flag
406
 | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; }
407
 ;
408

    
409
mrtdump_flag:
410
   STATES	{ $$ = MD_STATES; }
411
 | MESSAGES	{ $$ = MD_MESSAGES; }
412
 ;
413

    
414
/* Password lists */
415

    
416
password_list:
417
   PASSWORDS '{' password_items '}'
418
 | password_item
419
;
420

    
421
password_items: 
422
    /* empty */
423
  | password_item ';' password_items
424
;
425

    
426
password_item:
427
    password_item_begin '{' password_item_params '}'
428
  | password_item_begin
429
;
430

    
431
password_item_begin:
432
   PASSWORD text {
433
     if (!this_p_list) {
434
     	this_p_list = cfg_alloc(sizeof(list));
435
     	init_list(this_p_list);
436
        password_id = 1;
437
     }
438
     this_p_item = cfg_alloc(sizeof (struct password_item));
439
     this_p_item->password = $2;
440
     this_p_item->genfrom = 0;
441
     this_p_item->gento = TIME_INFINITY;
442
     this_p_item->accfrom = 0;
443
     this_p_item->accto = TIME_INFINITY;
444
     this_p_item->id = password_id++;
445
     add_tail(this_p_list, &this_p_item->n);
446
   }
447
;
448

    
449
password_item_params:
450
   /* empty */ { } 
451
 | GENERATE FROM datetime ';' password_item_params { this_p_item->genfrom = $3; }
452
 | GENERATE TO datetime ';' password_item_params { this_p_item->gento = $3; }
453
 | GENERATE FROM datetime TO datetime ';' password_item_params { this_p_item->genfrom = $3; this_p_item->gento = $5; }
454
 | ACCEPT FROM datetime ';' password_item_params { this_p_item->accfrom = $3; }
455
 | ACCEPT TO datetime ';' password_item_params { this_p_item->accto = $3; }
456
 | ACCEPT FROM datetime TO datetime ';' password_item_params { this_p_item->accfrom = $3; this_p_item->accto = $5; }
457
 | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 <= 0) cf_error("Password ID has to be greated than zero."); }
458
 ;
459

    
460

    
461

    
462
/* Core commands */
463
CF_CLI_HELP(SHOW, ..., [[Show status information]])
464

    
465
CF_CLI(SHOW STATUS,,, [[Show router status]])
466
{ cmd_show_status(); } ;
467

    
468
CF_CLI(SHOW MEMORY,,, [[Show memory usage]])
469
{ cmd_show_memory(); } ;
470

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

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

    
477
optsym:
478
   SYM
479
 | /* empty */ { $$ = NULL; }
480
 ;
481

    
482
CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
483
{ if_show(); } ;
484

    
485
CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
486
{ if_show_summary(); } ;
487

    
488
CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
489
CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [filtered] [(export|preexport|noexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
490
{ rt_show($3); } ;
491

    
492
r_args:
493
   /* empty */ {
494
     $$ = cfg_allocz(sizeof(struct rt_show_data));
495
     $$->filter = FILTER_ACCEPT;
496
   }
497
 | r_args net_any {
498
     $$ = $1;
499
     if ($$->addr) cf_error("Only one prefix expected");
500
     $$->addr = $2;
501
   }
502
 | r_args FOR net_or_ipa {
503
     $$ = $1;
504
     if ($$->addr) cf_error("Only one prefix expected");
505
     $$->show_for = 1;
506
     $$->addr = cfg_alloc($3.length);
507
     net_copy($$->addr, &($3));
508
   }
509
 | r_args TABLE SYM {
510
     $$ = $1;
511
     if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name);
512
     $$->table = ((struct rtable_config *)$3->def)->table;
513
   }
514
 | r_args FILTER filter {
515
     $$ = $1;
516
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
517
     $$->filter = $3;
518
   }
519
 | r_args where_filter {
520
     $$ = $1;
521
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
522
     $$->filter = $2;
523
   }
524
 | r_args ALL {
525
     $$ = $1;
526
     $$->verbose = 1;
527
   }
528
 | r_args PRIMARY {
529
     $$ = $1;
530
     $$->primary_only = 1;
531
   }
532
 | r_args FILTERED {
533
     $$ = $1;
534
     $$->filtered = 1;
535
   }
536
 | r_args export_mode SYM {
537
     struct proto_config *c = (struct proto_config *) $3->def;
538
     $$ = $1;
539
     if ($$->export_mode) cf_error("Protocol specified twice");
540
     if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
541
     $$->export_mode = $2;
542
     $$->export_protocol = c->proto;
543
     $$->running_on_config = c->proto->cf->global;
544
   }
545
 | r_args PROTOCOL SYM {
546
     struct proto_config *c = (struct proto_config *) $3->def;
547
     $$ = $1;
548
     if ($$->show_protocol) cf_error("Protocol specified twice");
549
     if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
550
     $$->show_protocol = c->proto;
551
     $$->running_on_config = c->proto->cf->global;
552
   }
553
 | r_args STATS {
554
     $$ = $1;
555
     $$->stats = 1;
556
   }
557
 | r_args COUNT {
558
     $$ = $1;
559
     $$->stats = 2;
560
   }
561
 ;
562

    
563
export_mode:
564
   PREEXPORT	{ $$ = RSEM_PREEXPORT; }
565
 | EXPORT	{ $$ = RSEM_EXPORT; }
566
 | NOEXPORT	{ $$ = RSEM_NOEXPORT; }
567
 ;
568

    
569

    
570
CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]])
571
CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|<symbol>], [[Show all known symbolic names]])
572
{ cmd_show_symbols($3); } ;
573

    
574
sym_args:
575
   /* empty */ {
576
     $$ = cfg_allocz(sizeof(struct sym_show_data));
577
   }
578
 | sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; }
579
 | sym_args FUNCTION { $$ = $1; $$->type = SYM_FUNCTION; }
580
 | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
581
 | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; }
582
 | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; }
583
 | sym_args SYM { $$ = $1; $$->sym = $2; }
584
 ;
585

    
586

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

    
605
CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]])
606
{ cmd_eval($2); } ;
607

    
608
CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]])
609
CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug | trace | info | remote | warning | error | auth }) [<buffer-size>], [[Control echoing of log messages]]) {
610
  cli_set_log_echo(this_cli, $2, $3);
611
  cli_msg(0, "");
612
} ;
613

    
614
echo_mask:
615
   ALL { $$ = ~0; }
616
 | OFF { $$ = 0; }
617
 | '{' log_mask_list '}' { $$ = $2; }
618
 ;
619

    
620
echo_size:
621
   /* empty */ { $$ = 4096; }
622
 | NUM {
623
     if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
624
     $$ = $1;
625
   }
626
 ;
627

    
628
CF_CLI(DISABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Disable protocol]])
629
{ proto_apply_cmd($2, proto_cmd_disable, 1, 0); } ;
630
CF_CLI(ENABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Enable protocol]])
631
{ proto_apply_cmd($2, proto_cmd_enable, 1, 0); } ;
632
CF_CLI(RESTART, proto_patt, <protocol> | \"<pattern>\" | all, [[Restart protocol]])
633
{ proto_apply_cmd($2, proto_cmd_restart, 1, 0); } ;
634
CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
635
{ proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ;
636
CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
637
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ;
638
CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
639
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ;
640

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

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

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

    
652
proto_patt:
653
   SYM  { $$.ptr = $1; $$.patt = 0; }
654
 | ALL  { $$.ptr = NULL; $$.patt = 1; }
655
 | TEXT { $$.ptr = $1; $$.patt = 1; }
656
 ;
657

    
658
proto_patt2:
659
   SYM  { $$.ptr = $1; $$.patt = 0; }
660
 |      { $$.ptr = NULL; $$.patt = 1; }
661
 | TEXT { $$.ptr = $1; $$.patt = 1; }
662
 ;
663

    
664
CF_ADDTO(dynamic_attr, IGP_METRIC
665
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); })
666

    
667

    
668
CF_CODE
669

    
670
CF_END