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>
35 #if defined(HAVE_SIN6_SCOPE_ID_LINUX)
36 # define in6_addr in6_addr_libc
37 # define ipv6_mreq ipv6_mreq_libc
38 # define sockaddr_in6 sockaddr_in6_libc
40 #include <netinet/in.h>
41 #ifdef HAVE_NETINET_TCP_H
42 # include <netinet/tcp.h>
44 #ifdef HAVE_NETINET_UDP_H
45 # include <netinet/udp.h>
47 #ifdef HAVE_NETINET_SCTP_H
48 # include <netinet/sctp.h>
50 #include <arpa/inet.h>
52 #include <asm/types.h>
53 #if defined(__GLIBC__)
54 # include <netipx/ipx.h>
56 # include <linux/ipx.h>
59 #if defined(__GLIBC__) && defined(HAVE_SIN6_SCOPE_ID_LINUX)
60 # if defined(HAVE_LINUX_IN6_H)
61 # if defined(HAVE_SIN6_SCOPE_ID_LINUX)
65 # define in6_addr in6_addr_kernel
66 # define ipv6_mreq ipv6_mreq_kernel
67 # define sockaddr_in6 sockaddr_in6_kernel
69 # include <linux/in6.h>
70 # if defined(HAVE_SIN6_SCOPE_ID_LINUX)
74 # define in6_addr in6_addr_libc
75 # define ipv6_mreq ipv6_mreq_libc
76 # define sockaddr_in6 sockaddr_in6_kernel
81 #if defined(HAVE_SYS_UIO_H)
84 #if defined(HAVE_LINUX_NETLINK_H)
85 # include <linux/netlink.h>
87 #if defined(HAVE_LINUX_IF_PACKET_H)
88 # include <linux/if_packet.h>
90 #if defined(HAVE_LINUX_ICMP_H)
91 # include <linux/icmp.h>
94 # define PF_UNSPEC AF_UNSPEC
97 #include "xlat/domains.h"
98 #include "xlat/addrfams.h"
99 #include "xlat/socktypes.h"
100 #include "xlat/sock_type_flags.h"
101 #ifndef SOCK_TYPE_MASK
102 # define SOCK_TYPE_MASK 0xf
104 #include "xlat/socketlayers.h"
105 /*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
106 falls into "inet_protocols" array below!!!! This is intended!!! ***/
107 #include "xlat/inet_protocols.h"
110 #include "xlat/netlink_protocols.h"
113 #include "xlat/msg_flags.h"
114 #include "xlat/sockoptions.h"
116 #if !defined(SOL_IP) && defined(IPPROTO_IP)
117 #define SOL_IP IPPROTO_IP
121 #include "xlat/sockipoptions.h"
125 #include "xlat/sockipv6options.h"
126 #endif /* SOL_IPV6 */
129 #include "xlat/sockipxoptions.h"
133 #include "xlat/sockrawoptions.h"
137 #include "xlat/sockpacketoptions.h"
138 #endif /* SOL_PACKET */
141 #include "xlat/socksctpoptions.h"
144 #if !defined(SOL_TCP) && defined(IPPROTO_TCP)
145 #define SOL_TCP IPPROTO_TCP
149 #include "xlat/socktcpoptions.h"
153 #include "xlat/icmpfilterflags.h"
156 #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
157 #include "xlat/af_packet_types.h"
158 #endif /* defined(AF_PACKET) */
161 printsock(struct tcb *tcp, long addr, int addrlen)
166 struct sockaddr_in sin;
167 struct sockaddr_un sau;
168 #ifdef HAVE_INET_NTOP
169 struct sockaddr_in6 sa6;
172 struct sockaddr_ipx sipx;
175 struct sockaddr_ll ll;
178 struct sockaddr_nl nl;
181 char string_addr[100];
188 tprintf("%#lx", addr);
192 if (addrlen < 2 || addrlen > sizeof(addrbuf))
193 addrlen = sizeof(addrbuf);
195 memset(&addrbuf, 0, sizeof(addrbuf));
196 if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
200 addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
202 tprints("{sa_family=");
203 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
206 switch (addrbuf.sa.sa_family) {
210 } else if (addrbuf.sau.sun_path[0]) {
211 tprints("sun_path=");
212 printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
214 tprints("sun_path=@");
215 printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
219 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
220 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
222 #ifdef HAVE_INET_NTOP
224 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
225 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
226 ntohs(addrbuf.sa6.sin6_port), string_addr,
227 addrbuf.sa6.sin6_flowinfo);
228 #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
230 #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
231 int numericscope = 0;
232 if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr)
233 || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) {
234 char scopebuf[IFNAMSIZ + 1];
236 if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
239 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
245 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
254 tprintf("sipx_port=htons(%u), ",
255 ntohs(addrbuf.sipx.sipx_port));
256 /* Yes, I know, this does not look too
257 * strace-ish, but otherwise the IPX
258 * addresses just look monstrous...
259 * Anyways, feel free if you don't like
262 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
263 for (i = 0; i < IPX_NODE_LEN; i++)
264 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
265 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
273 tprintf("proto=%#04x, if%d, pkttype=",
274 ntohs(addrbuf.ll.sll_protocol),
275 addrbuf.ll.sll_ifindex);
276 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
277 tprintf(", addr(%d)={%d, ",
278 addrbuf.ll.sll_halen,
279 addrbuf.ll.sll_hatype);
280 for (i = 0; i < addrbuf.ll.sll_halen; i++)
281 tprintf("%02x", addrbuf.ll.sll_addr[i]);
285 #endif /* AF_PACKET */
288 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
290 #endif /* AF_NETLINK */
291 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
292 AF_X25 AF_ROSE etc. still need to be done */
296 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
297 sizeof addrbuf.sa.sa_data);
304 #include "xlat/scmvals.h"
307 printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len)
309 struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ?
311 if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) {
312 tprintf(", msg_control=%#lx", addr);
317 tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len);
318 printxval(socketlayers, cmsg->cmsg_level, "SOL_???");
319 tprints(", cmsg_type=");
321 if (cmsg->cmsg_level == SOL_SOCKET) {
322 unsigned long cmsg_len;
324 printxval(scmvals, cmsg->cmsg_type, "SCM_???");
325 cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len;
327 if (cmsg->cmsg_type == SCM_RIGHTS
328 && CMSG_LEN(sizeof(int)) <= cmsg_len) {
329 int *fds = (int *) CMSG_DATA(cmsg);
333 while ((char *) fds < ((char *) cmsg + cmsg_len)) {
336 printfd(tcp, *fds++);
343 if (cmsg->cmsg_type == SCM_CREDENTIALS
344 && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) {
345 struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg);
347 tprintf("{pid=%ld, uid=%ld, gid=%ld}}",
348 (long)uc->pid, (long)uc->uid, (long)uc->gid);
358 do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
360 tprintf("{msg_name(%d)=", msg->msg_namelen);
361 printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
363 tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
364 tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
365 (unsigned long)msg->msg_iov, 1, data_size);
367 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
368 tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
369 if (msg->msg_controllen)
370 printcmsghdr(tcp, (unsigned long) msg->msg_control,
371 msg->msg_controllen);
372 tprints(", msg_flags=");
373 printflags(msg_flags, msg->msg_flags, "MSG_???");
374 #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
375 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
376 (unsigned long) msg->msg_accrights, msg->msg_accrightslen);
377 #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
382 uint32_t /* void* */ msg_name;
383 uint32_t /* socklen_t */msg_namelen;
384 uint32_t /* iovec* */ msg_iov;
385 uint32_t /* size_t */ msg_iovlen;
386 uint32_t /* void* */ msg_control;
387 uint32_t /* size_t */ msg_controllen;
388 uint32_t /* int */ msg_flags;
391 struct msghdr32 msg_hdr;
392 uint32_t /* unsigned */ msg_len;
396 printmsghdr(struct tcb *tcp, long addr, unsigned long data_size)
400 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
401 if (current_wordsize == 4) {
402 struct msghdr32 msg32;
404 if (umove(tcp, addr, &msg32) < 0) {
405 tprintf("%#lx", addr);
408 msg.msg_name = (void*)(long)msg32.msg_name;
409 msg.msg_namelen = msg32.msg_namelen;
410 msg.msg_iov = (void*)(long)msg32.msg_iov;
411 msg.msg_iovlen = msg32.msg_iovlen;
412 msg.msg_control = (void*)(long)msg32.msg_control;
413 msg.msg_controllen = msg32.msg_controllen;
414 msg.msg_flags = msg32.msg_flags;
417 if (umove(tcp, addr, &msg) < 0) {
418 tprintf("%#lx", addr);
421 do_msghdr(tcp, &msg, data_size);
425 printmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
428 struct msghdr msg_hdr;
432 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
433 if (current_wordsize == 4) {
434 struct mmsghdr32 mmsg32;
436 addr += sizeof(mmsg32) * idx;
437 if (umove(tcp, addr, &mmsg32) < 0) {
438 tprintf("%#lx", addr);
441 mmsg.msg_hdr.msg_name = (void*)(long)mmsg32.msg_hdr.msg_name;
442 mmsg.msg_hdr.msg_namelen = mmsg32.msg_hdr.msg_namelen;
443 mmsg.msg_hdr.msg_iov = (void*)(long)mmsg32.msg_hdr.msg_iov;
444 mmsg.msg_hdr.msg_iovlen = mmsg32.msg_hdr.msg_iovlen;
445 mmsg.msg_hdr.msg_control = (void*)(long)mmsg32.msg_hdr.msg_control;
446 mmsg.msg_hdr.msg_controllen = mmsg32.msg_hdr.msg_controllen;
447 mmsg.msg_hdr.msg_flags = mmsg32.msg_hdr.msg_flags;
448 mmsg.msg_len = mmsg32.msg_len;
452 addr += sizeof(mmsg) * idx;
453 if (umove(tcp, addr, &mmsg) < 0) {
454 tprintf("%#lx", addr);
459 do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
460 tprintf(", %u}", mmsg.msg_len);
464 decode_mmsg(struct tcb *tcp, unsigned long msg_len)
468 tprintf("%#lx", tcp->u_arg[1]);
470 unsigned int len = tcp->u_rval;
474 for (i = 0; i < len; ++i) {
477 printmmsghdr(tcp, tcp->u_arg[1], i, msg_len);
482 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
484 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
487 #endif /* HAVE_SENDMSG */
490 * low bits of the socket type define real socket type,
491 * other bits are socket type flags.
494 tprint_sock_type(struct tcb *tcp, int flags)
496 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
500 flags &= ~SOCK_TYPE_MASK;
505 printflags(sock_type_flags, flags, "SOCK_???");
509 sys_socket(struct tcb *tcp)
512 printxval(domains, tcp->u_arg[0], "PF_???");
514 tprint_sock_type(tcp, tcp->u_arg[1]);
516 switch (tcp->u_arg[0]) {
521 printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
525 /* BTW: I don't believe this.. */
527 printxval(domains, tcp->u_arg[2], "PF_???");
533 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
537 tprintf("%lu", tcp->u_arg[2]);
545 sys_bind(struct tcb *tcp)
548 printfd(tcp, tcp->u_arg[0]);
550 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
551 tprintf(", %lu", tcp->u_arg[2]);
557 sys_connect(struct tcb *tcp)
559 return sys_bind(tcp);
563 sys_listen(struct tcb *tcp)
566 printfd(tcp, tcp->u_arg[0]);
568 tprintf("%lu", tcp->u_arg[1]);
574 do_accept(struct tcb *tcp, int flags_arg)
577 printfd(tcp, tcp->u_arg[0]);
582 tprintf("%#lx, NULL", tcp->u_arg[1]);
585 if (tcp->u_arg[1] == 0 || syserror(tcp)
586 || umove(tcp, tcp->u_arg[2], &len) < 0) {
587 tprintf("%#lx", tcp->u_arg[1]);
589 printsock(tcp, tcp->u_arg[1], len);
592 printnum_int(tcp, tcp->u_arg[2], "%u");
594 if (flags_arg >= 0) {
596 printflags(sock_type_flags, tcp->u_arg[flags_arg],
603 sys_accept(struct tcb *tcp)
605 return do_accept(tcp, -1);
609 sys_accept4(struct tcb *tcp)
611 return do_accept(tcp, 3);
615 sys_send(struct tcb *tcp)
618 printfd(tcp, tcp->u_arg[0]);
620 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
621 tprintf(", %lu, ", tcp->u_arg[2]);
623 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
629 sys_sendto(struct tcb *tcp)
632 printfd(tcp, tcp->u_arg[0]);
634 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
635 tprintf(", %lu, ", tcp->u_arg[2]);
637 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
640 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
642 tprintf(", %lu", tcp->u_arg[5]);
650 sys_sendmsg(struct tcb *tcp)
653 printfd(tcp, tcp->u_arg[0]);
655 printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
658 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
664 sys_sendmmsg(struct tcb *tcp)
668 printfd(tcp, tcp->u_arg[0]);
671 tprintf("%#lx, %u, ",
672 tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
673 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
677 decode_mmsg(tcp, (unsigned long) -1L);
682 #endif /* HAVE_SENDMSG */
685 sys_recv(struct tcb *tcp)
688 printfd(tcp, tcp->u_arg[0]);
692 tprintf("%#lx", tcp->u_arg[1]);
694 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
696 tprintf(", %lu, ", tcp->u_arg[2]);
697 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
703 sys_recvfrom(struct tcb *tcp)
708 printfd(tcp, tcp->u_arg[0]);
712 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
713 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
714 tcp->u_arg[4], tcp->u_arg[5]);
718 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
720 tprintf(", %lu, ", tcp->u_arg[2]);
722 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
723 /* from address, len */
724 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
725 if (tcp->u_arg[4] == 0)
728 tprintf(", %#lx", tcp->u_arg[4]);
729 if (tcp->u_arg[5] == 0)
732 tprintf(", %#lx", tcp->u_arg[5]);
735 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
736 tprints(", {...}, [?]");
740 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
742 tprintf(", [%u]", fromlen);
750 sys_recvmsg(struct tcb *tcp)
753 printfd(tcp, tcp->u_arg[0]);
756 if (syserror(tcp) || !verbose(tcp))
757 tprintf("%#lx", tcp->u_arg[1]);
759 printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval);
762 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
768 sys_recvmmsg(struct tcb *tcp)
770 /* +5 chars are for "left " prefix */
771 static char str[5 + TIMESPEC_TEXT_BUFSIZE];
774 printfd(tcp, tcp->u_arg[0]);
777 sprint_timespec(str, tcp, tcp->u_arg[4]);
778 /* Abusing tcp->auxstr as temp storage.
779 * Will be used and freed on syscall exit.
781 tcp->auxstr = strdup(str);
783 tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
784 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
786 print_timespec(tcp, tcp->u_arg[4]);
792 /* timeout on entrance */
793 tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
794 free((void *) tcp->auxstr);
799 if (tcp->u_rval == 0) {
800 tcp->auxstr = "Timeout";
805 /* timeout on exit */
806 sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
812 #endif /* HAVE_SENDMSG */
814 #include "xlat/shutdown_modes.h"
817 sys_shutdown(struct tcb *tcp)
820 printfd(tcp, tcp->u_arg[0]);
822 printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
828 sys_getsockname(struct tcb *tcp)
830 return sys_accept(tcp);
834 sys_getpeername(struct tcb *tcp)
836 return sys_accept(tcp);
840 do_pipe(struct tcb *tcp, int flags_arg)
844 tprintf("%#lx", tcp->u_arg[0]);
846 #if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
849 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
852 tprintf("[%u, %u]", fds[0], fds[1]);
853 #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64)
854 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
856 tprintf("%#lx", tcp->u_arg[0]);
859 if (flags_arg >= 0) {
861 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
868 sys_pipe(struct tcb *tcp)
870 return do_pipe(tcp, -1);
874 sys_pipe2(struct tcb *tcp)
876 return do_pipe(tcp, 1);
880 sys_socketpair(struct tcb *tcp)
885 printxval(domains, tcp->u_arg[0], "PF_???");
887 tprint_sock_type(tcp, tcp->u_arg[1]);
888 tprintf(", %lu", tcp->u_arg[2]);
891 tprintf(", %#lx", tcp->u_arg[3]);
894 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
897 tprintf(", [%u, %u]", fds[0], fds[1]);
903 sys_getsockopt(struct tcb *tcp)
906 printfd(tcp, tcp->u_arg[0]);
908 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
910 switch (tcp->u_arg[1]) {
912 printxval(sockoptions, tcp->u_arg[2], "SO_???");
916 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
921 printxval(sockipv6options, tcp->u_arg[2], "IPV6_???");
926 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
931 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
936 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
941 printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???");
945 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
946 * etc. still need work */
948 tprintf("%lu", tcp->u_arg[2]);
954 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
955 tprintf("%#lx, %#lx",
956 tcp->u_arg[3], tcp->u_arg[4]);
960 switch (tcp->u_arg[1]) {
962 switch (tcp->u_arg[2]) {
965 if (len == sizeof(struct linger)) {
966 struct linger linger;
971 tprintf("{onoff=%d, linger=%d}, "
982 if (len == sizeof(struct ucred)) {
988 tprintf("{pid=%ld, uid=%ld, gid=%ld}, "
1001 switch (tcp->u_arg[2]) {
1002 #ifdef PACKET_STATISTICS
1003 case PACKET_STATISTICS:
1004 if (len == sizeof(struct tpacket_stats)) {
1005 struct tpacket_stats stats;
1010 tprintf("{packets=%u, drops=%u}, "
1023 if (len == sizeof(int)) {
1024 printnum_int(tcp, tcp->u_arg[3], "%d");
1027 printstr(tcp, tcp->u_arg[3], len);
1029 tprintf(", [%d]", len);
1034 #if defined(ICMP_FILTER)
1035 static void printicmpfilter(struct tcb *tcp, long addr)
1037 struct icmp_filter filter;
1043 if (syserror(tcp) || !verbose(tcp)) {
1044 tprintf("%#lx", addr);
1047 if (umove(tcp, addr, &filter) < 0) {
1053 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
1056 #endif /* ICMP_FILTER */
1059 printsockopt(struct tcb *tcp, int level, int name, long addr, int len)
1061 printxval(socketlayers, level, "SOL_??");
1065 printxval(sockoptions, name, "SO_???");
1067 #if defined(SO_LINGER)
1069 if (len == sizeof(struct linger)) {
1070 struct linger linger;
1071 if (umove(tcp, addr, &linger) < 0)
1073 tprintf(", {onoff=%d, linger=%d}",
1084 printxval(sockipoptions, name, "IP_???");
1089 printxval(sockipv6options, name, "IPV6_???");
1094 printxval(sockipxoptions, name, "IPX_???");
1099 printxval(sockpacketoptions, name, "PACKET_???");
1100 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
1102 #ifdef PACKET_RX_RING
1103 case PACKET_RX_RING:
1105 #ifdef PACKET_TX_RING
1106 case PACKET_TX_RING:
1108 #if defined(PACKET_RX_RING) || defined(PACKET_TX_RING)
1109 if (len == sizeof(struct tpacket_req)) {
1110 struct tpacket_req req;
1111 if (umove(tcp, addr, &req) < 0)
1113 tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}",
1121 #endif /* PACKET_RX_RING || PACKET_TX_RING */
1127 printxval(socktcpoptions, name, "TCP_???");
1132 printxval(socksctpoptions, name, "SCTP_???");
1137 printxval(sockrawoptions, name, "RAW_???");
1139 #if defined(ICMP_FILTER)
1142 printicmpfilter(tcp, addr);
1149 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
1150 * etc. still need work */
1153 tprintf("%u", name);
1156 /* default arg printing */
1160 if (len == sizeof(int)) {
1161 printnum_int(tcp, addr, "%d");
1164 printstr(tcp, addr, len);
1170 sys_setsockopt(struct tcb *tcp)
1172 if (entering(tcp)) {
1173 printfd(tcp, tcp->u_arg[0]);
1175 printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1176 tcp->u_arg[3], tcp->u_arg[4]);
1177 tprintf(", %lu", tcp->u_arg[4]);