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 #include <netinet/in.h>
37 #ifdef HAVE_NETINET_TCP_H
38 # include <netinet/tcp.h>
40 #ifdef HAVE_NETINET_UDP_H
41 # include <netinet/udp.h>
43 #ifdef HAVE_NETINET_SCTP_H
44 # include <netinet/sctp.h>
46 #include <arpa/inet.h>
48 #include <asm/types.h>
49 #ifdef HAVE_NETIPX_IPX_H
50 # include <netipx/ipx.h>
52 # include <linux/ipx.h>
55 #if defined(HAVE_LINUX_IP_VS_H)
56 # include <linux/ip_vs.h>
58 #include <linux/netlink.h>
59 #if defined(HAVE_LINUX_NETFILTER_ARP_ARP_TABLES_H)
60 # include <linux/netfilter_arp/arp_tables.h>
62 #if defined(HAVE_LINUX_NETFILTER_BRIDGE_EBTABLES_H)
63 # include <linux/netfilter_bridge/ebtables.h>
65 #if defined(HAVE_LINUX_NETFILTER_IPV4_IP_TABLES_H)
66 # include <linux/netfilter_ipv4/ip_tables.h>
68 #if defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H)
69 # include <linux/netfilter_ipv6/ip6_tables.h>
71 #include <linux/if_packet.h>
72 #include <linux/icmp.h>
74 #include "xlat/socktypes.h"
75 #include "xlat/sock_type_flags.h"
76 #ifndef SOCK_TYPE_MASK
77 # define SOCK_TYPE_MASK 0xf
80 #include "xlat/socketlayers.h"
82 #include "xlat/inet_protocols.h"
84 #if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG
85 # define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
87 #include "xlat/netlink_protocols.h"
89 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
90 # include <bluetooth/bluetooth.h>
91 # include "xlat/bt_protocols.h"
94 #include "xlat/msg_flags.h"
97 print_ifindex(unsigned int ifindex)
99 #ifdef HAVE_IF_INDEXTONAME
100 char buf[IFNAMSIZ + 1];
102 if (if_indextoname(ifindex, buf)) {
103 tprints("if_nametoindex(");
104 print_quoted_string(buf, sizeof(buf), QUOTE_0_TERMINATED);
109 tprintf("%u", ifindex);
112 #include "xlat/scmvals.h"
113 #include "xlat/ip_cmsg_types.h"
115 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
125 struct cmsghdr *cmsg;
126 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
127 struct cmsghdr32 *cmsg32;
132 print_scm_rights(struct tcb *tcp, const void *cmsg_data,
133 const size_t data_len)
135 const int *fds = cmsg_data;
136 const char *end = (const char *) cmsg_data + data_len;
139 if (sizeof(*fds) > data_len)
143 while ((const char *) fds < end) {
148 printfd(tcp, *fds++);
154 print_scm_creds(struct tcb *tcp, const void *cmsg_data,
155 const size_t data_len)
157 const struct ucred *uc = cmsg_data;
159 if (sizeof(*uc) > data_len)
162 tprintf(", {pid=%u, uid=%u, gid=%u}",
163 (unsigned) uc->pid, (unsigned) uc->uid, (unsigned) uc->gid);
167 print_scm_security(struct tcb *tcp, const void *cmsg_data,
168 const size_t data_len)
174 print_quoted_string(cmsg_data, data_len, 0);
178 print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data,
179 const size_t data_len)
181 const struct in_pktinfo *info = cmsg_data;
183 if (sizeof(*info) > data_len)
186 tprints(", {ipi_ifindex=");
187 print_ifindex(info->ipi_ifindex);
188 tprintf(", ipi_spec_dst=inet_addr(\"%s\"), ipi_addr=inet_addr(\"%s\")}",
189 inet_ntoa(info->ipi_spec_dst), inet_ntoa(info->ipi_addr));
193 print_cmsg_ip_ttl(struct tcb *tcp, const void *cmsg_data,
194 const size_t data_len)
196 const unsigned int *ttl = cmsg_data;
198 if (sizeof(*ttl) > data_len)
201 tprintf(", {ttl=%u}", *ttl);
205 print_cmsg_ip_tos(struct tcb *tcp, const void *cmsg_data,
206 const size_t data_len)
208 const uint8_t *tos = cmsg_data;
210 if (sizeof(*tos) > data_len)
213 tprintf(", {tos=%x}", *tos);
217 print_cmsg_ip_checksum(struct tcb *tcp, const void *cmsg_data,
218 const size_t data_len)
220 const uint32_t *csum = cmsg_data;
222 if (sizeof(*csum) > data_len)
225 tprintf(", {csum=%u}", *csum);
229 print_cmsg_ip_opts(struct tcb *tcp, const void *cmsg_data,
230 const size_t data_len)
232 const unsigned char *opts = cmsg_data;
238 tprints(", {opts=0x");
239 for (i = 0; i < data_len; ++i)
240 tprintf("%02x", opts[i]);
245 print_cmsg_ip_recverr(struct tcb *tcp, const void *cmsg_data,
246 const size_t data_len)
256 struct sockaddr_in offender;
259 if (sizeof(*err) > data_len)
262 tprintf(", {ee_errno=%u, ee_origin=%u, ee_type=%u, ee_code=%u"
263 ", ee_info=%u, ee_data=%u, offender=",
264 err->ee_errno, err->ee_origin, err->ee_type,
265 err->ee_code, err->ee_info, err->ee_data);
266 print_sockaddr(tcp, &err->offender, sizeof(err->offender));
271 print_cmsg_ip_origdstaddr(struct tcb *tcp, const void *cmsg_data,
272 const size_t data_len)
274 if (sizeof(struct sockaddr_in) > data_len)
278 print_sockaddr(tcp, cmsg_data, data_len);
282 print_cmsg_type_data(struct tcb *tcp, const int cmsg_level, const int cmsg_type,
283 const void *cmsg_data, const size_t data_len)
285 switch (cmsg_level) {
287 printxval(scmvals, cmsg_type, "SCM_???");
290 print_scm_rights(tcp, cmsg_data, data_len);
292 case SCM_CREDENTIALS:
293 print_scm_creds(tcp, cmsg_data, data_len);
296 print_scm_security(tcp, cmsg_data, data_len);
301 printxval(ip_cmsg_types, cmsg_type, "IP_???");
304 print_cmsg_ip_pktinfo(tcp, cmsg_data, data_len);
307 print_cmsg_ip_ttl(tcp, cmsg_data, data_len);
310 print_cmsg_ip_tos(tcp, cmsg_data, data_len);
314 print_cmsg_ip_opts(tcp, cmsg_data, data_len);
317 print_cmsg_ip_recverr(tcp, cmsg_data, data_len);
320 print_cmsg_ip_origdstaddr(tcp, cmsg_data, data_len);
323 print_cmsg_ip_checksum(tcp, cmsg_data, data_len);
326 print_scm_security(tcp, cmsg_data, data_len);
331 tprintf("%u", cmsg_type);
336 decode_msg_control(struct tcb *tcp, unsigned long addr, size_t len)
338 const size_t cmsg_size =
339 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
340 (current_wordsize < sizeof(long)) ? sizeof(struct cmsghdr32) :
342 sizeof(struct cmsghdr);
346 tprints(", msg_control=");
348 char *buf = len < cmsg_size ? NULL : malloc(len);
349 if (!buf || umoven(tcp, addr, len, buf) < 0) {
355 union_cmsghdr u = { .ptr = buf };
358 while (len >= cmsg_size) {
360 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
361 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_len :
365 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
366 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_level :
370 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
371 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_type :
377 tprintf("{cmsg_len=%lu, cmsg_level=", (unsigned long) cmsg_len);
378 printxval(socketlayers, cmsg_level, "SOL_???");
379 tprints(", cmsg_type=");
384 print_cmsg_type_data(tcp, cmsg_level, cmsg_type,
385 (const void *) (u.ptr + cmsg_size),
386 cmsg_len > cmsg_size ? cmsg_len - cmsg_size: 0);
389 if (cmsg_len < cmsg_size) {
393 cmsg_len = (cmsg_len + current_wordsize - 1) &
394 (size_t) ~(current_wordsize - 1);
395 if (cmsg_len >= len) {
409 print_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
411 tprintf("{msg_name(%d)=", msg->msg_namelen);
412 decode_sockaddr(tcp, (long)msg->msg_name, msg->msg_namelen);
414 tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
416 tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
417 (unsigned long)msg->msg_iov, IOV_DECODE_STR, data_size);
419 decode_msg_control(tcp, (unsigned long) msg->msg_control,
420 msg->msg_controllen);
421 tprintf(", msg_controllen=%lu", (unsigned long) msg->msg_controllen);
423 tprints(", msg_flags=");
424 printflags(msg_flags, msg->msg_flags, "MSG_???");
429 uint32_t /* void* */ msg_name;
430 uint32_t /* socklen_t */msg_namelen;
431 uint32_t /* iovec* */ msg_iov;
432 uint32_t /* size_t */ msg_iovlen;
433 uint32_t /* void* */ msg_control;
434 uint32_t /* size_t */ msg_controllen;
435 uint32_t /* int */ msg_flags;
438 struct msghdr32 msg_hdr;
439 uint32_t /* unsigned */ msg_len;
442 #ifndef HAVE_STRUCT_MMSGHDR
444 struct msghdr msg_hdr;
449 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
451 copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32)
453 to_msg->msg_name = (void*)(long)from_msg32->msg_name;
454 to_msg->msg_namelen = from_msg32->msg_namelen;
455 to_msg->msg_iov = (void*)(long)from_msg32->msg_iov;
456 to_msg->msg_iovlen = from_msg32->msg_iovlen;
457 to_msg->msg_control = (void*)(long)from_msg32->msg_control;
458 to_msg->msg_controllen = from_msg32->msg_controllen;
459 to_msg->msg_flags = from_msg32->msg_flags;
464 fetch_msghdr(struct tcb *tcp, long addr, struct msghdr *msg)
466 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
467 if (current_wordsize == 4) {
468 struct msghdr32 msg32;
470 if (umove(tcp, addr, &msg32) < 0)
472 copy_from_msghdr32(msg, &msg32);
475 if (umove(tcp, addr, msg) < 0)
481 fetch_mmsghdr(struct tcb *tcp, long addr, unsigned int idx, struct mmsghdr *mmsg)
483 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
484 if (current_wordsize == 4) {
485 struct mmsghdr32 mmsg32;
487 addr += sizeof(struct mmsghdr32) * idx;
488 if (umove(tcp, addr, &mmsg32) < 0)
491 copy_from_msghdr32(&mmsg->msg_hdr, &mmsg32.msg_hdr);
492 mmsg->msg_len = mmsg32.msg_len;
496 addr += sizeof(*mmsg) * idx;
497 if (umove(tcp, addr, mmsg) < 0)
504 decode_msghdr(struct tcb *tcp, long addr, unsigned long data_size)
508 if (verbose(tcp) && fetch_msghdr(tcp, addr, &msg))
509 print_msghdr(tcp, &msg, data_size);
515 dumpiov_in_msghdr(struct tcb *tcp, long addr, unsigned long data_size)
519 if (fetch_msghdr(tcp, addr, &msg))
520 dumpiov_upto(tcp, msg.msg_iovlen, (long)msg.msg_iov, data_size);
524 decode_mmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
528 if (fetch_mmsghdr(tcp, addr, idx, &mmsg)) {
530 print_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
531 tprintf(", %u}", mmsg.msg_len);
538 decode_mmsg(struct tcb *tcp, unsigned long msg_len)
542 printaddr(tcp->u_arg[1]);
544 unsigned int len = tcp->u_rval;
548 for (i = 0; i < len; ++i) {
551 decode_mmsghdr(tcp, tcp->u_arg[1], i, msg_len);
556 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
558 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
562 dumpiov_in_mmsghdr(struct tcb *tcp, long addr)
564 unsigned int len = tcp->u_rval;
568 for (i = 0; i < len; ++i) {
569 if (fetch_mmsghdr(tcp, addr, i, &mmsg)) {
570 tprintf(" = %lu buffers in vector %u\n",
571 (unsigned long)mmsg.msg_hdr.msg_iovlen, i);
572 dumpiov_upto(tcp, mmsg.msg_hdr.msg_iovlen,
573 (long)mmsg.msg_hdr.msg_iov, mmsg.msg_len);
579 * low bits of the socket type define real socket type,
580 * other bits are socket type flags.
583 tprint_sock_type(unsigned int flags)
585 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
589 flags &= ~SOCK_TYPE_MASK;
594 printflags(sock_type_flags, flags, "SOCK_???");
599 printxval(addrfams, tcp->u_arg[0], "AF_???");
601 tprint_sock_type(tcp->u_arg[1]);
603 switch (tcp->u_arg[0]) {
606 printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
610 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
613 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
615 printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
620 tprintf("%lu", tcp->u_arg[2]);
624 return RVAL_DECODED | RVAL_FD;
629 printfd(tcp, tcp->u_arg[0]);
631 decode_sockaddr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
632 tprintf(", %lu", tcp->u_arg[2]);
639 printfd(tcp, tcp->u_arg[0]);
641 tprintf("%lu", tcp->u_arg[1]);
647 do_sockname(struct tcb *tcp, int flags_arg)
650 printfd(tcp, tcp->u_arg[0]);
656 if (!tcp->u_arg[2] || !verbose(tcp) || syserror(tcp) ||
657 umove(tcp, tcp->u_arg[2], &len) < 0) {
658 printaddr(tcp->u_arg[1]);
660 printaddr(tcp->u_arg[2]);
662 decode_sockaddr(tcp, tcp->u_arg[1], len);
663 tprintf(", [%d]", len);
666 if (flags_arg >= 0) {
668 printflags(sock_type_flags, tcp->u_arg[flags_arg],
676 do_sockname(tcp, -1);
688 printfd(tcp, tcp->u_arg[0]);
690 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
691 tprintf(", %lu, ", tcp->u_arg[2]);
693 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
700 printfd(tcp, tcp->u_arg[0]);
702 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
703 tprintf(", %lu, ", tcp->u_arg[2]);
705 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
708 decode_sockaddr(tcp, tcp->u_arg[4], tcp->u_arg[5]);
710 tprintf(", %lu", tcp->u_arg[5]);
717 printfd(tcp, tcp->u_arg[0]);
719 decode_msghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
722 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
731 printfd(tcp, tcp->u_arg[0]);
734 printaddr(tcp->u_arg[1]);
735 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
736 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
740 decode_mmsg(tcp, (unsigned long) -1L);
748 printfd(tcp, tcp->u_arg[0]);
752 printaddr(tcp->u_arg[1]);
754 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
756 tprintf(", %lu, ", tcp->u_arg[2]);
757 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
767 printfd(tcp, tcp->u_arg[0]);
772 printaddr(tcp->u_arg[1]);
774 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
777 tprintf(", %lu, ", tcp->u_arg[2]);
779 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
781 if (syserror(tcp) || !tcp->u_arg[4] || !tcp->u_arg[5] ||
782 umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
783 /* from address, len */
784 printaddr(tcp->u_arg[4]);
786 printaddr(tcp->u_arg[5]);
790 decode_sockaddr(tcp, tcp->u_arg[4], fromlen);
792 tprintf(", [%u]", fromlen);
800 printfd(tcp, tcp->u_arg[0]);
804 printaddr(tcp->u_arg[1]);
806 decode_msghdr(tcp, tcp->u_arg[1], tcp->u_rval);
809 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
816 static char str[sizeof("left") + TIMESPEC_TEXT_BUFSIZE];
819 printfd(tcp, tcp->u_arg[0]);
822 /* Abusing tcp->auxstr as temp storage.
823 * Will be used and cleared on syscall exit.
825 tcp->auxstr = sprint_timespec(tcp, tcp->u_arg[4]);
827 printaddr(tcp->u_arg[1]);
828 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
829 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
831 print_timespec(tcp, tcp->u_arg[4]);
838 /* timeout on entrance */
839 tprints(tcp->auxstr);
844 if (tcp->u_rval == 0) {
845 tcp->auxstr = "Timeout";
850 /* timeout on exit */
851 snprintf(str, sizeof(str), "left %s",
852 sprint_timespec(tcp, tcp->u_arg[4]));
858 #include "xlat/shutdown_modes.h"
862 printfd(tcp, tcp->u_arg[0]);
864 printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
869 SYS_FUNC(getsockname)
871 return do_sockname(tcp, -1);
875 printpair_fd(struct tcb *tcp, const int i0, const int i1)
885 decode_pair_fd(struct tcb *tcp, const long addr)
889 if (umove_or_printaddr(tcp, addr, &pair))
892 printpair_fd(tcp, pair[0], pair[1]);
896 do_pipe(struct tcb *tcp, int flags_arg)
899 decode_pair_fd(tcp, tcp->u_arg[0]);
900 if (flags_arg >= 0) {
902 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
911 if (exiting(tcp) && !syserror(tcp))
912 printpair_fd(tcp, tcp->u_rval, getrval2(tcp));
915 return do_pipe(tcp, -1);
921 return do_pipe(tcp, 1);
927 printxval(addrfams, tcp->u_arg[0], "AF_???");
929 tprint_sock_type(tcp->u_arg[1]);
930 tprintf(", %lu", tcp->u_arg[2]);
933 decode_pair_fd(tcp, tcp->u_arg[3]);
938 #include "xlat/sockoptions.h"
939 #include "xlat/sockipoptions.h"
940 #include "xlat/getsockipoptions.h"
941 #include "xlat/setsockipoptions.h"
942 #include "xlat/sockipv6options.h"
943 #include "xlat/getsockipv6options.h"
944 #include "xlat/setsockipv6options.h"
945 #include "xlat/sockipxoptions.h"
946 #include "xlat/sockrawoptions.h"
947 #include "xlat/sockpacketoptions.h"
948 #include "xlat/socksctpoptions.h"
949 #include "xlat/socktcpoptions.h"
952 print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level,
953 unsigned int name, bool is_getsockopt)
957 printxval(socketlayers, level, "SOL_??");
962 printxval(sockoptions, name, "SO_???");
965 printxvals(name, "IP_???", sockipoptions,
966 is_getsockopt ? getsockipoptions : setsockipoptions, NULL);
969 printxvals(name, "IPV6_???", sockipv6options,
970 is_getsockopt ? getsockipv6options : setsockipv6options, NULL);
973 printxval(sockipxoptions, name, "IPX_???");
976 printxval(sockpacketoptions, name, "PACKET_???");
979 printxval(socktcpoptions, name, "TCP_???");
982 printxval(socksctpoptions, name, "SCTP_???");
985 printxval(sockrawoptions, name, "RAW_???");
988 /* Other SOL_* protocol levels still need work. */
998 print_linger(struct tcb *tcp, long addr, int len)
1000 struct linger linger;
1002 if (len != sizeof(linger) ||
1003 umove(tcp, addr, &linger) < 0) {
1008 tprintf("{onoff=%d, linger=%d}",
1015 print_ucred(struct tcb *tcp, long addr, int len)
1019 if (len != sizeof(uc) ||
1020 umove(tcp, addr, &uc) < 0) {
1023 tprintf("{pid=%u, uid=%u, gid=%u}",
1029 #endif /* SO_PEERCRED */
1031 #ifdef PACKET_STATISTICS
1033 print_tpacket_stats(struct tcb *tcp, long addr, int len)
1035 struct tpacket_stats stats;
1037 if (len != sizeof(stats) ||
1038 umove(tcp, addr, &stats) < 0) {
1041 tprintf("{packets=%u, drops=%u}",
1046 #endif /* PACKET_STATISTICS */
1048 #include "xlat/icmpfilterflags.h"
1051 print_icmp_filter(struct tcb *tcp, const long addr, int len)
1053 struct icmp_filter filter = {};
1055 if (len > (int) sizeof(filter))
1056 len = sizeof(filter);
1057 else if (len <= 0) {
1062 if (umoven_or_printaddr(tcp, addr, len, &filter))
1066 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
1071 print_getsockopt(struct tcb *tcp, unsigned int level, unsigned int name,
1074 if (addr && verbose(tcp))
1079 print_linger(tcp, addr, len);
1083 print_ucred(tcp, addr, len);
1091 #ifdef PACKET_STATISTICS
1092 case PACKET_STATISTICS:
1093 print_tpacket_stats(tcp, addr, len);
1102 print_icmp_filter(tcp, addr, len);
1108 /* default arg printing */
1111 if (len == sizeof(int)) {
1112 printnum_int(tcp, addr, "%d");
1114 printstr(tcp, addr, len);
1120 tprintf(", [%d]", len);
1123 SYS_FUNC(getsockopt)
1125 if (entering(tcp)) {
1126 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1127 tcp->u_arg[1], tcp->u_arg[2], true);
1131 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
1132 printaddr(tcp->u_arg[3]);
1134 printaddr(tcp->u_arg[4]);
1136 print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1137 tcp->u_arg[3], len);
1143 #ifdef IP_ADD_MEMBERSHIP
1145 print_mreq(struct tcb *tcp, long addr, unsigned int len)
1147 struct ip_mreq mreq;
1149 if (len < sizeof(mreq)) {
1150 printstr(tcp, addr, len);
1153 if (umove_or_printaddr(tcp, addr, &mreq))
1156 tprints("{imr_multiaddr=inet_addr(");
1157 print_quoted_string(inet_ntoa(mreq.imr_multiaddr),
1158 16, QUOTE_0_TERMINATED);
1159 tprints("), imr_interface=inet_addr(");
1160 print_quoted_string(inet_ntoa(mreq.imr_interface),
1161 16, QUOTE_0_TERMINATED);
1164 #endif /* IP_ADD_MEMBERSHIP */
1166 #ifdef IPV6_ADD_MEMBERSHIP
1168 print_mreq6(struct tcb *tcp, long addr, unsigned int len)
1170 struct ipv6_mreq mreq;
1172 if (len < sizeof(mreq))
1175 if (umove_or_printaddr(tcp, addr, &mreq))
1178 const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr;
1179 char address[INET6_ADDRSTRLEN];
1181 if (!inet_ntop(AF_INET6, in6, address, sizeof(address)))
1184 tprints("{ipv6mr_multiaddr=inet_pton(");
1185 print_quoted_string(address, sizeof(address), QUOTE_0_TERMINATED);
1186 tprints("), ipv6mr_interface=");
1187 print_ifindex(mreq.ipv6mr_interface);
1192 printstr(tcp, addr, len);
1194 #endif /* IPV6_ADD_MEMBERSHIP */
1196 #ifdef MCAST_JOIN_GROUP
1198 print_group_req(struct tcb *tcp, long addr, int len)
1200 struct group_req greq;
1202 if (len != sizeof(greq) ||
1203 umove(tcp, addr, &greq) < 0) {
1208 tprintf("{gr_interface=%u, gr_group=", greq.gr_interface);
1209 print_sockaddr(tcp, &greq.gr_group, sizeof(greq.gr_group));
1213 #endif /* MCAST_JOIN_GROUP */
1215 #ifdef PACKET_RX_RING
1217 print_tpacket_req(struct tcb *tcp, long addr, int len)
1219 struct tpacket_req req;
1221 if (len != sizeof(req) ||
1222 umove(tcp, addr, &req) < 0) {
1225 tprintf("{block_size=%u, block_nr=%u, "
1226 "frame_size=%u, frame_nr=%u}",
1233 #endif /* PACKET_RX_RING */
1235 #ifdef PACKET_ADD_MEMBERSHIP
1236 # include "xlat/packet_mreq_type.h"
1239 print_packet_mreq(struct tcb *tcp, long addr, int len)
1241 struct packet_mreq mreq;
1243 if (len != sizeof(mreq) ||
1244 umove(tcp, addr, &mreq) < 0) {
1249 tprintf("{mr_ifindex=%u, mr_type=", mreq.mr_ifindex);
1250 printxval(packet_mreq_type, mreq.mr_type, "PACKET_MR_???");
1251 tprintf(", mr_alen=%u, mr_address=", mreq.mr_alen);
1252 if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address))
1253 mreq.mr_alen = ARRAY_SIZE(mreq.mr_address);
1254 for (i = 0; i < mreq.mr_alen; ++i)
1255 tprintf("%02x", mreq.mr_address[i]);
1259 #endif /* PACKET_ADD_MEMBERSHIP */
1262 print_setsockopt(struct tcb *tcp, unsigned int level, unsigned int name,
1265 if (addr && verbose(tcp))
1270 print_linger(tcp, addr, len);
1277 #ifdef IP_ADD_MEMBERSHIP
1278 case IP_ADD_MEMBERSHIP:
1279 case IP_DROP_MEMBERSHIP:
1280 print_mreq(tcp, addr, len);
1282 #endif /* IP_ADD_MEMBERSHIP */
1283 #ifdef MCAST_JOIN_GROUP
1284 case MCAST_JOIN_GROUP:
1285 case MCAST_LEAVE_GROUP:
1286 print_group_req(tcp, addr, len);
1288 #endif /* MCAST_JOIN_GROUP */
1294 #ifdef IPV6_ADD_MEMBERSHIP
1295 case IPV6_ADD_MEMBERSHIP:
1296 case IPV6_DROP_MEMBERSHIP:
1297 # ifdef IPV6_JOIN_ANYCAST
1298 case IPV6_JOIN_ANYCAST:
1300 # ifdef IPV6_LEAVE_ANYCAST
1301 case IPV6_LEAVE_ANYCAST:
1303 print_mreq6(tcp, addr, len);
1305 #endif /* IPV6_ADD_MEMBERSHIP */
1311 #ifdef PACKET_RX_RING
1312 case PACKET_RX_RING:
1313 # ifdef PACKET_TX_RING
1314 case PACKET_TX_RING:
1316 print_tpacket_req(tcp, addr, len);
1318 #endif /* PACKET_RX_RING */
1319 #ifdef PACKET_ADD_MEMBERSHIP
1320 case PACKET_ADD_MEMBERSHIP:
1321 case PACKET_DROP_MEMBERSHIP:
1322 print_packet_mreq(tcp, addr, len);
1324 #endif /* PACKET_ADD_MEMBERSHIP */
1331 print_icmp_filter(tcp, addr, len);
1337 /* default arg printing */
1340 if (len == sizeof(int)) {
1341 printnum_int(tcp, addr, "%d");
1343 printstr(tcp, addr, len);
1349 tprintf(", %d", len);
1352 SYS_FUNC(setsockopt)
1354 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1355 tcp->u_arg[1], tcp->u_arg[2], false);
1356 print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1357 tcp->u_arg[3], tcp->u_arg[4]);
1359 return RVAL_DECODED;