ospfd: json support for ospf database command.

Description:
Added json support to ospf lsdb command and its subcommands.
Added json to the following sub commands.
show ip ospf  database json
show ip ospf  database router json
show ip ospf  database network json
show ip ospf  database external json
show ip ospf  database summary json
show ip ospf  database asbr-summary json
show ip ospf  database nssa-external json
show ip ospf  databas max-age json
show ip ospf  database self-originate json

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
This commit is contained in:
rgirada 2020-07-23 16:25:04 -07:00
parent d65c0a679a
commit f328dc606e
4 changed files with 842 additions and 255 deletions

View File

@ -905,59 +905,63 @@ Showing Information
.. _show-ip-ospf:
.. index:: show ip ospf
.. clicmd:: show ip ospf
.. index:: show ip ospf [json]
.. clicmd:: show ip ospf [json]
Show information on a variety of general OSPF and area state and
configuration information.
.. index:: show ip ospf interface [INTERFACE]
.. clicmd:: show ip ospf interface [INTERFACE]
.. index:: show ip ospf interface [INTERFACE] [json]
.. clicmd:: show ip ospf interface [INTERFACE] [json]
Show state and configuration of OSPF the specified interface, or all
interfaces if no interface is given.
.. index:: show ip ospf neighbor
.. clicmd:: show ip ospf neighbor
.. index:: show ip ospf neighbor [json]
.. clicmd:: show ip ospf neighbor [json]
.. index:: show ip ospf neighbor INTERFACE
.. clicmd:: show ip ospf neighbor INTERFACE
.. index:: show ip ospf neighbor INTERFACE [json]
.. clicmd:: show ip ospf neighbor INTERFACE [json]
.. index:: show ip ospf neighbor detail
.. clicmd:: show ip ospf neighbor detail
.. index:: show ip ospf neighbor detail [json]
.. clicmd:: show ip ospf neighbor detail [json]
.. index:: show ip ospf neighbor INTERFACE detail
.. clicmd:: show ip ospf neighbor INTERFACE detail
.. index:: show ip ospf neighbor INTERFACE detail [json]
.. clicmd:: show ip ospf neighbor INTERFACE detail [json]
.. index:: show ip ospf database
.. clicmd:: show ip ospf database
Display lsa information of LSDB.
Json o/p of this command covers base route information
i.e all LSAs except opaque lsa info.
.. index:: show ip ospf database (asbr-summary|external|network|router|summary)
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary)
.. index:: show ip ospf database [json]
.. clicmd:: show ip ospf database [json]
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) [json]
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) [json]
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID adv-router ADV-ROUTER
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID adv-router ADV-ROUTER
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID [json]
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID [json]
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) adv-router ADV-ROUTER
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) adv-router ADV-ROUTER
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID adv-router ADV-ROUTER [json]
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID adv-router ADV-ROUTER [json]
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID self-originate
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID self-originate
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) adv-router ADV-ROUTER [json]
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) adv-router ADV-ROUTER [json]
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) self-originate
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) self-originate
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID self-originate [json]
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) LINK-STATE-ID self-originate [json]
.. index:: show ip ospf database max-age
.. clicmd:: show ip ospf database max-age
.. index:: show ip ospf database (asbr-summary|external|network|router|summary) self-originate [json]
.. clicmd:: show ip ospf database (asbr-summary|external|network|router|summary) self-originate [json]
.. index:: show ip ospf database self-originate
.. clicmd:: show ip ospf database self-originate
.. index:: show ip ospf database max-age [json]
.. clicmd:: show ip ospf database max-age [json]
.. index:: show ip ospf route
.. clicmd:: show ip ospf route
.. index:: show ip ospf database self-originate [json]
.. clicmd:: show ip ospf database self-originate [json]
.. index:: show ip ospf route [json]
.. clicmd:: show ip ospf route [json]
Show the OSPF routing table, as determined by the most recent SPF
calculation.

View File

@ -1159,7 +1159,8 @@ void ospf_opaque_config_write_debug(struct vty *vty)
return;
}
void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa)
void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa,
json_object *json)
{
struct lsa_header *lsah = lsa->data;
uint32_t lsid = ntohl(lsah->id.s_addr);
@ -1169,13 +1170,17 @@ void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa)
/* Switch output functionality by vty address. */
if (vty != NULL) {
vty_out(vty, " Opaque-Type %u (%s)\n", opaque_type,
ospf_opaque_type_name(opaque_type));
vty_out(vty, " Opaque-ID 0x%x\n", opaque_id);
if (!json) {
vty_out(vty, " Opaque-Type %u (%s)\n", opaque_type,
ospf_opaque_type_name(opaque_type));
vty_out(vty, " Opaque-ID 0x%x\n", opaque_id);
vty_out(vty, " Opaque-Info: %u octets of data%s\n",
ntohs(lsah->length) - OSPF_LSA_HEADER_SIZE,
VALID_OPAQUE_INFO_LEN(lsah) ? "" : "(Invalid length?)");
vty_out(vty, " Opaque-Info: %u octets of data%s\n",
ntohs(lsah->length) - OSPF_LSA_HEADER_SIZE,
VALID_OPAQUE_INFO_LEN(lsah)
? ""
: "(Invalid length?)");
}
} else {
zlog_debug(" Opaque-Type %u (%s)", opaque_type,
ospf_opaque_type_name(opaque_type));
@ -1200,7 +1205,7 @@ void ospf_opaque_lsa_dump(struct stream *s, uint16_t length)
struct ospf_lsa lsa;
lsa.data = (struct lsa_header *)stream_pnt(s);
show_opaque_info_detail(NULL, &lsa);
show_opaque_info_detail(NULL, &lsa, NULL);
return;
}

View File

@ -24,6 +24,7 @@
#define _ZEBRA_OSPF_OPAQUE_H
#include "vty.h"
#include <lib/json.h>
#define IS_OPAQUE_LSA(type) \
((type) == OSPF_OPAQUE_LINK_LSA || (type) == OSPF_OPAQUE_AREA_LSA \
@ -148,7 +149,8 @@ extern void ospf_opaque_nsm_change(struct ospf_neighbor *nbr, int old_status);
extern void ospf_opaque_config_write_router(struct vty *vty, struct ospf *ospf);
extern void ospf_opaque_config_write_if(struct vty *vty, struct interface *ifp);
extern void ospf_opaque_config_write_debug(struct vty *vty);
extern void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa);
extern void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa,
json_object *json);
extern void ospf_opaque_lsa_dump(struct stream *s, uint16_t length);
extern void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi,

File diff suppressed because it is too large Load Diff