]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Moved filter value union to lib
authorMaria Matejka <mq@ucw.cz>
Thu, 31 Mar 2022 17:29:17 +0000 (19:29 +0200)
committerMaria Matejka <mq@ucw.cz>
Wed, 4 May 2022 13:37:41 +0000 (15:37 +0200)
filter/data.h
lib/attrs.h
lib/route.h
lib/type.h

index 0b1e8e573c7b89b5738f3be11af8b14627fa4fe9..9ffa1b61cbfeb158f2bf5dbfbf42cc27dcbbc73d 100644 (file)
 /* Filter value; size of this affects filter memory consumption */
 struct f_val {
   btype type;  /* T_*  */
-  union {
-    union bval bval;
-    BVAL_ITEMS;
-
-    u64 ec;
-    lcomm lc;
-    ip_addr ip;
-    const net_addr *net;
-    const char *s;
-    const struct f_tree *t;
-    const struct f_trie *ti;
-    const struct f_path_mask *path_mask;
-    struct f_path_mask_item pmi;
-  } val;
+  union bval_long val;
 };
 
 #define fputip(a)   ({ ip_addr *ax = falloc(sizeof(*ax)); *ax = (a); ax; })
index e05958465c5295275658405d2f2486e38fdc2afa..97a9630fdb0d7487e07b6828148f5d2019a11a43 100644 (file)
 
 #include <stdint.h>
 #include "lib/unaligned.h"
-#include "lib/route.h"
+
+typedef struct adata {
+  uint length;                         /* Length of data */
+  byte data[0];
+} adata;
+
+extern const adata null_adata;         /* adata of length 0 */
+
+static inline struct adata *
+lp_alloc_adata(struct linpool *pool, uint len)
+{
+  struct adata *ad = lp_alloc(pool, sizeof(struct adata) + len);
+  ad->length = len;
+  return ad;
+}
+
+static inline int adata_same(const struct adata *a, const struct adata *b)
+{ return (a->length == b->length && !memcmp(a->data, b->data, a->length)); }
+
 
 
 /* a-path.c */
index 47355abc65eba3c603dfdf7ca9ab2015e037de0c..8e60f749c3be41f5b4420c551d673f32a7d66281 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef _BIRD_LIB_ROUTE_H_
 #define _BIRD_LIB_ROUTE_H_
 
+#include "lib/type.h"
+
 struct network;
 struct proto;
 struct cli;
@@ -163,25 +165,6 @@ const char *ea_custom_name(uint ea);
 #define EA_BIT(n) ((n) << 24)          /* Used in bitfield accessors */
 #define EA_BIT_GET(ea) ((ea) >> 24)
 
-typedef struct adata {
-  uint length;                         /* Length of data */
-  byte data[0];
-} adata;
-
-extern const adata null_adata;         /* adata of length 0 */
-
-static inline struct adata *
-lp_alloc_adata(struct linpool *pool, uint len)
-{
-  struct adata *ad = lp_alloc(pool, sizeof(struct adata) + len);
-  ad->length = len;
-  return ad;
-}
-
-static inline int adata_same(const struct adata *a, const struct adata *b)
-{ return (a->length == b->length && !memcmp(a->data, b->data, a->length)); }
-
-
 typedef struct ea_list {
   struct ea_list *next;                        /* In case we have an override list */
   byte flags;                          /* Flags: EALF_... */
index d0a887d8a83840c165c9a128072415bd24f63d40..6d19a2501d9de839a7f61c061e71eae6789c210e 100644 (file)
@@ -10,6 +10,7 @@
 #define _BIRD_TYPE_H_
 
 #include "lib/birdlib.h"
+#include "lib/attrs.h"
 
 union bval {
 #define BVAL_ITEMS     \
@@ -18,9 +19,25 @@ union bval {
   const struct adata *ptr;     /* Generic attribute data inherited from eattrs */      \
   const struct adata *ad;      /* Generic attribute data inherited from filters */     \
 
-  BVAL_ITEMS
+  BVAL_ITEMS;
 };
 
+union bval_long {
+  union bval bval;             /* For direct assignments */
+  BVAL_ITEMS;                  /* For item-wise access */
+
+  u64 ec;
+  lcomm lc;
+  ip_addr ip;
+  const net_addr *net;
+  const char *s;
+  const struct f_tree *t;
+  const struct f_trie *ti;
+  const struct f_path_mask *path_mask;
+  struct f_path_mask_item pmi;
+};
+
+
 /* Internal types */
 enum btype {
 /* Nothing. Simply nothing. */