Statistics
| Branch: | Revision:

iof-bird-daemon / nest / config.Y @ 04632fd7

History | View | Annotate | Download (17.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 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->prefix.type)
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(IPV4, IPV6, VPN4, VPN6)
59
CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED)
60
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
61
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, NOEXPORT, GENERATE) /* ,ROA */
62
CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION, SORTED)
63
CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP)
64
CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS)
65

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

    
72
%type <i32> idval
73
%type <f> imexport
74
%type <r> rtable
75
%type <s> optsym
76
%type <ra> r_args
77
%type <sd> sym_args
78
%type <i> proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_mode limit_action table_type table_sorted tos
79
%type <ps> proto_patt proto_patt2
80
%type <g> limit_spec
81

    
82
CF_GRAMMAR
83

    
84
/* Setting of router ID */
85

    
86
CF_ADDTO(conf, rtrid)
87

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

    
93
idval:
94
   NUM { $$ = $1; }
95
 | '(' term ')' { $$ = f_eval_int($2); }
96
 | IP4 { $$ = ip4_to_u32($1); }
97
 | SYM {
98
     if ($1->class == (SYM_CONSTANT | T_INT) || $1->class == (SYM_CONSTANT | T_QUAD))
99
       $$ = SYM_VAL($1).i;
100
     else if (($1->class == (SYM_CONSTANT | T_IP)) && ipa_is_ip4(SYM_VAL($1).ip))
101
       $$ = ipa_to_u32(SYM_VAL($1).ip);
102
     else
103
       cf_error("Number of IPv4 address constant expected");
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
CF_ADDTO(conf, table)
133

    
134
table_type:
135
   /* empty */ { $$ = NET_IP4; }
136
 | IPV4 { $$ = NET_IP4; }
137
 | IPV6 { $$ = NET_IP6; }
138
 | VPN4 { $$ = NET_VPN4; }
139
 | VPN6 { $$ = NET_VPN6; }
140
 ;
141

    
142
table_sorted:
143
          { $$ = 0; }
144
 | SORTED { $$ = 1; }
145
 ;
146

    
147
table: table_type TABLE SYM table_sorted {
148
   struct rtable_config *cf;
149
   cf = rt_new_table($3, $1);
150
   cf->sorted = $4;
151
   }
152
 ;
153

    
154
/* Definition of protocols */
155

    
156
CF_ADDTO(conf, proto)
157

    
158
proto_start:
159
   PROTOCOL { $$ = SYM_PROTO; }
160
 | TEMPLATE { $$ = SYM_TEMPLATE; }
161
 ;
162

    
163
proto_name:
164
   /* EMPTY */ {
165
     struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
166
     s->class = this_proto->class;
167
     s->def = this_proto;
168
     this_proto->name = s->name;
169
     }
170
 | SYM {
171
     cf_define_symbol($1, this_proto->class, this_proto);
172
     this_proto->name = $1->name;
173
   }
174
 | FROM SYM {
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
     if (($2->class != SYM_TEMPLATE) && ($2->class != SYM_PROTO)) cf_error("Template or protocol name expected");
181
     proto_copy_config(this_proto, $2->def);
182
   }
183
 | SYM FROM SYM {
184
     cf_define_symbol($1, this_proto->class, this_proto);
185
     this_proto->name = $1->name;
186

    
187
     if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected");
188
     proto_copy_config(this_proto, $3->def);
189
   }
190
 ;
191

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

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

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

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

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

    
244
CF_ADDTO(conf, debug_default)
245

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

    
251
/* MRTDUMP PROTOCOLS is in systep/unix/config.Y */
252

    
253
/* Interface patterns */
254

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

    
263
iface_patt_node_body:
264
   TEXT { this_ipn->pattern = $1; /* this_ipn->prefix stays zero */ }
265
 | opttext net_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2; }
266
 ;
267

    
268
iface_negate:
269
       { this_ipn->positive = 1; }
270
 | '-' { this_ipn->positive = 0; }
271
 ;
272

    
273
iface_patt_node:
274
   iface_patt_node_init iface_negate iface_patt_node_body
275
 ;
276

    
277

    
278
iface_patt_list:
279
   iface_patt_node
280
 | iface_patt_list ',' iface_patt_node
281
 ;
282

    
283
/* For name/mask-only iface patterns */
284
iface_patt_list_nopx: iface_patt_list { iface_patt_check(); }
285

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

    
293
iface_patt:
294
   iface_patt_init iface_patt_list
295
 ;
296

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

    
302
/* Direct device route protocol */
303

    
304
CF_ADDTO(proto, dev_proto '}')
305

    
306
dev_proto_start: proto_start DIRECT {
307
     this_proto = proto_config_new(&proto_device, $1);
308
     init_list(&DIRECT_CFG->iface_list);
309
   }
310
 ;
311

    
312
dev_proto:
313
   dev_proto_start proto_name '{'
314
 | dev_proto proto_item ';'
315
 | dev_proto dev_iface_patt ';'
316
 ;
317

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

    
326
dev_iface_patt:
327
   INTERFACE dev_iface_init iface_patt_list
328
 ;
329

    
330
/* Debug flags */
331

    
332
debug_mask:
333
   ALL { $$ = ~0; }
334
 | OFF { $$ = 0; }
335
 | '{' debug_list '}' { $$ = $2; }
336
 ;
337

    
338
debug_list:
339
   debug_flag
