Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (18.9 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 void
28
iface_patt_check(void)
29
{
30
  struct iface_patt_node *pn;
31

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

    
37

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

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

    
52
#define DIRECT_CFG ((struct rt_dev_config *) this_proto)
53

    
54
CF_DECLS
55

    
56
CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
57
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
58
CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED)
59
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
60
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE, ROA, MAX, FLUSH, AS)
61
CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION, SORTED)
62
CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP)
63
CF_KEYWORDS(GRACEFUL, RESTART, WAIT)
64

    
65
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
66
	RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
67
CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE, UNDEFINED)
68
CF_ENUM(T_ENUM_RTC, RTC_, UNICAST, BROADCAST, MULTICAST, ANYCAST)
69
CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT, MULTIPATH)
70
CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID)
71

    
72
%type <i32> idval
73
%type <f> imexport
74
%type <r> rtable
75
%type <s> optsym
76
%type <ra> r_args
77
%type <ro> roa_args
78
%type <rot> roa_table_arg
79
%type <sd> sym_args
80
%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 tos
81
%type <ps> proto_patt proto_patt2
82
%type <g> limit_spec
83

    
84
CF_GRAMMAR
85

    
86
/* Setting of router ID */
87

    
88
CF_ADDTO(conf, rtrid)
89

    
90
rtrid: 
91
   ROUTER ID idval ';' { new_config->router_id = $3; }
92
 | ROUTER ID FROM iface_patt ';' { new_config->router_id_from = this_ipatt; }
93
 ;
94

    
95
idval:
96
   NUM { $$ = $1; }
97
 | RTRID
98
 | IPA {
99
#ifndef IPV6
100
     $$ = ipa_to_u32($1);
101
#else
102
     cf_error("Router IDs must be entered as hexadecimal numbers or IPv4 addresses in IPv6 version");
103
#endif
104
   }
105
 ;
106

    
107

    
108
CF_ADDTO(conf, listen)
109

    
110
listen: LISTEN BGP listen_opts ';' ;
111

    
112
listen_opts:
113
   /* Nothing */
114
 | listen_opts listen_opt
115
 ;
116

    
117
listen_opt: 
118
   ADDRESS ipa { new_config->listen_bgp_addr = $2; }
119
 | PORT expr { new_config->listen_bgp_port = $2; }
120
 | V6ONLY { new_config->listen_bgp_flags = 0; }
121
 | DUAL { new_config->listen_bgp_flags = 1; }
122
 ;
123

    
124

    
125
CF_ADDTO(conf, gr_opts)
126

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

    
129

    
130
/* Creation of routing tables */
131

    
132
tab_sorted:
133
          { $$ = 0; }
134
 | SORTED { $$ = 1; }
135
 ;
136

    
137
CF_ADDTO(conf, newtab)
138

    
139
newtab: TABLE SYM tab_sorted {
140
   struct rtable_config *cf;
141
   cf = rt_new_table($2);
142
   cf->sorted = $3;
143
   }
144
 ;
145

    
146
CF_ADDTO(conf, roa_table)
147

    
148
roa_table_start: ROA TABLE SYM {
149
  this_roa_table = roa_new_table_config($3);
150
};
151

    
152
roa_table_opts:
153
   /* empty */
154
 | roa_table_opts ROA prefix MAX NUM AS NUM ';' {
155
     roa_add_item_config(this_roa_table, $3.addr, $3.len, $5, $7);
156
   }
157
 ;
158

    
159
roa_table:
160
   roa_table_start
161
 | roa_table_start '{' roa_table_opts '}'
162
 ;
163

    
164
/* Definition of protocols */
165

    
166
CF_ADDTO(conf, proto)
167

    
168
proto_start:
169
   PROTOCOL { $$ = SYM_PROTO; }
170
 | TEMPLATE { $$ = SYM_TEMPLATE; }
171
 ;
172

    
173
proto_name:
174
   /* EMPTY */ {
175
     struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
176
     s->class = this_proto->class;
177
     s->def = this_proto;
178
     this_proto->name = s->name;
179
     }
180
 | SYM {
181
     cf_define_symbol($1, this_proto->class, this_proto);
182
     this_proto->name = $1->name;
183
   }
184
 | SYM FROM SYM {
185
     if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected");
186

    
187
     cf_define_symbol($1, this_proto->class, this_proto);
188
     this_proto->name = $1->name;
189

    
190
     proto_copy_config(this_proto, $3->def);
191
   }
