summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2022-09-27 16:47:52 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2022-10-03 20:18:12 +0200
commit92a856554780c262f188acb4cdcee363bf6dd1bb (patch)
treee8e847cd28c19195ba83ca7cfc23d3c7923b82ba /nest
parentda0b589e7bbcd8177702caa925063d36e7f316ec (diff)
Filter: Add some minor functions for f_tree and EC
Add some supportive functions for f_tree and EC. These functions are used by L3VPN code.
Diffstat (limited to 'nest')
-rw-r--r--nest/attrs.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/nest/attrs.h b/nest/attrs.h
index 9412439b..fcd5ac16 100644
--- a/nest/attrs.h
+++ b/nest/attrs.h
@@ -138,6 +138,11 @@ static inline const char *ec_subtype_str(const enum ec_subtype ecs) {
}
}
+/* Check for EC_RT subtype within different types (0-2) */
+static inline int ec_type_is_rt(uint type)
+{ return (type == EC_RT) || (type == (0x0100 | EC_RT)) || (type == (0x0200 | EC_RT)); }
+
+
/* Transitive bit (for first u32 half of EC) */
#define EC_TBIT 0x40000000
@@ -157,9 +162,13 @@ static inline u32 *int_set_get_data(const struct adata *list)
static inline u32 ec_hi(u64 ec) { return ec >> 32; }
static inline u32 ec_lo(u64 ec) { return ec; }
+
static inline u64 ec_get(const u32 *l, int i)
{ return (((u64) l[i]) << 32) | l[i+1]; }
+static inline void ec_put(u32 *l, int i, u64 val)
+{ l[i] = ec_hi(val); l[i+1] = ec_lo(val); }
+
/* RFC 4360 3.1. Two-Octet AS Specific Extended Community */
static inline u64 ec_as2(enum ec_subtype kind, u64 key, u64 val)
{ return (((u64) kind | 0x0000) << 48) | (key << 32) | val; }