Skip to content

Commit

Permalink
isisd: Add pack func for Sub-Sub-TLVs in general
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cscarpitta committed Sep 11, 2023
1 parent ac62420 commit dce3e45
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions isisd/isis_tlvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dce3e45

Please sign in to comment.