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_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_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_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, "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)));
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
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",
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",
json_nexthop_global = json_object_new_object();
- json_object_string_add(json_nexthop_global, "ip",
- inet_ntop(AF_INET,
- &attr->nexthop, buf,
- sizeof(buf)));
+ json_object_string_addf(json_nexthop_global, "ip",
+ "%pI4", &attr->nexthop);
if (path->peer->hostname)
json_object_string_add(json_nexthop_global,
json_object_string_add(json_nexthop_global,
"afi", "ipv4");
- json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntop(AF_INET, &attr->nexthop, buf,
- sizeof(buf)));
+ json_object_string_addf(json_nexthop_global,
+ "ip", "%pI4",
+ &attr->nexthop);
if (path->peer->hostname)
json_object_string_add(
json_nexthop_global = json_object_new_object();
- json_object_string_add(json_nexthop_global, "ip",
- inet_ntop(AF_INET,
- &attr->nexthop, buf,
- sizeof(buf)));
+ json_object_string_addf(json_nexthop_global, "ip",
+ "%pI4", &attr->nexthop);
if (path->peer->hostname)
json_object_string_add(json_nexthop_global,
if (json_paths) {
json_nexthop_global = json_object_new_object();
- json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntop(AF_INET6, &attr->mp_nexthop_global,
- buf, BUFSIZ));
+ json_object_string_addf(json_nexthop_global, "ip",
+ "%pI6",
+ &attr->mp_nexthop_global);
if (path->peer->hostname)
json_object_string_add(json_nexthop_global,
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
|| (path->peer->conf_if)) {
json_nexthop_ll = json_object_new_object();
- json_object_string_add(
- json_nexthop_ll, "ip",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_local, buf,
- BUFSIZ));
+ json_object_string_addf(
+ json_nexthop_ll, "ip", "%pI6",
+ &attr->mp_nexthop_local);
if (path->peer->hostname)
json_object_string_add(
&& (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)
- json_object_string_add(
- json_net, "nextHop",
- inet_ntop(
- AF_INET,
- &attr->mp_nexthop_global_in,
- buf, sizeof(buf)));
+ json_object_string_addf(
+ json_net, "nextHop", "%pI4",
+ &attr->mp_nexthop_global_in);
else
- json_object_string_add(
- json_net, "nextHop",
- inet_ntop(AF_INET,
- &attr->nexthop, buf,
- sizeof(buf)));
+ json_object_string_addf(
+ json_net, "nextHop", "%pI4",
+ &attr->nexthop);
} else if (p->family == AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
char buf[BUFSIZ];
- json_object_string_add(
- json_net, "nextHopGlobal",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_global, buf,
- BUFSIZ));
+ json_object_string_addf(
+ json_net, "nextHopGlobal", "%pI6",
+ &attr->mp_nexthop_global);
} else if (p->family == AF_EVPN
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
char buf[BUFSIZ] = {0};
- json_object_string_add(
- json_net, "nextHop",
- inet_ntop(AF_INET,
- &attr->mp_nexthop_global_in,
- buf, sizeof(buf)));
+ json_object_string_addf(
+ json_net, "nextHop", "%pI4",
+ &attr->mp_nexthop_global_in);
}
if (attr->flag
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) {
if (json)
- json_object_string_add(
- json_out, "mpNexthopGlobalIn",
- inet_ntop(AF_INET,
- &attr->mp_nexthop_global_in,
- buf, sizeof(buf)));
+ json_object_string_addf(
+ json_out, "mpNexthopGlobalIn", "%pI4",
+ &attr->mp_nexthop_global_in);
else
vty_out(vty, "%-16pI4",
&attr->mp_nexthop_global_in);
} else {
if (json)
- json_object_string_add(
- json_out, "nexthop",
- inet_ntop(AF_INET, &attr->nexthop, buf,
- sizeof(buf)));
+ json_object_string_addf(json_out, "nexthop",
+ "%pI4", &attr->nexthop);
else
vty_out(vty, "%-16pI4", &attr->nexthop);
}
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) {
if (json)
- json_object_string_add(
- json_out, "mpNexthopGlobalIn",
- inet_ntop(AF_INET6,
- &attr->mp_nexthop_global,
- buf_a, sizeof(buf_a)));
+ json_object_string_addf(
+ json_out, "mpNexthopGlobalIn", "%pI6",
+ &attr->mp_nexthop_global);
else
vty_out(vty, "%s",
inet_ntop(AF_INET6,
json_object_int_add(json_path, "aggregatorAs",
attr->aggregator_as);
- json_object_string_add(json_path, "aggregatorId",
- inet_ntop(AF_INET,
- &attr->aggregator_addr,
- buf, sizeof(buf)));
+ json_object_string_addf(json_path, "aggregatorId",
+ "%pI4", &attr->aggregator_addr);
} else {
vty_out(vty, ", (aggregated by %u %pI4)",
attr->aggregator_as, &attr->aggregator_addr);
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) {
if (json_paths) {
- json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntop(AF_INET,
- &attr->mp_nexthop_global_in,
- buf, sizeof(buf)));
+ json_object_string_addf(
+ json_nexthop_global, "ip", "%pI4",
+ &attr->mp_nexthop_global_in);
if (path->peer->hostname)
json_object_string_add(
}
} else {
if (json_paths) {
- json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntop(AF_INET, &attr->nexthop, buf,
- sizeof(buf)));
+ json_object_string_addf(json_nexthop_global,
+ "ip", "%pI4",
+ &attr->nexthop);
if (path->peer->hostname)
json_object_string_add(
"ipv4");
} else {
if (json_paths) {
- json_object_string_add(
- json_nexthop_global, "ip",
- inet_ntop(AF_INET6, &attr->mp_nexthop_global,
- buf, INET6_ADDRSTRLEN));
+ json_object_string_addf(json_nexthop_global, "ip",
+ "%pI6",
+ &attr->mp_nexthop_global);
if (path->peer->hostname)
json_object_string_add(json_nexthop_global,
if (json_paths) {
char buf[BUFSIZ] = {0};
- json_object_string_add(json_peer, "routerId",
- inet_ntop(AF_INET,
- &bgp->router_id, buf,
- sizeof(buf)));
+ json_object_string_addf(json_peer, "routerId", "%pI4",
+ &bgp->router_id);
} else {
vty_out(vty, "(%pI4)", &bgp->router_id);
}
sockunion2str(&path->peer->su,
buf,
SU_ADDRSTRLEN));
- json_object_string_add(json_peer, "routerId",
- inet_ntop(AF_INET,
- &path->peer->remote_id,
- buf1, sizeof(buf1)));
+ json_object_string_addf(json_peer, "routerId", "%pI4",
+ &path->peer->remote_id);
if (path->peer->hostname)
json_object_string_add(json_peer, "hostname",
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
if (json_paths) {
json_nexthop_ll = json_object_new_object();
- json_object_string_add(
- json_nexthop_ll, "ip",
- inet_ntop(AF_INET6, &attr->mp_nexthop_local,
- buf, INET6_ADDRSTRLEN));
+ json_object_string_addf(json_nexthop_ll, "ip", "%pI6",
+ &attr->mp_nexthop_local);
if (path->peer->hostname)
json_object_string_add(json_nexthop_ll,
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) {
if (json_paths)
- json_object_string_add(
- json_path, "originatorId",
- inet_ntop(AF_INET, &attr->originator_id,
- buf, sizeof(buf)));
+ json_object_string_addf(json_path,
+ "originatorId", "%pI4",
+ &attr->originator_id);
else
vty_out(vty, " Originator: %pI4",
&attr->originator_id);
if (*header1) {
if (json) {
json_object_int_add(json, "bgpTableVersion", version);
- json_object_string_add(json, "bgpLocalRouterId",
- inet_ntop(AF_INET,
- &bgp->router_id, buf,
- sizeof(buf)));
+ json_object_string_addf(json, "bgpLocalRouterId",
+ "%pI4", &bgp->router_id);
json_object_int_add(json, "defaultLocPrf",
bgp->default_local_pref);
json_object_int_add(json, "localAS", bgp->as);
if (use_json) {
json_object_int_add(json, "bgpTableVersion",
table->version);
- json_object_string_add(json, "bgpLocalRouterId",
- inet_ntop(AF_INET,
- &bgp->router_id, buf,
- sizeof(buf)));
+ json_object_string_addf(json, "bgpLocalRouterId",
+ "%pI4", &bgp->router_id);
json_object_int_add(json, "defaultLocPrf",
bgp->default_local_pref);
json_object_int_add(json, "localAS", bgp->as);
json_object_string_add(json_vrf, "type", type);
json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
- json_object_string_add(json_vrf, "routerId",
- inet_ntop(AF_INET,
- &bgp->router_id, buf,
- sizeof(buf)));
+ json_object_string_addf(json_vrf, "routerId", "%pI4",
+ &bgp->router_id);
json_object_int_add(json_vrf, "numConfiguredPeers",
peers_cfg);
json_object_int_add(json_vrf, "numEstablishedPeers",
if (use_json) {
char buf[BUFSIZ] = {0};
- json_object_string_add(
- json, "routerId",
- inet_ntop(AF_INET, &bgp->router_id, buf,
- sizeof(buf)));
+ json_object_string_addf(json, "routerId",
+ "%pI4",
+ &bgp->router_id);
json_object_int_add(json, "as", bgp->as);
json_object_int_add(json, "vrfId", vrf_id_ui);
json_object_string_add(
/* BGP Version. */
json_object_int_add(json_neigh, "bgpVersion", 4);
- json_object_string_add(
- json_neigh, "remoteRouterId",
- inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1)));
- json_object_string_add(
- json_neigh, "localRouterId",
- inet_ntop(AF_INET, &bgp->router_id, buf1,
- sizeof(buf1)));
+ json_object_string_addf(json_neigh, "remoteRouterId", "%pI4",
+ &p->remote_id);
+ json_object_string_addf(json_neigh, "localRouterId", "%pI4",
+ &bgp->router_id);
/* Confederation */
if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
/* Nexthop display. */
if (p->su_local) {
if (use_json) {
- json_object_string_add(json_neigh, "nexthop",
- inet_ntop(AF_INET,
- &p->nexthop.v4, buf1,
- sizeof(buf1)));
- json_object_string_add(json_neigh, "nexthopGlobal",
- inet_ntop(AF_INET6,
- &p->nexthop.v6_global,
- buf1, sizeof(buf1)));
- json_object_string_add(json_neigh, "nexthopLocal",
- inet_ntop(AF_INET6,
- &p->nexthop.v6_local,
- buf1, sizeof(buf1)));
+ json_object_string_addf(json_neigh, "nexthop", "%pI4",
+ &p->nexthop.v4);
+ json_object_string_addf(json_neigh, "nexthopGlobal",
+ "%pI6", &p->nexthop.v6_global);
+ json_object_string_addf(json_neigh, "nexthopLocal",
+ "%pI6", &p->nexthop.v6_local);
if (p->shared_network)
json_object_string_add(json_neigh,
"bgpConnection",