diff options
author | github login name <ranjany@vmware.com> | 2020-10-13 14:44:52 +0200 |
---|---|---|
committer | Yash Ranjan <ranjany@vmware.com> | 2020-11-17 04:37:26 +0100 |
commit | 35a45deadaa57d2dd671d6b179d77b8d2cee57c1 (patch) | |
tree | edb55d0a8f19398a42ffb1ad583eff86f4902330 /ospf6d/ospf6_area.c | |
parent | Merge pull request #7533 from donaldsharp/zlog_missing_on_failure (diff) | |
download | frr-35a45deadaa57d2dd671d6b179d77b8d2cee57c1.tar.xz frr-35a45deadaa57d2dd671d6b179d77b8d2cee57c1.zip |
ospf6d: Json support added for command "show ipv6 ospf6 [json]"
Modify code to add JSON format output in show command
"show ipv6 ospf6" with proper formating.
Signed-off-by: Yash Ranjan <ranjany@vmware.com>
Diffstat (limited to 'ospf6d/ospf6_area.c')
-rw-r--r-- | ospf6d/ospf6_area.c | 108 |
1 files changed, 81 insertions, 27 deletions
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index e98764cd2..2ef61ae0c 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -359,40 +359,94 @@ void ospf6_area_disable(struct ospf6_area *oa) } -void ospf6_area_show(struct vty *vty, struct ospf6_area *oa) +void ospf6_area_show(struct vty *vty, struct ospf6_area *oa, + json_object *json_areas, bool use_json) { struct listnode *i; struct ospf6_interface *oi; unsigned long result; + json_object *json_area; + json_object *array_interfaces; - if (!IS_AREA_STUB(oa)) - vty_out(vty, " Area %s\n", oa->name); - else { - if (oa->no_summary) { - vty_out(vty, " Area %s[Stub, No Summary]\n", oa->name); - } else { - vty_out(vty, " Area %s[Stub]\n", oa->name); + if (use_json) { + json_area = json_object_new_object(); + json_object_boolean_add(json_area, "areaIsStub", + IS_AREA_STUB(oa)); + if (IS_AREA_STUB(oa)) { + json_object_boolean_add(json_area, "areaNoSummary", + oa->no_summary); } - } - vty_out(vty, " Number of Area scoped LSAs is %u\n", - oa->lsdb->count); - - vty_out(vty, " Interface attached to this area:"); - for (ALL_LIST_ELEMENTS_RO(oa->if_list, i, oi)) - vty_out(vty, " %s", oi->interface->name); - vty_out(vty, "\n"); - - if (oa->ts_spf.tv_sec || oa->ts_spf.tv_usec) { - result = monotime_since(&oa->ts_spf, NULL); - if (result / TIMER_SECOND_MICRO > 0) { - vty_out(vty, "SPF last executed %ld.%lds ago\n", - result / TIMER_SECOND_MICRO, - result % TIMER_SECOND_MICRO); - } else { - vty_out(vty, "SPF last executed %ldus ago\n", result); + + json_object_int_add(json_area, "numberOfAreaScopedLsa", + oa->lsdb->count); + + /* Interfaces Attached */ + array_interfaces = json_object_new_array(); + for (ALL_LIST_ELEMENTS_RO(oa->if_list, i, oi)) + json_object_array_add( + array_interfaces, + json_object_new_string(oi->interface->name)); + + json_object_object_add(json_area, "interfacesAttachedToArea", + array_interfaces); + + if (oa->ts_spf.tv_sec || oa->ts_spf.tv_usec) { + json_object_boolean_true_add(json_area, "spfHasRun"); + result = monotime_since(&oa->ts_spf, NULL); + if (result / TIMER_SECOND_MICRO > 0) { + json_object_int_add( + json_area, "spfLastExecutedSecs", + result / TIMER_SECOND_MICRO); + + json_object_int_add( + json_area, "spfLastExecutedMicroSecs", + result % TIMER_SECOND_MICRO); + } else { + json_object_int_add(json_area, + "spfLastExecutedSecs", 0); + json_object_int_add(json_area, + "spfLastExecutedMicroSecs", + result); + } + } else + json_object_boolean_false_add(json_area, "spfHasRun"); + + + json_object_object_add(json_areas, oa->name, json_area); + + } else { + + if (!IS_AREA_STUB(oa)) + vty_out(vty, " Area %s\n", oa->name); + else { + if (oa->no_summary) { + vty_out(vty, " Area %s[Stub, No Summary]\n", + oa->name); + } else { + vty_out(vty, " Area %s[Stub]\n", oa->name); + } } - } else - vty_out(vty, "SPF has not been run\n"); + vty_out(vty, " Number of Area scoped LSAs is %u\n", + oa->lsdb->count); + + vty_out(vty, " Interface attached to this area:"); + for (ALL_LIST_ELEMENTS_RO(oa->if_list, i, oi)) + vty_out(vty, " %s", oi->interface->name); + vty_out(vty, "\n"); + + if (oa->ts_spf.tv_sec || oa->ts_spf.tv_usec) { + result = monotime_since(&oa->ts_spf, NULL); + if (result / TIMER_SECOND_MICRO > 0) { + vty_out(vty, "SPF last executed %ld.%lds ago\n", + result / TIMER_SECOND_MICRO, + result % TIMER_SECOND_MICRO); + } else { + vty_out(vty, "SPF last executed %ldus ago\n", + result); + } + } else + vty_out(vty, "SPF has not been run\n"); + } } DEFUN (area_range, |