From f26becb27ad64f10fb60e56ab60a0f4507436ef6 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Sat, 15 Apr 2023 18:11:10 +0200 Subject: [PATCH] lib: Add SRv6 flavors manipulation macros `struct seg6local_context` contains a `struct seg6local_flavors_info` that carries SRv6 flavors information. The `seg6local_flavors_info` data structure contains a field `flv_ops` that indicates which flavors are enabled for the `seg6local` nexthop. `flv_ops` is a bit-map where each bit indicates if a particular SRv6 flavor is enabled (bit set to 1) or not (bit set to 0). This commit defines some macros that can be used to manipulate the SRv6 flavors bit-map: * CHECK_SRV6_FLV_OP(OPS,OP) - check if a particular flavor is enabled; * SET_SRV6_FLV_OP(OPS,OP) - enable a particular flavor (OP); * UNSET_SRV6_FLV_OP(OPS,OP) - disable a particular flavor (OP); * RESET_SRV6_FLV_OP(OPS) - disable all SRv6 flavors. Signed-off-by: Carmine Scarpitta --- lib/srv6.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/srv6.h b/lib/srv6.h index f5a9431896..111963daa2 100644 --- a/lib/srv6.h +++ b/lib/srv6.h @@ -24,6 +24,12 @@ extern "C" { #define sid2str(sid, str, size) \ inet_ntop(AF_INET6, sid, str, size) +/* SRv6 flavors manipulation macros */ +#define CHECK_SRV6_FLV_OP(OPS,OP) ((OPS) & (1 << OP)) +#define SET_SRV6_FLV_OP(OPS,OP) (OPS) |= (1 << OP) +#define UNSET_SRV6_FLV_OP(OPS,OP) (OPS) &= ~(1 << OP) +#define RESET_SRV6_FLV_OP(OPS) (OPS) = 0 + enum seg6_mode_t { INLINE, ENCAP, -- 2.39.5