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 #include "xlat/netlink_protocols.h"
118 #if defined(HAVE_BLUETOOTH_BLUETOOTH_H)
119 # include "xlat/bt_protocols.h"
122 #include "xlat/msg_flags.h"
123 #include "xlat/sockoptions.h"
125 #if !defined(SOL_IP) && defined(IPPROTO_IP)
126 #define SOL_IP IPPROTO_IP
130 #include "xlat/sockipoptions.h"
134 #include "xlat/sockipv6options.h"
135 #endif /* SOL_IPV6 */
138 #include "xlat/sockipxoptions.h"
142 #include "xlat/sockrawoptions.h"
146 #include "xlat/sockpacketoptions.h"
147 #endif /* SOL_PACKET */
150 #include "xlat/socksctpoptions.h"
153 #if !defined(SOL_TCP) && defined(IPPROTO_TCP)
154 #define SOL_TCP IPPROTO_TCP
158 #include "xlat/socktcpoptions.h"
162 #include "xlat/icmpfilterflags.h"
165 #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
166 #include "xlat/af_packet_types.h"
167 #endif /* defined(AF_PACKET) */
170 printsock(struct tcb *tcp, long addr, int addrlen)
175 struct sockaddr_in sin;
176 struct sockaddr_un sau;
177 #ifdef HAVE_INET_NTOP
178 struct sockaddr_in6 sa6;
181 struct sockaddr_ipx sipx;
184 struct sockaddr_ll ll;
187 struct sockaddr_nl nl;
189 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
190 struct sockaddr_hci hci;
191 struct sockaddr_l2 l2;
192 struct sockaddr_rc rc;
193 struct sockaddr_sco sco;
196 char string_addr[100];
203 tprintf("%#lx", addr);
207 if (addrlen < 2 || addrlen > (int) sizeof(addrbuf))
208 addrlen = sizeof(addrbuf);
210 memset(&addrbuf, 0, sizeof(addrbuf));
211 if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
215 addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
217 tprints("{sa_family=");
218 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
221 switch (addrbuf.sa.sa_family) {
225 } else if (addrbuf.sau.sun_path[0]) {
226 tprints("sun_path=");
227 printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
229 tprints("sun_path=@");
230 printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
234 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
235 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
237 #ifdef HAVE_INET_NTOP
239 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
240 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
241 ntohs(addrbuf.sa6.sin6_port), string_addr,
242 addrbuf.sa6.sin6_flowinfo);
243 #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
245 #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
246 int numericscope = 0;
247 if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr)
248 || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) {
249 char scopebuf[IFNAMSIZ + 1];
251 if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
254 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
260 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
269 tprintf("sipx_port=htons(%u), ",
270 ntohs(addrbuf.sipx.sipx_port));
271 /* Yes, I know, this does not look too
272 * strace-ish, but otherwise the IPX
273 * addresses just look monstrous...
274 * Anyways, feel free if you don't like
277 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
278 for (i = 0; i < IPX_NODE_LEN; i++)
279 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
280 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
288 tprintf("proto=%#04x, if%d, pkttype=",
289 ntohs(addrbuf.ll.sll_protocol),
290 addrbuf.ll.sll_ifindex);
291 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "PACKET_???");
292 tprintf(", addr(%d)={%d, ",
293 addrbuf.ll.sll_halen,
294 addrbuf.ll.sll_hatype);
295 for (i = 0; i < addrbuf.ll.sll_halen; i++)
296 tprintf("%02x", addrbuf.ll.sll_addr[i]);
300 #endif /* AF_PACKET */
303 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
305 #endif /* AF_NETLINK */
306 #if defined(AF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
308 tprintf("{sco_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X} or "
309 "{rc_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, rc_channel=%d} or "
310 "{l2_psm=htobs(%d), l2_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, l2_cid=htobs(%d)} or "
311 "{hci_dev=htobs(%d)}",
312 addrbuf.sco.sco_bdaddr.b[0], addrbuf.sco.sco_bdaddr.b[1],
313 addrbuf.sco.sco_bdaddr.b[2], addrbuf.sco.sco_bdaddr.b[3],
314 addrbuf.sco.sco_bdaddr.b[4], addrbuf.sco.sco_bdaddr.b[5],
315 addrbuf.rc.rc_bdaddr.b[0], addrbuf.rc.rc_bdaddr.b[1],
316 addrbuf.rc.rc_bdaddr.b[2], addrbuf.rc.rc_bdaddr.b[3],
317 addrbuf.rc.rc_bdaddr.b[4], addrbuf.rc.rc_bdaddr.b[5],
318 addrbuf.rc.rc_channel,
319 btohs(addrbuf.l2.l2_psm), addrbuf.l2.l2_bdaddr.b[0],
320 addrbuf.l2.l2_bdaddr.b[1], addrbuf.l2.l2_bdaddr.b[2],
321 addrbuf.l2.l2_bdaddr.b[3], addrbuf.l2.l2_bdaddr.b[4],
322 addrbuf.l2.l2_bdaddr.b[5], btohs(addrbuf.l2.l2_cid),
323 btohs(addrbuf.hci.hci_dev));
325 #endif /* AF_BLUETOOTH && HAVE_BLUETOOTH_BLUETOOTH_H */
326 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
327 AF_X25 AF_ROSE etc. still need to be done */
331 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
332 sizeof addrbuf.sa.sa_data);
339 #include "xlat/scmvals.h"
342 printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len)
344 struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ?
346 if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) {
347 tprintf(", msg_control=%#lx", addr);
352 tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len);
353 printxval(socketlayers, cmsg->cmsg_level, "SOL_???");
354 tprints(", cmsg_type=");
356 if (cmsg->cmsg_level == SOL_SOCKET) {
357 unsigned long cmsg_len;
359 printxval(scmvals, cmsg->cmsg_type, "SCM_???");
360 cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len;
362 if (cmsg->cmsg_type == SCM_RIGHTS
363 && CMSG_LEN(sizeof(int)) <= cmsg_len) {
364 int *fds = (int *) CMSG_DATA(cmsg);
368 while ((char *) fds < ((char *) cmsg + cmsg_len)) {
371 printfd(tcp, *fds++);
378 if (cmsg->cmsg_type == SCM_CREDENTIALS
379 && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) {
380 struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg);
382 tprintf("{pid=%ld, uid=%ld, gid=%ld}}",
383 (long)uc->pid, (long)uc->uid, (long)uc->gid);
393 do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
395 tprintf("{msg_name(%d)=", msg->msg_namelen);
396 printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
398 tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
399 tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
400 (unsigned long)msg->msg_iov, 1, data_size);
402 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
403 tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
404 if (msg->msg_controllen)
405 printcmsghdr(tcp, (unsigned long) msg->msg_control,
406 msg->msg_controllen);
407 tprints(", msg_flags=");
408 printflags(msg_flags, msg->msg_flags, "MSG_???");
409 #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
410 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
411 (unsigned long) msg->msg_accrights, msg->msg_accrightslen);
412 #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
417 uint32_t /* void* */ msg_name;
418 uint32_t /* socklen_t */msg_namelen;
419 uint32_t /* iovec* */ msg_iov;
420 uint32_t /* size_t */ msg_iovlen;
421 uint32_t /* void* */ msg_control;
422 uint32_t /* size_t */ msg_controllen;
423 uint32_t /* int */ msg_flags;
426 struct msghdr32 msg_hdr;
427 uint32_t /* unsigned */ msg_len;
430 #ifndef HAVE_STRUCT_MMSGHDR
432 struct msghdr msg_hdr;
437 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
439 copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32)
441 to_msg->msg_name = (void*)(long)from_msg32->msg_name;
442 to_msg->msg_namelen = from_msg32->msg_namelen;
443 to_msg->msg_iov = (void*)(long)from_msg32->msg_iov;
444 to_msg->msg_iovlen = from_msg32->msg_iovlen;
445 to_msg->msg_control = (void*)(long)from_msg32->msg_control;
446 to_msg->msg_controllen = from_msg32->msg_controllen;
447 to_msg->msg_flags = from_msg32->msg_flags;
452 extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg)
454 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
455 if (current_wordsize == 4) {
456 struct msghdr32 msg32;
458 if (umove(tcp, addr, &msg32) < 0)
460 copy_from_msghdr32(msg, &msg32);
463 if (umove(tcp, addr, msg) < 0)
469 extractmmsghdr(struct tcb *tcp, long addr, unsigned int idx, struct mmsghdr *mmsg)
471 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
472 if (current_wordsize == 4) {
473 struct mmsghdr32 mmsg32;
475 addr += sizeof(struct mmsghdr32) * idx;
476 if (umove(tcp, addr, &mmsg32) < 0)
479 copy_from_msghdr32(&mmsg->msg_hdr, &mmsg32.msg_hdr);
480 mmsg->msg_len = mmsg32.msg_len;
484 addr += sizeof(*mmsg) * idx;
485 if (umove(tcp, addr, mmsg) < 0)
492 printmsghdr(struct tcb *tcp, long addr, unsigned long data_size)
496 if (extractmsghdr(tcp, addr, &msg))
497 do_msghdr(tcp, &msg, data_size);
499 tprintf("%#lx", addr);
503 dumpiov_in_msghdr(struct tcb *tcp, long addr)
507 if (extractmsghdr(tcp, addr, &msg))
508 dumpiov(tcp, msg.msg_iovlen, (long)msg.msg_iov);
512 printmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
516 if (extractmmsghdr(tcp, addr, idx, &mmsg)) {
518 do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
519 tprintf(", %u}", mmsg.msg_len);
522 tprintf("%#lx", addr);
526 decode_mmsg(struct tcb *tcp, unsigned long msg_len)
530 tprintf("%#lx", tcp->u_arg[1]);
532 unsigned int len = tcp->u_rval;
536 for (i = 0; i < len; ++i) {
539 printmmsghdr(tcp, tcp->u_arg[1], i, msg_len);
544 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
546 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
550 dumpiov_in_mmsghdr(struct tcb *tcp, long addr)
552 unsigned int len = tcp->u_rval;
556 for (i = 0; i < len; ++i) {
557 if (extractmmsghdr(tcp, addr, i, &mmsg)) {
558 tprintf(" = %lu buffers in vector %u\n",
559 (unsigned long)mmsg.msg_hdr.msg_iovlen, i);
560 dumpiov(tcp, mmsg.msg_hdr.msg_iovlen,
561 (long)mmsg.msg_hdr.msg_iov);
565 #endif /* HAVE_SENDMSG */
568 * low bits of the socket type define real socket type,
569 * other bits are socket type flags.
572 tprint_sock_type(int flags)
574 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
578 flags &= ~SOCK_TYPE_MASK;
583 printflags(sock_type_flags, flags, "SOCK_???");
587 sys_socket(struct tcb *tcp)
590 printxval(domains, tcp->u_arg[0], "PF_???");
592 tprint_sock_type(tcp->u_arg[1]);
594 switch (tcp->u_arg[0]) {
599 printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
603 /* BTW: I don't believe this.. */
605 printxval(domains, tcp->u_arg[2], "PF_???");
611 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
614 #if defined(PF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
616 printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
620 tprintf("%lu", tcp->u_arg[2]);
628 sys_bind(struct tcb *tcp)
631 printfd(tcp, tcp->u_arg[0]);
633 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
634 tprintf(", %lu", tcp->u_arg[2]);
640 sys_connect(struct tcb *tcp)
642 return sys_bind(tcp);
646 sys_listen(struct tcb *tcp)
649 printfd(tcp, tcp->u_arg[0]);
651 tprintf("%lu", tcp->u_arg[1]);
657 do_sockname(struct tcb *tcp, int flags_arg)
660 printfd(tcp, tcp->u_arg[0]);
665 tprintf("%#lx, NULL", tcp->u_arg[1]);
668 if (tcp->u_arg[1] == 0 || syserror(tcp)
669 || umove(tcp, tcp->u_arg[2], &len) < 0) {
670 tprintf("%#lx", tcp->u_arg[1]);
672 printsock(tcp, tcp->u_arg[1], len);
675 printnum_int(tcp, tcp->u_arg[2], "%u");
677 if (flags_arg >= 0) {
679 printflags(sock_type_flags, tcp->u_arg[flags_arg],
686 sys_accept(struct tcb *tcp)
688 do_sockname(tcp, -1);
693 sys_accept4(struct tcb *tcp)
700 sys_send(struct tcb *tcp)
703 printfd(tcp, tcp->u_arg[0]);
705 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
706 tprintf(", %lu, ", tcp->u_arg[2]);
708 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
714 sys_sendto(struct tcb *tcp)
717 printfd(tcp, tcp->u_arg[0]);
719 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
720 tprintf(", %lu, ", tcp->u_arg[2]);
722 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
725 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
727 tprintf(", %lu", tcp->u_arg[5]);
735 sys_sendmsg(struct tcb *tcp)
738 printfd(tcp, tcp->u_arg[0]);
740 printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
743 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
749 sys_sendmmsg(struct tcb *tcp)
753 printfd(tcp, tcp->u_arg[0]);
756 tprintf("%#lx, %u, ",
757 tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
758 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
762 decode_mmsg(tcp, (unsigned long) -1L);
767 #endif /* HAVE_SENDMSG */
770 sys_recv(struct tcb *tcp)
773 printfd(tcp, tcp->u_arg[0]);
777 tprintf("%#lx", tcp->u_arg[1]);
779 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
781 tprintf(", %lu, ", tcp->u_arg[2]);
782 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
788 sys_recvfrom(struct tcb *tcp)
793 printfd(tcp, tcp->u_arg[0]);
797 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
798 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
799 tcp->u_arg[4], tcp->u_arg[5]);
803 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
805 tprintf(", %lu, ", tcp->u_arg[2]);
807 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
808 /* from address, len */
809 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
810 if (tcp->u_arg[4] == 0)
813 tprintf(", %#lx", tcp->u_arg[4]);
814 if (tcp->u_arg[5] == 0)
817 tprintf(", %#lx", tcp->u_arg[5]);
820 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
821 tprints(", {...}, [?]");
825 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
827 tprintf(", [%u]", fromlen);
835 sys_recvmsg(struct tcb *tcp)
838 printfd(tcp, tcp->u_arg[0]);
841 if (syserror(tcp) || !verbose(tcp))
842 tprintf("%#lx", tcp->u_arg[1]);
844 printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval);
847 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
853 sys_recvmmsg(struct tcb *tcp)
855 /* +5 chars are for "left " prefix */
856 static char str[5 + TIMESPEC_TEXT_BUFSIZE];
859 printfd(tcp, tcp->u_arg[0]);
862 sprint_timespec(str, tcp, tcp->u_arg[4]);
863 /* Abusing tcp->auxstr as temp storage.
864 * Will be used and freed on syscall exit.
866 tcp->auxstr = strdup(str);
868 tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
869 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
871 print_timespec(tcp, tcp->u_arg[4]);
877 /* timeout on entrance */
878 tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
879 free((void *) tcp->auxstr);
884 if (tcp->u_rval == 0) {
885 tcp->auxstr = "Timeout";
890 /* timeout on exit */
891 sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
897 #endif /* HAVE_SENDMSG */
899 #include "xlat/shutdown_modes.h"
902 sys_shutdown(struct tcb *tcp)
905 printfd(tcp, tcp->u_arg[0]);
907 printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
913 sys_getsockname(struct tcb *tcp)
915 return do_sockname(tcp, -1);
919 do_pipe(struct tcb *tcp, int flags_arg)
923 tprintf("%#lx", tcp->u_arg[0]);
925 #if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
928 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
931 tprintf("[%u, %u]", fds[0], fds[1]);
932 #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64)
933 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
935 tprintf("%#lx", tcp->u_arg[0]);
938 if (flags_arg >= 0) {
940 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
947 sys_pipe(struct tcb *tcp)
949 return do_pipe(tcp, -1);
953 sys_pipe2(struct tcb *tcp)
955 return do_pipe(tcp, 1);
959 sys_socketpair(struct tcb *tcp)
964 printxval(domains, tcp->u_arg[0], "PF_???");
966 tprint_sock_type(tcp->u_arg[1]);
967 tprintf(", %lu", tcp->u_arg[2]);
970 tprintf(", %#lx", tcp->u_arg[3]);
973 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
976 tprintf(", [%u, %u]", fds[0], fds[1]);
982 sys_getsockopt(struct tcb *tcp)
985 printfd(tcp, tcp->u_arg[0]);
987 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
989 switch (tcp->u_arg[1]) {
991 printxval(sockoptions, tcp->u_arg[2], "SO_???");
995 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
1000 printxval(sockipv6options, tcp->u_arg[2], "IPV6_???");
1005 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
1010 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
1015 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
1020 printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???");
1024 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1025 * etc. still need work */
1027 tprintf("%lu", tcp->u_arg[2]);
1033 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
1034 tprintf("%#lx, %#lx",
1035 tcp->u_arg[3], tcp->u_arg[4]);
1039 switch (tcp->u_arg[1]) {
1041 switch (tcp->u_arg[2]) {
1044 if (len == sizeof(struct linger)) {
1045 struct linger linger;
1050 tprintf("{onoff=%d, linger=%d}, "
1061 if (len == sizeof(struct ucred)) {
1067 tprintf("{pid=%ld, uid=%ld, gid=%ld}, "
1080 switch (tcp->u_arg[2]) {
1081 #ifdef PACKET_STATISTICS
1082 case PACKET_STATISTICS:
1083 if (len == sizeof(struct tpacket_stats)) {
1084 struct tpacket_stats stats;
1089 tprintf("{packets=%u, drops=%u}, "
1102 if (len == sizeof(int)) {
1103 printnum_int(tcp, tcp->u_arg[3], "%d");
1106 printstr(tcp, tcp->u_arg[3], len);
1108 tprintf(", [%d]", len);
1113 #if defined(ICMP_FILTER)
1114 static void printicmpfilter(struct tcb *tcp, long addr)
1116 struct icmp_filter filter;
1122 if (syserror(tcp) || !verbose(tcp)) {
1123 tprintf("%#lx", addr);
1126 if (umove(tcp, addr, &filter) < 0) {
1132 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
1135 #endif /* ICMP_FILTER */
1138 printsockopt(struct tcb *tcp, int level, int name, long addr, int len)
1140 printxval(socketlayers, level, "SOL_??");
1144 printxval(sockoptions, name, "SO_???");
1146 #if defined(SO_LINGER)
1148 if (len == sizeof(struct linger)) {
1149 struct linger linger;
1150 if (umove(tcp, addr, &linger) < 0)
1152 tprintf(", {onoff=%d, linger=%d}",
1163 printxval(sockipoptions, name, "IP_???");
1168 printxval(sockipv6options, name, "IPV6_???");
1173 printxval(sockipxoptions, name, "IPX_???");
1178 printxval(sockpacketoptions, name, "PACKET_???");
1179 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1181 #ifdef PACKET_RX_RING
1182 case PACKET_RX_RING:
1184 #ifdef PACKET_TX_RING
1185 case PACKET_TX_RING:
1187 #if defined(PACKET_RX_RING) || defined(PACKET_TX_RING)
1188 if (len == sizeof(struct tpacket_req)) {
1189 struct tpacket_req req;
1190 if (umove(tcp, addr, &req) < 0)
1192 tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}",
1200 #endif /* PACKET_RX_RING || PACKET_TX_RING */
1206 printxval(socktcpoptions, name, "TCP_???");
1211 printxval(socksctpoptions, name, "SCTP_???");
1216 printxval(sockrawoptions, name, "RAW_???");
1218 #if defined(ICMP_FILTER)
1221 printicmpfilter(tcp, addr);
1228 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1229 * etc. still need work */
1232 tprintf("%u", name);
1235 /* default arg printing */
1239 if (len == sizeof(int)) {
1240 printnum_int(tcp, addr, "%d");
1243 printstr(tcp, addr, len);
1249 sys_setsockopt(struct tcb *tcp)
1251 if (entering(tcp)) {
1252 printfd(tcp, tcp->u_arg[0]);
1254 printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1255 tcp->u_arg[3], tcp->u_arg[4]);
1256 tprintf(", %lu", tcp->u_arg[4]);