diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-11-18 09:57:01 +0100 |
---|---|---|
committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-11-18 10:35:31 +0100 |
commit | 19fee2b7eba7034e0c0b60b8956e40a294792770 (patch) | |
tree | c51836bd56071021f0396cf6f6b706750e727f81 /ldpd/ldp_vty_exec.c | |
parent | bgpd: Replace inet_ntop to %pI4/6 for JSON outputs (diff) | |
download | frr-19fee2b7eba7034e0c0b60b8956e40a294792770.tar.xz frr-19fee2b7eba7034e0c0b60b8956e40a294792770.zip |
ldpd: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'ldpd/ldp_vty_exec.c')
-rw-r--r-- | ldpd/ldp_vty_exec.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c index 09b820e3f..1b7999890 100644 --- a/ldpd/ldp_vty_exec.c +++ b/ldpd/ldp_vty_exec.c @@ -467,9 +467,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"); @@ -509,8 +508,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, @@ -542,9 +540,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)); @@ -766,9 +762,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 +825,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", @@ -1258,9 +1251,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", @@ -1316,18 +1308,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); @@ -1401,9 +1391,8 @@ show_l2vpn_binding_msg_json(struct imsg *imsg, struct show_params *params, 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 */ @@ -1489,9 +1478,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) |