diff options
Diffstat (limited to 'ldpd/ldp_vty_exec.c')
| -rw-r--r-- | ldpd/ldp_vty_exec.c | 122 |
1 files changed, 75 insertions, 47 deletions
diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c index 609598a768..09b820e3f6 100644 --- a/ldpd/ldp_vty_exec.c +++ b/ldpd/ldp_vty_exec.c @@ -19,6 +19,7 @@ #include <zebra.h> #include <sys/un.h> +#include "lib/printfrr.h" #include "ldpd.h" #include "ldpe.h" @@ -237,8 +238,8 @@ show_ldp_sync_msg(struct vty *vty, struct imsg *imsg, } if (iface->peer_ldp_id.s_addr) - vty_out (vty, " Peer LDP Identifier: %s:0\n", - inet_ntoa(iface->peer_ldp_id)); + vty_out (vty, " Peer LDP Identifier: %pI4:0\n", + &iface->peer_ldp_id); break; case IMSG_CTL_END: @@ -256,6 +257,7 @@ show_ldp_sync_msg_json(struct imsg *imsg, struct show_params *params, { struct ctl_ldp_sync *iface; json_object *json_iface; + char buf[PREFIX_STRLEN]; switch (imsg->hdr.type) { case IMSG_CTL_SHOW_LDP_SYNC: @@ -278,7 +280,8 @@ show_ldp_sync_msg_json(struct imsg *imsg, struct show_params *params, json_object_string_add(json_iface, "peerLdpId", iface->peer_ldp_id.s_addr ? - inet_ntoa(iface->peer_ldp_id) : ""); + inet_ntop(AF_INET, &iface->peer_ldp_id, buf, sizeof(buf)) : + ""); json_object_object_add(json, iface->name, json_iface); break; @@ -305,8 +308,7 @@ show_discovery_msg(struct vty *vty, struct imsg *imsg, if (params->family != AF_UNSPEC && params->family != adj->af) break; - vty_out(vty, "%-4s %-15s ", af_name(adj->af), - inet_ntoa(adj->id)); + vty_out(vty, "%-4s %-15pI4 ", af_name(adj->af), &adj->id); switch(adj->type) { case HELLO_LINK: vty_out(vty, "%-8s %-15s ", "Link", adj->ifname); @@ -336,8 +338,8 @@ show_discovery_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj) { size_t buflen = strlen(buffer); - snprintf(buffer + buflen, LDPBUFSIZ - buflen, - " LSR Id: %s:0\n", inet_ntoa(adj->id)); + snprintfrr(buffer + buflen, LDPBUFSIZ - buflen, + " LSR Id: %pI4:0\n", &adj->id); buflen = strlen(buffer); snprintf(buffer + buflen, LDPBUFSIZ - buflen, " Source address: %s\n", @@ -419,7 +421,7 @@ show_discovery_detail_msg(struct vty *vty, struct imsg *imsg, case IMSG_CTL_END: rtr_id.s_addr = ldp_rtr_id_get(ldpd_conf); vty_out (vty, "Local:\n"); - vty_out (vty, " LSR Id: %s:0\n",inet_ntoa(rtr_id)); + vty_out (vty, " LSR Id: %pI4:0\n",&rtr_id); if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED) vty_out (vty, " Transport Address (IPv4): %s\n", log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr)); @@ -445,6 +447,7 @@ 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; @@ -465,7 +468,8 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params, json_object_string_add(json_adj, "addressFamily", af_name(adj->af)); json_object_string_add(json_adj, "neighborId", - inet_ntoa(adj->id)); + inet_ntop(AF_INET, &adj->id, buf, + sizeof(buf))); switch(adj->type) { case HELLO_LINK: json_object_string_add(json_adj, "type", "link"); @@ -494,6 +498,7 @@ 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; @@ -504,7 +509,8 @@ 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_ntoa(adj->id)); + json_object_string_add(json_adj, "lsrId", inet_ntop(AF_INET, &adj->id, + buf, sizeof(buf))); 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, @@ -526,6 +532,7 @@ 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; @@ -535,7 +542,9 @@ 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_ntoa(rtr_id)); + json_object_string_add(json, "lsrId", + inet_ntop(AF_INET, &rtr_id, buf, + sizeof(buf))); if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED) json_object_string_add(json, "transportAddressIPv4", log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr)); @@ -612,9 +621,9 @@ show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params) addr = log_addr(nbr->af, &nbr->raddr); - vty_out(vty, "%-4s %-15s %-11s %-15s", - af_name(nbr->af), inet_ntoa(nbr->id), - nbr_state_name(nbr->nbr_state), addr); + vty_out(vty, "%-4s %-15pI4 %-11s %-15s", + af_name(nbr->af), &nbr->id, + nbr_state_name(nbr->nbr_state), addr); if (strlen(addr) > 15) vty_out(vty, "\n%48s", " "); vty_out (vty, " %8s\n", log_time(nbr->uptime)); @@ -662,8 +671,8 @@ show_nbr_detail_msg(struct vty *vty, struct imsg *imsg, v4adjs_buffer[0] = '\0'; v6adjs_buffer[0] = '\0'; - vty_out (vty, "Peer LDP Identifier: %s:0\n", - inet_ntoa(nbr->id)); + vty_out (vty, "Peer LDP Identifier: %pI4:0\n", + &nbr->id); vty_out (vty, " TCP connection: %s:%u - %s:%u\n", log_addr(nbr->af, &nbr->laddr), ntohs(nbr->lport), log_addr(nbr->af, &nbr->raddr),ntohs(nbr->rport)); @@ -740,6 +749,7 @@ 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; @@ -757,7 +767,8 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params, json_object_string_add(json_nbr, "addressFamily", af_name(nbr->af)); json_object_string_add(json_nbr, "neighborId", - inet_ntoa(nbr->id)); + inet_ntop(AF_INET, &nbr->id, buf, + sizeof(buf))); json_object_string_add(json_nbr, "state", nbr_state_name(nbr->nbr_state)); json_object_string_add(json_nbr, "transportAddress", @@ -803,6 +814,7 @@ show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params, struct ctl_nbr *nbr; struct ldp_stats *stats; struct ctl_adj *adj; + char buf[PREFIX_STRLEN]; json_object *json_nbr; json_object *json_array; json_object *json_counter; @@ -815,9 +827,12 @@ show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params, nbr = imsg->data; json_nbr = json_object_new_object(); - json_object_object_add(json, inet_ntoa(nbr->id), json_nbr); - - json_object_string_add(json_nbr, "peerId", inet_ntoa(nbr->id)); + 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_add(json_nbr, "tcpLocalAddress", log_addr(nbr->af, &nbr->laddr)); json_object_int_add(json_nbr, "tcpLocalPort", @@ -998,8 +1013,8 @@ show_nbr_capabilities_msg(struct vty *vty, struct imsg *imsg, struct show_params if (nbr->nbr_state != NBR_STA_OPER) break; - vty_out (vty, "Peer LDP Identifier: %s:0\n", - inet_ntoa(nbr->id)); + vty_out (vty, "Peer LDP Identifier: %pI4:0\n", + &nbr->id); show_nbr_capabilities(vty, nbr); vty_out (vty, "\n"); break; @@ -1079,6 +1094,7 @@ show_nbr_capabilities_msg_json(struct imsg *imsg, struct show_params *params, json_object *json) { struct ctl_nbr *nbr; + char buf[PREFIX_STRLEN]; json_object *json_nbr; switch (imsg->hdr.type) { @@ -1089,7 +1105,8 @@ show_nbr_capabilities_msg_json(struct imsg *imsg, struct show_params *params, break; json_nbr = json_object_new_object(); - json_object_object_add(json, inet_ntoa(nbr->id), json_nbr); + json_object_object_add(json, inet_ntop(AF_INET, &nbr->id, buf, + sizeof(buf)), json_nbr); show_nbr_capabilities_json(nbr, json_nbr); break; case IMSG_CTL_END: @@ -1128,9 +1145,10 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params) vty_out(vty, "%-4s %-20s", af_name(rt->af), dstnet); if (strlen(dstnet) > 20) vty_out(vty, "\n%25s", " "); - vty_out (vty, " %-15s %-11s %-13s %6s\n", inet_ntoa(rt->nexthop), - log_label(rt->local_label), log_label(rt->remote_label), - rt->in_use ? "yes" : "no"); + vty_out (vty, " %-15pI4 %-11s %-13s %6s\n", + &rt->nexthop, log_label(rt->local_label), + log_label(rt->remote_label), + rt->in_use ? "yes" : "no"); break; case IMSG_CTL_END: vty_out (vty, "\n"); @@ -1168,17 +1186,17 @@ show_lib_detail_msg(struct vty *vty, struct imsg *imsg, struct show_params *para upstream = 1; buflen = strlen(sent_buffer); - snprintf(sent_buffer + buflen, LDPBUFSIZ - buflen, - "%12s%s:0\n", "", inet_ntoa(rt->nexthop)); + snprintfrr(sent_buffer + buflen, LDPBUFSIZ - buflen, + "%12s%pI4:0\n", "", &rt->nexthop); break; case IMSG_CTL_SHOW_LIB_RCVD: rt = imsg->data; downstream = 1; buflen = strlen(rcvd_buffer); - snprintf(rcvd_buffer + buflen, LDPBUFSIZ - buflen, - "%12s%s:0, label %s%s\n", "", inet_ntoa(rt->nexthop), - log_label(rt->remote_label), - rt->in_use ? " (in use)" : ""); + snprintfrr(rcvd_buffer + buflen, LDPBUFSIZ - buflen, + "%12s%pI4:0, label %s%s\n", "", &rt->nexthop, + log_label(rt->remote_label), + rt->in_use ? " (in use)" : ""); break; case IMSG_CTL_SHOW_LIB_END: rt = imsg->data; @@ -1217,6 +1235,7 @@ 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: @@ -1240,11 +1259,12 @@ show_lib_msg_json(struct imsg *imsg, struct show_params *params, 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_ntoa(rt->nexthop)); + inet_ntop(AF_INET, &rt->nexthop, buf, + sizeof(buf))); json_object_string_add(json_lib_entry, "localLabel", - log_label(rt->local_label)); + log_label(rt->local_label)); json_object_string_add(json_lib_entry, "remoteLabel", - log_label(rt->remote_label)); + log_label(rt->remote_label)); json_object_int_add(json_lib_entry, "inUse", rt->in_use); json_object_array_add(json_array, json_lib_entry); @@ -1264,6 +1284,7 @@ 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; @@ -1296,7 +1317,8 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params, json_adv_label = json_object_new_object(); json_object_string_add(json_adv_label, "neighborId", - inet_ntoa(rt->nexthop)); + inet_ntop(AF_INET, &rt->nexthop, buf, + sizeof(buf))); json_object_array_add(json_adv_labels, json_adv_label); break; case IMSG_CTL_SHOW_LIB_RCVD: @@ -1304,9 +1326,10 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params, json_remote_label = json_object_new_object(); json_object_string_add(json_remote_label, "neighborId", - inet_ntoa(rt->nexthop)); + inet_ntop(AF_INET, &rt->nexthop, + buf, sizeof(buf))); json_object_string_add(json_remote_label, "label", - log_label(rt->remote_label)); + log_label(rt->remote_label)); json_object_int_add(json_remote_label, "inUse", rt->in_use); json_object_array_add(json_remote_labels, json_remote_label); break; @@ -1329,8 +1352,8 @@ show_l2vpn_binding_msg(struct vty *vty, struct imsg *imsg, case IMSG_CTL_SHOW_L2VPN_BINDING: pw = imsg->data; - vty_out (vty, " Destination Address: %s, VC ID: %u\n", - inet_ntoa(pw->lsr_id), pw->pwid); + vty_out (vty, " Destination Address: %pI4, VC ID: %u\n", + &pw->lsr_id, pw->pwid); /* local binding */ if (pw->local_label != NO_LABEL) { @@ -1371,6 +1394,7 @@ 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: @@ -1378,7 +1402,8 @@ show_l2vpn_binding_msg_json(struct imsg *imsg, struct show_params *params, json_pw = json_object_new_object(); json_object_string_add(json_pw, "destination", - inet_ntoa(pw->lsr_id)); + inet_ntop(AF_INET, &pw->lsr_id, buf, + sizeof(buf))); json_object_int_add(json_pw, "vcId", pw->pwid); /* local binding */ @@ -1415,8 +1440,8 @@ show_l2vpn_binding_msg_json(struct imsg *imsg, struct show_params *params, json_object_string_add(json_pw, "remoteLabel", "unassigned"); - snprintf(key_name, sizeof(key_name), "%s: %u", - inet_ntoa(pw->lsr_id), pw->pwid); + snprintfrr(key_name, sizeof(key_name), "%pI4: %u", + &pw->lsr_id, pw->pwid); json_object_object_add(json, key_name, json_pw); break; case IMSG_CTL_END: @@ -1437,9 +1462,9 @@ show_l2vpn_pw_msg(struct vty *vty, struct imsg *imsg, struct show_params *params case IMSG_CTL_SHOW_L2VPN_PW: pw = imsg->data; - vty_out (vty, "%-9s %-15s %-10u %-16s %-10s\n", pw->ifname, - inet_ntoa(pw->lsr_id), pw->pwid, pw->l2vpn_name, - (pw->status == PW_FORWARDING ? "UP" : "DOWN")); + vty_out (vty, "%-9s %-15pI4 %-10u %-16s %-10s\n", pw->ifname, + &pw->lsr_id, pw->pwid, pw->l2vpn_name, + (pw->status == PW_FORWARDING ? "UP" : "DOWN")); break; case IMSG_CTL_END: vty_out (vty, "\n"); @@ -1456,6 +1481,7 @@ 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) { @@ -1463,7 +1489,9 @@ 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_ntoa(pw->lsr_id)); + json_object_string_add(json_pw, "peerId", + inet_ntop(AF_INET, &pw->lsr_id, + buf, sizeof(buf))); json_object_int_add(json_pw, "vcId", pw->pwid); json_object_string_add(json_pw, "VpnName", pw->l2vpn_name); if (pw->status == PW_FORWARDING) |