192
 ;
193

    
194
proto_item:
195
   /* EMPTY */
196
 | PREFERENCE expr {
197
     if ($2 < 0 || $2 > 0xFFFF) cf_error("Invalid preference");
198
     this_proto->preference = $2;
199
   }
200
 | DISABLED bool { this_proto->disabled = $2; }
201
 | DEBUG debug_mask { this_proto->debug = $2; }
202
 | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
203
 | IMPORT imexport { this_proto->in_filter = $2; }
204
 | EXPORT imexport { this_proto->out_filter = $2; }
205
 | RECEIVE LIMIT limit_spec { this_proto->rx_limit = $3; }
206
 | IMPORT LIMIT limit_spec { this_proto->in_limit = $3; }
207
 | EXPORT LIMIT limit_spec { this_proto->out_limit = $3; }
208
 | IMPORT KEEP FILTERED bool { this_proto->in_keep_filtered = $4; }
209
 | TABLE rtable { this_proto->table = $2; }
210
 | ROUTER ID idval { this_proto->router_id = $3; }
211
 | DESCRIPTION TEXT { this_proto->dsc = $2; }
212
 ;
213

    
214
imexport:
215
   FILTER filter { $$ = $2; }
216
 | where_filter
217
 | ALL { $$ = FILTER_ACCEPT; }
218
 | NONE { $$ = FILTER_REJECT; }
219
 ;
220

    
221
limit_action:
222
   /* default */ { $$ = PLA_DISABLE; }
223
 | ACTION WARN { $$ = PLA_WARN; }
224
 | ACTION BLOCK { $$ = PLA_BLOCK; }
225
 | ACTION RESTART { $$ = PLA_RESTART; }
226
 | ACTION DISABLE { $$ = PLA_DISABLE; }
227
 ;
228

    
229
limit_spec:
230
   expr limit_action {
231
     struct proto_limit *l = cfg_allocz(sizeof(struct proto_limit));
232
     l->limit = $1;
233
     l->action = $2;
234
     $$ = l;
235
   }
236
 | OFF { $$ = NULL; }
237
 ;
238

    
239
rtable:
240
   SYM {
241
     if ($1->class != SYM_TABLE) cf_error("Table name expected");
242
     $$ = $1->def;
243
   }
244
 ;
245

    
246
CF_ADDTO(conf, debug_default)
247

    
248
debug_default:
249
   DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
250
 | DEBUG COMMANDS expr { new_config->cli_debug = $3; }
251
 ;
252

    
253
/* MRTDUMP PROTOCOLS is in systep/unix/config.Y */
254

    
255
/* Interface patterns */
256

    
257
iface_patt_node_init:
258
   /* EMPTY */ {
259
     struct iface_patt_node *ipn = cfg_allocz(sizeof(struct iface_patt_node));
260
     add_tail(&this_ipatt->ipn_list, NODE ipn);
261
     this_ipn = ipn;
262
   }
263
 ;
264

    
265
iface_patt_node_body:
266
   TEXT { this_ipn->pattern = $1; this_ipn->prefix = IPA_NONE; this_ipn->pxlen = 0; }
267
 | prefix_or_ipa { this_ipn->pattern = NULL; this_ipn->prefix = $1.addr; this_ipn->pxlen = $1.len; }
268
 | TEXT prefix_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2.addr; this_ipn->pxlen = $2.len; }
269
 ;
270

    
271
iface_negate:
272
       { this_ipn->positive = 1; }
273
 | '-' { this_ipn->positive = 0; }
274
 ;
275

    
276
iface_patt_node:
277
   iface_patt_node_init iface_negate iface_patt_node_body 
278
 ;
279

    
280

    
281
iface_patt_list:
282
   iface_patt_node
283
 | iface_patt_list ',' iface_patt_node
284
 ;
285

    
286
/* For name/mask-only iface patterns */
287
iface_patt_list_nopx: iface_patt_list { iface_patt_check(); }
288

    
289
iface_patt_init: {
290
   /* Generic this_ipatt init */
291
   this_ipatt = cfg_allocz(sizeof(struct iface_patt));
292
   init_list(&this_ipatt->ipn_list);
293
 }
294
 ;
295

    
296
iface_patt:
297
   iface_patt_init iface_patt_list
298
 ;
