diff options
| -rw-r--r-- | lib/json.h | 9 | ||||
| -rw-r--r-- | ospf6d/ospf6_area.c | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/json.h b/lib/json.h index 9d33ac7ae3..fcaa84c816 100644 --- a/lib/json.h +++ b/lib/json.h @@ -42,6 +42,15 @@ extern "C" { json_object_iter_equal(&(joi), &(join)) == 0; \ json_object_iter_next(&(joi))) +#define JSON_OBJECT_NEW_ARRAY(json_func, fields, n) \ + ({ \ + struct json_object *_json_array = json_object_new_array(); \ + for (int _i = 0; _i < (n); _i++) \ + json_object_array_add(_json_array, \ + (json_func)((fields)[_i])); \ + (_json_array); \ + }) + extern bool use_json(const int argc, struct cmd_token *argv[]); extern void json_object_string_add(struct json_object *obj, const char *key, const char *s); diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 417fc69694..4225b59e26 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -453,6 +453,11 @@ void ospf6_area_show(struct vty *vty, struct ospf6_area *oa, json_object_int_add(json_area, "numberOfAreaScopedLsa", oa->lsdb->count); + json_object_object_add( + json_area, "lsaStatistics", + JSON_OBJECT_NEW_ARRAY(json_object_new_int, + oa->lsdb->stats, + OSPF6_LSTYPE_SIZE)); /* Interfaces Attached */ array_interfaces = json_object_new_array(); |
