if (type == bgp_show_type_lcommunity_exact) {
struct lcommunity *lcom = output_arg;
- if (!pi->attr->lcommunity ||
- !lcommunity_cmp(
- pi->attr->lcommunity, lcom))
+ if (!bgp_attr_get_lcommunity(
+ pi->attr) ||
+ !lcommunity_cmp(
+ bgp_attr_get_lcommunity(
+ pi->attr),
+ lcom))
continue;
}
if (type == bgp_show_type_lcommunity) {
struct lcommunity *lcom = output_arg;
- if (!pi->attr->lcommunity ||
- !lcommunity_match(
- pi->attr->lcommunity, lcom))
+ if (!bgp_attr_get_lcommunity(
+ pi->attr) ||
+ !lcommunity_match(
+ bgp_attr_get_lcommunity(
+ pi->attr),
+ lcom))
continue;
}
if (type == bgp_show_type_community) {
json_prefix_info = json_object_new_object();
- json_object_string_add(
- json_prefix_info, "prefix",
- prefix2str((struct prefix_evpn *)p, buf,
- BUFSIZ));
+ prefix2str((struct prefix_evpn *)p, buf,
+ BUFSIZ);
+
+ json_object_string_addf(
+ json_prefix_info, "prefix", "%pFX",
+ (struct prefix_evpn *)p);
json_object_int_add(json_prefix_info,
"prefixLen", p->prefixlen);
if (use_json) {
json_object_int_add(json, "numPrefix", output_count);
json_object_int_add(json, "totalPrefix", total_count);
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
if (output_count == 0)
vty_out(vty, "No prefixes displayed, %ld exist\n",
evpn_show_vni(vty, bgp_evpn, vni, json);
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json,
- JSON_C_TO_STRING_PRETTY
- | JSON_C_TO_STRING_NOSLASHESCAPE));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_all_routes(vty, bgp, type, json, detail);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
else
evpn_show_route_rd(vty, bgp, &prd, type, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
else
evpn_show_route_rd_macip(vty, bgp, &prd, &mac, &ip, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_routes_esi(vty, bgp, &esi, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_routes_vni(vty, bgp, vni, type, vtep_ip, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_route_vni_macip(vty, bgp, vni, &mac, &ip, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_route_vni_multicast(vty, bgp, vni, orig_ip, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_routes_vni_all(vty, bgp, vtep_ip, json, da);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
if (uj)
json = json_object_new_object();
bgp_evpn_show_routes_mac_ip_evi_es(vty, esi_p, json, !!detail);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
if (uj)
json = json_object_new_object();
bgp_evpn_show_routes_mac_ip_global_es(vty, esi_p, json, !!detail);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_vrf_import_rts(vty, bgp_evpn, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
evpn_show_import_rts(vty, bgp, json);
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
prefix_rd2str(&bgp->vrf_prd, buf1, RD_ADDRSTRLEN));
}
- if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}