From 08d79bce3df0028f3db56010a49b57ca908c1f25 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 31 Jan 2022 15:17:03 +0200 Subject: [PATCH] ospfd,ospf6d: Add JSON additional keys with no whitespaces inside Signed-off-by: Donatas Abraitis --- ospf6d/ospf6_top.c | 15 ++++++++++++++- ospfd/ospf_vty.c | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 57a55a6ef4..6c707e3555 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -1999,6 +1999,9 @@ ospf6_show_vrf_name(struct vty *vty, struct ospf6 *ospf6, } } +#if CONFDATE > 20230131 +CPP_NOTICE("Remove JSON object commands with keys containing whitespaces") +#endif static int ospf6_show_summary_address(struct vty *vty, struct ospf6 *ospf6, json_object *json, @@ -2019,7 +2022,9 @@ ospf6_show_summary_address(struct vty *vty, struct ospf6 *ospf6, ospf6_show_vrf_name(vty, ospf6, json_vrf); json_object_int_add(json_vrf, "aggregation delay interval", - ospf6->aggr_delay_interval); + ospf6->aggr_delay_interval); + json_object_int_add(json_vrf, "aggregationDelayInterval", + ospf6->aggr_delay_interval); } @@ -2044,12 +2049,18 @@ ospf6_show_summary_address(struct vty *vty, struct ospf6 *ospf6, json_object_string_add(json_aggr, "Summary address", buf); + json_object_string_add(json_aggr, "summaryAddress", + buf); json_object_string_add( json_aggr, "Metric-type", (aggr->mtype == DEFAULT_METRIC_TYPE) ? "E2" : "E1"); + json_object_string_add( + json_aggr, "metricType", + (aggr->mtype == DEFAULT_METRIC_TYPE) ? "E2" + : "E1"); json_object_int_add(json_aggr, "Metric", (aggr->metric != -1) @@ -2062,6 +2073,8 @@ ospf6_show_summary_address(struct vty *vty, struct ospf6 *ospf6, json_object_int_add(json_aggr, "External route count", OSPF6_EXTERNAL_RT_COUNT(aggr)); + json_object_int_add(json_aggr, "externalRouteCount", + OSPF6_EXTERNAL_RT_COUNT(aggr)); if (OSPF6_EXTERNAL_RT_COUNT(aggr) && detail) { json_object_int_add(json_aggr, "ID", diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c82c8cb42e..ac87c0805f 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10534,6 +10534,9 @@ static void config_write_stub_router(struct vty *vty, struct ospf *ospf) return; } +#if CONFDATE > 20230131 +CPP_NOTICE("Remove JSON object commands with keys containing whitespaces") +#endif static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, struct route_table *rt, json_object *json) @@ -10641,6 +10644,12 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, ifindex2ifname( path->ifindex, ospf->vrf_id)); + json_object_string_add( + json_nexthop, + "directlyAttachedTo", + ifindex2ifname( + path->ifindex, + ospf->vrf_id)); } else { vty_out(vty, "%24s directly attached to %s\n", @@ -10780,6 +10789,12 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, ifindex2ifname( path->ifindex, ospf->vrf_id)); + json_object_string_add( + json_nexthop, + "directlyAttachedTo", + ifindex2ifname( + path->ifindex, + ospf->vrf_id)); } else { vty_out(vty, "%24s directly attached to %s\n", @@ -10906,6 +10921,12 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, ifindex2ifname( path->ifindex, ospf->vrf_id)); + json_object_string_add( + json_nexthop, + "directlyAttachedTo", + ifindex2ifname( + path->ifindex, + ospf->vrf_id)); } else { vty_out(vty, "%24s directly attached to %s\n", @@ -11428,12 +11449,15 @@ static int ospf_show_summary_address(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); - if (!uj) + if (!uj) { vty_out(vty, "aggregation delay interval :%u(in seconds)\n\n", ospf->aggr_delay_interval); - else + } else { json_object_int_add(json_vrf, "aggregation delay interval", ospf->aggr_delay_interval); + json_object_int_add(json_vrf, "aggregationDelayInterval", + ospf->aggr_delay_interval); + } for (rn = route_top(ospf->rt_aggr_tbl); rn; rn = route_next(rn)) if (rn->info) { @@ -11452,12 +11476,19 @@ static int ospf_show_summary_address(struct vty *vty, struct ospf *ospf, json_object_string_add(json_aggr, "Summary address", buf); + json_object_string_add(json_aggr, + "summaryAddress", buf); json_object_string_add( json_aggr, "Metric-type", (mtype == EXTERNAL_METRIC_TYPE_1) ? "E1" : "E2"); + json_object_string_add( + json_aggr, "metricType", + (mtype == EXTERNAL_METRIC_TYPE_1) + ? "E1" + : "E2"); json_object_int_add(json_aggr, "Metric", mval); @@ -11467,6 +11498,9 @@ static int ospf_show_summary_address(struct vty *vty, struct ospf *ospf, json_object_int_add( json_aggr, "External route count", OSPF_EXTERNAL_RT_COUNT(aggr)); + json_object_int_add( + json_aggr, "externalRouteCount", + OSPF_EXTERNAL_RT_COUNT(aggr)); if (OSPF_EXTERNAL_RT_COUNT(aggr) && detail) { hash_walk( -- 2.39.5