mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 07:37:54 +00:00
Merge pull request #10092 from ton31337/feature/replace_json_object_string_add_to_json_object_string_addf_for_inet_ntop
*: inet_ntop for JSON output
This commit is contained in:
commit
3c52293809
@ -2191,13 +2191,11 @@ static void bgp_evpn_es_json_vtep_fill(json_object *json_vteps,
|
||||
{
|
||||
json_object *json_vtep_entry;
|
||||
json_object *json_flags;
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
json_vtep_entry = json_object_new_object();
|
||||
|
||||
json_object_string_add(
|
||||
json_vtep_entry, "vtep_ip",
|
||||
inet_ntop(AF_INET, &es_vtep->vtep_ip, ip_buf, sizeof(ip_buf)));
|
||||
json_object_string_addf(json_vtep_entry, "vtep_ip", "%pI4",
|
||||
&es_vtep->vtep_ip);
|
||||
if (es_vtep->flags & (BGP_EVPNES_VTEP_ESR |
|
||||
BGP_EVPNES_VTEP_ACTIVE)) {
|
||||
json_flags = json_object_new_array();
|
||||
@ -2314,8 +2312,6 @@ static void bgp_evpn_es_show_entry(struct vty *vty,
|
||||
static void bgp_evpn_es_show_entry_detail(struct vty *vty,
|
||||
struct bgp_evpn_es *es, json_object *json)
|
||||
{
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
if (json) {
|
||||
json_object *json_flags;
|
||||
json_object *json_incons;
|
||||
@ -2338,9 +2334,8 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
|
||||
json_array_string_add(json_flags, "bypass");
|
||||
json_object_object_add(json, "flags", json_flags);
|
||||
}
|
||||
json_object_string_add(json, "originator_ip",
|
||||
inet_ntop(AF_INET, &es->originator_ip,
|
||||
ip_buf, sizeof(ip_buf)));
|
||||
json_object_string_addf(json, "originator_ip", "%pI4",
|
||||
&es->originator_ip);
|
||||
json_object_int_add(json, "remoteVniCount",
|
||||
es->remote_es_evi_cnt);
|
||||
json_object_int_add(json, "vrfCount",
|
||||
@ -3714,13 +3709,11 @@ static void bgp_evpn_es_evi_json_vtep_fill(json_object *json_vteps,
|
||||
{
|
||||
json_object *json_vtep_entry;
|
||||
json_object *json_flags;
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
json_vtep_entry = json_object_new_object();
|
||||
|
||||
json_object_string_add(
|
||||
json_vtep_entry, "vtep_ip",
|
||||
inet_ntop(AF_INET, &evi_vtep->vtep_ip, ip_buf, sizeof(ip_buf)));
|
||||
json_object_string_addf(json_vtep_entry, "vtep_ip", "%pI4",
|
||||
&evi_vtep->vtep_ip);
|
||||
if (evi_vtep->flags & (BGP_EVPN_EVI_VTEP_EAD_PER_ES |
|
||||
BGP_EVPN_EVI_VTEP_EAD_PER_EVI)) {
|
||||
json_flags = json_object_new_array();
|
||||
|
@ -377,7 +377,6 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
|
||||
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;
|
||||
|
||||
@ -390,19 +389,15 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
|
||||
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)));
|
||||
@ -483,7 +478,6 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
|
||||
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();
|
||||
|
||||
@ -497,12 +491,10 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
|
||||
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
|
||||
@ -933,7 +925,6 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
|
||||
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;
|
||||
@ -956,9 +947,8 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
|
||||
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));
|
||||
@ -968,10 +958,8 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
|
||||
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)));
|
||||
@ -1060,7 +1048,6 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
|
||||
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;
|
||||
@ -1090,12 +1077,10 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
|
||||
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
|
||||
@ -1207,7 +1192,6 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
|
||||
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;
|
||||
@ -1296,14 +1280,11 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
|
||||
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",
|
||||
@ -5781,7 +5762,6 @@ DEFUN (show_bgp_vrf_l3vni_info,
|
||||
{
|
||||
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;
|
||||
@ -5845,10 +5825,8 @@ DEFUN (show_bgp_vrf_l3vni_info,
|
||||
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",
|
||||
|
184
bgpd/bgp_route.c
184
bgpd/bgp_route.c
@ -8733,14 +8733,10 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
||||
}
|
||||
} else if (safi == SAFI_EVPN) {
|
||||
if (json_paths) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
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,
|
||||
@ -8768,16 +8764,13 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
||||
} else if (safi == SAFI_FLOWSPEC) {
|
||||
if (attr->nexthop.s_addr != INADDR_ANY) {
|
||||
if (json_paths) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
json_nexthop_global = json_object_new_object();
|
||||
|
||||
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(
|
||||
@ -8807,14 +8800,10 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
||||
}
|
||||
} else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
|
||||
if (json_paths) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
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,
|
||||
@ -8843,14 +8832,11 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
||||
|
||||
/* IPv6 Next Hop */
|
||||
else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
|
||||
char buf[BUFSIZ];
|
||||
|
||||
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,
|
||||
@ -8868,11 +8854,9 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
||||
== 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(
|
||||
@ -9125,42 +9109,27 @@ void route_vty_out_tmp(struct vty *vty, struct bgp_dest *dest,
|
||||
/* Print attribute */
|
||||
if (attr) {
|
||||
if (use_json) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
if (p->family == AF_INET
|
||||
&& (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
|
||||
@ -9279,25 +9248,19 @@ void route_vty_out_tag(struct vty *vty, const struct prefix *p,
|
||||
&& ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)))
|
||||
|| (safi == SAFI_EVPN && !BGP_ATTR_NEXTHOP_AFI_IP6(attr))
|
||||
|| (!BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
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);
|
||||
}
|
||||
@ -9309,11 +9272,9 @@ void route_vty_out_tag(struct vty *vty, const struct prefix *p,
|
||||
|
||||
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,
|
||||
@ -9887,14 +9848,10 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
|
||||
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))) {
|
||||
if (json_paths) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
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);
|
||||
@ -9944,16 +9901,12 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
|| bn_p->family == AF_EVPN)
|
||||
&& (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN
|
||||
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
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(
|
||||
@ -9970,10 +9923,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
}
|
||||
} 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(
|
||||
@ -9995,10 +9947,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
"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,
|
||||
@ -10070,16 +10021,11 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
vty_out(vty, " from :: ");
|
||||
}
|
||||
|
||||
if (json_paths) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
json_object_string_add(json_peer, "routerId",
|
||||
inet_ntop(AF_INET,
|
||||
&bgp->router_id, buf,
|
||||
sizeof(buf)));
|
||||
} else {
|
||||
if (json_paths)
|
||||
json_object_string_addf(json_peer, "routerId", "%pI4",
|
||||
&bgp->router_id);
|
||||
else
|
||||
vty_out(vty, "(%pI4)", &bgp->router_id);
|
||||
}
|
||||
}
|
||||
|
||||
/* We RXed this path from one of our peers */
|
||||
@ -10090,10 +10036,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
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",
|
||||
@ -10193,10 +10137,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
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,
|
||||
@ -10459,10 +10401,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||
|
||||
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);
|
||||
@ -13435,15 +13376,12 @@ static void show_adj_route_header(struct vty *vty, struct bgp *bgp,
|
||||
json_object *json_ocode, bool wide)
|
||||
{
|
||||
uint64_t version = table ? table->version : 0;
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
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);
|
||||
@ -13509,15 +13447,11 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
|
||||
|
||||
if (type == bgp_show_adj_route_advertised && subgrp
|
||||
&& CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
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);
|
||||
|
@ -118,15 +118,11 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
|
||||
|
||||
if (header) {
|
||||
if (use_json) {
|
||||
char buf[BUFSIZ] = {0};
|
||||
|
||||
json_object_int_add(
|
||||
json, "bgpTableVersion", 0);
|
||||
json_object_string_add(
|
||||
json_object_string_addf(
|
||||
json, "bgpLocalRouterId",
|
||||
inet_ntop(AF_INET,
|
||||
&bgp->router_id, buf,
|
||||
sizeof(buf)));
|
||||
"%pI4", &bgp->router_id);
|
||||
json_object_int_add(
|
||||
json,
|
||||
"defaultLocPrf",
|
||||
|
@ -9690,10 +9690,8 @@ DEFUN (show_bgp_vrfs,
|
||||
|
||||
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",
|
||||
@ -10290,12 +10288,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
|
||||
|
||||
/* Usage summary and header */
|
||||
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(
|
||||
@ -12404,13 +12399,10 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
|
||||
|
||||
/* 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)
|
||||
@ -13999,18 +13991,12 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
|
||||
/* 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",
|
||||
|
@ -447,7 +447,6 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
json_object *json)
|
||||
{
|
||||
struct ctl_adj *adj;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_array;
|
||||
json_object *json_adj;
|
||||
|
||||
@ -467,9 +466,8 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
json_adj = json_object_new_object();
|
||||
json_object_string_add(json_adj, "addressFamily",
|
||||
af_name(adj->af));
|
||||
json_object_string_add(json_adj, "neighborId",
|
||||
inet_ntop(AF_INET, &adj->id, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json_adj, "neighborId", "%pI4",
|
||||
&adj->id);
|
||||
switch(adj->type) {
|
||||
case HELLO_LINK:
|
||||
json_object_string_add(json_adj, "type", "link");
|
||||
@ -498,7 +496,6 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
static void
|
||||
show_discovery_detail_adj_json(json_object *json, struct ctl_adj *adj)
|
||||
{
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_adj;
|
||||
json_object *json_array;
|
||||
|
||||
@ -509,8 +506,7 @@ show_discovery_detail_adj_json(json_object *json, struct ctl_adj *adj)
|
||||
}
|
||||
|
||||
json_adj = json_object_new_object();
|
||||
json_object_string_add(json_adj, "lsrId", inet_ntop(AF_INET, &adj->id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_adj, "lsrId", "%pI4", &adj->id);
|
||||
json_object_string_add(json_adj, "sourceAddress", log_addr(adj->af,
|
||||
&adj->src_addr));
|
||||
json_object_string_add(json_adj, "transportAddress", log_addr(adj->af,
|
||||
@ -532,7 +528,6 @@ show_discovery_detail_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
struct ctl_disc_tnbr *tnbr;
|
||||
struct in_addr rtr_id;
|
||||
union ldpd_addr *trans_addr;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_interface;
|
||||
json_object *json_target;
|
||||
static json_object *json_interfaces;
|
||||
@ -542,9 +537,7 @@ show_discovery_detail_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
switch (imsg->hdr.type) {
|
||||
case IMSG_CTL_SHOW_DISCOVERY:
|
||||
rtr_id.s_addr = ldp_rtr_id_get(ldpd_conf);
|
||||
json_object_string_add(json, "lsrId",
|
||||
inet_ntop(AF_INET, &rtr_id, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json, "lsrId", "%pI4", &rtr_id);
|
||||
if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED)
|
||||
json_object_string_add(json, "transportAddressIPv4",
|
||||
log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr));
|
||||
@ -749,7 +742,6 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
json_object *json)
|
||||
{
|
||||
struct ctl_nbr *nbr;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_array;
|
||||
json_object *json_nbr;
|
||||
|
||||
@ -766,9 +758,8 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
json_nbr = json_object_new_object();
|
||||
json_object_string_add(json_nbr, "addressFamily",
|
||||
af_name(nbr->af));
|
||||
json_object_string_add(json_nbr, "neighborId",
|
||||
inet_ntop(AF_INET, &nbr->id, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json_nbr, "neighborId", "%pI4",
|
||||
&nbr->id);
|
||||
json_object_string_add(json_nbr, "state",
|
||||
nbr_state_name(nbr->nbr_state));
|
||||
json_object_string_add(json_nbr, "transportAddress",
|
||||
@ -830,9 +821,7 @@ show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
json_object_object_add(json,
|
||||
inet_ntop(AF_INET, &nbr->id, buf,
|
||||
sizeof(buf)), json_nbr);
|
||||
json_object_string_add(json_nbr, "peerId",
|
||||
inet_ntop(AF_INET, &nbr->id, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json_nbr, "peerId", "%pI4", &nbr->id);
|
||||
json_object_string_add(json_nbr, "tcpLocalAddress",
|
||||
log_addr(nbr->af, &nbr->laddr));
|
||||
json_object_int_add(json_nbr, "tcpLocalPort",
|
||||
@ -1235,7 +1224,6 @@ show_lib_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
json_object *json_array;
|
||||
json_object *json_lib_entry;
|
||||
char dstnet[BUFSIZ];
|
||||
char buf[PREFIX_STRLEN];
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
case IMSG_CTL_SHOW_LIB_BEGIN:
|
||||
@ -1258,9 +1246,8 @@ show_lib_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
snprintf(dstnet, sizeof(dstnet), "%s/%d",
|
||||
log_addr(rt->af, &rt->prefix), rt->prefixlen);
|
||||
json_object_string_add(json_lib_entry, "prefix", dstnet);
|
||||
json_object_string_add(json_lib_entry, "neighborId",
|
||||
inet_ntop(AF_INET, &rt->nexthop, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json_lib_entry, "neighborId", "%pI4",
|
||||
&rt->nexthop);
|
||||
json_object_string_add(json_lib_entry, "localLabel",
|
||||
log_label(rt->local_label));
|
||||
json_object_string_add(json_lib_entry, "remoteLabel",
|
||||
@ -1284,7 +1271,6 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
{
|
||||
struct ctl_rt *rt = NULL;
|
||||
char dstnet[BUFSIZ];
|
||||
char buf[PREFIX_STRLEN];
|
||||
static json_object *json_lib_entry;
|
||||
static json_object *json_adv_labels;
|
||||
json_object *json_adv_label;
|
||||
@ -1316,18 +1302,16 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
rt = imsg->data;
|
||||
|
||||
json_adv_label = json_object_new_object();
|
||||
json_object_string_add(json_adv_label, "neighborId",
|
||||
inet_ntop(AF_INET, &rt->nexthop, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json_adv_label, "neighborId", "%pI4",
|
||||
&rt->nexthop);
|
||||
json_object_array_add(json_adv_labels, json_adv_label);
|
||||
break;
|
||||
case IMSG_CTL_SHOW_LIB_RCVD:
|
||||
rt = imsg->data;
|
||||
|
||||
json_remote_label = json_object_new_object();
|
||||
json_object_string_add(json_remote_label, "neighborId",
|
||||
inet_ntop(AF_INET, &rt->nexthop,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_remote_label, "neighborId", "%pI4",
|
||||
&rt->nexthop);
|
||||
json_object_string_add(json_remote_label, "label",
|
||||
log_label(rt->remote_label));
|
||||
json_object_int_add(json_remote_label, "inUse", rt->in_use);
|
||||
@ -1394,16 +1378,14 @@ show_l2vpn_binding_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
struct ctl_pw *pw;
|
||||
json_object *json_pw;
|
||||
char key_name[64];
|
||||
char buf[PREFIX_STRLEN];
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
case IMSG_CTL_SHOW_L2VPN_BINDING:
|
||||
pw = imsg->data;
|
||||
|
||||
json_pw = json_object_new_object();
|
||||
json_object_string_add(json_pw, "destination",
|
||||
inet_ntop(AF_INET, &pw->lsr_id, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json_pw, "destination", "%pI4",
|
||||
&pw->lsr_id);
|
||||
json_object_int_add(json_pw, "vcId", pw->pwid);
|
||||
|
||||
/* local binding */
|
||||
@ -1481,7 +1463,6 @@ show_l2vpn_pw_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
json_object *json)
|
||||
{
|
||||
struct ctl_pw *pw;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_pw;
|
||||
|
||||
switch (imsg->hdr.type) {
|
||||
@ -1489,9 +1470,7 @@ show_l2vpn_pw_msg_json(struct imsg *imsg, struct show_params *params,
|
||||
pw = imsg->data;
|
||||
|
||||
json_pw = json_object_new_object();
|
||||
json_object_string_add(json_pw, "peerId",
|
||||
inet_ntop(AF_INET, &pw->lsr_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_pw, "peerId", "%pI4", &pw->lsr_id);
|
||||
json_object_int_add(json_pw, "vcId", pw->pwid);
|
||||
json_object_string_add(json_pw, "VpnName", pw->l2vpn_name);
|
||||
if (pw->status == PW_FORWARDING)
|
||||
|
@ -1035,7 +1035,6 @@ void nexthop_group_write_nexthop(struct vty *vty, const struct nexthop *nh)
|
||||
|
||||
void nexthop_group_json_nexthop(json_object *j, const struct nexthop *nh)
|
||||
{
|
||||
char buf[100];
|
||||
struct vrf *vrf;
|
||||
json_object *json_backups = NULL;
|
||||
int i;
|
||||
@ -1046,26 +1045,18 @@ void nexthop_group_json_nexthop(json_object *j, const struct nexthop *nh)
|
||||
ifindex2ifname(nh->ifindex, nh->vrf_id));
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
json_object_string_add(
|
||||
j, "nexthop",
|
||||
inet_ntop(AF_INET, &nh->gate.ipv4, buf, sizeof(buf)));
|
||||
json_object_string_addf(j, "nexthop", "%pI4", &nh->gate.ipv4);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
json_object_string_add(
|
||||
j, "nexthop",
|
||||
inet_ntop(AF_INET, &nh->gate.ipv4, buf, sizeof(buf)));
|
||||
json_object_string_addf(j, "nexthop", "%pI4", &nh->gate.ipv4);
|
||||
json_object_string_add(j, "vrfId",
|
||||
ifindex2ifname(nh->ifindex, nh->vrf_id));
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
json_object_string_add(
|
||||
j, "nexthop",
|
||||
inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)));
|
||||
json_object_string_addf(j, "nexthop", "%pI6", &nh->gate.ipv6);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||
json_object_string_add(
|
||||
j, "nexthop",
|
||||
inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)));
|
||||
json_object_string_addf(j, "nexthop", "%pI6", &nh->gate.ipv6);
|
||||
json_object_string_add(j, "vrfId",
|
||||
ifindex2ifname(nh->ifindex, nh->vrf_id));
|
||||
break;
|
||||
|
@ -142,19 +142,15 @@ static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
json_object_string_add(json_loop, "type", name);
|
||||
json_object_int_add(json_loop, "metric",
|
||||
ntohs(lsdesc->metric));
|
||||
json_object_string_add(json_loop, "interfaceId",
|
||||
inet_ntop(AF_INET,
|
||||
&lsdesc->interface_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_add(
|
||||
json_loop, "neighborInterfaceId",
|
||||
inet_ntop(AF_INET,
|
||||
&lsdesc->neighbor_interface_id, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_add(
|
||||
json_loop, "neighborRouterId",
|
||||
inet_ntop(AF_INET, &lsdesc->neighbor_router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(
|
||||
json_loop, "interfaceId", "%pI4",
|
||||
(in_addr_t *)&lsdesc->interface_id);
|
||||
json_object_string_addf(
|
||||
json_loop, "neighborInterfaceId", "%pI4",
|
||||
(in_addr_t *)&lsdesc->neighbor_interface_id);
|
||||
json_object_string_addf(json_loop, "neighborRouterId",
|
||||
"%pI4",
|
||||
&lsdesc->neighbor_router_id);
|
||||
json_object_array_add(json_arr, json_loop);
|
||||
} else {
|
||||
vty_out(vty, " Type: %s Metric: %d\n", name,
|
||||
|
@ -1482,9 +1482,8 @@ DEFUN(show_ipv6_ospf6_vrfs, show_ipv6_ospf6_vrfs_cmd,
|
||||
|
||||
if (uj) {
|
||||
json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
|
||||
json_object_string_add(json_vrf, "routerId",
|
||||
inet_ntop(AF_INET, &router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_vrf, "routerId", "%pI4",
|
||||
&router_id);
|
||||
json_object_object_add(json_vrfs, name, json_vrf);
|
||||
|
||||
} else {
|
||||
|
@ -2674,10 +2674,8 @@ static void show_sr_prefix(struct sbuf *sbuf, struct json_object *json,
|
||||
srp->nhlfe.label_out);
|
||||
json_object_string_add(json_obj, "interface",
|
||||
itf ? itf->name : "-");
|
||||
json_object_string_add(
|
||||
json_obj, "nexthop",
|
||||
inet_ntop(AF_INET, &srp->nhlfe.nexthop,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_obj, "nexthop", "%pI4",
|
||||
&srp->nhlfe.nexthop);
|
||||
json_object_array_add(json_route, json_obj);
|
||||
} else {
|
||||
sbuf_push(sbuf, 0, "%20s %9s %15s\n",
|
||||
@ -2712,10 +2710,8 @@ static void show_sr_prefix(struct sbuf *sbuf, struct json_object *json,
|
||||
path->srni.label_out);
|
||||
json_object_string_add(json_obj, "interface",
|
||||
itf ? itf->name : "-");
|
||||
json_object_string_add(
|
||||
json_obj, "nexthop",
|
||||
inet_ntop(AF_INET, &path->nexthop,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_obj, "nexthop", "%pI4",
|
||||
&path->nexthop);
|
||||
json_object_array_add(json_route, json_obj);
|
||||
} else {
|
||||
sbuf_push(sbuf, indent, "%20s %9s %15s\n",
|
||||
@ -2755,9 +2751,8 @@ static void show_sr_node(struct vty *vty, struct json_object *json,
|
||||
|
||||
if (json) {
|
||||
json_node = json_object_new_object();
|
||||
json_object_string_add(json_node, "routerID",
|
||||
inet_ntop(AF_INET, &srn->adv_router,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_node, "routerID", "%pI4",
|
||||
&srn->adv_router);
|
||||
json_object_int_add(json_node, "srgbSize",
|
||||
srn->srgb.range_size);
|
||||
json_object_int_add(json_node, "srgbLabel",
|
||||
@ -2846,10 +2841,8 @@ static void show_sr_node(struct vty *vty, struct json_object *json,
|
||||
srl->nhlfe[0].label_out);
|
||||
json_object_string_add(json_obj, "interface",
|
||||
itf ? itf->name : "-");
|
||||
json_object_string_add(
|
||||
json_obj, "nexthop",
|
||||
inet_ntop(AF_INET, &srl->nhlfe[0].nexthop,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_obj, "nexthop", "%pI4",
|
||||
&srl->nhlfe[0].nexthop);
|
||||
json_object_array_add(json_link, json_obj);
|
||||
/* Backup Link */
|
||||
json_obj = json_object_new_object();
|
||||
@ -2862,10 +2855,8 @@ static void show_sr_node(struct vty *vty, struct json_object *json,
|
||||
srl->nhlfe[1].label_out);
|
||||
json_object_string_add(json_obj, "interface",
|
||||
itf ? itf->name : "-");
|
||||
json_object_string_add(
|
||||
json_obj, "nexthop",
|
||||
inet_ntop(AF_INET, &srl->nhlfe[1].nexthop,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_obj, "nexthop", "%pI4",
|
||||
&srl->nhlfe[1].nexthop);
|
||||
json_object_array_add(json_link, json_obj);
|
||||
} else {
|
||||
sbuf_push(&sbuf, 0, "%18s %21s %20s %9s %15s\n",
|
||||
@ -2925,7 +2916,6 @@ DEFUN (show_ip_opsf_srdb,
|
||||
int idx = 0;
|
||||
struct in_addr rid;
|
||||
struct sr_node *srn;
|
||||
char buf[PREFIX_STRLEN];
|
||||
bool uj = use_json(argc, argv);
|
||||
json_object *json = NULL, *json_node_array = NULL;
|
||||
|
||||
@ -2937,10 +2927,8 @@ DEFUN (show_ip_opsf_srdb,
|
||||
if (uj) {
|
||||
json = json_object_new_object();
|
||||
json_node_array = json_object_new_array();
|
||||
json_object_string_add(
|
||||
json, "srdbID",
|
||||
inet_ntop(AF_INET, &OspfSR.self->adv_router,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json, "srdbID", "%pI4",
|
||||
&OspfSR.self->adv_router);
|
||||
json_object_object_add(json, "srNodes", json_node_array);
|
||||
} else {
|
||||
vty_out(vty,
|
||||
|
219
ospfd/ospf_vty.c
219
ospfd/ospf_vty.c
@ -3043,7 +3043,6 @@ static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf,
|
||||
struct ospf_area *area;
|
||||
struct timeval result;
|
||||
char timebuf[OSPF_TIME_DUMP_SIZE];
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_vrf = NULL;
|
||||
json_object *json_areas = NULL;
|
||||
|
||||
@ -3068,9 +3067,8 @@ static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf,
|
||||
|
||||
/* Show Router ID. */
|
||||
if (json) {
|
||||
json_object_string_add(json_vrf, "routerId",
|
||||
inet_ntop(AF_INET, &ospf->router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_vrf, "routerId", "%pI4",
|
||||
&ospf->router_id);
|
||||
} else {
|
||||
vty_out(vty, " OSPF Routing Process, Router ID: %pI4\n",
|
||||
&ospf->router_id);
|
||||
@ -3533,7 +3531,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
||||
int is_up;
|
||||
struct ospf_neighbor *nbr;
|
||||
struct route_node *rn;
|
||||
char buf[PREFIX_STRLEN];
|
||||
uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed;
|
||||
|
||||
/* Is interface up? */
|
||||
@ -3603,11 +3600,9 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
||||
|
||||
/* Show OSPF interface information. */
|
||||
if (use_json) {
|
||||
json_object_string_add(
|
||||
json_interface_sub, "ipAddress",
|
||||
inet_ntop(AF_INET,
|
||||
&oi->address->u.prefix4,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(
|
||||
json_interface_sub, "ipAddress", "%pI4",
|
||||
&oi->address->u.prefix4);
|
||||
json_object_int_add(json_interface_sub,
|
||||
"ipAddressPrefixlen",
|
||||
oi->address->prefixlen);
|
||||
@ -3637,17 +3632,13 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
||||
json_interface_sub,
|
||||
"ospfIfType", dstr);
|
||||
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
|
||||
json_object_string_add(
|
||||
json_interface_sub,
|
||||
"vlinkPeer",
|
||||
inet_ntop(AF_INET, &dest,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(
|
||||
json_interface_sub, "vlinkPeer",
|
||||
"%pI4", &dest);
|
||||
else
|
||||
json_object_string_add(
|
||||
json_object_string_addf(
|
||||
json_interface_sub,
|
||||
"localIfUsed",
|
||||
inet_ntop(AF_INET, &dest,
|
||||
buf, sizeof(buf)));
|
||||
"localIfUsed", "%pI4", &dest);
|
||||
} else
|
||||
vty_out(vty, " %s %pI4,", dstr,
|
||||
&dest);
|
||||
@ -3659,10 +3650,8 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
||||
json_object_boolean_true_add(
|
||||
json_interface_sub,
|
||||
"mtuMismatchDetect");
|
||||
json_object_string_add(
|
||||
json_interface_sub, "routerId",
|
||||
inet_ntop(AF_INET, &ospf->router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_interface_sub, "routerId",
|
||||
"%pI4", &ospf->router_id);
|
||||
json_object_string_add(json_interface_sub,
|
||||
"networkType",
|
||||
ospf_network_type_str[oi->type]);
|
||||
@ -3706,17 +3695,13 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
||||
nbr = ospf_nbr_lookup_by_addr(oi->nbrs, &DR(oi));
|
||||
if (nbr) {
|
||||
if (use_json) {
|
||||
json_object_string_add(
|
||||
json_object_string_addf(
|
||||
json_interface_sub, "drId",
|
||||
inet_ntop(AF_INET,
|
||||
&nbr->router_id, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_add(
|
||||
"%pI4", &nbr->router_id);
|
||||
json_object_string_addf(
|
||||
json_interface_sub, "drAddress",
|
||||
inet_ntop(
|
||||
AF_INET,
|
||||
&nbr->address.u.prefix4,
|
||||
buf, sizeof(buf)));
|
||||
"%pI4",
|
||||
&nbr->address.u.prefix4);
|
||||
} else {
|
||||
vty_out(vty,
|
||||
" Designated Router (ID) %pI4",
|
||||
@ -3735,18 +3720,13 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
||||
" No backup designated router on this network\n");
|
||||
} else {
|
||||
if (use_json) {
|
||||
json_object_string_add(
|
||||
json_object_string_addf(
|
||||
json_interface_sub, "bdrId",
|
||||
inet_ntop(AF_INET,
|
||||
&nbr->router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_add(
|
||||
"%pI4", &nbr->router_id);
|
||||
json_object_string_addf(
|
||||
json_interface_sub,
|
||||
"bdrAddress",
|
||||
inet_ntop(AF_INET,
|
||||
&nbr->address.u
|
||||
.prefix4,
|
||||
buf, sizeof(buf)));
|
||||
"bdrAddress", "%pI4",
|
||||
&nbr->address.u.prefix4);
|
||||
} else {
|
||||
vty_out(vty,
|
||||
" Backup Designated Router (ID) %pI4,",
|
||||
@ -4347,7 +4327,6 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
|
||||
struct route_node *rn;
|
||||
struct ospf_neighbor *nbr, *prev_nbr = NULL;
|
||||
char msgbuf[16];
|
||||
char buf[PREFIX_STRLEN];
|
||||
char timebuf[OSPF_TIME_DUMP_SIZE];
|
||||
json_object *json_neighbor = NULL, *json_neigh_array = NULL;
|
||||
struct timeval res = {.tv_sec = 0, .tv_usec = 0};
|
||||
@ -4447,10 +4426,9 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
|
||||
"deadTimeMsecs",
|
||||
"inactive");
|
||||
}
|
||||
json_object_string_add(
|
||||
json_neighbor, "address",
|
||||
inet_ntop(AF_INET, &nbr->src,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_neighbor,
|
||||
"address", "%pI4",
|
||||
&nbr->src);
|
||||
json_object_string_add(json_neighbor,
|
||||
"ifaceName",
|
||||
IF_NAME(oi));
|
||||
@ -5028,7 +5006,6 @@ static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty,
|
||||
bool use_json, json_object *json)
|
||||
{
|
||||
char timebuf[OSPF_TIME_DUMP_SIZE];
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_sub = NULL;
|
||||
|
||||
if (use_json)
|
||||
@ -5038,9 +5015,8 @@ static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty,
|
||||
|
||||
/* Show interface address. */
|
||||
if (use_json)
|
||||
json_object_string_add(json_sub, "ifaceAddress",
|
||||
inet_ntop(AF_INET, &nbr_nbma->addr,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_sub, "ifaceAddress", "%pI4",
|
||||
&nbr_nbma->addr);
|
||||
else
|
||||
vty_out(vty, " interface address %pI4\n",
|
||||
&nbr_nbma->addr);
|
||||
@ -5113,7 +5089,6 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
|
||||
char timebuf[OSPF_TIME_DUMP_SIZE];
|
||||
json_object *json_neigh = NULL, *json_neigh_array = NULL;
|
||||
char neigh_str[INET_ADDRSTRLEN] = {0};
|
||||
char buf[PREFIX_STRLEN];
|
||||
|
||||
if (use_json) {
|
||||
if (prev_nbr &&
|
||||
@ -5150,10 +5125,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
|
||||
|
||||
/* Show interface address. */
|
||||
if (use_json)
|
||||
json_object_string_add(json_neigh, "ifaceAddress",
|
||||
inet_ntop(AF_INET,
|
||||
&nbr->address.u.prefix4,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_neigh, "ifaceAddress", "%pI4",
|
||||
&nbr->address.u.prefix4);
|
||||
else
|
||||
vty_out(vty, " interface address %pI4\n",
|
||||
&nbr->address.u.prefix4);
|
||||
@ -5230,17 +5203,15 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
|
||||
|
||||
/* Show Designated Rotuer ID. */
|
||||
if (use_json)
|
||||
json_object_string_add(json_neigh, "routerDesignatedId",
|
||||
inet_ntop(AF_INET, &nbr->d_router,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_neigh, "routerDesignatedId",
|
||||
"%pI4", &nbr->d_router);
|
||||
else
|
||||
vty_out(vty, " DR is %pI4,", &nbr->d_router);
|
||||
|
||||
/* Show Backup Designated Rotuer ID. */
|
||||
if (use_json)
|
||||
json_object_string_add(json_neigh, "routerDesignatedBackupId",
|
||||
inet_ntop(AF_INET, &nbr->bd_router,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_neigh, "routerDesignatedBackupId",
|
||||
"%pI4", &nbr->bd_router);
|
||||
else
|
||||
vty_out(vty, " BDR is %pI4\n", &nbr->bd_router);
|
||||
|
||||
@ -6018,15 +5989,11 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self,
|
||||
ntohl(lsa->data->ls_seqnum));
|
||||
snprintf(checksum, sizeof(checksum), "%x",
|
||||
ntohs(lsa->data->checksum));
|
||||
json_object_string_add(
|
||||
json_lsa, "lsId",
|
||||
inet_ntop(AF_INET, &lsa->data->id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_add(
|
||||
json_lsa, "advertisedRouter",
|
||||
inet_ntop(AF_INET,
|
||||
&lsa->data->adv_router,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_lsa, "lsId",
|
||||
"%pI4", &lsa->data->id);
|
||||
json_object_string_addf(
|
||||
json_lsa, "advertisedRouter", "%pI4",
|
||||
&lsa->data->adv_router);
|
||||
json_object_int_add(json_lsa, "lsaAge",
|
||||
LS_AGE(lsa));
|
||||
json_object_string_add(
|
||||
@ -6162,7 +6129,6 @@ static const char *const show_database_header[] = {
|
||||
static void show_ip_ospf_database_header(struct vty *vty, struct ospf_lsa *lsa,
|
||||
json_object *json)
|
||||
{
|
||||
char buf[PREFIX_STRLEN];
|
||||
struct router_lsa *rlsa = (struct router_lsa *)lsa->data;
|
||||
|
||||
if (!json) {
|
||||
@ -6243,13 +6209,10 @@ static void show_ip_ospf_database_header(struct vty *vty, struct ospf_lsa *lsa,
|
||||
json_object_string_add(
|
||||
json, "lsaType",
|
||||
lookup_msg(ospf_lsa_type_msg, lsa->data->type, NULL));
|
||||
json_object_string_add(json, "linkStateId",
|
||||
inet_ntop(AF_INET, &lsa->data->id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_add(json, "advertisingRouter",
|
||||
inet_ntop(AF_INET,
|
||||
&lsa->data->adv_router,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json, "linkStateId", "%pI4",
|
||||
&lsa->data->id);
|
||||
json_object_string_addf(json, "advertisingRouter", "%pI4",
|
||||
&lsa->data->adv_router);
|
||||
json_object_string_add(json, "lsaSeqNumber", seqnum);
|
||||
json_object_string_add(json, "checksum", checksum);
|
||||
json_object_int_add(json, "length", ntohs(lsa->data->length));
|
||||
@ -6478,7 +6441,6 @@ static int show_summary_asbr_lsa_detail(struct vty *vty, struct ospf_lsa *lsa,
|
||||
static int show_as_external_lsa_detail(struct vty *vty, struct ospf_lsa *lsa,
|
||||
json_object *json)
|
||||
{
|
||||
char buf[PREFIX_STRLEN];
|
||||
int tos = 0;
|
||||
|
||||
if (lsa != NULL) {
|
||||
@ -6513,10 +6475,8 @@ static int show_as_external_lsa_detail(struct vty *vty, struct ospf_lsa *lsa,
|
||||
json_object_int_add(json, "tos", tos);
|
||||
json_object_int_add(json, "metric",
|
||||
GET_METRIC(al->e[0].metric));
|
||||
json_object_string_add(json, "forwardAddress",
|
||||
inet_ntop(AF_INET,
|
||||
&(al->e[0].fwd_addr),
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json, "forwardAddress", "%pI4",
|
||||
&(al->e[0].fwd_addr));
|
||||
json_object_int_add(
|
||||
json, "externalRouteTag",
|
||||
(route_tag_t)ntohl(al->e[0].route_tag));
|
||||
@ -6530,7 +6490,6 @@ static int show_as_external_lsa_detail(struct vty *vty, struct ospf_lsa *lsa,
|
||||
static int show_as_nssa_lsa_detail(struct vty *vty, struct ospf_lsa *lsa,
|
||||
json_object *json)
|
||||
{
|
||||
char buf[PREFIX_STRLEN];
|
||||
int tos = 0;
|
||||
|
||||
if (lsa != NULL) {
|
||||
@ -6566,10 +6525,8 @@ static int show_as_nssa_lsa_detail(struct vty *vty, struct ospf_lsa *lsa,
|
||||
json_object_int_add(json, "tos", tos);
|
||||
json_object_int_add(json, "metric",
|
||||
GET_METRIC(al->e[0].metric));
|
||||
json_object_string_add(json, "nssaForwardAddress",
|
||||
inet_ntop(AF_INET,
|
||||
&al->e[0].fwd_addr,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json, "nssaForwardAddress",
|
||||
"%pI4", &al->e[0].fwd_addr);
|
||||
json_object_int_add(
|
||||
json, "externalRouteTag",
|
||||
(route_tag_t)ntohl(al->e[0].route_tag));
|
||||
@ -6961,15 +6918,11 @@ static void show_ip_ospf_database_maxage(struct vty *vty, struct ospf *ospf,
|
||||
json_lsa = json_object_new_object();
|
||||
json_object_int_add(json_lsa, "linkType",
|
||||
lsa->data->type);
|
||||
json_object_string_add(
|
||||
json_lsa, "linkStateId",
|
||||
inet_ntop(AF_INET, &lsa->data->id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_add(
|
||||
json_lsa, "advertisingRouter",
|
||||
inet_ntop(AF_INET,
|
||||
&lsa->data->adv_router,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_lsa, "linkStateId",
|
||||
"%pI4", &lsa->data->id);
|
||||
json_object_string_addf(
|
||||
json_lsa, "advertisingRouter", "%pI4",
|
||||
&lsa->data->adv_router);
|
||||
json_object_int_add(json_lsa, "lsaLockCount",
|
||||
lsa->lock);
|
||||
json_object_object_add(
|
||||
@ -7011,7 +6964,6 @@ static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf,
|
||||
int idx_type = 4;
|
||||
int type, ret;
|
||||
struct in_addr id, adv_router;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_vrf = NULL;
|
||||
|
||||
if (uj) {
|
||||
@ -7033,9 +6985,8 @@ static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf,
|
||||
|
||||
/* Show Router ID. */
|
||||
if (uj) {
|
||||
json_object_string_add(json_vrf, "routerId",
|
||||
inet_ntop(AF_INET, &ospf->router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_vrf, "routerId", "%pI4",
|
||||
&ospf->router_id);
|
||||
} else {
|
||||
vty_out(vty, "\n OSPF Router with ID (%pI4)\n\n",
|
||||
&ospf->router_id);
|
||||
@ -7285,7 +7236,6 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty,
|
||||
int idx_type = 4;
|
||||
int type, ret;
|
||||
struct in_addr adv_router;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_vrf = NULL;
|
||||
|
||||
if (uj) {
|
||||
@ -7307,9 +7257,8 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty,
|
||||
|
||||
/* Show Router ID. */
|
||||
if (uj) {
|
||||
json_object_string_add(json_vrf, "routerId",
|
||||
inet_ntop(AF_INET, &ospf->router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_vrf, "routerId", "%pI4",
|
||||
&ospf->router_id);
|
||||
} else {
|
||||
vty_out(vty, "\n OSPF Router with ID (%pI4)\n\n",
|
||||
&ospf->router_id);
|
||||
@ -10082,7 +10031,6 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
||||
struct ospf_route * or ;
|
||||
struct listnode *pnode, *pnnode;
|
||||
struct ospf_path *path;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_route = NULL, *json_nexthop_array = NULL,
|
||||
*json_nexthop = NULL;
|
||||
|
||||
@ -10112,11 +10060,9 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
||||
"N IA");
|
||||
json_object_int_add(json_route, "cost",
|
||||
or->cost);
|
||||
json_object_string_add(
|
||||
json_route, "area",
|
||||
inet_ntop(AF_INET,
|
||||
&or->u.std.area_id,
|
||||
buf1, sizeof(buf1)));
|
||||
json_object_string_addf(
|
||||
json_route, "area", "%pI4",
|
||||
&or->u.std.area_id);
|
||||
} else {
|
||||
vty_out(vty,
|
||||
"N IA %-18s [%d] area: %pI4\n",
|
||||
@ -10141,10 +10087,9 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
||||
"N");
|
||||
json_object_int_add(json_route, "cost",
|
||||
or->cost);
|
||||
json_object_string_add(
|
||||
json_route, "area",
|
||||
inet_ntop(AF_INET, &or->u.std.area_id,
|
||||
buf1, sizeof(buf1)));
|
||||
json_object_string_addf(json_route, "area",
|
||||
"%pI4",
|
||||
&or->u.std.area_id);
|
||||
} else {
|
||||
vty_out(vty, "N %-18s [%d] area: %pI4\n",
|
||||
buf1, or->cost,
|
||||
@ -10195,14 +10140,10 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
|
||||
}
|
||||
} else {
|
||||
if (json) {
|
||||
json_object_string_add(
|
||||
json_object_string_addf(
|
||||
json_nexthop,
|
||||
"ip",
|
||||
inet_ntop(
|
||||
AF_INET,
|
||||
&path->nexthop,
|
||||
buf,
|
||||
sizeof(buf)));
|
||||
"ip", "%pI4",
|
||||
&path->nexthop);
|
||||
json_object_string_add(
|
||||
json_nexthop,
|
||||
"via",
|
||||
@ -10271,10 +10212,9 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,
|
||||
if (json) {
|
||||
json_object_int_add(json_route, "cost",
|
||||
or->cost);
|
||||
json_object_string_add(
|
||||
json_route, "area",
|
||||
inet_ntop(AF_INET, &or->u.std.area_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_route, "area",
|
||||
"%pI4",
|
||||
&or->u.std.area_id);
|
||||
if (or->path_type == OSPF_PATH_INTER_AREA)
|
||||
json_object_boolean_true_add(json_route,
|
||||
"IA");
|
||||
@ -10339,13 +10279,10 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,
|
||||
}
|
||||
} else {
|
||||
if (json) {
|
||||
json_object_string_add(
|
||||
json_object_string_addf(
|
||||
json_nexthop,
|
||||
"ip",
|
||||
inet_ntop(
|
||||
AF_INET,
|
||||
&path->nexthop,
|
||||
buf, sizeof(buf)));
|
||||
"ip", "%pI4",
|
||||
&path->nexthop);
|
||||
json_object_string_add(
|
||||
json_nexthop,
|
||||
"via",
|
||||
@ -10378,7 +10315,6 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,
|
||||
struct ospf_route *er;
|
||||
struct listnode *pnode, *pnnode;
|
||||
struct ospf_path *path;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json_route = NULL, *json_nexthop_array = NULL,
|
||||
*json_nexthop = NULL;
|
||||
|
||||
@ -10469,13 +10405,9 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,
|
||||
}
|
||||
} else {
|
||||
if (json) {
|
||||
json_object_string_add(
|
||||
json_object_string_addf(
|
||||
json_nexthop, "ip",
|
||||
inet_ntop(
|
||||
AF_INET,
|
||||
&path->nexthop,
|
||||
buf,
|
||||
sizeof(buf)));
|
||||
"%pI4", &path->nexthop);
|
||||
json_object_string_add(
|
||||
json_nexthop, "via",
|
||||
ifindex2ifname(
|
||||
@ -10797,7 +10729,6 @@ DEFUN (show_ip_ospf_vrfs,
|
||||
struct ospf *ospf = NULL;
|
||||
struct listnode *node = NULL;
|
||||
int count = 0;
|
||||
char buf[PREFIX_STRLEN];
|
||||
static const char header[] = "Name Id RouterId ";
|
||||
|
||||
if (uj) {
|
||||
@ -10825,10 +10756,8 @@ DEFUN (show_ip_ospf_vrfs,
|
||||
|
||||
if (uj) {
|
||||
json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
|
||||
json_object_string_add(
|
||||
json_vrf, "routerId",
|
||||
inet_ntop(AF_INET, &ospf->router_id,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_vrf, "routerId", "%pI4",
|
||||
&ospf->router_id);
|
||||
|
||||
json_object_object_add(json_vrfs, name, json_vrf);
|
||||
|
||||
|
@ -308,14 +308,12 @@ static void json_object_pim_ifp_add(struct json_object *json,
|
||||
struct interface *ifp)
|
||||
{
|
||||
struct pim_interface *pim_ifp;
|
||||
char buf[PREFIX_STRLEN];
|
||||
|
||||
pim_ifp = ifp->info;
|
||||
json_object_string_add(json, "name", ifp->name);
|
||||
json_object_string_add(json, "state", if_is_up(ifp) ? "up" : "down");
|
||||
json_object_string_add(json, "address",
|
||||
inet_ntop(AF_INET, &pim_ifp->primary_address,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json, "address", "%pI4",
|
||||
&pim_ifp->primary_address);
|
||||
json_object_int_add(json, "index", ifp->ifindex);
|
||||
|
||||
if (if_is_multicast(ifp))
|
||||
@ -489,7 +487,6 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||
struct interface *ifp;
|
||||
time_t now;
|
||||
char buf[PREFIX_STRLEN];
|
||||
char quer_buf[PREFIX_STRLEN];
|
||||
json_object *json = NULL;
|
||||
json_object *json_row = NULL;
|
||||
|
||||
@ -537,10 +534,9 @@ static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||
"queryTimer",
|
||||
query_hhmmss);
|
||||
}
|
||||
json_object_string_add(
|
||||
json_row, "querierIp",
|
||||
inet_ntop(AF_INET, &igmp->querier_addr,
|
||||
quer_buf, sizeof(quer_buf)));
|
||||
json_object_string_addf(json_row, "querierIp",
|
||||
"%pI4",
|
||||
&igmp->querier_addr);
|
||||
|
||||
json_object_object_add(json, ifp->name,
|
||||
json_row);
|
||||
@ -584,7 +580,6 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
|
||||
struct listnode *sock_node;
|
||||
struct pim_interface *pim_ifp;
|
||||
char uptime[10];
|
||||
char quer_buf[PREFIX_STRLEN];
|
||||
char query_hhmmss[10];
|
||||
char other_hhmmss[10];
|
||||
int found_ifname = 0;
|
||||
@ -669,10 +664,9 @@ static void igmp_show_interfaces_single(struct pim_instance *pim,
|
||||
igmp->t_igmp_query_timer
|
||||
? "local"
|
||||
: "other");
|
||||
json_object_string_add(
|
||||
json_row, "querierIp",
|
||||
inet_ntop(AF_INET, &igmp->querier_addr,
|
||||
quer_buf, sizeof(quer_buf)));
|
||||
json_object_string_addf(json_row, "querierIp",
|
||||
"%pI4",
|
||||
&igmp->querier_addr);
|
||||
json_object_int_add(json_row, "queryStartCount",
|
||||
igmp->startup_query_count);
|
||||
json_object_string_add(json_row,
|
||||
@ -928,7 +922,6 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
|
||||
int mloop = 0;
|
||||
int found_ifname = 0;
|
||||
int print_header;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json = NULL;
|
||||
json_object *json_row = NULL;
|
||||
json_object *json_pim_neighbor = NULL;
|
||||
@ -979,11 +972,9 @@ static void pim_show_interfaces_single(struct pim_instance *pim,
|
||||
json_object_pim_ifp_add(json_row, ifp);
|
||||
|
||||
if (pim_ifp->update_source.s_addr != INADDR_ANY) {
|
||||
json_object_string_add(
|
||||
json_row, "useSource",
|
||||
inet_ntop(AF_INET,
|
||||
&pim_ifp->update_source,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(
|
||||
json_row, "useSource", "%pI4",
|
||||
&pim_ifp->update_source);
|
||||
}
|
||||
if (pim_ifp->sec_addr_list) {
|
||||
json_object *sec_list = NULL;
|
||||
@ -1407,7 +1398,6 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||
int fhr = 0;
|
||||
int pim_nbrs = 0;
|
||||
int pim_ifchannels = 0;
|
||||
char buf[PREFIX_STRLEN];
|
||||
json_object *json = NULL;
|
||||
json_object *json_row = NULL;
|
||||
json_object *json_tmp;
|
||||
@ -1437,10 +1427,8 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||
json_object_int_add(json_row, "pimNeighbors", pim_nbrs);
|
||||
json_object_int_add(json_row, "pimIfChannels", pim_ifchannels);
|
||||
json_object_int_add(json_row, "firstHopRouterCount", fhr);
|
||||
json_object_string_add(json_row, "pimDesignatedRouter",
|
||||
inet_ntop(AF_INET,
|
||||
&pim_ifp->pim_dr_addr, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json_row, "pimDesignatedRouter", "%pI4",
|
||||
&pim_ifp->pim_dr_addr);
|
||||
|
||||
if (pim_ifp->pim_dr_addr.s_addr
|
||||
== pim_ifp->primary_address.s_addr)
|
||||
@ -5715,10 +5703,8 @@ static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||
json_object_string_add(json_row, "name", ifp->name);
|
||||
json_object_string_add(json_row, "state",
|
||||
if_is_up(ifp) ? "up" : "down");
|
||||
json_object_string_add(
|
||||
json_row, "address",
|
||||
inet_ntop(AF_INET, &pim_ifp->primary_address,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_row, "address", "%pI4",
|
||||
&pim_ifp->primary_address);
|
||||
json_object_int_add(json_row, "ifIndex", ifp->ifindex);
|
||||
json_object_int_add(json_row, "vif",
|
||||
pim_ifp->mroute_vif_index);
|
||||
|
@ -1228,12 +1228,9 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
|
||||
json_rp_rows = json_object_new_array();
|
||||
|
||||
json_row = json_object_new_object();
|
||||
json_object_string_add(
|
||||
json_row, "rpAddress",
|
||||
inet_ntop(AF_INET,
|
||||
&rp_info->rp.rpf_addr.u
|
||||
.prefix4,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(
|
||||
json_row, "rpAddress", "%pI4",
|
||||
&rp_info->rp.rpf_addr.u.prefix4);
|
||||
if (rp_info->rp.source_nexthop.interface)
|
||||
json_object_string_add(
|
||||
json_row, "outboundInterface",
|
||||
|
19
tools/coccinelle/json_object_string_addf.cocci
Normal file
19
tools/coccinelle/json_object_string_addf.cocci
Normal file
@ -0,0 +1,19 @@
|
||||
@@
|
||||
identifier json;
|
||||
expression family, buf, value;
|
||||
constant key, buflen;
|
||||
@@
|
||||
|
||||
(
|
||||
-json_object_string_add(json, key, inet_ntop(AF_INET, &value, buf, sizeof(buf)));
|
||||
+json_object_string_addf(json, key, "%pI4", &value);
|
||||
|
|
||||
-json_object_string_add(json, key, inet_ntop(AF_INET, &value, buf, buflen));
|
||||
+json_object_string_addf(json, key, "%pI4", &value);
|
||||
|
|
||||
-json_object_string_add(json, key, inet_ntop(AF_INET6, &value, buf, sizeof(buf)));
|
||||
+json_object_string_addf(json, key, "%pI6", &value);
|
||||
|
|
||||
-json_object_string_add(json, key, inet_ntop(AF_INET6, &value, buf, buflen));
|
||||
+json_object_string_addf(json, key, "%pI6", &value);
|
||||
)
|
@ -2062,18 +2062,14 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
|
||||
vxlan_info = &zebra_if->l2info.vxl;
|
||||
json_object_int_add(json_if, "vxlanId", vxlan_info->vni);
|
||||
if (vxlan_info->vtep_ip.s_addr != INADDR_ANY)
|
||||
json_object_string_add(json_if, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&vxlan_info->vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_if, "vtepIp", "%pI4",
|
||||
&vxlan_info->vtep_ip);
|
||||
if (vxlan_info->access_vlan)
|
||||
json_object_int_add(json_if, "accessVlanId",
|
||||
vxlan_info->access_vlan);
|
||||
if (vxlan_info->mcast_grp.s_addr != INADDR_ANY)
|
||||
json_object_string_add(json_if, "mcastGroup",
|
||||
inet_ntop(AF_INET,
|
||||
&vxlan_info->mcast_grp,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_if, "mcastGroup", "%pI4",
|
||||
&vxlan_info->mcast_grp);
|
||||
if (vxlan_info->ifindex_link
|
||||
&& (vxlan_info->link_nsid != NS_UNKNOWN)) {
|
||||
struct interface *ifp;
|
||||
@ -2090,16 +2086,12 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
|
||||
|
||||
gre_info = &zebra_if->l2info.gre;
|
||||
if (gre_info->vtep_ip.s_addr != INADDR_ANY) {
|
||||
json_object_string_add(json_if, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&gre_info->vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_if, "vtepIp", "%pI4",
|
||||
&gre_info->vtep_ip);
|
||||
if (gre_info->vtep_ip_remote.s_addr != INADDR_ANY)
|
||||
json_object_string_add(
|
||||
json_if, "vtepRemoteIp",
|
||||
inet_ntop(AF_INET,
|
||||
&gre_info->vtep_ip_remote,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(
|
||||
json_if, "vtepRemoteIp", "%pI4",
|
||||
&gre_info->vtep_ip_remote);
|
||||
}
|
||||
if (gre_info->ifindex_link
|
||||
&& (gre_info->link_nsid != NS_UNKNOWN)) {
|
||||
@ -2233,9 +2225,8 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
|
||||
json_object_double_add(json_te, "utilizedBandwidth",
|
||||
iflp->use_bw);
|
||||
if (IS_PARAM_SET(iflp, LP_RMT_AS))
|
||||
json_object_string_add(json_te, "neighborAsbrIp",
|
||||
inet_ntop(AF_INET, &iflp->rmt_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_te, "neighborAsbrIp",
|
||||
"%pI4", &iflp->rmt_ip);
|
||||
json_object_int_add(json_te, "neighborAsbrAs", iflp->rmt_as);
|
||||
}
|
||||
|
||||
|
@ -152,12 +152,10 @@ void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt)
|
||||
json_object_int_add(json, "sviIfindex",
|
||||
zevpn->svi_if->ifindex);
|
||||
}
|
||||
json_object_string_add(json, "vtepIp",
|
||||
inet_ntop(AF_INET, &zevpn->local_vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_add(json, "mcastGroup",
|
||||
inet_ntop(AF_INET, &zevpn->mcast_grp,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json, "vtepIp", "%pI4",
|
||||
&zevpn->local_vtep_ip);
|
||||
json_object_string_addf(json, "mcastGroup", "%pI4",
|
||||
&zevpn->mcast_grp);
|
||||
json_object_string_add(json, "advertiseGatewayMacip",
|
||||
zevpn->advertise_gw_macip ? "Yes" : "No");
|
||||
json_object_string_add(json, "advertiseSviMacip",
|
||||
|
@ -619,7 +619,6 @@ void zebra_evpn_print_mac(struct zebra_mac *mac, void *ctxt, json_object *json)
|
||||
struct listnode *node = NULL;
|
||||
char buf1[ETHER_ADDR_STRLEN];
|
||||
char buf2[INET6_ADDRSTRLEN];
|
||||
char addr_buf[PREFIX_STRLEN];
|
||||
struct zebra_vrf *zvrf;
|
||||
struct timeval detect_start_time = {0, 0};
|
||||
char timebuf[MONOTIME_STRLEN];
|
||||
@ -658,10 +657,8 @@ void zebra_evpn_print_mac(struct zebra_mac *mac, void *ctxt, json_object *json)
|
||||
json_object_int_add(json_mac, "vlan", vid);
|
||||
} else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) {
|
||||
json_object_string_add(json_mac, "type", "remote");
|
||||
json_object_string_add(
|
||||
json_mac, "remoteVtep",
|
||||
inet_ntop(AF_INET, &mac->fwd_info.r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json_mac, "remoteVtep", "%pI4",
|
||||
&mac->fwd_info.r_vtep_ip);
|
||||
} else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO))
|
||||
json_object_string_add(json_mac, "type", "auto");
|
||||
|
||||
@ -944,10 +941,8 @@ void zebra_evpn_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
|
||||
"", mac->loc_seq, mac->rem_seq);
|
||||
} else {
|
||||
json_object_string_add(json_mac, "type", "remote");
|
||||
json_object_string_add(
|
||||
json_mac, "remoteVtep",
|
||||
inet_ntop(AF_INET, &mac->fwd_info.r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json_mac, "remoteVtep", "%pI4",
|
||||
&mac->fwd_info.r_vtep_ip);
|
||||
json_object_object_add(json_mac_hdr, buf1, json_mac);
|
||||
json_object_int_add(json_mac, "localSequence",
|
||||
mac->loc_seq);
|
||||
@ -2241,7 +2236,7 @@ int zebra_evpn_add_update_local_mac(struct zebra_vrf *zvrf,
|
||||
zlog_debug(
|
||||
" Add/Update %sMAC %pEA intf %s(%u) VID %u -> VNI %u%s, "
|
||||
"entry exists and has not changed ",
|
||||
sticky ? "sticky " : "",
|
||||
sticky ? "sticky " : "",
|
||||
macaddr, ifp->name,
|
||||
ifp->ifindex, vid, zevpn->vni,
|
||||
local_inactive
|
||||
|
@ -1325,12 +1325,9 @@ static void zebra_evpn_es_l2_nh_show_entry(struct zebra_evpn_l2_nh *nh,
|
||||
{
|
||||
if (json_array) {
|
||||
json_object *json = NULL;
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
json = json_object_new_object();
|
||||
json_object_string_add(json, "vtep",
|
||||
inet_ntop(AF_INET, &nh->vtep_ip, ip_buf,
|
||||
sizeof(ip_buf)));
|
||||
json_object_string_addf(json, "vtep", "%pI4", &nh->vtep_ip);
|
||||
json_object_int_add(json, "nhId", nh->nh_id);
|
||||
json_object_int_add(json, "refCnt", nh->ref_cnt);
|
||||
|
||||
@ -3008,13 +3005,11 @@ static void zebra_evpn_es_json_vtep_fill(struct zebra_evpn_es *es,
|
||||
struct listnode *node;
|
||||
json_object *json_vtep_entry;
|
||||
char alg_buf[EVPN_DF_ALG_STR_LEN];
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, es_vtep)) {
|
||||
json_vtep_entry = json_object_new_object();
|
||||
json_object_string_add(json_vtep_entry, "vtep",
|
||||
inet_ntop(AF_INET, &es_vtep->vtep_ip,
|
||||
ip_buf, sizeof(ip_buf)));
|
||||
json_object_string_addf(json_vtep_entry, "vtep", "%pI4",
|
||||
&es_vtep->vtep_ip);
|
||||
if (es_vtep->flags & ZEBRA_EVPNES_VTEP_RXED_ESR) {
|
||||
json_object_string_add(
|
||||
json_vtep_entry, "dfAlgorithm",
|
||||
|
@ -1725,7 +1725,6 @@ void zebra_evpn_print_neigh(struct zebra_neigh *n, void *ctxt,
|
||||
struct vty *vty;
|
||||
char buf1[ETHER_ADDR_STRLEN];
|
||||
char buf2[INET6_ADDRSTRLEN];
|
||||
char addr_buf[PREFIX_STRLEN];
|
||||
const char *type_str;
|
||||
const char *state_str;
|
||||
bool flags_present = false;
|
||||
@ -1812,10 +1811,8 @@ void zebra_evpn_print_neigh(struct zebra_neigh *n, void *ctxt,
|
||||
n->mac->es->esi_str);
|
||||
} else {
|
||||
if (json)
|
||||
json_object_string_add(
|
||||
json, "remoteVtep",
|
||||
inet_ntop(AF_INET, &n->r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json, "remoteVtep",
|
||||
"%pI4", &n->r_vtep_ip);
|
||||
else
|
||||
vty_out(vty, " Remote VTEP: %pI4\n",
|
||||
&n->r_vtep_ip);
|
||||
@ -1974,10 +1971,8 @@ void zebra_evpn_print_neigh_hash(struct hash_bucket *bucket, void *ctxt)
|
||||
json_object_string_add(json_row, "remoteEs",
|
||||
n->mac->es->esi_str);
|
||||
else
|
||||
json_object_string_add(
|
||||
json_row, "remoteVtep",
|
||||
inet_ntop(AF_INET, &n->r_vtep_ip,
|
||||
addr_buf, sizeof(addr_buf)));
|
||||
json_object_string_addf(json_row, "remoteVtep",
|
||||
"%pI4", &n->r_vtep_ip);
|
||||
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_DEF_GW))
|
||||
json_object_boolean_true_add(json_row,
|
||||
"defaultGateway");
|
||||
|
@ -1514,7 +1514,6 @@ static int mpls_static_lsp_uninstall_all(struct zebra_vrf *zvrf,
|
||||
|
||||
static json_object *nhlfe_json(struct zebra_nhlfe *nhlfe)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
json_object *json_nhlfe = NULL;
|
||||
json_object *json_backups = NULL;
|
||||
json_object *json_label_stack;
|
||||
@ -1541,15 +1540,13 @@ static json_object *nhlfe_json(struct zebra_nhlfe *nhlfe)
|
||||
switch (nexthop->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
json_object_string_add(json_nhlfe, "nexthop",
|
||||
inet_ntop(AF_INET, &nexthop->gate.ipv4,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_nhlfe, "nexthop", "%pI4",
|
||||
&nexthop->gate.ipv4);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||
json_object_string_add(
|
||||
json_nhlfe, "nexthop",
|
||||
inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
|
||||
json_object_string_addf(json_nhlfe, "nexthop", "%pI6",
|
||||
&nexthop->gate.ipv6);
|
||||
|
||||
if (nexthop->ifindex)
|
||||
json_object_string_add(json_nhlfe, "interface",
|
||||
|
@ -709,10 +709,8 @@ static void show_nexthop_json_helper(json_object *json_nexthop,
|
||||
switch (nexthop->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
json_object_string_add(
|
||||
json_nexthop, "ip",
|
||||
inet_ntop(AF_INET, &nexthop->gate.ipv4,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_nexthop, "ip", "%pI4",
|
||||
&nexthop->gate.ipv4);
|
||||
json_object_string_add(json_nexthop, "afi",
|
||||
"ipv4");
|
||||
|
||||
@ -729,10 +727,8 @@ static void show_nexthop_json_helper(json_object *json_nexthop,
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||
json_object_string_add(
|
||||
json_nexthop, "ip",
|
||||
inet_ntop(AF_INET6, &nexthop->gate.ipv6,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_nexthop, "ip", "%pI6",
|
||||
&nexthop->gate.ipv6);
|
||||
json_object_string_add(json_nexthop, "afi",
|
||||
"ipv6");
|
||||
|
||||
|
@ -385,10 +385,8 @@ static void zl3vni_print_rmac(struct zebra_mac *zrmac, struct vty *vty,
|
||||
json_object_string_add(
|
||||
json, "routerMac",
|
||||
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
|
||||
json_object_string_add(json, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&zrmac->fwd_info.r_vtep_ip,
|
||||
buf1, sizeof(buf1)));
|
||||
json_object_string_addf(json, "vtepIp", "%pI4",
|
||||
&zrmac->fwd_info.r_vtep_ip);
|
||||
json_object_int_add(json, "refCount",
|
||||
rb_host_count(&zrmac->host_rb));
|
||||
RB_FOREACH (hle, host_rb_tree_entry, &zrmac->host_rb)
|
||||
@ -680,10 +678,8 @@ static void zl3vni_print_rmac_hash(struct hash_bucket *bucket, void *ctx)
|
||||
json_object_string_add(
|
||||
json_rmac, "routerMac",
|
||||
prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)));
|
||||
json_object_string_add(json_rmac, "vtepIp",
|
||||
inet_ntop(AF_INET,
|
||||
&zrmac->fwd_info.r_vtep_ip,
|
||||
buf, sizeof(buf)));
|
||||
json_object_string_addf(json_rmac, "vtepIp", "%pI4",
|
||||
&zrmac->fwd_info.r_vtep_ip);
|
||||
json_object_object_add(
|
||||
json, prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
|
||||
json_rmac);
|
||||
@ -729,10 +725,8 @@ static void zl3vni_print(struct zebra_l3vni *zl3vni, void **ctx)
|
||||
json_evpn_list = json_object_new_array();
|
||||
json_object_int_add(json, "vni", zl3vni->vni);
|
||||
json_object_string_add(json, "type", "L3");
|
||||
json_object_string_add(
|
||||
json, "localVtepIp",
|
||||
inet_ntop(AF_INET, &zl3vni->local_vtep_ip, buf,
|
||||
sizeof(buf)));
|
||||
json_object_string_addf(json, "localVtepIp", "%pI4",
|
||||
&zl3vni->local_vtep_ip);
|
||||
json_object_string_add(json, "vxlanIntf",
|
||||
zl3vni_vxlan_if_name(zl3vni));
|
||||
json_object_string_add(json, "sviIntf",
|
||||
|
Loading…
Reference in New Issue
Block a user