Revision f4a60a9b nest/config.Y

View differences:

nest/config.Y
17 17
CF_DEFINES
18 18

  
19 19
static struct proto_config *this_proto;
20
static struct channel_config *this_channel;
20 21
static struct iface_patt *this_ipatt;
21 22
static struct iface_patt_node *this_ipn;
22 23
/* static struct roa_table_config *this_roa_table; */
......
49 50
  return rv;
50 51
}
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

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

  
54 64
CF_DECLS
......
76 86
%type <s> optsym
77 87
%type <ra> r_args
78 88
%type <sd> sym_args
79
%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
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
80 90
%type <ps> proto_patt proto_patt2
81
%type <g> limit_spec
91
%type <cc> channel_start proto_channel
92
%type <cl> limit_spec
82 93

  
83 94
CF_GRAMMAR
84 95

  
......
115 126
 | listen_opts listen_opt
116 127
 ;
117 128

  
118
listen_opt: 
129
listen_opt:
119 130
   ADDRESS ipa { new_config->listen_bgp_addr = $2; }
120 131
 | PORT expr { new_config->listen_bgp_port = $2; }
121 132
 | V6ONLY { new_config->listen_bgp_flags = 0; }
......
128 139
gr_opts: GRACEFUL RESTART WAIT expr ';' { new_config->gr_wait = $4; } ;
129 140

  
130 141

  
131
/* Creation of routing tables */
142
/* Network types (for tables, channels) */
132 143

  
133
CF_ADDTO(conf, table)
134

  
135
table_type:
136
   /* empty */ { $$ = NET_IP4; }
137
 | IPV4 { $$ = NET_IP4; }
144
net_type:
145
   IPV4 { $$ = NET_IP4; }
138 146
 | IPV6 { $$ = NET_IP6; }
139 147
 | VPN4 { $$ = NET_VPN4; }
140 148
 | VPN6 { $$ = NET_VPN6; }
......
142 150
 | ROA6 { $$ = NET_ROA6; }
143 151
 ;
144 152

  
153

  
154
/* Creation of routing tables */
155

  
156
CF_ADDTO(conf, table)
157

  
145 158
table_sorted:
146 159
          { $$ = 0; }
147 160
 | SORTED { $$ = 1; }
148 161
 ;
149 162

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

  
170

  
157 171
/* Definition of protocols */
158 172

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

  
161 175
proto_start:
162 176
   PROTOCOL { $$ = SYM_PROTO; }
......
194 208

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

  
215 267
imexport:
216 268
   FILTER filter { $$ = $2; }
217 269
 | where_filter
......
228 280
 ;
229 281

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

  
240
rtable:
241
   SYM {
242
     if ($1->class != SYM_TABLE) cf_error("Table name expected");
243
     $$ = $1->def;
244
   }
283
   expr limit_action { $$ = (struct channel_limit){ .limit = $1, $$.action = $2 }; }
284
 | OFF { $$ = (struct channel_limit){}; }
245 285
 ;
246 286

  
247 287
CF_ADDTO(conf, debug_default)
......
315 355
dev_proto:
316 356
   dev_proto_start proto_name '{'
317 357
 | dev_proto proto_item ';'
358
 | dev_proto proto_channel ';'
318 359
 | dev_proto dev_iface_patt ';'
319 360
 ;
320 361

  

Also available in: Unified diff