mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 16:26:10 +00:00
ospf6d: JSON output for database dump show command
Added missing output to "show ipv6 ospf6 databse dump json" VTY shell command. Co-authored-by: David Schweizer dschweizer@opensourcerouting.org Signed-off-by: Quentin Young <qlyoung@nvidia.com>
This commit is contained in:
parent
0c0830c599
commit
6ddb368d6b
@ -29,6 +29,7 @@
|
||||
#include "memory.h"
|
||||
#include "thread.h"
|
||||
#include "checksum.h"
|
||||
#include "frrstr.h"
|
||||
|
||||
#include "ospf6_proto.h"
|
||||
#include "ospf6_lsa.h"
|
||||
@ -80,7 +81,6 @@ static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
json_object *json_obj, bool use_json)
|
||||
{
|
||||
uint8_t *start, *end, *current;
|
||||
char byte[4];
|
||||
|
||||
start = (uint8_t *)lsa->header + sizeof(struct ospf6_lsa_header);
|
||||
end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
|
||||
@ -95,8 +95,7 @@ static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
else if ((current - start) % 4 == 0)
|
||||
vty_out(vty, " ");
|
||||
|
||||
snprintf(byte, sizeof(byte), "%02x", *current);
|
||||
vty_out(vty, "%s", byte);
|
||||
vty_out(vty, "%02x", *current);
|
||||
}
|
||||
|
||||
vty_out(vty, "\n\n");
|
||||
@ -553,30 +552,52 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
json_object *json_array, bool use_json)
|
||||
{
|
||||
uint8_t *start, *end, *current;
|
||||
uint8_t *start = NULL;
|
||||
uint8_t *end = NULL;
|
||||
uint8_t *current = NULL;
|
||||
char byte[4];
|
||||
char *header_str = NULL;
|
||||
char adv_router[INET6_ADDRSTRLEN];
|
||||
char id[INET6_ADDRSTRLEN];
|
||||
json_object *json = NULL;
|
||||
|
||||
start = (uint8_t *)lsa->header;
|
||||
end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
|
||||
|
||||
if (use_json)
|
||||
return;
|
||||
if (use_json) {
|
||||
json = json_object_new_object();
|
||||
size_t header_str_sz = (2 * (end - start)) + 1;
|
||||
|
||||
vty_out(vty, "\n");
|
||||
vty_out(vty, "%s:\n", lsa->name);
|
||||
header_str = XMALLOC(MTYPE_TMP, header_str_sz);
|
||||
|
||||
for (current = start; current < end; current++) {
|
||||
if ((current - start) % 16 == 0)
|
||||
vty_out(vty, "\n ");
|
||||
else if ((current - start) % 4 == 0)
|
||||
vty_out(vty, " ");
|
||||
inet_ntop(AF_INET, &lsa->header->id, id, sizeof(id));
|
||||
inet_ntop(AF_INET, &lsa->header->adv_router, adv_router,
|
||||
sizeof(adv_router));
|
||||
|
||||
snprintf(byte, sizeof(byte), "%02x", *current);
|
||||
vty_out(vty, "%s", byte);
|
||||
frrstr_hex(header_str, header_str_sz, start, end - start);
|
||||
|
||||
json_object_string_add(json, "linkStateId", id);
|
||||
json_object_string_add(json, "advertisingRouter", adv_router);
|
||||
json_object_string_add(json, "header", header_str);
|
||||
json_object_array_add(json_array, json);
|
||||
|
||||
XFREE(MTYPE_TMP, header_str);
|
||||
} else {
|
||||
vty_out(vty, "\n%s:\n", lsa->name);
|
||||
|
||||
for (current = start; current < end; current++) {
|
||||
if ((current - start) % 16 == 0)
|
||||
vty_out(vty, "\n ");
|
||||
else if ((current - start) % 4 == 0)
|
||||
vty_out(vty, " ");
|
||||
|
||||
snprintf(byte, sizeof(byte), "%02x", *current);
|
||||
vty_out(vty, "%s", byte);
|
||||
}
|
||||
|
||||
vty_out(vty, "\n\n");
|
||||
}
|
||||
|
||||
vty_out(vty, "\n\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user