299

    
300
tos:
301
   CLASS expr { $$ = $2 & 0xfc;        if (($2 < 0) || ($2 > 255)) cf_error("TX class must be in range 0-255"); }
302
 | DSCP expr  { $$ = ($2 & 0x3f) << 2; if (($2 < 0) || ($2 > 63))  cf_error("TX DSCP must be in range 0-63"); }
303
 ;
304

    
305
/* Direct device route protocol */
306

    
307
CF_ADDTO(proto, dev_proto '}')
308

    
309
dev_proto_start: proto_start DIRECT {
310
     this_proto = proto_config_new(&proto_device, sizeof(struct rt_dev_config), $1);
311
     init_list(&DIRECT_CFG->iface_list);
312
   }
313
 ;
314

    
315
dev_proto:
316
   dev_proto_start proto_name '{'
317
 | dev_proto proto_item ';'
318
 | dev_proto dev_iface_patt ';'
319
 ;
320

    
321
dev_iface_init:
322
   /* EMPTY */ {
323
     this_ipatt = cfg_allocz(sizeof(struct iface_patt));
324
     add_tail(&DIRECT_CFG->iface_list, NODE this_ipatt);
325
     init_list(&this_ipatt->ipn_list);
326
   }
327
 ;
328

    
329
dev_iface_patt:
330
   INTERFACE dev_iface_init iface_patt_list
331
 ;
332

    
333
/* Debug flags */
334

    
335
debug_mask:
336
   ALL { $$ = ~0; }
337
 | OFF { $$ = 0; }
338
 | '{' debug_list '}' { $$ = $2; }
339
 ;
340

    
341
debug_list:
342
   debug_flag
343
 | debug_list ',' debug_flag { $$ = $1 | $3; }
344
 ;
345

    
346
debug_flag:
347
   STATES	{ $$ = D_STATES; }
348
 | ROUTES	{ $$ = D_ROUTES; }
349
 | FILTERS	{ $$ = D_FILTERS; }
350
 | INTERFACES	{ $$ = D_IFACES; }
351
 | EVENTS	{ $$ = D_EVENTS; }
352
 | PACKETS	{ $$ = D_PACKETS; }
353
 ;
354

    
355
/* MRTDump flags */
356

    
357
mrtdump_mask:
358
   ALL { $$ = ~0; }
359
 | OFF { $$ = 0; }
360
 | '{' mrtdump_list '}' { $$ = $2; }
361
 ;
362

    
363
mrtdump_list:
364
   mrtdump_flag
365
 | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; }
366
 ;
367

    
368
mrtdump_flag:
369
   STATES	{ $$ = MD_STATES; }
370
 | MESSAGES	{ $$ = MD_MESSAGES; }
371
 ;
372

    
373
/* Password lists */
374

    
375
password_list:
376
   PASSWORDS '{' password_items '}'
377
 | password_item
378
;
379

    
380
password_items: 
381
    /* empty */
382
  | password_item ';' password_items
383
;
384

    
385
password_item:
386
    password_item_begin '{' password_item_params '}'
387
  | password_item_begin
388
;
389

    
390
password_item_begin:
391
   PASSWORD TEXT {
392
     if (!this_p_list) {
393
     	this_p_list = cfg_alloc(sizeof(list));
394
     	init_list(this_p_list);
395
        password_id = 1;
396
     }
397
     this_p_item = cfg_alloc(sizeof (struct password_item));
398
     this_p_item->password = $2;
399
     this_p_item->genfrom = 0;
400
     this_p_item->gento = TIME_INFINITY;
401
     this_p_item->accfrom = 0;
402
     this_p_item->accto = TIME_INFINITY;
403
     this_p_item->id = password_id++;
404
     add_tail(this_p_list, &this_p_item->n);
405
   }
406
;
407

    
408
password_item_params:
409
   /* empty */ { } 
410
 | GENERATE FROM datetime ';' password_item_params { this_p_item->genfrom = $3; }
411
 | GENERATE TO datetime ';' password_item_params { this_p_item->gento = $3; }
412
 | ACCEPT FROM datetime ';' password_item_params { this_p_item->accfrom = $3; }
413
 | ACCEPT TO datetime ';' password_item_params { this_p_item->accto = $3; }
414
 | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 <= 0) cf_error("Password ID has to be greated than zero."); }
415
 ;
