summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>2023-02-14 11:30:45 +0100
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>2023-09-11 17:35:13 +0200
commitb2f0b7d0b053ca5c81875ada994260b004b4268f (patch)
tree837e47a45a8d7b111df375ecb2889e6cb93e0a4a /isisd
parentisisd: Free SRv6 Locator TLV when freeing TLVs (diff)
downloadfrr-b2f0b7d0b053ca5c81875ada994260b004b4268f.tar.xz
frr-b2f0b7d0b053ca5c81875ada994260b004b4268f.zip
isisd: Add pack function for SRv6 Locator TLV
Add a function to pack an SRv6 Locator TLV and all its Sub-TLVs (RFC 9352 section #7.1). Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'isisd')
-rw-r--r--isisd/isis_tlvs.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c
index 2d24a98c4..b0ec3d2d6 100644
--- a/isisd/isis_tlvs.c
+++ b/isisd/isis_tlvs.c
@@ -5588,6 +5588,43 @@ static void free_item_srv6_locator(struct isis_item *i)
XFREE(MTYPE_ISIS_TLV, item);
}
+static int pack_item_srv6_locator(struct isis_item *i, struct stream *s,
+ size_t *min_len)
+{
+ struct isis_srv6_locator_tlv *loc = (struct isis_srv6_locator_tlv *)i;
+
+ if (STREAM_WRITEABLE(s) < 7 + (unsigned)PSIZE(loc->prefix.prefixlen)) {
+ *min_len = 7 + (unsigned)PSIZE(loc->prefix.prefixlen);
+ return 1;
+ }
+
+ stream_putl(s, loc->metric);
+ stream_putc(s, loc->flags);
+ stream_putc(s, loc->algorithm);
+ /* Locator size */
+ stream_putc(s, loc->prefix.prefixlen);
+ /* Locator prefix */
+ stream_put(s, &loc->prefix.prefix.s6_addr,
+ PSIZE(loc->prefix.prefixlen));
+
+ if (loc->subtlvs) {
+ /* Pack Sub-TLVs */
+ if (pack_subtlvs(loc->subtlvs, s))
+ return 1;
+ } else {
+ /* No Sub-TLVs */
+ if (STREAM_WRITEABLE(s) < 1) {
+ *min_len = 8 + (unsigned)PSIZE(loc->prefix.prefixlen);
+ return 1;
+ }
+
+ /* Put 0 as Sub-TLV length, because we have no Sub-TLVs */
+ stream_putc(s, 0);
+ }
+
+ return 0;
+}
+
/* Functions related to tlvs in general */
struct isis_tlvs *isis_alloc_tlvs(void)