Dynamic attributes are now declared in per-protocol grammar files instead
of filter/config.Y. Bird now compiles even if you disable RIP. Removed RTA and IMPOSSIBLE tokens (unused). Removed superfluous comment in filter.h. I've tried to do my best, but Pavel, please check these changes.
This commit is contained in:
parent
2ca3d9a8fc
commit
db1326aa5e
4 changed files with 26 additions and 13 deletions
|
@ -34,16 +34,15 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST, UNSET, RETURN,
|
||||||
INT, BOOL, IP, PREFIX, PAIR, SET, STRING,
|
INT, BOOL, IP, PREFIX, PAIR, SET, STRING,
|
||||||
IF, THEN, ELSE, CASE,
|
IF, THEN, ELSE, CASE,
|
||||||
TRUE, FALSE,
|
TRUE, FALSE,
|
||||||
RTA, FROM, GW, NET, MASK, RIP_METRIC, RIP_TAG, SOURCE,
|
FROM, GW, NET, MASK, SOURCE,
|
||||||
LEN,
|
LEN,
|
||||||
DEFINED,
|
DEFINED,
|
||||||
IMPOSSIBLE,
|
|
||||||
FILTER, WHERE)
|
FILTER, WHERE)
|
||||||
|
|
||||||
%nonassoc THEN
|
%nonassoc THEN
|
||||||
%nonassoc ELSE
|
%nonassoc ELSE
|
||||||
|
|
||||||
%type <x> term block cmds cmd function_body constant print_one print_list var_list var_listn any_dynamic function_call
|
%type <x> term block cmds cmd function_body constant print_one print_list var_list var_listn dynamic_attr function_call
|
||||||
%type <f> filter filter_body where_filter
|
%type <f> filter filter_body where_filter
|
||||||
%type <i> type break_command pair
|
%type <i> type break_command pair
|
||||||
%type <e> set_item set_items switch_body
|
%type <e> set_item set_items switch_body
|
||||||
|
@ -268,10 +267,12 @@ constant:
|
||||||
| ENUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
|
| ENUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
|
||||||
;
|
;
|
||||||
|
|
||||||
any_dynamic:
|
/*
|
||||||
RIP_METRIC { $$ = f_new_inst(); $$->aux = T_INT; $$->a2.i = EA_RIP_METRIC;}
|
* Maybe there are no dynamic attributes defined by protocols.
|
||||||
| RIP_TAG { $$ = f_new_inst(); $$->aux = T_INT; $$->a2.i = EA_RIP_TAG; }
|
* For such cases, we force the dynamic_attr list to contain
|
||||||
;
|
* at least an invalid token, so it's syntantically correct.
|
||||||
|
*/
|
||||||
|
CF_ADDTO(dynamic_attr, INVALID_TOKEN { $$ = NULL; })
|
||||||
|
|
||||||
rtadot: /* EMPTY, we are not permitted RTA. prefix */
|
rtadot: /* EMPTY, we are not permitted RTA. prefix */
|
||||||
;
|
;
|
||||||
|
@ -334,7 +335,7 @@ term:
|
||||||
| rtadot NET { $$ = f_new_inst(); $$->code = 'a'; $$->aux = T_PREFIX; $$->a2.i = 0x12345678; }
|
| rtadot NET { $$ = f_new_inst(); $$->code = 'a'; $$->aux = T_PREFIX; $$->a2.i = 0x12345678; }
|
||||||
| rtadot SOURCE { $$ = f_new_inst(); $$->code = 'a'; $$->aux = T_ENUM_RTS; $$->a2.i = OFFSETOF(struct rta, gw); }
|
| rtadot SOURCE { $$ = f_new_inst(); $$->code = 'a'; $$->aux = T_ENUM_RTS; $$->a2.i = OFFSETOF(struct rta, gw); }
|
||||||
|
|
||||||
| rtadot any_dynamic { $$ = $2; $$->code = P('e','a'); }
|
| rtadot dynamic_attr { $$ = $2; $$->code = P('e','a'); }
|
||||||
|
|
||||||
| term '.' IP { $$ = f_new_inst(); $$->code = P('c','p'); $$->a1.p = $1; $$->aux = T_IP; }
|
| term '.' IP { $$ = f_new_inst(); $$->code = P('c','p'); $$->a1.p = $1; $$->aux = T_IP; }
|
||||||
| term '.' LEN { $$ = f_new_inst(); $$->code = P('c','p'); $$->a1.p = $1; $$->aux = T_INT; }
|
| term '.' LEN { $$ = f_new_inst(); $$->code = P('c','p'); $$->a1.p = $1; $$->aux = T_INT; }
|
||||||
|
@ -416,12 +417,12 @@ cmd:
|
||||||
$$->code = 'r';
|
$$->code = 'r';
|
||||||
$$->a1.p = $2;
|
$$->a1.p = $2;
|
||||||
}
|
}
|
||||||
| rtadot any_dynamic '=' term ';' {
|
| rtadot dynamic_attr '=' term ';' {
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
$$->code = P('e','S');
|
$$->code = P('e','S');
|
||||||
$$->a1.p = $4;
|
$$->a1.p = $4;
|
||||||
}
|
}
|
||||||
| UNSET '(' rtadot any_dynamic ')' ';' {
|
| UNSET '(' rtadot dynamic_attr ')' ';' {
|
||||||
$$ = $4;
|
$$ = $4;
|
||||||
$$->aux = T_VOID;
|
$$->aux = T_VOID;
|
||||||
$$->code = P('e','S');
|
$$->code = P('e','S');
|
||||||
|
|
|
@ -32,6 +32,15 @@ f_new_inst(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct f_inst *
|
||||||
|
f_new_dynamic_attr(int code)
|
||||||
|
{
|
||||||
|
struct f_inst *f = f_new_inst();
|
||||||
|
f->aux = T_INT;
|
||||||
|
f->a2.i = code;
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
filter_name(struct filter *filter)
|
filter_name(struct filter *filter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct filter {
|
||||||
|
|
||||||
void filters_postconfig(void);
|
void filters_postconfig(void);
|
||||||
struct f_inst *f_new_inst(void);
|
struct f_inst *f_new_inst(void);
|
||||||
|
struct f_inst *f_new_dynamic_attr(int code);
|
||||||
struct f_tree *f_new_tree(void);
|
struct f_tree *f_new_tree(void);
|
||||||
|
|
||||||
struct f_tree *build_tree(struct f_tree *);
|
struct f_tree *build_tree(struct f_tree *);
|
||||||
|
@ -121,6 +122,4 @@ struct f_tree {
|
||||||
|
|
||||||
#define NEW_F_VAL struct f_val * val; val = cfg_alloc(sizeof(struct f_val));
|
#define NEW_F_VAL struct f_val * val; val = cfg_alloc(sizeof(struct f_val));
|
||||||
|
|
||||||
/* Create pair from two letters */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,7 +25,8 @@ CF_DECLS
|
||||||
CF_KEYWORDS(RIP, INFINITY, METRIC, PORT, PERIOD, GARBAGETIME, PASSWORDS,
|
CF_KEYWORDS(RIP, INFINITY, METRIC, PORT, PERIOD, GARBAGETIME, PASSWORDS,
|
||||||
MODE, BROADCAST, QUIET, NOLISTEN, VERSION1,
|
MODE, BROADCAST, QUIET, NOLISTEN, VERSION1,
|
||||||
AUTHENTICATION, NONE, PLAINTEXT, MD5,
|
AUTHENTICATION, NONE, PLAINTEXT, MD5,
|
||||||
HONOUR, NEVER, NEIGHBOUR, ALWAYS)
|
HONOUR, NEVER, NEIGHBOUR, ALWAYS,
|
||||||
|
RIP_METRIC, RIP_TAG)
|
||||||
|
|
||||||
%type <i> rip_mode rip_auth
|
%type <i> rip_mode rip_auth
|
||||||
|
|
||||||
|
@ -97,6 +98,9 @@ rip_iface_list:
|
||||||
| rip_iface_list ',' rip_iface
|
| rip_iface_list ',' rip_iface
|
||||||
;
|
;
|
||||||
|
|
||||||
|
CF_ADDTO(dynamic_attr, RIP_METRIC { $$ = f_new_dynamic_attr(EA_RIP_METRIC); })
|
||||||
|
CF_ADDTO(dynamic_attr, RIP_TAG { $$ = f_new_dynamic_attr(EA_RIP_TAG); })
|
||||||
|
|
||||||
CF_CODE
|
CF_CODE
|
||||||
|
|
||||||
CF_END
|
CF_END
|
||||||
|
|
Loading…
Reference in a new issue