Revision 758458be filter/config.Y

View differences:

filter/config.Y
42 42
%type <f> filter filter_body where_filter
43 43
%type <i> type break_command pair
44 44
%type <e> set_item set_items switch_body
45
%type <v> set_atom prefix prefix_s ipa
45
%type <v> set_atom fprefix fprefix_s ipa
46 46
%type <s> decls declsn one_decl function_params 
47 47
%type <h> bgp_path
48 48
%type <i> bgp_one
......
212 212
/*
213 213
 * Complex types, their bison value is struct f_val
214 214
 */
215
prefix_s:
216
   IPA '/' NUM { $$.type = T_PREFIX; $$.val.px.ip = $1; $$.val.px.len = $3; if (ipa_nonzero(ipa_and($$.val.px.ip, ipa_not(ipa_mkmask($$.val.px.len))))) cf_error( "%I/%d is not really prefix\n", $$.val.px.ip, $$.val.px.len ); }
215
fprefix_s:
216
   IPA '/' NUM {
217
     if (!ip_is_prefix($1, $3)) cf_error("Invalid network prefix: %I/%d", $1, $3);
218
     $$.type = T_PREFIX; $$.val.px.ip = $1; $$.val.px.len = $3;
219
   }
217 220
 ;
218 221

  
219
prefix:
220
   prefix_s { $$ = $1; }
221
 | prefix_s '+' { $$ = $1; $$.val.px.len |= LEN_PLUS; }
222
 | prefix_s '-' { $$ = $1; $$.val.px.len |= LEN_MINUS; }
223
 | prefix_s '{' NUM ',' NUM '}' { $$ = $1; $$.val.px.len |= LEN_RANGE | ($3 << 16) | ($5 << 8); }
222
fprefix:
223
   fprefix_s { $$ = $1; }
224
 | fprefix_s '+' { $$ = $1; $$.val.px.len |= LEN_PLUS; }
225
 | fprefix_s '-' { $$ = $1; $$.val.px.len |= LEN_MINUS; }
226
 | fprefix_s '{' NUM ',' NUM '}' { $$ = $1; $$.val.px.len |= LEN_RANGE | ($3 << 16) | ($5 << 8); }
224 227
 ;
225 228

  
226 229
ipa:
......
231 234
   NUM  { $$.type = T_INT; $$.val.i = $1; }
232 235
 | pair { $$.type = T_PAIR; $$.val.i = $1; }
233 236
 | ipa  { $$ = $1; }
234
 | prefix { $$ = $1; }
237
 | fprefix { $$ = $1; }
235 238
 ; 
236 239

  
237 240
set_item:
......
291 294
 | TEXT   { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_STRING; $$->a2.p = $1; }
292 295
 | pair   { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PAIR;  $$->a2.i = $1; }
293 296
 | ipa	   { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
294
 | prefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
297
 | fprefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
295 298
 | '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
296 299
 | ENUM	  { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
297 300
 | '/' bgp_path '/' { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; val->type = T_PATH_MASK; val->val.path_mask = $2; $$->a1.p = val; }

Also available in: Unified diff