416

    
417

    
418

    
419
/* Core commands */
420
CF_CLI_HELP(SHOW, ..., [[Show status information]])
421

    
422
CF_CLI(SHOW STATUS,,, [[Show router status]])
423
{ cmd_show_status(); } ;
424

    
425
CF_CLI(SHOW MEMORY,,, [[Show memory usage]])
426
{ cmd_show_memory(); } ;
427

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

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

    
434
optsym:
435
   SYM
436
 | /* empty */ { $$ = NULL; }
437
 ;
438

    
439
CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
440
{ if_show(); } ;
441

    
442
CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
443
{ if_show_summary(); } ;
444

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

    
449
r_args:
450
   /* empty */ {
451
     $$ = cfg_allocz(sizeof(struct rt_show_data));
452
     $$->pxlen = 256;
453
     $$->filter = FILTER_ACCEPT;
454
   }
455
 | r_args prefix {
456
     $$ = $1;
457
     if ($$->pxlen != 256) cf_error("Only one prefix expected");
458
     $$->prefix = $2.addr;
459
     $$->pxlen = $2.len;
460
   }
461
 | r_args FOR prefix_or_ipa {
462
     $$ = $1;
463
     if ($$->pxlen != 256) cf_error("Only one prefix expected");
464
     $$->prefix = $3.addr;
465
     $$->pxlen = $3.len;
466
     $$->show_for = 1;
467
   }
468
 | r_args TABLE SYM {
469
     $$ = $1;
470
     if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name);
471
     $$->table = ((struct rtable_config *)$3->def)->table;
472
   }
473
 | r_args FILTER filter {
474
     $$ = $1;
475
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
476
     $$->filter = $3;
477
   }
478
 | r_args where_filter {
479
     $$ = $1;
480
     if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
481
     $$->filter = $2;
482
   }
483
 | r_args ALL {
484
     $$ = $1;
485
     $$->verbose = 1;
486
   }
487
 | r_args PRIMARY {
488
     $$ = $1;
489
     $$->primary_only = 1;
490
   }
491
 | r_args FILTERED {
492
     $$ = $1;
493
     $$->filtered = 1;
494
   }
495
 | r_args export_or_preexport SYM {
496
     struct proto_config *c = (struct proto_config *) $3->def;
497
     $$ = $1;
498
     if ($$->export_mode) cf_error("Protocol specified twice");
499
     if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
500
     $$->export_mode = $2;
501
     $$->primary_only = 1;
502
     $$->export_protocol = c->proto;
503
     $$->running_on_config = c->proto->cf->global;
504
   }
505
 | r_args PROTOCOL SYM {
506
     struct proto_config *c = (struct proto_config *) $3->def;
507
     $$ = $1;
508
     if ($$->show_protocol) cf_error("Protocol specified twice");
509
     if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
510
     $$->show_protocol = c->proto;
511
     $$->running_on_config = c->proto->cf->global;
512
   }
513
 | r_args STATS {
514
     $$ = $1;
515
     $$->stats = 1;
516
   }
517
 | r_args COUNT {
518
     $$ = $1;
519
     $$->stats = 2;
520
   }
521
 ;
522

    
523
export_or_preexport:
524
   PREEXPORT { $$ = 1; }
525
 | EXPORT { $$ = 2; }
526
 ;
527

    
528

    
529
CF_CLI_HELP(SHOW ROA, ..., [[Show ROA table]])
530
CF_CLI(SHOW ROA, roa_args, [<prefix> | in <prefix> | for <prefix>] [as <num>] [table <t>], [[Show ROA table]])
531
{ roa_show($3); } ;
532

    
533
roa_args:
534
   /* empty */ {
535
     $$ = cfg_allocz(sizeof(struct roa_show_data));
536
     $$->mode = ROA_SHOW_ALL;
537
     $$->table = roa_table_default;
538
     if (roa_table_default == NULL)
539
       cf_error("No ROA table defined");
540
   }
541
 | roa_args roa_mode prefix {
542
     $$ = $1;
543
     if ($$->mode != ROA_SHOW_ALL) cf_error("Only one prefix expected");
544
     $$->prefix = $3.addr;
545
     $$->pxlen = $3.len;
546
     $$->mode = $2;
547
   }
548
 | roa_args AS NUM {
549
     $$ = $1;
550
     $$->asn = $3;
551
   }
552
 | roa_args TABLE SYM {
553
     $$ = $1;
554
     if ($3->class != SYM_ROA) cf_error("%s is not a ROA table", $3->name);
555
     $$->table = ((struct roa_table_config *)$3->def)->table;
556
   }
