summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_vty.c
diff options
context:
space:
mode:
authorOlivier Dugeon <olivier.dugeon@orange.com>2018-01-19 17:40:14 +0100
committerGitHub <noreply@github.com>2018-01-19 17:40:14 +0100
commit4ff9eb721d5b089a86070f03282c3d0843194504 (patch)
treea6436c9d0b141fe7cf7cc3e1670851505f9a8d72 /ospfd/ospf_vty.c
parentMerge pull request #1630 from LabNConsulting/working/master/pr1629-no-json (diff)
parentospfd: show ip ospf interface json output format (diff)
downloadfrr-4ff9eb721d5b089a86070f03282c3d0843194504.tar.xz
frr-4ff9eb721d5b089a86070f03282c3d0843194504.zip
Merge pull request #1647 from chiragshah6/ospf_vrf_dev
ospfd: show ip ospf interface json output format
Diffstat (limited to 'ospfd/ospf_vty.c')
-rw-r--r--ospfd/ospf_vty.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index bc9511834..e2aa44557 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -3693,14 +3693,15 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
{
struct interface *ifp;
struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
- json_object *json_vrf = NULL;
- json_object *json_interface_sub = NULL;
+ json_object *json_vrf = NULL, *json_intf_array = NULL;
+ json_object *json_interface_sub = NULL, *json_interface = NULL;
if (use_json) {
if (use_vrf)
json_vrf = json_object_new_object();
else
json_vrf = json;
+ json_intf_array = json_object_new_array();
}
if (ospf->instance) {
@@ -3714,21 +3715,29 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf);
if (intf_name == NULL) {
+ if (use_json)
+ json_object_object_add(json_vrf, "interfaces",
+ json_intf_array);
/* Show All Interfaces.*/
FOR_ALL_INTERFACES (vrf, ifp) {
if (ospf_oi_count(ifp)) {
- if (use_json)
+ if (use_json) {
+ json_interface =
+ json_object_new_object();
json_interface_sub =
json_object_new_object();
-
+ }
show_ip_ospf_interface_sub(vty, ospf, ifp,
json_interface_sub,
use_json);
- if (use_json)
+ if (use_json) {
+ json_object_array_add(json_intf_array,
+ json_interface);
json_object_object_add(
- json_vrf, ifp->name,
+ json_interface, ifp->name,
json_interface_sub);
+ }
}
}
} else {
@@ -3741,15 +3750,23 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
else
vty_out(vty, "No such interface name\n");
} else {
- if (use_json)
+ if (use_json) {
json_interface_sub = json_object_new_object();
+ json_interface = json_object_new_object();
+ json_object_object_add(json_vrf, "interfaces",
+ json_intf_array);
+ }
show_ip_ospf_interface_sub(
vty, ospf, ifp, json_interface_sub, use_json);
- if (use_json)
- json_object_object_add(json_vrf, ifp->name,
+ if (use_json) {
+ json_object_array_add(json_intf_array,
+ json_interface);
+ json_object_object_add(json_interface,
+ ifp->name,
json_interface_sub);
+ }
}
}