diff options
| author | Carmine Scarpitta <cscarpit@cisco.com> | 2024-05-06 17:44:18 +0200 |
|---|---|---|
| committer | Carmine Scarpitta <cscarpit@cisco.com> | 2024-06-13 14:54:16 +0200 |
| commit | 3cb88e69848d607a8d069b0858798e2de324fd43 (patch) | |
| tree | 02f6d268af20868cc41971822147b22e78b712c2 /lib/srv6.c | |
| parent | 779d4c2702ac446cc4b96a1a9d2d62d1b0bbe232 (diff) | |
lib: Add support for SRv6 SIDs
Add a data structure to represent an SRv6 SID context and the related
management functions (allocate/free).
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Diffstat (limited to 'lib/srv6.c')
| -rw-r--r-- | lib/srv6.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/srv6.c b/lib/srv6.c index 1f485fb8ac..883d429b62 100644 --- a/lib/srv6.c +++ b/lib/srv6.c @@ -14,6 +14,7 @@ DEFINE_QOBJ_TYPE(srv6_sid_format); DEFINE_MTYPE_STATIC(LIB, SRV6_LOCATOR, "SRV6 locator"); DEFINE_MTYPE_STATIC(LIB, SRV6_LOCATOR_CHUNK, "SRV6 locator chunk"); DEFINE_MTYPE_STATIC(LIB, SRV6_SID_FORMAT, "SRv6 SID format"); +DEFINE_MTYPE_STATIC(LIB, SRV6_SID_CTX, "SRv6 SID context"); const char *seg6local_action2str(uint32_t action) { @@ -201,6 +202,29 @@ void delete_srv6_sid_format(void *val) srv6_sid_format_free((struct srv6_sid_format *)val); } +struct srv6_sid_ctx *srv6_sid_ctx_alloc(enum seg6local_action_t behavior, + struct in_addr *nh4, + struct in6_addr *nh6, vrf_id_t vrf_id) +{ + struct srv6_sid_ctx *ctx = NULL; + + ctx = XCALLOC(MTYPE_SRV6_SID_CTX, sizeof(struct srv6_sid_ctx)); + ctx->behavior = behavior; + if (nh4) + ctx->nh4 = *nh4; + if (nh6) + ctx->nh6 = *nh6; + if (vrf_id) + ctx->vrf_id = vrf_id; + + return ctx; +} + +void srv6_sid_ctx_free(struct srv6_sid_ctx *ctx) +{ + XFREE(MTYPE_SRV6_SID_CTX, ctx); +} + json_object *srv6_locator_chunk_json(const struct srv6_locator_chunk *chunk) { json_object *jo_root = NULL; |
