const struct prefix *prefix),
(peer, attr, prefix));
+/* Render dest to prefix_rd based on safi */
+static const struct prefix_rd *bgp_rd_from_dest(const struct bgp_dest *dest,
+ safi_t safi);
+
/* Extern from bgp_dump.c */
extern const char *bgp_origin_str[];
extern const char *bgp_origin_long_str[];
{
struct bgp_path_info *pi;
struct bgp_dest *dest;
- int header = 1;
+ bool header = true;
+ bool json_detail_header = false;
int display;
unsigned long output_count = 0;
unsigned long total_count = 0;
bool all = CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_ALL);
if (output_cum && *output_cum != 0)
- header = 0;
+ header = false;
if (use_json && !*json_header_depth) {
if (all)
vty_out(vty, " \"%s\" : { ", rd);
}
+ /* Check for 'json detail', where we need header output once per dest */
+ if (use_json && CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL) &&
+ type != bgp_show_type_dampend_paths &&
+ type != bgp_show_type_damp_neighbor &&
+ type != bgp_show_type_flap_statistics &&
+ type != bgp_show_type_flap_neighbor)
+ json_detail_header = true;
+
/* Start processing of routes. */
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
const struct prefix *dest_p = bgp_dest_get_prefix(dest);
enum rpki_states rpki_curr_state = RPKI_NOT_BEING_USED;
+ bool json_detail = json_detail_header;
pi = bgp_dest_get_bgp_path_info(dest);
if (pi == NULL)
else
vty_out(vty, (wide ? BGP_SHOW_HEADER_WIDE
: BGP_SHOW_HEADER));
- header = 0;
+ header = false;
+
+ } else if (json_detail && json_paths != NULL) {
+ const struct prefix_rd *prd;
+ json_object *jtemp;
+
+ /* Use common detail header, for most types;
+ * need a json 'object'.
+ */
+
+ jtemp = json_object_new_object();
+ prd = bgp_rd_from_dest(dest, safi);
+
+ route_vty_out_detail_header(
+ vty, bgp, dest, prd, table->afi,
+ safi, jtemp);
+
+ json_object_array_add(json_paths, jtemp);
+
+ json_detail = false;
}
+
if (rd != NULL && !display && !output_count) {
if (!use_json)
vty_out(vty,
}
return CMD_SUCCESS;
}
+
static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
enum bgp_show_type type, void *output_arg,
uint16_t show_flags, enum rpki_states rpki_target_state)
}
}
+/*
+ * Return rd based on safi
+ */
+static const struct prefix_rd *bgp_rd_from_dest(const struct bgp_dest *dest,
+ safi_t safi)
+{
+ switch (safi) {
+ case SAFI_MPLS_VPN:
+ case SAFI_ENCAP:
+ case SAFI_EVPN:
+ return (struct prefix_rd *)(bgp_dest_get_prefix(dest));
+ default:
+ return NULL;
+
+ }
+}
+
/* Display specified route of BGP table. */
static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
struct bgp_table *rib, const char *ip_str,