diff options
author | Christian Hopps <chopps@labn.net> | 2023-02-18 18:16:18 +0100 |
---|---|---|
committer | Christian Hopps <chopps@gmail.com> | 2023-02-20 17:58:30 +0100 |
commit | 1794afe01030b3111e83e26986cd004dce290049 (patch) | |
tree | ff19fccef0385460a02fabd5cd4a433d7cf3c38e /ospfd/ospf_opaque.c | |
parent | Merge pull request #12791 from taspelund/loc_rib_json_fix (diff) | |
download | frr-1794afe01030b3111e83e26986cd004dce290049.tar.xz frr-1794afe01030b3111e83e26986cd004dce290049.zip |
ospfd: inc. opaque data in `show opaque info detail json` output
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'ospfd/ospf_opaque.c')
-rw-r--r-- | ospfd/ospf_opaque.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 2af5d09ed..2e8e48bb5 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -19,6 +19,7 @@ #include "thread.h" #include "hash.h" #include "sockunion.h" /* for inet_aton() */ +#include "printfrr.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -1147,11 +1148,13 @@ void ospf_opaque_config_write_debug(struct vty *vty) void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa, json_object *json) { + char buf[128], *bp; struct lsa_header *lsah = lsa->data; uint32_t lsid = ntohl(lsah->id.s_addr); uint8_t opaque_type = GET_OPAQUE_TYPE(lsid); uint32_t opaque_id = GET_OPAQUE_ID(lsid); struct ospf_opaque_functab *functab; + int len, lenValid; /* Switch output functionality by vty address. */ if (vty != NULL) { @@ -1170,11 +1173,19 @@ void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa, json, "opaqueType", ospf_opaque_type_name(opaque_type)); json_object_int_add(json, "opaqueId", opaque_id); - json_object_int_add(json, "opaqueDataLength", - ntohs(lsah->length) - - OSPF_LSA_HEADER_SIZE); + len = ntohs(lsah->length) - OSPF_LSA_HEADER_SIZE; + json_object_int_add(json, "opaqueDataLength", len); + lenValid = VALID_OPAQUE_INFO_LEN(lsah); json_object_boolean_add(json, "opaqueDataLengthValid", - VALID_OPAQUE_INFO_LEN(lsah)); + lenValid); + if (lenValid) { + bp = asnprintfrr(MTYPE_TMP, buf, sizeof(buf), + "%*pHXn", (int)len, + (lsah + 1)); + json_object_string_add(json, "opaqueData", buf); + if (bp != buf) + XFREE(MTYPE_TMP, bp); + } } } else { zlog_debug(" Opaque-Type %u (%s)", opaque_type, |