#include <zebra.h>
#include <sys/un.h>
+#include "lib/printfrr.h"
#include "ldpd.h"
#include "ldpe.h"
}
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:
{
struct ctl_ldp_sync *iface;
json_object *json_iface;
+ char buf[PREFIX_STRLEN];
switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_LDP_SYNC:
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;
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);
{
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",
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));
json_object *json)
{
struct ctl_adj *adj;
+ char buf[PREFIX_STRLEN];
json_object *json_array;
json_object *json_adj;
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");
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;
}
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,
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;
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));
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));
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));
json_object *json)
{
struct ctl_nbr *nbr;
+ char buf[PREFIX_STRLEN];
json_object *json_array;
json_object *json_nbr;
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",
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;
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",
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;
json_object *json)
{
struct ctl_nbr *nbr;
+ char buf[PREFIX_STRLEN];
json_object *json_nbr;
switch (imsg->hdr.type) {
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:
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");
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;
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:
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);
{
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;
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:
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;
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) {
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:
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 */
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:
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");
json_object *json)
{
struct ctl_pw *pw;
+ char buf[PREFIX_STRLEN];
json_object *json_pw;
switch (imsg->hdr.type) {
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)