diff options
author | Maria Matejka <mq@ucw.cz> | 2022-03-31 19:29:17 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-05-04 15:37:41 +0200 |
commit | 0b871c170472202770691af8995766ee57920fdc (patch) | |
tree | 08c5045208a5d11838ca2735925ddf1d03d3d2c7 /lib | |
parent | 3fb70b26faca6788aa0bdf1d558414f9f777c6cd (diff) |
Moved filter value union to lib
Diffstat (limited to 'lib')
-rw-r--r-- | lib/attrs.h | 20 | ||||
-rw-r--r-- | lib/route.h | 21 | ||||
-rw-r--r-- | lib/type.h | 19 |
3 files changed, 39 insertions, 21 deletions
diff --git a/lib/attrs.h b/lib/attrs.h index e0595846..97a9630f 100644 --- a/lib/attrs.h +++ b/lib/attrs.h @@ -11,7 +11,25 @@ #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 */ diff --git a/lib/route.h b/lib/route.h index 47355abc..8e60f749 100644 --- a/lib/route.h +++ b/lib/route.h @@ -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_... */ @@ -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. */ |