340
 | debug_list ',' debug_flag { $$ = $1 | $3; }
341
 ;
342

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

    
352
/* MRTDump flags */
353

    
354
mrtdump_mask:
355
   ALL { $$ = ~0; }
356
 | OFF { $$ = 0; }
357
 | '{' mrtdump_list '}' { $$ = $2; }
358
 ;
359

    
360
mrtdump_list:
361
   mrtdump_flag
362
 | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; }
363
 ;
364

    
365
mrtdump_flag:
366
   STATES	{ $$ = MD_STATES; }
367
 | MESSAGES	{ $$ = MD_MESSAGES; }
368
 ;
369

    
370
/* Password lists */
371

    
372
password_list:
373
   PASSWORDS '{' password_items '}'
374
 | password_item
375
;
376

    
377
password_items: 
378
    /* empty */
379
  | password_item ';' password_items
380
;
381

    
382
password_item:
383
    password_item_begin '{' password_item_params '}'
384
  | password_item_begin
385
;
386

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

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

    
414

    
415

    
416
/* Core commands */
417
CF_CLI_HELP(SHOW, ..., [[Show status information]])
418

    
419
CF_CLI(SHOW STATUS,,, [[Show router status]])
420
{ cmd_show_status(); } ;
421

    
422
CF_CLI(SHOW MEMORY,,, [[Show memory usage]])
423
{ cmd_show_memory(); } ;
424

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

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

    
431
optsym:
432
   SYM
433
 | /* empty */ { $$ = NULL; }
434
 ;
435

    
436
CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
437
{ if_show(); } ;
438

    
439
CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
440
{ if_show_summary(); } ;
441

    
442
CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
443
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]])
444
{ rt_show($3); } ;
445

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

    
517
export_mode:
518
   PREEXPORT	{ $$ = RSEM_PREEXPORT; }
519
 | EXPORT	{ $$ = RSEM_EXPORT; }
520
 | NOEXPORT	{ $$ = RSEM_NOEXPORT; }
521
 ;
522

    
523

    
524
CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]])
525
CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|<symbol>], [[Show all known symbolic names]])
526
{ cmd_show_symbols($3); } ;
527

    
528
sym_args:
529
   /* empty */ {
530
     $$ = cfg_allocz(sizeof(struct sym_show_data));
531
   }
532
 | sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; }
533
 | sym_args FUNCTION { $$ = $1; $$->type = SYM_FUNCTION; }
534
 | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
535
 | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; }
536
 | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; }
537
 | sym_args SYM { $$ = $1; $$->sym = $2; }
538
 ;
539

    
540

    
541
CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
542
CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
543
{ rdump(&root_pool); cli_msg(0, ""); } ;
544
CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
545
{ sk_dump_all(); cli_msg(0, ""); } ;
546
CF_CLI(DUMP EVENTS,,, [[Dump event log]])
547
{ io_log_dump(); cli_msg(0, ""); } ;
548
CF_CLI(DUMP INTERFACES,,, [[Dump interface information]])
549
{ if_dump_all(); cli_msg(0, ""); } ;
550
CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
551
{ neigh_dump_all(); cli_msg(0, ""); } ;
552
CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
553
{ rta_dump_all(); cli_msg(0, ""); } ;
554
CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
555
{ rt_dump_all(); cli_msg(0, ""); } ;
556
CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
557
{ protos_dump_all(); cli_msg(0, ""); } ;
558

    
559
CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]])
560
{ cmd_eval($2); } ;
561

    
562
CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]])
563
CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug | trace | info | remote | warning | error | auth }) [<buffer-size>], [[Control echoing of log messages]]) {
564
  cli_set_log_echo(this_cli, $2, $3);
565
  cli_msg(0, "");
566
} ;
567

    
568
echo_mask:
569
   ALL { $$ = ~0; }
570
 | OFF { $$ = 0; }
571
 | '{' log_mask_list '}' { $$ = $2; }
572
 ;
573

    
574
echo_size:
575
   /* empty */ { $$ = 4096; }
576
 | NUM {
577
     if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
578
     $$ = $1;
579
   }
580
 ;
581

    
582
CF_CLI(DISABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Disable protocol]])
583
{ proto_apply_cmd($2, proto_cmd_disable, 1, 0); } ;
584
CF_CLI(ENABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Enable protocol]])
585
{ proto_apply_cmd($2, proto_cmd_enable, 1, 0); } ;
586
CF_CLI(RESTART, proto_patt, <protocol> | \"<pattern>\" | all, [[Restart protocol]])
587
{ proto_apply_cmd($2, proto_cmd_restart, 1, 0); } ;
588
CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
589
{ proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ;
590
CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
591
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ;
592
CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
593
{ proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ;
594

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

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

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

    
606
proto_patt:
607
   SYM  { $$.ptr = $1; $$.patt = 0; }
608
 | ALL  { $$.ptr = NULL; $$.patt = 1; }
609
 | TEXT { $$.ptr = $1; $$.patt = 1; }
610
 ;
611

    
612
proto_patt2:
613
   SYM  { $$.ptr = $1; $$.patt = 0; }
614
 |      { $$.ptr = NULL; $$.patt = 1; }
615
 | TEXT { $$.ptr = $1; $$.patt = 1; }
616
 ;
617

    
618
CF_ADDTO(dynamic_attr, IGP_METRIC
619
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); })
620

    
621

    
622
CF_CODE
623

    
624
CF_END