From b38fed40a16b6c5dd187df4c03097e9a5a6f7d42 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Tue, 14 Feb 2023 13:43:42 +0100 Subject: [PATCH] isisd: Add pack function for SRv6 End SID Sub-TLV Add a function to pack an SRv6 End SID Sub-TLV (RFC 9352 section #7.2). Signed-off-by: Carmine Scarpitta --- isisd/isis_tlvs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index 206971d79a..59a0e2e51e 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -2098,6 +2098,28 @@ static void free_item_srv6_end_sid(struct isis_item *i) XFREE(MTYPE_ISIS_SUBTLV, i); } +static int pack_item_srv6_end_sid(struct isis_item *i, struct stream *s, + size_t *min_len) +{ + struct isis_srv6_end_sid_subtlv *sid = + (struct isis_srv6_end_sid_subtlv *)i; + + if (STREAM_WRITEABLE(s) < 19) { + *min_len = 19; + return 1; + } + + stream_putc(s, sid->flags); + stream_putw(s, sid->behavior); + stream_put(s, &sid->sid, IPV6_MAX_BYTELEN); + + /* Put 0 as Sub-Sub-TLV length, because we don't support any Sub-Sub-TLV + * at this time */ + stream_putc(s, 0); + + return 0; +} + /* Functions related to TLVs 1 Area Addresses */ static struct isis_item *copy_item_area_address(struct isis_item *i) -- 2.39.5