From: Dinesh G Dutt Date: Mon, 16 Jan 2017 14:24:09 +0000 (-0800) Subject: bgpd: Add decoded notification code strings to JSON output X-Git-Tag: frr-2.0-rc2~24^2~6 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=cca1dda8bf5aca42aec577b2e156b5e56a2bc996;p=matthieu%2Ffrr.git bgpd: Add decoded notification code strings to JSON output Ticket: CM-14136 Reviewed By: CCR-5585 Testing Done: bgpmin The JSON output of 'bgp neighbor show' lacked the decoded strings for the last notification error code/subcode. Decoding these strings outside quagga is painful, and then needs to match with any updates to the codes from RFCs/drafts. Further, all apps that look to understanding this need to then add their own decoders for these strings. Just add the decoded strings to the JSON output as well. JSON key name for this is 'lastNotificationReason'. Signed-off-by: Dinesh Dutt --- diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 52ce1273c3..79e5a0c332 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -11917,11 +11917,19 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js tm = gmtime(&uptime); json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); - if (p->last_reset_cause_size) + if (p->last_reset == PEER_DOWN_NOTIFY_SEND || + p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { char errorcodesubcode_hexstr[5]; + char errorcodesubcode_str[256]; + + code_str = bgp_notify_code_str(p->notify.code); + subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); + sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); + snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str); + json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str); } } else