]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: Add format func for SID Struct Sub-Sub-TLV
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Wed, 1 Mar 2023 15:42:56 +0000 (16:42 +0100)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Mon, 11 Sep 2023 20:11:32 +0000 (22:11 +0200)
Add a function to return information about an SRv6 SID Structure
Sub-Sub-TLV (RFC 9352 section #9).

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

index f9ae8e9fd241026066f614caab659a7e6716a7b1..dc1a469edfb3d73168ae50cb3348d00cd5dd1667 100644 (file)
@@ -1975,6 +1975,40 @@ copy_subsubtlv_srv6_sid_structure(
        return rv;
 }
 
+static void format_subsubtlv_srv6_sid_structure(
+       struct isis_srv6_sid_structure_subsubtlv *sid_struct, struct sbuf *buf,
+       struct json_object *json, int indent)
+{
+       if (!sid_struct)
+               return;
+
+       if (json) {
+               struct json_object *sid_struct_json;
+               sid_struct_json = json_object_new_object();
+               json_object_object_add(json, "srv6-sid-structure",
+                                      sid_struct_json);
+               json_object_int_add(sid_struct_json, "loc-block-len",
+                                   sid_struct->loc_block_len);
+               json_object_int_add(sid_struct_json, "loc-node-len",
+                                   sid_struct->loc_node_len);
+               json_object_int_add(sid_struct_json, "func-len",
+                                   sid_struct->func_len);
+               json_object_int_add(sid_struct_json, "arg-len",
+                                   sid_struct->arg_len);
+       } else {
+               sbuf_push(buf, indent, "SRv6 SID Structure ");
+               sbuf_push(buf, 0, "Locator Block length: %hhu, ",
+                         sid_struct->loc_block_len);
+               sbuf_push(buf, 0, "Locator Node length: %hhu, ",
+                         sid_struct->loc_node_len);
+               sbuf_push(buf, 0, "Function length: %hhu, ",
+                         sid_struct->func_len);
+               sbuf_push(buf, 0, "Argument length: %hhu, ",
+                         sid_struct->arg_len);
+               sbuf_push(buf, 0, "\n");
+       }
+}
+
 static struct isis_item *copy_item(enum isis_tlv_context context,
                                   enum isis_tlv_type type,
                                   struct isis_item *item);