summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2000-05-30 12:42:39 +0200
committerPavel Machek <pavel@ucw.cz>2000-05-30 12:42:39 +0200
commit26c09e1d25abff7fb88959dc6fbaa7ae5eb295ad (patch)
tree2a309ee61845f91be7f9f4d58d88246fb64f1278
parent2d6627a7a5e52f8314520f9aefd82040e24849cb (diff)
downloadbird-26c09e1d25abff7fb88959dc6fbaa7ae5eb295ad.tar
bird-26c09e1d25abff7fb88959dc6fbaa7ae5eb295ad.zip
Added read-only access to all required fields in rta.
-rw-r--r--filter/config.Y22
-rw-r--r--filter/filter.c20
-rw-r--r--filter/filter.h3
-rw-r--r--nest/config.Y3
4 files changed, 27 insertions, 21 deletions
diff --git a/filter/config.Y b/filter/config.Y
index f72dc83..37c0f3f 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 246fbf6..e69e9e1 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 1039c6f..04a2623 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 2918d25..9454e62 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