mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
Added read-only access to all required fields in rta.
This commit is contained in:
parent
2d6627a7a5
commit
26c09e1d25
@ -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; }
|
||||
|
@ -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 {
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user