]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: Add pack func for Sub-Sub-TLVs in general
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Sun, 12 Mar 2023 20:19:12 +0000 (21:19 +0100)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Mon, 11 Sep 2023 20:11:28 +0000 (22:11 +0200)
Add a function to pack all the Sub-Sub-TLVs passed as an argument.

At this time, this function does not pack any Sub-Sub-TLVs because no
Sub-Sub-TLVs have been defined yet. This function will be extended in
future commits to pack specific Sub-Sub-TLVs, as they become supported.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
isisd/isis_tlvs.c

index 50110a4e2f9c07b76e991fc9d1d96d82adb205e3..117c90a8af0558e6d419657bd2eb88826fc24573 100644 (file)
@@ -2014,6 +2014,25 @@ static void isis_free_subsubtlvs(struct isis_subsubtlvs *subsubtlvs)
        XFREE(MTYPE_ISIS_SUBSUBTLV, subsubtlvs);
 }
 
+static int isis_pack_subsubtlvs(struct isis_subsubtlvs *subsubtlvs,
+                               struct stream *s)
+{
+       int rv;
+       size_t subsubtlv_len_pos = stream_get_endp(s);
+
+       if (STREAM_WRITEABLE(s) < 1)
+               return 1;
+
+       stream_putc(s, 0); /* Put 0 as Sub-Sub-TLVs length, filled in later */
+
+       size_t subsubtlv_len = stream_get_endp(s) - subsubtlv_len_pos - 1;
+       if (subsubtlv_len > 255)
+               return 1;
+
+       stream_putc_at(s, subsubtlv_len_pos, subsubtlv_len);
+       return 0;
+}
+
 /* Functions related to subtlvs */
 
 static struct isis_subtlvs *isis_alloc_subtlvs(enum isis_tlv_context context)