diff options
-rw-r--r-- | filter/config.Y | 22 | ||||
-rw-r--r-- | filter/filter.c | 20 | ||||
-rw-r--r-- | filter/filter.h | 3 | ||||
-rw-r--r-- | nest/config.Y | 3 |
4 files changed, 27 insertions, 21 deletions
diff --git a/filter/config.Y b/filter/config.Y index f72dc835..37c0f3f3 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -20,7 +20,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN, INT, BOOL, IP, PREFIX, PAIR, SET, STRING, BGPMASK, BGPPATH, CLIST, IF, THEN, ELSE, CASE, TRUE, FALSE, - FROM, GW, NET, MASK, SOURCE, + FROM, GW, NET, MASK, SOURCE, SCOPE, CAST, DEST, LEN, DEFINED, ADD, DELETE, CONTAINS, RESET, @@ -301,9 +301,6 @@ CF_ADDTO(dynamic_attr, INVALID_TOKEN { $$ = NULL; }) rtadot: /* EMPTY, we are not permitted RTA. prefix */ ; - - - function_call: SYM '(' var_list ')' { struct symbol *sym; @@ -329,19 +326,16 @@ function_call: static_attr: /* FIXME (maybe?) rta.from read/write */ - FROM { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, from); } + FROM { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, from); } -/* FIXME Gw read/write */ - | GW { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); } - | NET { $$ = f_new_inst(); $$->aux = T_PREFIX; $$->a2.i = 0x12345678; /* This is actually ok - T_PREFIX is special-cased. */ } - | SOURCE { $$ = f_new_inst(); $$->aux = T_ENUM_RTS; $$->a2.i = OFFSETOF(struct rta, source); } + | GW { $$ = f_new_inst(); $$->aux = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); } /* FIXME: want it read/write */ + | NET { $$ = f_new_inst(); $$->aux = T_PREFIX; $$->a2.i = 0x12345678; /* This is actually ok - T_PREFIX is special-cased. */ } + | SOURCE { $$ = f_new_inst(); $$->aux = T_ENUM_RTS; $$->a2.i = OFFSETOF(struct rta, source); } + | SCOPE { $$ = f_new_inst(); $$->aux = T_ENUM_SCOPE; $$->a2.i = OFFSETOF(struct rta, scope); } /* FIXME: want it read/write */ + | CAST { $$ = f_new_inst(); $$->aux = T_ENUM_RTC; $$->a2.i = OFFSETOF(struct rta, cast); } + | DEST { $$ = f_new_inst(); $$->aux = T_ENUM_RTD; $$->a2.i = OFFSETOF(struct rta, dest); } ; -/* FIXME rta.Scope - read/write */ -/* FIXME rta.Cast - read */ -/* FIXME rta.Dest - read */ - - term: '(' term ')' { $$ = $2; } | term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->a1.p = $1; $$->a2.p = $3; } diff --git a/filter/filter.c b/filter/filter.c index 246fbf67..e69e9e10 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -200,6 +200,18 @@ static struct ea_list **f_tmp_attrs; static int f_flags; static rta *f_rta_copy; +void +rta_cow(void) +{ + if (!f_rta_copy) { + f_rta_copy = lp_alloc(f_pool, sizeof(rta)); + memcpy(f_rta_copy, (*f_rte)->attrs, sizeof(rta)); + f_rta_copy->aflags = 0; + *f_rte = rte_cow(*f_rte); + (*f_rte)->attrs = f_rta_copy; + } +} + #define runtime(x) do { \ log( L_ERR "filters, line %d: %s", what->lineno, x); \ res.type = T_RETURN; \ @@ -477,13 +489,7 @@ interpret(struct f_inst *what) } if (!(what->aux & EAF_TEMP) && (!(f_flags & FF_FORCE_TMPATTR))) { - if (!f_rta_copy) { - f_rta_copy = lp_alloc(f_pool, sizeof(rta)); - memcpy(f_rta_copy, (*f_rte)->attrs, sizeof(rta)); - f_rta_copy->aflags = 0; - *f_rte = rte_cow(*f_rte); - (*f_rte)->attrs = f_rta_copy; - } + rta_cow(); l->next = f_rta_copy->eattrs; f_rta_copy->eattrs = l; } else { diff --git a/filter/filter.h b/filter/filter.h index 1039c6ff..04a26236 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -109,6 +109,9 @@ void val_print(struct f_val v); #define T_ENUM_RTS 0x30 #define T_ENUM_BGP_ORIGIN 0x31 +#define T_ENUM_SCOPE 0x32 +#define T_ENUM_RTC 0x33 +#define T_ENUM_RTD 0x34 /* new enums go here */ #define T_ENUM_EMPTY 0x3f /* Special hack for atomic_aggr */ diff --git a/nest/config.Y b/nest/config.Y index 2918d255..9454e622 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -26,6 +26,9 @@ CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS) CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE) +CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE) +CF_ENUM(T_ENUM_RTC, RTC_, UNICAST, BROADCAST, MULTICAST, ANYCAST) +CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT) %type <i32> idval %type <f> imexport |