From b96879c0d135201f0a6de8c0a587d477410c4693 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Sep 2017 13:57:35 -0400 Subject: [PATCH] bgpd: Add large community json support Add the ability to display large commnunity json support Fixes: 1191 Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index e3f63f11b6..a12abd9fd0 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7328,6 +7328,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, json_object *json_cluster_list = NULL; json_object *json_cluster_list_list = NULL; json_object *json_ext_community = NULL; + json_object *json_lcommunity = NULL; json_object *json_last_update = NULL; json_object *json_nexthop_global = NULL; json_object *json_nexthop_ll = NULL; @@ -7900,9 +7901,20 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, } /* Line 6 display Large community */ - if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) - vty_out(vty, " Large Community: %s\n", - attr->lcommunity->str); + if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) { + if (json_paths) { + json_lcommunity = json_object_new_object(); + json_object_string_add(json_lcommunity, + "string", + attr->lcommunity->str); + json_object_object_add(json_path, + "largeCommunity", + json_lcommunity); + } else { + vty_out(vty, " Large Community: %s\n", + attr->lcommunity->str); + } + } /* Line 7 display Originator, Cluster-id */ if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) -- 2.39.5