summaryrefslogtreecommitdiff
path: root/proto/bgp/bgp.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-03-26 11:56:02 +0100
committerMaria Matejka <mq@ucw.cz>2022-05-04 15:37:41 +0200
commit0d0f6554a5c233bf2bf830ae319191c4b1808d49 (patch)
treeb90790a9450dc4eaefd1cab522d49221d358a5d9 /proto/bgp/bgp.h
parent80272d4b64a38ee6f04a1c4e8566cac3a2293176 (diff)
Unified attribute and filter types
This commit removes the EAF_TYPE_* namespace completely and also for route attributes, filter-based types T_* are used. This simplifies fetching and setting route attributes from filters. Also, there is now union bval which serves as an universal value holder instead of private unions held separately by eattr and filter code.
Diffstat (limited to 'proto/bgp/bgp.h')
-rw-r--r--proto/bgp/bgp.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 8a44514c..6f209595 100644
--- a/proto/bgp/bgp.h
+++ b/proto/bgp/bgp.h
@@ -545,22 +545,28 @@ bgp_find_attr(ea_list *attrs, uint code)
}
eattr *
-bgp_set_attr(ea_list **attrs, struct linpool *pool, uint code, uint flags, uintptr_t val);
+bgp_set_attr(ea_list **attrs, struct linpool *pool, uint code, uint flags, union bval val);
static inline void
bgp_set_attr_u32(ea_list **to, struct linpool *pool, uint code, uint flags, u32 val)
-{ bgp_set_attr(to, pool, code, flags, (uintptr_t) val); }
+{
+ union bval bv = { .data = val };
+ bgp_set_attr(to, pool, code, flags, bv);
+}
static inline void
-bgp_set_attr_ptr(ea_list **to, struct linpool *pool, uint code, uint flags, const struct adata *val)
-{ bgp_set_attr(to, pool, code, flags, (uintptr_t) val); }
+bgp_set_attr_ptr(ea_list **to, struct linpool *pool, uint code, uint flags, const struct adata *ad)
+{
+ union bval bv = { .ptr = ad };
+ bgp_set_attr(to, pool, code, flags, bv);
+}
static inline void
bgp_set_attr_data(ea_list **to, struct linpool *pool, uint code, uint flags, void *data, uint len)
{
struct adata *a = lp_alloc_adata(pool, len);
bmemcpy(a->data, data, len);
- bgp_set_attr(to, pool, code, flags, (uintptr_t) a);
+ bgp_set_attr_ptr(to, pool, code, flags, a);
}
#define bgp_unset_attr(to, pool, code) ea_unset_attr(to, pool, 0, code)