Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (4.26 KB)

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

    
9
CF_HDR
10

    
11
static struct proto_config *this_proto;
12
static struct iface_patt *this_ipatt;
13

    
14
#include "nest/rt-dev.h"
15
#include "nest/password.h"
16

    
17
CF_DECLS
18

    
19
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
20
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE)
21
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID)
22

    
23
%type <i32> idval
24
%type <f> imexport
25
%type <r> rtable
26
%type <p> password_list password_begin
27

    
28
CF_GRAMMAR
29

    
30
/* Setting of router ID */
31

    
32
CF_ADDTO(conf, rtrid)
33

    
34
rtrid: ROUTER ID idval ';' {
35
   new_config->router_id = $3;
36
   }
37
 ;
38

    
39
idval:
40
   NUM { $$ = $1; }
41
 | RTRID
42
 | IPA {
43
#ifndef IPV6
44
     $$ = ipa_to_u32($1);
45
#else
46
     cf_error("Router IDs must be entered as hexadecimal numbers in IPv6 version");
47
#endif
48
   }
49
 ;
50

    
51
/* Creation of routing tables */
52

    
53
CF_ADDTO(conf, newtab)
54

    
55
newtab: TABLE SYM {
56
     struct rtable_config *c = cfg_allocz(sizeof(struct rtable_config));
57
     struct symbol *s = $2;
58
     cf_define_symbol(s, SYM_TABLE, c);
59
     c->name = s->name;
60
     add_tail(&new_config->tables, &c->n);
61
   }
62
 ;
63

    
64
/* Definition of protocols */
65

    
66
CF_ADDTO(conf, proto)
67

    
68
proto_start: PROTOCOL
69

    
70
proto_name:
71
   /* EMPTY */ {
72
     struct symbol *s = cf_default_name(this_proto->proto->name, &this_proto->proto->name_counter);
73
     s->class = SYM_PROTO;
74
     s->def = this_proto;
75
     this_proto->name = s->name;
76
     }
77
 | SYM {
78
     cf_define_symbol($1, SYM_PROTO, this_proto);
79
     this_proto->name = $1->name;
80
   }
81
 ;
82

    
83
proto_item:
84
   /* EMPTY */
85
 | PREFERENCE expr {
86
     if ($2 < 0 || $2 > 255) cf_error("Invalid preference");
87
     this_proto->preference = $2;
88
   }
89
 | DISABLED { this_proto->disabled = 1; }
90
 | DEBUG expr { this_proto->debug = $2; }
91
 | DEBUG ALL { this_proto->debug = ~0; }
92
 | DEBUG OFF { this_proto->debug = 0; }
93
 | IMPORT imexport { this_proto->in_filter = $2; }
94
 | EXPORT imexport { this_proto->out_filter = $2; }
95
 | TABLE rtable { this_proto->table = $2; }
96
 ;
97

    
98
imexport:
99
   FILTER filter { $$ = $2; }
100
 | ALL { $$ = FILTER_ACCEPT; }
101
 | NONE { $$ = FILTER_REJECT; }
102
 ;
103

    
104
rtable:
105
   SYM {
106
     if ($1->class != SYM_TABLE) cf_error("Table name expected");
107
     $$ = $1->def;
108
   }
109
 ;
110

    
111
/* Interface patterns */
112

    
113
iface_patt:
114
   TEXT { this_ipatt->pattern = $1; this_ipatt->prefix = IPA_NONE; this_ipatt->pxlen = 0; }
115
 | IPA pxlen { this_ipatt->pattern = NULL; this_ipatt->prefix = $1; this_ipatt->pxlen = $2; }
116
 | TEXT IPA pxlen { this_ipatt->pattern = $1; this_ipatt->prefix = $2; this_ipatt->pxlen = $3; }
117
 ;
118

    
119
/* Direct device route protocol */
120

    
121
CF_ADDTO(proto, dev_proto '}')
122

    
123
dev_proto_start: proto_start DIRECT {
124
     struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config));
125
     this_proto = &p->c;
126
     p->c.preference = DEF_PREF_DIRECT;
127
     init_list(&p->iface_list);
128
   }
129
 ;
130

    
131
dev_proto:
132
   dev_proto_start proto_name '{'
133
 | dev_proto proto_item ';'
134
 | dev_proto dev_iface_list ';'
135
 ;
136

    
137
dev_iface_entry_init:
138
   /* EMPTY */ {
139
     struct rt_dev_config *p = (void *) this_proto;
140
     struct iface_patt *k = cfg_allocz(sizeof(struct iface_patt));
141
     add_tail(&p->iface_list, &k->n);
142
     this_ipatt = k;
143
   }
144
 ;
145

    
146
dev_iface_entry:
147
   dev_iface_entry_init iface_patt
148
 ;
149

    
150
dev_iface_list:
151
   INTERFACE dev_iface_entry
152
 | dev_iface_list ',' dev_iface_entry
153
 ;
154

    
155
/* Password lists */
156

    
157
password_begin: 
158
   PASSWORD TEXT {
159
     last_password_item = cfg_alloc(sizeof (struct password_item));
160
     last_password_item->password = $2;
161
     last_password_item->from = 0;
162
     last_password_item->to = 2000000000;
163
     last_password_item->id = 0;
164
     last_password_item->next = NULL;
165
     $$=last_password_item;
166
   }
167
 ;
168

    
169
password_items:
170
   /* empty */ { } 
171
 | FROM datetime password_items { last_password_item->from = $2; }
172
 | TO datetime password_items { last_password_item->to = $2; }
173
 | PASSIVE datetime password_items { last_password_item->passive = $2; }
174
 | ID NUM password_items { last_password_item->id = $2; }
175
 ;
176

    
177
password_list: 
178
   /* empty */ { $$ = NULL; } 
179
 | password_begin password_items ';' password_list {
180
     $1->next = $4;
181
     $$ = $1;
182
   }
183
 ;
184

    
185
/* Core commands */
186

    
187
CF_CLI(TEST LEDS, <N>, [[Flashes each LED <N> times]]) NUM { cli_msg(0, "%d", $3); } ;
188
CF_CLI(TEST, 1, 2) { cli_msg(0, "OK"); }
189

    
190
CF_CODE
191

    
192
CF_END