557
 ;
558

    
559
roa_mode:
560
       { $$ = ROA_SHOW_PX; }
561
 | IN  { $$ = ROA_SHOW_IN; }
562
 | FOR { $$ = ROA_SHOW_FOR; }
563
 ;
564

    
565

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

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

    
583

    
584
roa_table_arg:
585
   /* empty */ { 
586
     if (roa_table_default == NULL)
587
       cf_error("No ROA table defined");
588
     $$ = roa_table_default;
589
   }
590
 | TABLE SYM {
591
     if ($2->class != SYM_ROA)
592
       cf_error("%s is not a ROA table", $2->name);
593
     $$ = ((struct roa_table_config *)$2->def)->table;
594
   }
595
 ;
596

    
597
CF_CLI_HELP(ADD, roa ..., [[Add ROA record]])
598
CF_CLI(ADD ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Add ROA record]])
599
{
600
  if (! cli_access_restricted())
601
    { roa_add_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
602
};
603

    
604
CF_CLI_HELP(DELETE, roa ..., [[Delete ROA record]])
605
CF_CLI(DELETE ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Delete ROA record]])
606
{
607
  if (! cli_access_restricted())
608
    { roa_delete_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
609
};
610

    
611
CF_CLI_HELP(FLUSH, roa [table <name>], [[Removes all dynamic ROA records]])
612
CF_CLI(FLUSH ROA, roa_table_arg, [table <name>], [[Removes all dynamic ROA records]])
613
{
614
  if (! cli_access_restricted())
615
    { roa_flush($3, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
616
};
617

    
618

    
619
CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
620
CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
621
{ rdump(&root_pool); cli_msg(0, ""); } ;
622
CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
623
{ sk_dump_all(); cli_msg(0, ""); } ;
624
CF_CLI(DUMP INTERFACES,,, [[Dump interface information]])
625
{ if_dump_all(); cli_msg(0, ""); } ;
626
CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
627
{ neigh_dump_all(); cli_msg(0, ""); } ;
628
CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
629
{ rta_dump_all(); cli_msg(0, ""); } ;
630
CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
631
{ rt_dump_all(); cli_msg(0, ""); } ;
632
CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
633
{ protos_dump_all(); cli_msg(0, ""); } ;
634

    
635
CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]])
636
{ cmd_eval($2); } ;
637

    
638
CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]])
639
CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug | trace | info | remote | warning | error | auth }) [<buffer-size>], [[Control echoing of log messages]]) {
640
  cli_set_log_echo(this_cli, $2, $3);
641
  cli_msg(0, "");
642
} ;
643

    
644
echo_mask:
645
   ALL { $$ = ~0; }
646
 | OFF { $$ = 0; }
647
 | '{' log_mask_list '}' { $$ = $2; }
648
 ;
649

    
650
echo_size:
651
   /* empty */ { $$ = 4096; }
652
 | NUM {
653
     if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
654
     $$ = $1;
655
   }
656
 ;
657

    
658
CF_CLI(DISABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Disable protocol]])
659
{ proto_apply_cmd($2, proto_cmd_disable, 1, 0); } ;
660
CF_CLI(ENABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Enable protocol]])
661
{ proto_apply_cmd($2, proto_cmd_enable, 1, 0); } ;
662
CF_CLI(RESTART, proto_patt, <protocol> | \"<pattern>\" | all, [[Restart protocol]])
663
{ proto_apply_cmd($2, proto_cmd_restart, 1, 0); } ;
664
CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
665
{ proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ;
666
CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
667
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ;
668
CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
669
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ;
670

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

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

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

    
682
proto_patt:
683
   SYM  { $$.ptr = $1; $$.patt = 0; }
684
 | ALL  { $$.ptr = NULL; $$.patt = 1; }
685
 | TEXT { $$.ptr = $1; $$.patt = 1; }
686
 ;
687

    
688
proto_patt2:
689
   SYM  { $$.ptr = $1; $$.patt = 0; }
690
 |      { $$.ptr = NULL; $$.patt = 1; }
691
 | TEXT { $$.ptr = $1; $$.patt = 1; }
692
 ;
693

    
694
CF_ADDTO(dynamic_attr, IGP_METRIC
695
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); })
696

    
697

    
698
CF_CODE
699

    
700
CF_END