Added read-only access to all required fields in rta.

This commit is contained in:
Pavel Machek 2000-05-30 10:42:39 +00:00
parent 2d6627a7a5
commit 26c09e1d25
4 changed files with 27 additions and 21 deletions

View file

@ -20,7 +20,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
INT, BOOL, IP, PREFIX, PAIR, SET, STRING, BGPMASK, BGPPATH, CLIST, INT, BOOL, IP, PREFIX, PAIR, SET, STRING, BGPMASK, BGPPATH, CLIST,
IF, THEN, ELSE, CASE, IF, THEN, ELSE, CASE,
TRUE, FALSE, TRUE, FALSE,
FROM, GW, NET, MASK, SOURCE, FROM, GW, NET, MASK, SOURCE, SCOPE, CAST, DEST,
LEN, LEN,
DEFINED, DEFINED,
ADD, DELETE, CONTAINS, RESET, ADD, DELETE, CONTAINS, RESET,
@ -301,9 +301,6 @@ CF_ADDTO(dynamic_attr, INVALID_TOKEN { $$ = NULL; })
rtadot: /* EMPTY, we are not permitted RTA. prefix */ rtadot: /* EMPTY, we are not permitted RTA. prefix */
; ;
function_call: function_call:
SYM '(' var_list ')' { SYM '(' var_list ')' {
struct symbol *sym; struct symbol *sym;
@ -331,17 +328,14 @@ static_attr:
/* FIXME (maybe?) rta.from read/write */ /* 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); } /* FIXME: want it 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. */ } | 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); } | 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:
'(' term ')' { $$ = $2; } '(' term ')' { $$ = $2; }
| term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->a1.p = $1; $$->a2.p = $3; } | term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->a1.p = $1; $$->a2.p = $3; }

View file

@ -200,6 +200,18 @@ static struct ea_list **f_tmp_attrs;
static int f_flags; static int f_flags;
static rta *f_rta_copy; 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 { \ #define runtime(x) do { \
log( L_ERR "filters, line %d: %s", what->lineno, x); \ log( L_ERR "filters, line %d: %s", what->lineno, x); \
res.type = T_RETURN; \ res.type = T_RETURN; \
@ -477,13 +489,7 @@ interpret(struct f_inst *what)
} }
if (!(what->aux & EAF_TEMP) && (!(f_flags & FF_FORCE_TMPATTR))) { if (!(what->aux & EAF_TEMP) && (!(f_flags & FF_FORCE_TMPATTR))) {
if (!f_rta_copy) { rta_cow();
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;
}
l->next = f_rta_copy->eattrs; l->next = f_rta_copy->eattrs;
f_rta_copy->eattrs = l; f_rta_copy->eattrs = l;
} else { } else {

View file

@ -109,6 +109,9 @@ void val_print(struct f_val v);
#define T_ENUM_RTS 0x30 #define T_ENUM_RTS 0x30
#define T_ENUM_BGP_ORIGIN 0x31 #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 */ /* new enums go here */
#define T_ENUM_EMPTY 0x3f /* Special hack for atomic_aggr */ #define T_ENUM_EMPTY 0x3f /* Special hack for atomic_aggr */

View file

@ -26,6 +26,9 @@ CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS)
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE) 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 <i32> idval
%type <f> imexport %type <f> imexport