2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/socket.h>
36 #if defined(HAVE_SIN6_SCOPE_ID_LINUX)
37 # define in6_addr in6_addr_libc
38 # define ipv6_mreq ipv6_mreq_libc
39 # define sockaddr_in6 sockaddr_in6_libc
41 #include <netinet/in.h>
42 #ifdef HAVE_NETINET_TCP_H
43 # include <netinet/tcp.h>
45 #ifdef HAVE_NETINET_UDP_H
46 # include <netinet/udp.h>
48 #ifdef HAVE_NETINET_SCTP_H
49 # include <netinet/sctp.h>
51 #include <arpa/inet.h>
53 #include <asm/types.h>
54 #if defined(__GLIBC__)
55 # include <netipx/ipx.h>
57 # include <linux/ipx.h>
60 #if defined(__GLIBC__) && defined(HAVE_SIN6_SCOPE_ID_LINUX)
61 # if defined(HAVE_LINUX_IN6_H)
62 # if defined(HAVE_SIN6_SCOPE_ID_LINUX)
66 # define in6_addr in6_addr_kernel
67 # define ipv6_mreq ipv6_mreq_kernel
68 # define sockaddr_in6 sockaddr_in6_kernel
70 # include <linux/in6.h>
71 # if defined(HAVE_SIN6_SCOPE_ID_LINUX)
75 # define in6_addr in6_addr_libc
76 # define ipv6_mreq ipv6_mreq_libc
77 # define sockaddr_in6 sockaddr_in6_kernel
82 #if defined(HAVE_LINUX_NETLINK_H)
83 # include <linux/netlink.h>
85 #if defined(HAVE_LINUX_IF_PACKET_H)
86 # include <linux/if_packet.h>
88 #if defined(HAVE_LINUX_ICMP_H)
89 # include <linux/icmp.h>
91 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
92 # include <bluetooth/bluetooth.h>
93 # include <bluetooth/hci.h>
94 # include <bluetooth/l2cap.h>
95 # include <bluetooth/rfcomm.h>
96 # include <bluetooth/sco.h>
99 # define PF_UNSPEC AF_UNSPEC
102 #include "xlat/domains.h"
103 #include "xlat/addrfams.h"
104 #include "xlat/socktypes.h"
105 #include "xlat/sock_type_flags.h"
106 #ifndef SOCK_TYPE_MASK
107 # define SOCK_TYPE_MASK 0xf
109 #include "xlat/socketlayers.h"
110 /*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
111 falls into "inet_protocols" array below!!!! This is intended!!! ***/
112 #include "xlat/inet_protocols.h"
115 # if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG
116 # define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
118 # include "xlat/netlink_protocols.h"
121 #if defined(HAVE_BLUETOOTH_BLUETOOTH_H)
122 # include "xlat/bt_protocols.h"
125 #include "xlat/msg_flags.h"
126 #include "xlat/sockoptions.h"
128 #if !defined(SOL_IP) && defined(IPPROTO_IP)
129 #define SOL_IP IPPROTO_IP
133 #include "xlat/sockipoptions.h"
137 #include "xlat/sockipv6options.h"
138 #endif /* SOL_IPV6 */
141 #include "xlat/sockipxoptions.h"
145 #include "xlat/sockrawoptions.h"
149 #include "xlat/sockpacketoptions.h"
150 #endif /* SOL_PACKET */
153 #include "xlat/socksctpoptions.h"
156 #if !defined(SOL_TCP) && defined(IPPROTO_TCP)
157 #define SOL_TCP IPPROTO_TCP
161 #include "xlat/socktcpoptions.h"
165 #include "xlat/icmpfilterflags.h"
168 #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
169 #include "xlat/af_packet_types.h"
170 #endif /* defined(AF_PACKET) */
173 printsock(struct tcb *tcp, long addr, int addrlen)
178 struct sockaddr_in sin;
179 struct sockaddr_un sau;
180 #ifdef HAVE_INET_NTOP
181 struct sockaddr_in6 sa6;
184 struct sockaddr_ipx sipx;
187 struct sockaddr_ll ll;
190 struct sockaddr_nl nl;
192 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
193 struct sockaddr_hci hci;
194 struct sockaddr_l2 l2;
195 struct sockaddr_rc rc;
196 struct sockaddr_sco sco;
199 char string_addr[100];
206 tprintf("%#lx", addr);
210 if (addrlen < 2 || addrlen > (int) sizeof(addrbuf))
211 addrlen = sizeof(addrbuf);
213 memset(&addrbuf, 0, sizeof(addrbuf));
214 if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
218 addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
220 tprints("{sa_family=");
221 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
224 switch (addrbuf.sa.sa_family) {
228 } else if (addrbuf.sau.sun_path[0]) {
229 tprints("sun_path=");
230 printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
232 tprints("sun_path=@");
233 printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
237 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
238 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
240 #ifdef HAVE_INET_NTOP
242 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
243 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
244 ntohs(addrbuf.sa6.sin6_port), string_addr,
245 addrbuf.sa6.sin6_flowinfo);
246 #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
248 #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
249 int numericscope = 0;
250 if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr)
251 || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) {
252 char scopebuf[IFNAMSIZ + 1];
254 if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
257 tprints(", sin6_scope_id=if_nametoindex(");
258 print_quoted_string(scopebuf,
268 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
277 tprintf("sipx_port=htons(%u), ",
278 ntohs(addrbuf.sipx.sipx_port));
279 /* Yes, I know, this does not look too
280 * strace-ish, but otherwise the IPX
281 * addresses just look monstrous...
282 * Anyways, feel free if you don't like
285 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
286 for (i = 0; i < IPX_NODE_LEN; i++)
287 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
288 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
296 tprintf("proto=%#04x, if%d, pkttype=",
297 ntohs(addrbuf.ll.sll_protocol),
298 addrbuf.ll.sll_ifindex);
299 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "PACKET_???");
300 tprintf(", addr(%d)={%d, ",
301 addrbuf.ll.sll_halen,
302 addrbuf.ll.sll_hatype);
303 for (i = 0; i < addrbuf.ll.sll_halen; i++)
304 tprintf("%02x", addrbuf.ll.sll_addr[i]);
308 #endif /* AF_PACKET */
311 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
313 #endif /* AF_NETLINK */
314 #if defined(AF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
316 tprintf("{sco_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X} or "
317 "{rc_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, rc_channel=%d} or "
318 "{l2_psm=htobs(%d), l2_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, l2_cid=htobs(%d)} or "
319 "{hci_dev=htobs(%d)}",
320 addrbuf.sco.sco_bdaddr.b[0], addrbuf.sco.sco_bdaddr.b[1],
321 addrbuf.sco.sco_bdaddr.b[2], addrbuf.sco.sco_bdaddr.b[3],
322 addrbuf.sco.sco_bdaddr.b[4], addrbuf.sco.sco_bdaddr.b[5],
323 addrbuf.rc.rc_bdaddr.b[0], addrbuf.rc.rc_bdaddr.b[1],
324 addrbuf.rc.rc_bdaddr.b[2], addrbuf.rc.rc_bdaddr.b[3],
325 addrbuf.rc.rc_bdaddr.b[4], addrbuf.rc.rc_bdaddr.b[5],
326 addrbuf.rc.rc_channel,
327 btohs(addrbuf.l2.l2_psm), addrbuf.l2.l2_bdaddr.b[0],
328 addrbuf.l2.l2_bdaddr.b[1], addrbuf.l2.l2_bdaddr.b[2],
329 addrbuf.l2.l2_bdaddr.b[3], addrbuf.l2.l2_bdaddr.b[4],
330 addrbuf.l2.l2_bdaddr.b[5], btohs(addrbuf.l2.l2_cid),
331 btohs(addrbuf.hci.hci_dev));
333 #endif /* AF_BLUETOOTH && HAVE_BLUETOOTH_BLUETOOTH_H */
334 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
335 AF_X25 AF_ROSE etc. still need to be done */
339 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
340 sizeof addrbuf.sa.sa_data);
347 # ifndef SCM_SECURITY
348 # define SCM_SECURITY 0x03
350 # include "xlat/scmvals.h"
352 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
362 struct cmsghdr *cmsg;
363 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
364 struct cmsghdr32 *cmsg32;
369 print_scm_rights(struct tcb *tcp, size_t cmsg_size, char *ptr, size_t cmsg_len)
371 if (cmsg_size + sizeof(int) > cmsg_len)
374 int *fds = (int *) (ptr + cmsg_size);
378 while ((char *) fds < (ptr + cmsg_len)) {
383 printfd(tcp, *fds++);
390 print_scm_creds(struct tcb *tcp, size_t cmsg_size, char *ptr, size_t cmsg_len)
392 if (cmsg_size + sizeof(struct ucred) > cmsg_len)
395 const struct ucred *uc = (void *) (ptr + cmsg_size);
397 tprintf(", {pid=%u, uid=%u, gid=%u}}",
398 (unsigned) uc->pid, (unsigned) uc->uid, (unsigned) uc->gid);
403 print_scm_security(struct tcb *tcp, size_t cmsg_size, char *ptr, size_t cmsg_len)
405 if (cmsg_size + sizeof(char) > cmsg_len)
408 const char *label = (const char *) (ptr + cmsg_size);
409 const size_t label_len = cmsg_len - cmsg_size;
412 print_quoted_string(label, label_len, 0);
419 printcmsghdr(struct tcb *tcp, unsigned long addr, size_t len)
421 const size_t cmsg_size =
422 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
423 (current_wordsize < sizeof(long)) ? sizeof(struct cmsghdr32) :
425 sizeof(struct cmsghdr);
427 char *buf = len < cmsg_size ? NULL : malloc(len);
428 if (!buf || umoven(tcp, addr, len, buf) < 0) {
429 tprintf(", msg_control=%#lx", addr);
434 union_cmsghdr u = { .ptr = buf };
437 while (len >= cmsg_size) {
439 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
440 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_len :
444 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
445 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_level :
449 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
450 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_type :
456 tprintf("{cmsg_len=%lu, cmsg_level=", (unsigned long) cmsg_len);
457 printxval(socketlayers, cmsg_level, "SOL_???");
458 tprints(", cmsg_type=");
463 if (cmsg_level == SOL_SOCKET) {
464 printxval(scmvals, cmsg_type, "SCM_???");
467 if (print_scm_rights(tcp, cmsg_size, u.ptr, cmsg_len))
470 case SCM_CREDENTIALS:
471 if (print_scm_creds(tcp, cmsg_size, u.ptr, cmsg_len))
475 if (print_scm_security(tcp, cmsg_size, u.ptr, cmsg_len))
480 tprintf("%u", cmsg_type);
484 if (cmsg_len < cmsg_size) {
488 cmsg_len = (cmsg_len + current_wordsize - 1) &
489 (size_t) ~(current_wordsize - 1);
490 if (cmsg_len >= len) {
504 do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
506 tprintf("{msg_name(%d)=", msg->msg_namelen);
507 printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
509 tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
510 tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
511 (unsigned long)msg->msg_iov, 1, data_size);
513 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
514 tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
515 if (msg->msg_controllen)
516 printcmsghdr(tcp, (unsigned long) msg->msg_control,
517 msg->msg_controllen);
518 tprints(", msg_flags=");
519 printflags(msg_flags, msg->msg_flags, "MSG_???");
520 #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
521 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
522 (unsigned long) msg->msg_accrights, msg->msg_accrightslen);
523 #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
528 uint32_t /* void* */ msg_name;
529 uint32_t /* socklen_t */msg_namelen;
530 uint32_t /* iovec* */ msg_iov;
531 uint32_t /* size_t */ msg_iovlen;
532 uint32_t /* void* */ msg_control;
533 uint32_t /* size_t */ msg_controllen;
534 uint32_t /* int */ msg_flags;
537 struct msghdr32 msg_hdr;
538 uint32_t /* unsigned */ msg_len;
541 #ifndef HAVE_STRUCT_MMSGHDR
543 struct msghdr msg_hdr;
548 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
550 copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32)
552 to_msg->msg_name = (void*)(long)from_msg32->msg_name;
553 to_msg->msg_namelen = from_msg32->msg_namelen;
554 to_msg->msg_iov = (void*)(long)from_msg32->msg_iov;
555 to_msg->msg_iovlen = from_msg32->msg_iovlen;
556 to_msg->msg_control = (void*)(long)from_msg32->msg_control;
557 to_msg->msg_controllen = from_msg32->msg_controllen;
558 to_msg->msg_flags = from_msg32->msg_flags;
563 extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg)
565 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
566 if (current_wordsize == 4) {
567 struct msghdr32 msg32;
569 if (umove(tcp, addr, &msg32) < 0)
571 copy_from_msghdr32(msg, &msg32);
574 if (umove(tcp, addr, msg) < 0)
580 extractmmsghdr(struct tcb *tcp, long addr, unsigned int idx, struct mmsghdr *mmsg)
582 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
583 if (current_wordsize == 4) {
584 struct mmsghdr32 mmsg32;
586 addr += sizeof(struct mmsghdr32) * idx;
587 if (umove(tcp, addr, &mmsg32) < 0)
590 copy_from_msghdr32(&mmsg->msg_hdr, &mmsg32.msg_hdr);
591 mmsg->msg_len = mmsg32.msg_len;
595 addr += sizeof(*mmsg) * idx;
596 if (umove(tcp, addr, mmsg) < 0)
603 printmsghdr(struct tcb *tcp, long addr, unsigned long data_size)
607 if (verbose(tcp) && extractmsghdr(tcp, addr, &msg))
608 do_msghdr(tcp, &msg, data_size);
610 tprintf("%#lx", addr);
614 dumpiov_in_msghdr(struct tcb *tcp, long addr)
618 if (extractmsghdr(tcp, addr, &msg))
619 dumpiov(tcp, msg.msg_iovlen, (long)msg.msg_iov);
623 printmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
627 if (extractmmsghdr(tcp, addr, idx, &mmsg)) {
629 do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
630 tprintf(", %u}", mmsg.msg_len);
633 tprintf("%#lx", addr);
637 decode_mmsg(struct tcb *tcp, unsigned long msg_len)
641 tprintf("%#lx", tcp->u_arg[1]);
643 unsigned int len = tcp->u_rval;
647 for (i = 0; i < len; ++i) {
650 printmmsghdr(tcp, tcp->u_arg[1], i, msg_len);
655 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
657 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
661 dumpiov_in_mmsghdr(struct tcb *tcp, long addr)
663 unsigned int len = tcp->u_rval;
667 for (i = 0; i < len; ++i) {
668 if (extractmmsghdr(tcp, addr, i, &mmsg)) {
669 tprintf(" = %lu buffers in vector %u\n",
670 (unsigned long)mmsg.msg_hdr.msg_iovlen, i);
671 dumpiov(tcp, mmsg.msg_hdr.msg_iovlen,
672 (long)mmsg.msg_hdr.msg_iov);
676 #endif /* HAVE_SENDMSG */
679 * low bits of the socket type define real socket type,
680 * other bits are socket type flags.
683 tprint_sock_type(int flags)
685 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
689 flags &= ~SOCK_TYPE_MASK;
694 printflags(sock_type_flags, flags, "SOCK_???");
698 sys_socket(struct tcb *tcp)
701 printxval(domains, tcp->u_arg[0], "PF_???");
703 tprint_sock_type(tcp->u_arg[1]);
705 switch (tcp->u_arg[0]) {
710 printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
714 /* BTW: I don't believe this.. */
716 printxval(domains, tcp->u_arg[2], "PF_???");
722 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
725 #if defined(PF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
727 printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
731 tprintf("%lu", tcp->u_arg[2]);
739 sys_bind(struct tcb *tcp)
742 printfd(tcp, tcp->u_arg[0]);
744 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
745 tprintf(", %lu", tcp->u_arg[2]);
751 sys_connect(struct tcb *tcp)
753 return sys_bind(tcp);
757 sys_listen(struct tcb *tcp)
760 printfd(tcp, tcp->u_arg[0]);
762 tprintf("%lu", tcp->u_arg[1]);
768 do_sockname(struct tcb *tcp, int flags_arg)
771 printfd(tcp, tcp->u_arg[0]);
776 tprintf("%#lx, NULL", tcp->u_arg[1]);
779 if (tcp->u_arg[1] == 0 || syserror(tcp)
780 || umove(tcp, tcp->u_arg[2], &len) < 0) {
781 tprintf("%#lx", tcp->u_arg[1]);
783 printsock(tcp, tcp->u_arg[1], len);
786 printnum_int(tcp, tcp->u_arg[2], "%u");
788 if (flags_arg >= 0) {
790 printflags(sock_type_flags, tcp->u_arg[flags_arg],
797 sys_accept(struct tcb *tcp)
799 do_sockname(tcp, -1);
804 sys_accept4(struct tcb *tcp)
811 sys_send(struct tcb *tcp)
814 printfd(tcp, tcp->u_arg[0]);
816 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
817 tprintf(", %lu, ", tcp->u_arg[2]);
819 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
825 sys_sendto(struct tcb *tcp)
828 printfd(tcp, tcp->u_arg[0]);
830 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
831 tprintf(", %lu, ", tcp->u_arg[2]);
833 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
836 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
838 tprintf(", %lu", tcp->u_arg[5]);
846 sys_sendmsg(struct tcb *tcp)
849 printfd(tcp, tcp->u_arg[0]);
851 printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
854 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
860 sys_sendmmsg(struct tcb *tcp)
864 printfd(tcp, tcp->u_arg[0]);
867 tprintf("%#lx, %u, ",
868 tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
869 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
873 decode_mmsg(tcp, (unsigned long) -1L);
878 #endif /* HAVE_SENDMSG */
881 sys_recv(struct tcb *tcp)
884 printfd(tcp, tcp->u_arg[0]);
888 tprintf("%#lx", tcp->u_arg[1]);
890 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
892 tprintf(", %lu, ", tcp->u_arg[2]);
893 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
899 sys_recvfrom(struct tcb *tcp)
904 printfd(tcp, tcp->u_arg[0]);
908 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
909 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
910 tcp->u_arg[4], tcp->u_arg[5]);
914 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
916 tprintf(", %lu, ", tcp->u_arg[2]);
918 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
919 /* from address, len */
920 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
921 if (tcp->u_arg[4] == 0)
924 tprintf(", %#lx", tcp->u_arg[4]);
925 if (tcp->u_arg[5] == 0)
928 tprintf(", %#lx", tcp->u_arg[5]);
931 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
932 tprints(", {...}, [?]");
936 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
938 tprintf(", [%u]", fromlen);
946 sys_recvmsg(struct tcb *tcp)
949 printfd(tcp, tcp->u_arg[0]);
953 tprintf("%#lx", tcp->u_arg[1]);
955 printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval);
958 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
964 sys_recvmmsg(struct tcb *tcp)
966 /* +5 chars are for "left " prefix */
967 static char str[5 + TIMESPEC_TEXT_BUFSIZE];
970 printfd(tcp, tcp->u_arg[0]);
973 sprint_timespec(str, tcp, tcp->u_arg[4]);
974 /* Abusing tcp->auxstr as temp storage.
975 * Will be used and freed on syscall exit.
977 tcp->auxstr = strdup(str);
979 tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
980 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
982 print_timespec(tcp, tcp->u_arg[4]);
988 /* timeout on entrance */
989 tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
990 free((void *) tcp->auxstr);
995 if (tcp->u_rval == 0) {
996 tcp->auxstr = "Timeout";
1001 /* timeout on exit */
1002 sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
1008 #endif /* HAVE_SENDMSG */
1010 #include "xlat/shutdown_modes.h"
1013 sys_shutdown(struct tcb *tcp)
1015 if (entering(tcp)) {
1016 printfd(tcp, tcp->u_arg[0]);
1018 printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
1024 sys_getsockname(struct tcb *tcp)
1026 return do_sockname(tcp, -1);
1030 do_pipe(struct tcb *tcp, int flags_arg)
1033 if (syserror(tcp)) {
1034 tprintf("%#lx", tcp->u_arg[0]);
1036 #if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
1039 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
1042 tprintf("[%u, %u]", fds[0], fds[1]);
1043 #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64)
1044 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
1046 tprintf("%#lx", tcp->u_arg[0]);
1049 if (flags_arg >= 0) {
1051 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
1058 sys_pipe(struct tcb *tcp)
1060 return do_pipe(tcp, -1);
1064 sys_pipe2(struct tcb *tcp)
1066 return do_pipe(tcp, 1);
1070 sys_socketpair(struct tcb *tcp)
1074 if (entering(tcp)) {
1075 printxval(domains, tcp->u_arg[0], "PF_???");
1077 tprint_sock_type(tcp->u_arg[1]);
1078 tprintf(", %lu", tcp->u_arg[2]);
1080 if (syserror(tcp)) {
1081 tprintf(", %#lx", tcp->u_arg[3]);
1084 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
1087 tprintf(", [%u, %u]", fds[0], fds[1]);
1093 print_sockopt_fd_level_name(struct tcb *tcp, int fd, int level, int name)
1097 printxval(socketlayers, level, "SOL_??");
1102 printxval(sockoptions, name, "SO_???");
1106 printxval(sockipoptions, name, "IP_???");
1111 printxval(sockipv6options, name, "IPV6_???");
1116 printxval(sockipxoptions, name, "IPX_???");
1121 printxval(sockpacketoptions, name, "PACKET_???");
1126 printxval(socktcpoptions, name, "TCP_???");
1131 printxval(socksctpoptions, name, "SCTP_???");
1136 printxval(sockrawoptions, name, "RAW_???");
1140 /* Other SOL_* protocol levels still need work. */
1143 tprintf("%u", name);
1151 print_linger(struct tcb *tcp, long addr, int len)
1153 struct linger linger;
1155 if (len != sizeof(linger) ||
1156 umove(tcp, addr, &linger) < 0) {
1157 tprintf("%#lx", addr);
1161 tprintf("{onoff=%d, linger=%d}",
1165 #endif /* SO_LINGER */
1169 print_ucred(struct tcb *tcp, long addr, int len)
1173 if (len != sizeof(uc) ||
1174 umove(tcp, addr, &uc) < 0) {
1175 tprintf("%#lx", addr);
1177 tprintf("{pid=%u, uid=%u, gid=%u}",
1183 #endif /* SO_PEERCRED */
1185 #ifdef PACKET_STATISTICS
1187 print_tpacket_stats(struct tcb *tcp, long addr, int len)
1189 struct tpacket_stats stats;
1191 if (len != sizeof(stats) ||
1192 umove(tcp, addr, &stats) < 0) {
1193 tprintf("%#lx", addr);
1195 tprintf("{packets=%u, drops=%u}",
1200 #endif /* PACKET_STATISTICS */
1204 print_icmp_filter(struct tcb *tcp, long addr, int len)
1206 struct icmp_filter filter;
1208 if (len != sizeof(filter) ||
1209 umove(tcp, addr, &filter) < 0) {
1210 tprintf("%#lx", addr);
1215 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
1218 #endif /* ICMP_FILTER */
1221 print_getsockopt(struct tcb *tcp, int level, int name, long addr, int len)
1223 if (addr && verbose(tcp))
1229 print_linger(tcp, addr, len);
1234 print_ucred(tcp, addr, len);
1243 # ifdef PACKET_STATISTICS
1244 case PACKET_STATISTICS:
1245 print_tpacket_stats(tcp, addr, len);
1250 #endif /* SOL_PACKET */
1257 print_icmp_filter(tcp, addr, len);
1262 #endif /* SOL_RAW */
1265 /* default arg printing */
1268 if (len == sizeof(int)) {
1269 printnum_int(tcp, addr, "%d");
1271 printstr(tcp, addr, len);
1274 tprintf("%#lx", addr);
1277 tprintf(", [%d]", len);
1281 sys_getsockopt(struct tcb *tcp)
1283 if (entering(tcp)) {
1284 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1285 tcp->u_arg[1], tcp->u_arg[2]);
1289 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
1290 tprintf("%#lx, %#lx",
1291 tcp->u_arg[3], tcp->u_arg[4]);
1293 print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1294 tcp->u_arg[3], len);
1300 #ifdef PACKET_RX_RING
1302 print_tpacket_req(struct tcb *tcp, long addr, int len)
1304 struct tpacket_req req;
1306 if (len != sizeof(req) ||
1307 umove(tcp, addr, &req) < 0) {
1308 tprintf("%#lx", addr);
1310 tprintf("{block_size=%u, block_nr=%u, "
1311 "frame_size=%u, frame_nr=%u}",
1318 #endif /* PACKET_RX_RING */
1321 print_setsockopt(struct tcb *tcp, int level, int name, long addr, int len)
1323 if (addr && verbose(tcp))
1329 print_linger(tcp, addr, len);
1338 # ifdef PACKET_RX_RING
1339 case PACKET_RX_RING:
1340 # ifdef PACKET_TX_RING
1341 case PACKET_TX_RING:
1343 print_tpacket_req(tcp, addr, len);
1345 # endif /* PACKET_RX_RING */
1346 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1349 #endif /* SOL_PACKET */
1356 print_icmp_filter(tcp, addr, len);
1361 #endif /* SOL_RAW */
1364 /* default arg printing */
1367 if (len == sizeof(int)) {
1368 printnum_int(tcp, addr, "%d");
1370 printstr(tcp, addr, len);
1373 tprintf("%#lx", addr);
1376 tprintf(", %d", len);
1380 sys_setsockopt(struct tcb *tcp)
1382 if (entering(tcp)) {
1383 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1384 tcp->u_arg[1], tcp->u_arg[2]);
1385 print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1386 tcp->u_arg[3], tcp->u_arg[4]);