#endif
} sockaddr_buf_t;
-static void
-print_sockaddr(struct tcb *tcp, const sockaddr_buf_t *addr, const int addrlen)
+void
+print_sockaddr(struct tcb *tcp, const void *const buf, const int addrlen)
{
+ const sockaddr_buf_t *const addr = buf;
+
tprints("{sa_family=");
printxval(addrfams, addr->sa.sa_family, "AF_???");
tprints(", ");
tprints("}");
}
-void
+int
printsock(struct tcb *tcp, long addr, int addrlen)
{
- sockaddr_buf_t addrbuf;
-
if (addrlen < 2) {
printaddr(addr);
- return;
+ return -1;
}
- if (addrlen > (int) sizeof(addrbuf))
- addrlen = sizeof(addrbuf);
+ union {
+ struct sockaddr sa;
+ struct sockaddr_storage storage;
+ char pad[sizeof(struct sockaddr_storage) + 1];
+ } addrbuf;
+
+ if ((unsigned) addrlen > sizeof(addrbuf.storage))
+ addrlen = sizeof(addrbuf.storage);
- memset(&addrbuf, 0, sizeof(addrbuf));
if (umoven_or_printaddr(tcp, addr, addrlen, addrbuf.pad))
- return;
- addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
+ return -1;
+
+ memset(&addrbuf.pad[addrlen], 0, sizeof(addrbuf.pad) - addrlen);
print_sockaddr(tcp, &addrbuf, addrlen);
+
+ return addrbuf.sa.sa_family;
}
#include "xlat/scmvals.h"
", ee_info=%u, ee_data=%u, offender=",
err->ee_errno, err->ee_origin, err->ee_type,
err->ee_code, err->ee_info, err->ee_data);
- print_sockaddr(tcp, (const void *) &err->offender,
- sizeof(err->offender));
+ print_sockaddr(tcp, &err->offender, sizeof(err->offender));
tprints("}");
}
printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
+
tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
- (unsigned long)msg->msg_iov, 1, data_size);
+ (unsigned long)msg->msg_iov, IOV_DECODE_STR, data_size);
#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
}
tprintf("{gr_interface=%u, gr_group=", greq.gr_interface);
- print_sockaddr(tcp, (const void *) &greq.gr_group,
- sizeof(greq.gr_group));
+ print_sockaddr(tcp, &greq.gr_group, sizeof(greq.gr_group));
tprintf("}");
}