#include <arpa/inet.h>
#include <net/if.h>
#include <asm/types.h>
-#if defined(__GLIBC__)
+#ifdef HAVE_NETIPX_IPX_H
# include <netipx/ipx.h>
#else
# include <linux/ipx.h>
#if defined(HAVE_LINUX_IP_VS_H)
# include <linux/ip_vs.h>
#endif
-#if defined(HAVE_LINUX_NETLINK_H)
-# include <linux/netlink.h>
-#endif
+#include <linux/netlink.h>
#if defined(HAVE_LINUX_NETFILTER_ARP_ARP_TABLES_H)
# include <linux/netfilter_arp/arp_tables.h>
#endif
#if defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H)
# include <linux/netfilter_ipv6/ip6_tables.h>
#endif
-#if defined(HAVE_LINUX_IF_PACKET_H)
-# include <linux/if_packet.h>
-#endif
-#if defined(HAVE_LINUX_ICMP_H)
-# include <linux/icmp.h>
-#endif
+#include <linux/if_packet.h>
+#include <linux/icmp.h>
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
# include <bluetooth/bluetooth.h>
# include <bluetooth/hci.h>
# include <bluetooth/rfcomm.h>
# include <bluetooth/sco.h>
#endif
-#ifndef PF_UNSPEC
-# define PF_UNSPEC AF_UNSPEC
-#endif
-#include "xlat/domains.h"
#include "xlat/addrfams.h"
#include "xlat/socktypes.h"
#include "xlat/sock_type_flags.h"
#include "xlat/inet_protocols.h"
-#ifdef PF_NETLINK
-# if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG
-# define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
-# endif
-# include "xlat/netlink_protocols.h"
+#if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG
+# define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
#endif
+#include "xlat/netlink_protocols.h"
#if defined(HAVE_BLUETOOTH_BLUETOOTH_H)
# include "xlat/bt_protocols.h"
#include "xlat/msg_flags.h"
-#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
-# include "xlat/af_packet_types.h"
-#endif
+#include "xlat/af_packet_types.h"
static void
print_ifindex(unsigned int ifindex)
tprintf("%u", ifindex);
}
-void
-printsock(struct tcb *tcp, long addr, int addrlen)
-{
- union {
- char pad[128];
- struct sockaddr sa;
- struct sockaddr_in sin;
- struct sockaddr_un sau;
-#ifdef HAVE_INET_NTOP
- struct sockaddr_in6 sa6;
-#endif
-#if defined(AF_IPX)
- struct sockaddr_ipx sipx;
-#endif
-#ifdef AF_PACKET
- struct sockaddr_ll ll;
-#endif
-#ifdef AF_NETLINK
- struct sockaddr_nl nl;
-#endif
+typedef union {
+ char pad[128];
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_un sau;
+ struct sockaddr_in6 sa6;
+ struct sockaddr_ipx sipx;
+ struct sockaddr_ll ll;
+ struct sockaddr_nl nl;
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
- struct sockaddr_hci hci;
- struct sockaddr_l2 l2;
- struct sockaddr_rc rc;
- struct sockaddr_sco sco;
+ struct sockaddr_hci hci;
+ struct sockaddr_l2 l2;
+ struct sockaddr_rc rc;
+ struct sockaddr_sco sco;
#endif
- } addrbuf;
- char string_addr[100];
-
- if (addrlen < 2) {
- printaddr(addr);
- return;
- }
-
- if (addrlen > (int) sizeof(addrbuf))
- addrlen = sizeof(addrbuf);
+} sockaddr_buf_t;
- memset(&addrbuf, 0, sizeof(addrbuf));
- if (umoven_or_printaddr(tcp, addr, addrlen, addrbuf.pad))
- return;
- addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
+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, addrbuf.sa.sa_family, "AF_???");
+ printxval(addrfams, addr->sa.sa_family, "AF_???");
tprints(", ");
- switch (addrbuf.sa.sa_family) {
+ switch (addr->sa.sa_family) {
case AF_UNIX:
if (addrlen == 2) {
tprints("NULL");
- } else if (addrbuf.sau.sun_path[0]) {
+ } else if (addr->sau.sun_path[0]) {
tprints("sun_path=");
- print_quoted_string(addrbuf.sau.sun_path,
- sizeof(addrbuf.sau.sun_path) + 1,
+ print_quoted_string(addr->sau.sun_path,
+ sizeof(addr->sau.sun_path) + 1,
QUOTE_0_TERMINATED);
} else {
tprints("sun_path=@");
- print_quoted_string(addrbuf.sau.sun_path + 1,
- sizeof(addrbuf.sau.sun_path),
+ print_quoted_string(addr->sau.sun_path + 1,
+ sizeof(addr->sau.sun_path),
QUOTE_0_TERMINATED);
}
break;
case AF_INET:
tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
- ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
+ ntohs(addr->sin.sin_port), inet_ntoa(addr->sin.sin_addr));
break;
-#ifdef HAVE_INET_NTOP
+
case AF_INET6:
- inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
- tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
- ntohs(addrbuf.sa6.sin6_port), string_addr,
- addrbuf.sa6.sin6_flowinfo);
+ {
+ char string_addr[100];
+ inet_ntop(AF_INET6, &addr->sa6.sin6_addr,
+ string_addr, sizeof(string_addr));
+ tprintf("sin6_port=htons(%u), inet_pton(AF_INET6"
+ ", \"%s\", &sin6_addr), sin6_flowinfo=%u",
+ ntohs(addr->sa6.sin6_port), string_addr,
+ addr->sa6.sin6_flowinfo);
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
- tprints(", sin6_scope_id=");
-#if defined IN6_IS_ADDR_LINKLOCAL && defined IN6_IS_ADDR_MC_LINKLOCAL
- if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr)
- || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr))
- print_ifindex(addrbuf.sa6.sin6_scope_id);
- else
-#endif
- tprintf("%u", addrbuf.sa6.sin6_scope_id);
+ tprints(", sin6_scope_id=");
+# if defined IN6_IS_ADDR_LINKLOCAL && defined IN6_IS_ADDR_MC_LINKLOCAL
+ if (IN6_IS_ADDR_LINKLOCAL(&addr->sa6.sin6_addr)
+ || IN6_IS_ADDR_MC_LINKLOCAL(&addr->sa6.sin6_addr))
+ print_ifindex(addr->sa6.sin6_scope_id);
+ else
+# endif
+ tprintf("%u", addr->sa6.sin6_scope_id);
#endif /* HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID */
+ }
break;
-#endif
-#if defined(AF_IPX)
+
case AF_IPX:
{
+ tprintf("sipx_port=htons(%u)"
+ ", sipx_network=htonl(%08x)"
+ ", sipx_node=[",
+ ntohs(addr->sipx.sipx_port),
+ ntohl(addr->sipx.sipx_network));
int i;
- tprintf("sipx_port=htons(%u), ",
- ntohs(addrbuf.sipx.sipx_port));
- /* Yes, I know, this does not look too
- * strace-ish, but otherwise the IPX
- * addresses just look monstrous...
- * Anyways, feel free if you don't like
- * this way.. :)
- */
- tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
- for (i = 0; i < IPX_NODE_LEN; i++)
- tprintf("%02x", addrbuf.sipx.sipx_node[i]);
- tprintf("/[%02x]", addrbuf.sipx.sipx_type);
+ for (i = 0; i < IPX_NODE_LEN; ++i) {
+ tprintf("%s%02x", i ? ", " : "",
+ addr->sipx.sipx_node[i]);
+ }
+ tprintf("], sipx_type=%02x", addr->sipx.sipx_type);
}
break;
-#endif /* AF_IPX */
-#ifdef AF_PACKET
+
case AF_PACKET:
{
int i;
tprintf("proto=%#04x, if%d, pkttype=",
- ntohs(addrbuf.ll.sll_protocol),
- addrbuf.ll.sll_ifindex);
- printxval(af_packet_types, addrbuf.ll.sll_pkttype, "PACKET_???");
+ ntohs(addr->ll.sll_protocol),
+ addr->ll.sll_ifindex);
+ printxval(af_packet_types, addr->ll.sll_pkttype, "PACKET_???");
tprintf(", addr(%d)={%d, ",
- addrbuf.ll.sll_halen,
- addrbuf.ll.sll_hatype);
- for (i = 0; i < addrbuf.ll.sll_halen; i++)
- tprintf("%02x", addrbuf.ll.sll_addr[i]);
+ addr->ll.sll_halen,
+ addr->ll.sll_hatype);
+ for (i = 0; i < addr->ll.sll_halen; i++)
+ tprintf("%02x", addr->ll.sll_addr[i]);
}
break;
-#endif /* AF_PACKET */
-#ifdef AF_NETLINK
case AF_NETLINK:
- tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
+ tprintf("pid=%d, groups=%08x", addr->nl.nl_pid, addr->nl.nl_groups);
break;
-#endif /* AF_NETLINK */
-#if defined(AF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
+
+#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
case AF_BLUETOOTH:
tprintf("{sco_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X} or "
"{rc_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, rc_channel=%d} or "
"{l2_psm=htobs(%d), l2_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, l2_cid=htobs(%d)} or "
"{hci_dev=htobs(%d)}",
- addrbuf.sco.sco_bdaddr.b[0], addrbuf.sco.sco_bdaddr.b[1],
- addrbuf.sco.sco_bdaddr.b[2], addrbuf.sco.sco_bdaddr.b[3],
- addrbuf.sco.sco_bdaddr.b[4], addrbuf.sco.sco_bdaddr.b[5],
- addrbuf.rc.rc_bdaddr.b[0], addrbuf.rc.rc_bdaddr.b[1],
- addrbuf.rc.rc_bdaddr.b[2], addrbuf.rc.rc_bdaddr.b[3],
- addrbuf.rc.rc_bdaddr.b[4], addrbuf.rc.rc_bdaddr.b[5],
- addrbuf.rc.rc_channel,
- btohs(addrbuf.l2.l2_psm), addrbuf.l2.l2_bdaddr.b[0],
- addrbuf.l2.l2_bdaddr.b[1], addrbuf.l2.l2_bdaddr.b[2],
- addrbuf.l2.l2_bdaddr.b[3], addrbuf.l2.l2_bdaddr.b[4],
- addrbuf.l2.l2_bdaddr.b[5], btohs(addrbuf.l2.l2_cid),
- btohs(addrbuf.hci.hci_dev));
+ addr->sco.sco_bdaddr.b[0], addr->sco.sco_bdaddr.b[1],
+ addr->sco.sco_bdaddr.b[2], addr->sco.sco_bdaddr.b[3],
+ addr->sco.sco_bdaddr.b[4], addr->sco.sco_bdaddr.b[5],
+ addr->rc.rc_bdaddr.b[0], addr->rc.rc_bdaddr.b[1],
+ addr->rc.rc_bdaddr.b[2], addr->rc.rc_bdaddr.b[3],
+ addr->rc.rc_bdaddr.b[4], addr->rc.rc_bdaddr.b[5],
+ addr->rc.rc_channel,
+ btohs(addr->l2.l2_psm), addr->l2.l2_bdaddr.b[0],
+ addr->l2.l2_bdaddr.b[1], addr->l2.l2_bdaddr.b[2],
+ addr->l2.l2_bdaddr.b[3], addr->l2.l2_bdaddr.b[4],
+ addr->l2.l2_bdaddr.b[5], btohs(addr->l2.l2_cid),
+ btohs(addr->hci.hci_dev));
break;
-#endif /* AF_BLUETOOTH && HAVE_BLUETOOTH_BLUETOOTH_H */
+#endif /* HAVE_BLUETOOTH_BLUETOOTH_H */
+
/* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
AF_X25 AF_ROSE etc. still need to be done */
default:
tprints("sa_data=");
- print_quoted_string(addrbuf.sa.sa_data,
- sizeof(addrbuf.sa.sa_data), 0);
+ print_quoted_string(addr->sa.sa_data,
+ sizeof(addr->sa.sa_data), 0);
break;
}
tprints("}");
}
+int
+printsock(struct tcb *tcp, long addr, int addrlen)
+{
+ if (addrlen < 2) {
+ printaddr(addr);
+ return -1;
+ }
+
+ 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);
+
+ if (umoven_or_printaddr(tcp, addr, addrlen, addrbuf.pad))
+ 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"
+#include "xlat/ip_cmsg_types.h"
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
struct cmsghdr32 {
} union_cmsghdr;
static void
-print_scm_rights(struct tcb *tcp, const size_t cmsg_size, const char *ptr,
- const size_t cmsg_len)
+print_scm_rights(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
{
- if (cmsg_size + sizeof(int) > cmsg_len)
- return;
-
- const int *fds = (const int *) (ptr + cmsg_size);
+ const int *fds = cmsg_data;
+ const char *end = (const char *) cmsg_data + data_len;
bool seen = false;
+ if (sizeof(*fds) > data_len)
+ return;
+
tprints(", [");
- while ((const char *) fds < (ptr + cmsg_len)) {
+ while ((const char *) fds < end) {
if (seen)
tprints(", ");
else
}
static void
-print_scm_creds(struct tcb *tcp, const size_t cmsg_size, const char *ptr,
- const size_t cmsg_len)
+print_scm_creds(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
{
- if (cmsg_size + sizeof(struct ucred) > cmsg_len)
- return;
+ const struct ucred *uc = cmsg_data;
- const struct ucred *uc = (const void *) (ptr + cmsg_size);
+ if (sizeof(*uc) > data_len)
+ return;
tprintf(", {pid=%u, uid=%u, gid=%u}",
(unsigned) uc->pid, (unsigned) uc->uid, (unsigned) uc->gid);
}
static void
-print_scm_security(struct tcb *tcp, const size_t cmsg_size, const char *ptr,
- const size_t cmsg_len)
+print_scm_security(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
+{
+ if (!data_len)
+ return;
+
+ tprints(", ");
+ print_quoted_string(cmsg_data, data_len, 0);
+}
+
+static void
+print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
+{
+ const struct in_pktinfo *info = cmsg_data;
+
+ if (sizeof(*info) > data_len)
+ return;
+
+ tprints(", {ipi_ifindex=");
+ print_ifindex(info->ipi_ifindex);
+ tprintf(", ipi_spec_dst=inet_addr(\"%s\"), ipi_addr=inet_addr(\"%s\")}",
+ inet_ntoa(info->ipi_spec_dst), inet_ntoa(info->ipi_addr));
+}
+
+static void
+print_cmsg_ip_ttl(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
+{
+ const unsigned int *ttl = cmsg_data;
+
+ if (sizeof(*ttl) > data_len)
+ return;
+
+ tprintf(", {ttl=%u}", *ttl);
+}
+
+static void
+print_cmsg_ip_tos(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
{
- if (cmsg_size + sizeof(char) > cmsg_len)
+ const uint8_t *tos = cmsg_data;
+
+ if (sizeof(*tos) > data_len)
+ return;
+
+ tprintf(", {tos=%x}", *tos);
+}
+
+static void
+print_cmsg_ip_checksum(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
+{
+ const uint32_t *csum = cmsg_data;
+
+ if (sizeof(*csum) > data_len)
+ return;
+
+ tprintf(", {csum=%u}", *csum);
+}
+
+static void
+print_cmsg_ip_opts(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
+{
+ const unsigned char *opts = cmsg_data;
+ size_t i;
+
+ if (!data_len)
+ return;
+
+ tprints(", {opts=0x");
+ for (i = 0; i < data_len; ++i)
+ tprintf("%02x", opts[i]);
+ tprints("}");
+}
+
+static void
+print_cmsg_ip_recverr(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
+{
+ const struct {
+ uint32_t ee_errno;
+ uint8_t ee_origin;
+ uint8_t ee_type;
+ uint8_t ee_code;
+ uint8_t ee_pad;
+ uint32_t ee_info;
+ uint32_t ee_data;
+ struct sockaddr_in offender;
+ } *err = cmsg_data;
+
+ if (sizeof(*err) > data_len)
return;
- const char *label = ptr + cmsg_size;
- const size_t label_len = cmsg_len - cmsg_size;
+ tprintf(", {ee_errno=%u, ee_origin=%u, ee_type=%u, ee_code=%u"
+ ", 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, &err->offender, sizeof(err->offender));
+ tprints("}");
+}
+
+static void
+print_cmsg_ip_origdstaddr(struct tcb *tcp, const void *cmsg_data,
+ const size_t data_len)
+{
+ if (sizeof(struct sockaddr_in) > data_len)
+ return;
tprints(", ");
- print_quoted_string(label, label_len, 0);
+ print_sockaddr(tcp, cmsg_data, data_len);
}
static void
print_cmsg_type_data(struct tcb *tcp, const int cmsg_level, const int cmsg_type,
- const size_t cmsg_size, const char *ptr, const size_t cmsg_len)
+ const void *cmsg_data, const size_t data_len)
{
switch (cmsg_level) {
case SOL_SOCKET:
printxval(scmvals, cmsg_type, "SCM_???");
switch (cmsg_type) {
case SCM_RIGHTS:
- print_scm_rights(tcp, cmsg_size, ptr, cmsg_len);
+ print_scm_rights(tcp, cmsg_data, data_len);
break;
case SCM_CREDENTIALS:
- print_scm_creds(tcp, cmsg_size, ptr, cmsg_len);
+ print_scm_creds(tcp, cmsg_data, data_len);
break;
case SCM_SECURITY:
- print_scm_security(tcp, cmsg_size, ptr, cmsg_len);
+ print_scm_security(tcp, cmsg_data, data_len);
+ break;
+ }
+ break;
+ case SOL_IP:
+ printxval(ip_cmsg_types, cmsg_type, "IP_???");
+ switch (cmsg_type) {
+ case IP_PKTINFO:
+ print_cmsg_ip_pktinfo(tcp, cmsg_data, data_len);
+ break;
+ case IP_TTL:
+ print_cmsg_ip_ttl(tcp, cmsg_data, data_len);
+ break;
+ case IP_TOS:
+ print_cmsg_ip_tos(tcp, cmsg_data, data_len);
+ break;
+ case IP_RECVOPTS:
+ case IP_RETOPTS:
+ print_cmsg_ip_opts(tcp, cmsg_data, data_len);
+ break;
+ case IP_RECVERR:
+ print_cmsg_ip_recverr(tcp, cmsg_data, data_len);
+ break;
+ case IP_ORIGDSTADDR:
+ print_cmsg_ip_origdstaddr(tcp, cmsg_data, data_len);
+ break;
+ case IP_CHECKSUM:
+ print_cmsg_ip_checksum(tcp, cmsg_data, data_len);
+ break;
+ case SCM_SECURITY:
+ print_scm_security(tcp, cmsg_data, data_len);
break;
}
break;
cmsg_len = len;
print_cmsg_type_data(tcp, cmsg_level, cmsg_type,
- cmsg_size, u.ptr, cmsg_len);
+ (const void *) (u.ptr + cmsg_size),
+ cmsg_len > cmsg_size ? cmsg_len - cmsg_size: 0);
tprints("}");
if (cmsg_len < cmsg_size) {
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);
}
void
-dumpiov_in_msghdr(struct tcb *tcp, long addr)
+dumpiov_in_msghdr(struct tcb *tcp, long addr, unsigned long data_size)
{
struct msghdr msg;
if (extractmsghdr(tcp, addr, &msg))
- dumpiov(tcp, msg.msg_iovlen, (long)msg.msg_iov);
+ dumpiov_upto(tcp, msg.msg_iovlen, (long)msg.msg_iov, data_size);
}
static void
if (extractmmsghdr(tcp, addr, i, &mmsg)) {
tprintf(" = %lu buffers in vector %u\n",
(unsigned long)mmsg.msg_hdr.msg_iovlen, i);
- dumpiov(tcp, mmsg.msg_hdr.msg_iovlen,
- (long)mmsg.msg_hdr.msg_iov);
+ dumpiov_upto(tcp, mmsg.msg_hdr.msg_iovlen,
+ (long)mmsg.msg_hdr.msg_iov, mmsg.msg_len);
}
}
}
* other bits are socket type flags.
*/
static void
-tprint_sock_type(int flags)
+tprint_sock_type(unsigned int flags)
{
const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
SYS_FUNC(socket)
{
- printxval(domains, tcp->u_arg[0], "PF_???");
+ printxval(addrfams, tcp->u_arg[0], "AF_???");
tprints(", ");
tprint_sock_type(tcp->u_arg[1]);
tprints(", ");
switch (tcp->u_arg[0]) {
- case PF_INET:
-#ifdef PF_INET6
- case PF_INET6:
-#endif
+ case AF_INET:
+ case AF_INET6:
printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
break;
-#ifdef PF_IPX
- case PF_IPX:
- /* BTW: I don't believe this.. */
- tprints("[");
- printxval(domains, tcp->u_arg[2], "PF_???");
- tprints("]");
- break;
-#endif /* PF_IPX */
-#ifdef PF_NETLINK
- case PF_NETLINK:
+
+ case AF_NETLINK:
printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
break;
-#endif
-#if defined(PF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
- case PF_BLUETOOTH:
+
+#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
+ case AF_BLUETOOTH:
printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
break;
#endif
+
default:
tprintf("%lu", tcp->u_arg[2]);
break;
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
if (!verbose(tcp)) {
- tprintf("%#lx, %u, ",
- tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
+ printaddr(tcp->u_arg[1]);
+ tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
}
} else {
*/
tcp->auxstr = sprint_timespec(tcp, tcp->u_arg[4]);
} else {
- tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
+ printaddr(tcp->u_arg[1]);
+ tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
tprints(", ");
print_timespec(tcp, tcp->u_arg[4]);
do_pipe(struct tcb *tcp, int flags_arg)
{
if (exiting(tcp)) {
- if (syserror(tcp)) {
- printaddr(tcp->u_arg[0]);
- } else {
-#ifdef HAVE_GETRVAL2
- if (flags_arg < 0) {
- printpair_fd(tcp, tcp->u_rval, getrval2(tcp));
- } else
-#endif
- decode_pair_fd(tcp, tcp->u_arg[0]);
- }
+ decode_pair_fd(tcp, tcp->u_arg[0]);
if (flags_arg >= 0) {
tprints(", ");
printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
SYS_FUNC(pipe)
{
+#ifdef HAVE_GETRVAL2
+ if (exiting(tcp) && !syserror(tcp))
+ printpair_fd(tcp, tcp->u_rval, getrval2(tcp));
+ return 0;
+#else
return do_pipe(tcp, -1);
+#endif
}
SYS_FUNC(pipe2)
SYS_FUNC(socketpair)
{
if (entering(tcp)) {
- printxval(domains, tcp->u_arg[0], "PF_???");
+ printxval(addrfams, tcp->u_arg[0], "AF_???");
tprints(", ");
tprint_sock_type(tcp->u_arg[1]);
tprintf(", %lu", tcp->u_arg[2]);
#include "xlat/socktcpoptions.h"
static void
-print_sockopt_fd_level_name(struct tcb *tcp, int fd, int level, int name, bool is_getsockopt)
+print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level,
+ unsigned int name, bool is_getsockopt)
{
printfd(tcp, fd);
tprints(", ");
tprints(", ");
}
-#ifdef SO_LINGER
static void
print_linger(struct tcb *tcp, long addr, int len)
{
linger.l_onoff,
linger.l_linger);
}
-#endif /* SO_LINGER */
#ifdef SO_PEERCRED
static void
}
#endif /* PACKET_STATISTICS */
-#ifdef ICMP_FILTER
-# include "xlat/icmpfilterflags.h"
+#include "xlat/icmpfilterflags.h"
static void
-print_icmp_filter(struct tcb *tcp, long addr, int len)
+print_icmp_filter(struct tcb *tcp, const long addr, int len)
{
- struct icmp_filter filter;
+ struct icmp_filter filter = {};
- if (len != sizeof(filter) ||
- umove(tcp, addr, &filter) < 0) {
+ if (len > (int) sizeof(filter))
+ len = sizeof(filter);
+ else if (len <= 0) {
printaddr(addr);
return;
}
+ if (umoven_or_printaddr(tcp, addr, len, &filter))
+ return;
+
tprints("~(");
printflags(icmpfilterflags, ~filter.data, "ICMP_???");
tprints(")");
}
-#endif /* ICMP_FILTER */
static void
-print_getsockopt(struct tcb *tcp, int level, int name, long addr, int len)
+print_getsockopt(struct tcb *tcp, unsigned int level, unsigned int name,
+ long addr, int len)
{
if (addr && verbose(tcp))
switch (level) {
case SOL_SOCKET:
switch (name) {
-#ifdef SO_LINGER
case SO_LINGER:
print_linger(tcp, addr, len);
goto done;
-#endif
#ifdef SO_PEERCRED
case SO_PEERCRED:
print_ucred(tcp, addr, len);
case SOL_RAW:
switch (name) {
-#ifdef ICMP_FILTER
case ICMP_FILTER:
print_icmp_filter(tcp, addr, len);
goto done;
-#endif
}
break;
}
int len;
if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
- tprintf("%#lx, %#lx",
- tcp->u_arg[3], tcp->u_arg[4]);
+ printaddr(tcp->u_arg[3]);
+ tprints(", ");
+ printaddr(tcp->u_arg[4]);
} else {
print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
tcp->u_arg[3], len);
if (umove_or_printaddr(tcp, addr, &mreq))
return;
-#ifdef HAVE_INET_NTOP
const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr;
char address[INET6_ADDRSTRLEN];
print_ifindex(mreq.ipv6mr_interface);
tprints("}");
return;
-#endif /* HAVE_INET_NTOP */
fail:
printstr(tcp, addr, len);
return;
}
- union {
- struct sockaddr *sa;
- struct sockaddr_in *sin;
-#ifdef HAVE_INET_NTOP
- struct sockaddr_in6 *sin6;
-#endif
- } a = { .sa = (struct sockaddr *) &greq.gr_group };
-#ifdef HAVE_INET_NTOP
- char str[INET6_ADDRSTRLEN];
-#endif
-
- tprintf("{gr_interface=%u, gr_group={sa_family=", greq.gr_interface);
- printxval(addrfams, a.sa->sa_family, "AF_???");
-
- switch (a.sa->sa_family) {
- case AF_INET:
- tprintf(", sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}}",
- ntohs(a.sin->sin_port),
- inet_ntoa(a.sin->sin_addr));
- return;
-#ifdef HAVE_INET_NTOP
- case AF_INET6:
- if (!inet_ntop(AF_INET6, &a.sin6->sin6_addr, str, sizeof(str)))
- break;
- tprintf(", sin6_port=htons(%u)"
- ", inet_pton(AF_INET6, \"%s\", &sin6_addr)}}",
- ntohs(a.sin6->sin6_port), str);
- return;
-#endif /* HAVE_INET_NTOP */
- }
-
- tprints(", sa_data=");
- print_quoted_string(a.sa->sa_data, sizeof(a.sa->sa_data), 0);
- tprintf("}}");
+ tprintf("{gr_interface=%u, gr_group=", greq.gr_interface);
+ print_sockaddr(tcp, &greq.gr_group, sizeof(greq.gr_group));
+ tprintf("}");
}
#endif /* MCAST_JOIN_GROUP */
#endif /* PACKET_ADD_MEMBERSHIP */
static void
-print_setsockopt(struct tcb *tcp, int level, int name, long addr, int len)
+print_setsockopt(struct tcb *tcp, unsigned int level, unsigned int name,
+ long addr, int len)
{
if (addr && verbose(tcp))
switch (level) {
case SOL_SOCKET:
switch (name) {
-#ifdef SO_LINGER
case SO_LINGER:
print_linger(tcp, addr, len);
goto done;
-#endif
}
break;
case SOL_RAW:
switch (name) {
-#ifdef ICMP_FILTER
case ICMP_FILTER:
print_icmp_filter(tcp, addr, len);
goto done;
-#endif
}
break;
}