"Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
vty_out(vty, "Origin codes: i - IGP, e - EGP, ? - incomplete\n");
vty_out(vty,
- "EVPN type-1 prefix: [1]:[ESI]:[EthTag]:[IPlen]:[VTEP-IP]\n");
+ "EVPN type-1 prefix: [1]:[EthTag]:[ESI]:[IPlen]:[VTEP-IP]\n");
vty_out(vty,
"EVPN type-2 prefix: [2]:[EthTag]:[MAClen]:[MAC]:[IPlen]:[IP]\n");
vty_out(vty, "EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]\n");
json_object *json_import_rtl = NULL;
json_object *json_export_rtl = NULL;
char buf2[ETHER_ADDR_STRLEN];
- char originator_ip[BUFSIZ] = {0};
json_import_rtl = json_export_rtl = 0;
json_object_string_add(
json, "rd",
prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN));
- json_object_string_add(
- json, "originatorIp",
- inet_ntop(AF_INET, &bgp_vrf->originator_ip,
- originator_ip, sizeof(originator_ip)));
+ json_object_string_addf(json, "originatorIp", "%pI4",
+ &bgp_vrf->originator_ip);
json_object_string_add(json, "advertiseGatewayMacip", "n/a");
json_object_string_add(json, "advertiseSviMacIp", "n/a");
- json_object_to_json_string_ext(json,
- JSON_C_TO_STRING_NOSLASHESCAPE);
json_object_string_add(json, "advertisePip",
bgp_vrf->evpn_info->advertise_pip ?
"Enabled" : "Disabled");
- json_object_string_add(json, "sysIP",
- inet_ntop(AF_INET,
- &bgp_vrf->evpn_info->pip_ip,
- buf1, INET_ADDRSTRLEN));
+ json_object_string_addf(json, "sysIP", "%pI4",
+ &bgp_vrf->evpn_info->pip_ip);
json_object_string_add(json, "sysMac",
prefix_mac2str(&bgp_vrf->evpn_info->pip_rmac,
buf2, sizeof(buf2)));
json_object *json_import_rtl = NULL;
json_object *json_export_rtl = NULL;
struct bgp *bgp_evpn;
- char buf[BUFSIZ] = {0};
bgp_evpn = bgp_get_evpn();
json_object_string_add(
json, "rd",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
- json_object_string_add(json, "originatorIp",
- inet_ntop(AF_INET, &vpn->originator_ip,
- buf, sizeof(buf)));
- json_object_string_add(
- json, "mcastGroup",
- inet_ntop(AF_INET, &vpn->mcast_grp, buf, sizeof(buf)));
+ json_object_string_addf(json, "originatorIp", "%pI4",
+ &vpn->originator_ip);
+ json_object_string_addf(json, "mcastGroup", "%pI4",
+ &vpn->mcast_grp);
/* per vni knob is enabled -- Enabled
* Global knob is enabled -- Active
* default -- Disabled
json_object *json_export_rtl = NULL;
char buf1[10];
char buf2[INET6_ADDRSTRLEN];
- char buf3[BUFSIZ] = {0};
char rt_buf[25];
char *ecom_str;
struct listnode *node, *nnode;
json_object_int_add(json_vni, "vni", bgp->l3vni);
json_object_string_add(json_vni, "type", "L3");
json_object_string_add(json_vni, "inKernel", "True");
- json_object_string_add(json_vni, "originatorIp",
- inet_ntop(AF_INET, &bgp->originator_ip,
- buf3, sizeof(buf3)));
+ json_object_string_addf(json_vni, "originatorIp", "%pI4",
+ &bgp->originator_ip);
json_object_string_add(
json_vni, "rd",
prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN));
json_object_string_add(json_vni, "advertiseGatewayMacip",
"n/a");
json_object_string_add(json_vni, "advertiseSviMacIp", "n/a");
- json_object_to_json_string_ext(json_vni,
- JSON_C_TO_STRING_NOSLASHESCAPE);
json_object_string_add(
json_vni, "advertisePip",
bgp->evpn_info->advertise_pip ? "Enabled" : "Disabled");
- json_object_string_add(json_vni, "sysIP",
- inet_ntop(AF_INET,
- &bgp->evpn_info->pip_ip, buf3,
- sizeof(buf3)));
+ json_object_string_addf(json_vni, "sysIP", "%pI4",
+ &bgp->evpn_info->pip_ip);
json_object_string_add(json_vni, "sysMAC",
prefix_mac2str(&bgp->evpn_info->pip_rmac,
buf2, sizeof(buf2)));
struct bgpevpn *vpn = (struct bgpevpn *)bucket->data;
char buf1[10];
char buf2[RD_ADDRSTRLEN];
- char buf3[BUFSIZ] = {0};
char rt_buf[25];
char *ecom_str;
struct listnode *node, *nnode;
json_object_string_add(
json_vni, "rd",
prefix_rd2str(&vpn->prd, buf2, sizeof(buf2)));
- json_object_string_add(json_vni, "originatorIp",
- inet_ntop(AF_INET, &vpn->originator_ip,
- buf3, sizeof(buf3)));
- json_object_string_add(json_vni, "mcastGroup",
- inet_ntop(AF_INET, &vpn->mcast_grp, buf3,
- sizeof(buf3)));
+ json_object_string_addf(json_vni, "originatorIp", "%pI4",
+ &vpn->originator_ip);
+ json_object_string_addf(json_vni, "mcastGroup", "%pI4",
+ &vpn->mcast_grp);
/* per vni knob is enabled -- Enabled
* Global knob is enabled -- Active
* default -- Disabled
char rd_str[RD_ADDRSTRLEN];
char buf[BUFSIZ];
int no_display;
- char router_id[BUFSIZ] = {0};
unsigned long output_count = 0;
unsigned long total_count = 0;
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_object_int_add(
json, "bgpTableVersion",
tbl_ver);
- json_object_string_add(
+ json_object_string_addf(
json,
"bgpLocalRouterId",
- inet_ntop(
- AF_INET,
- &bgp->router_id,
- router_id,
- sizeof(router_id)));
+ "%pI4",
+ &bgp->router_id);
json_object_int_add(
json,
"defaultLocPrf",
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",
/* RD header and legend - once overall. */
if (rd_header && !json) {
vty_out(vty,
- "EVPN type-1 prefix: [1]:[ESI]:[EthTag]:[IPlen]:[VTEP-IP]\n");
+ "EVPN type-1 prefix: [1]:[EthTag]:[ESI]:[IPlen]:[VTEP-IP]\n");
vty_out(vty,
"EVPN type-2 prefix: [2]:[EthTag]:[MAClen]:[MAC]\n");
vty_out(vty,
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_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;
}
{
char buf[ETHER_ADDR_STRLEN];
char buf1[INET6_ADDRSTRLEN];
- char originator_ip[BUFSIZ] = {0};
int idx_vrf = 3;
const char *name = NULL;
struct bgp *bgp = NULL;
prefix_rd2str(&bgp->vrf_prd, buf1, RD_ADDRSTRLEN));
} else {
json_object_string_add(json, "vrf", name);
- json_object_string_add(json, "local-ip",
- inet_ntop(AF_INET, &bgp->originator_ip,
- originator_ip,
- sizeof(originator_ip)));
+ json_object_string_addf(json, "local-ip", "%pI4",
+ &bgp->originator_ip);
json_object_int_add(json, "l3vni", bgp->l3vni);
json_object_string_add(
json, "rmac",
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;
}