]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added read-only access to all required fields in rta.
authorPavel Machek <pavel@ucw.cz>
Tue, 30 May 2000 10:42:39 +0000 (10:42 +0000)
committerPavel Machek <pavel@ucw.cz>
Tue, 30 May 2000 10:42:39 +0000 (10:42 +0000)
filter/config.Y
filter/filter.c
filter/filter.h
nest/config.Y

index f72dc835858cb93304173cf91a66b33b420826fc..37c0f3f3fc3016b8b1ed4f925229954c055eaa68 100644 (file)
@@ -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; }
index 246fbf67a3135e363cde773d398c04991b079e86..e69e9e1028b2e99f349c8a8bd930a26d7d4fc954 100644 (file)
@@ -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 {
index 1039c6ffc84a5eb803ca89fba218a11fcf0a63dc..04a2623614ebf1fbdba4254b44f998e19f6f70a9 100644 (file)
@@ -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 */
 
index 2918d255e5e466b7de91c9bfa3bd29e284b627cf..9454e62276ccfcd8c536ec17a826a0526f4cb1de 100644 (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,
        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