diff options
Diffstat (limited to 'ospf6d/ospf6_spf.c')
| -rw-r--r-- | ospf6d/ospf6_spf.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index f94252991c..121e846843 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -649,14 +649,10 @@ static int ospf6_spf_calculation_thread(struct thread *t) ospf6_spf_reason_string(ospf6->spf_reason, rbuf, sizeof(rbuf)); if (IS_OSPF6_DEBUG_SPF(PROCESS) || IS_OSPF6_DEBUG_SPF(TIME)) - zlog_debug("SPF runtime: %lld sec %lld usec", - (long long)runtime.tv_sec, - (long long)runtime.tv_usec); - - zlog_info( - "SPF processing: # Areas: %d, SPF runtime: %lld sec %lld usec, Reason: %s", - areas_processed, (long long)runtime.tv_sec, - (long long)runtime.tv_usec, rbuf); + zlog_debug( + "SPF processing: # Areas: %d, SPF runtime: %lld sec %lld usec, Reason: %s", + areas_processed, (long long)runtime.tv_sec, + (long long)runtime.tv_usec, rbuf); ospf6->last_spf_reason = ospf6->spf_reason; ospf6_reset_spf_reason(ospf6); @@ -718,9 +714,7 @@ void ospf6_spf_schedule(struct ospf6 *ospf6, unsigned int reason) } if (IS_OSPF6_DEBUG_SPF(PROCESS) || IS_OSPF6_DEBUG_SPF(TIME)) - zlog_debug("SPF: calculation timer delay = %ld", delay); - - zlog_info("SPF: Scheduled in %ld msec", delay); + zlog_debug("SPF: Rescheduling in %ld msec", delay); ospf6->t_spf_calc = NULL; thread_add_timer_msec(master, ospf6_spf_calculation_thread, ospf6, @@ -728,16 +722,24 @@ void ospf6_spf_schedule(struct ospf6 *ospf6, unsigned int reason) } void ospf6_spf_display_subtree(struct vty *vty, const char *prefix, int rest, - struct ospf6_vertex *v) + struct ospf6_vertex *v, json_object *json_obj, + bool use_json) { struct listnode *node, *nnode; struct ospf6_vertex *c; char *next_prefix; int len; int restnum; + json_object *json_childs = NULL; + json_object *json_child = NULL; - /* "prefix" is the space prefix of the display line */ - vty_out(vty, "%s+-%s [%d]\n", prefix, v->name, v->cost); + if (use_json) { + json_childs = json_object_new_object(); + json_object_int_add(json_obj, "cost", v->cost); + } else { + /* "prefix" is the space prefix of the display line */ + vty_out(vty, "%s+-%s [%d]\n", prefix, v->name, v->cost); + } len = strlen(prefix) + 4; next_prefix = (char *)malloc(len); @@ -749,10 +751,27 @@ void ospf6_spf_display_subtree(struct vty *vty, const char *prefix, int rest, restnum = listcount(v->child_list); for (ALL_LIST_ELEMENTS(v->child_list, node, nnode, c)) { - restnum--; - ospf6_spf_display_subtree(vty, next_prefix, restnum, c); - } + if (use_json) + json_child = json_object_new_object(); + else + restnum--; + + ospf6_spf_display_subtree(vty, next_prefix, restnum, c, + json_child, use_json); + if (use_json) + json_object_object_add(json_childs, c->name, + json_child); + } + if (use_json) { + json_object_boolean_add(json_obj, "isLeafNode", + !listcount(v->child_list)); + if (listcount(v->child_list)) + json_object_object_add(json_obj, "children", + json_childs); + else + json_object_free(json_childs); + } free(next_prefix); } |
