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.
34 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #ifdef HAVE_NETINET_TCP_H
39 # include <netinet/tcp.h>
41 #ifdef HAVE_NETINET_UDP_H
42 # include <netinet/udp.h>
44 #ifdef HAVE_NETINET_SCTP_H
45 # include <netinet/sctp.h>
47 #include <arpa/inet.h>
49 #include <asm/types.h>
50 #ifdef HAVE_NETIPX_IPX_H
51 # include <netipx/ipx.h>
53 # include <linux/ipx.h>
56 #if defined(HAVE_LINUX_IP_VS_H)
57 # include <linux/ip_vs.h>
59 #include <linux/netlink.h>
60 #if defined(HAVE_LINUX_NETFILTER_ARP_ARP_TABLES_H)
61 # include <linux/netfilter_arp/arp_tables.h>
63 #if defined(HAVE_LINUX_NETFILTER_BRIDGE_EBTABLES_H)
64 # include <linux/netfilter_bridge/ebtables.h>
66 #if defined(HAVE_LINUX_NETFILTER_IPV4_IP_TABLES_H)
67 # include <linux/netfilter_ipv4/ip_tables.h>
69 #if defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H)
70 # include <linux/netfilter_ipv6/ip6_tables.h>
72 #include <linux/if_packet.h>
73 #include <linux/icmp.h>
75 #include "xlat/socktypes.h"
76 #include "xlat/sock_type_flags.h"
77 #ifndef SOCK_TYPE_MASK
78 # define SOCK_TYPE_MASK 0xf
81 #include "xlat/socketlayers.h"
83 #include "xlat/inet_protocols.h"
85 #if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG
86 # define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
88 #include "xlat/netlink_protocols.h"
90 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
91 # include <bluetooth/bluetooth.h>
92 # include "xlat/bt_protocols.h"
95 #include "xlat/msg_flags.h"
98 print_ifindex(unsigned int ifindex)
100 #ifdef HAVE_IF_INDEXTONAME
101 char buf[IFNAMSIZ + 1];
103 if (if_indextoname(ifindex, buf)) {
104 tprints("if_nametoindex(");
105 print_quoted_string(buf, sizeof(buf), QUOTE_0_TERMINATED);
110 tprintf("%u", ifindex);
113 #include "xlat/scmvals.h"
114 #include "xlat/ip_cmsg_types.h"
116 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
126 struct cmsghdr *cmsg;
127 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
128 struct cmsghdr32 *cmsg32;
133 print_scm_rights(struct tcb *tcp, const void *cmsg_data,
134 const size_t data_len)
136 const int *fds = cmsg_data;
137 const char *end = (const char *) cmsg_data + data_len;
140 if (sizeof(*fds) > data_len)
144 while ((const char *) fds < end) {
149 printfd(tcp, *fds++);
155 print_scm_creds(struct tcb *tcp, const void *cmsg_data,
156 const size_t data_len)
158 const struct ucred *uc = cmsg_data;
160 if (sizeof(*uc) > data_len)
163 tprintf(", {pid=%u, uid=%u, gid=%u}",
164 (unsigned) uc->pid, (unsigned) uc->uid, (unsigned) uc->gid);
168 print_scm_security(struct tcb *tcp, const void *cmsg_data,
169 const size_t data_len)
175 print_quoted_string(cmsg_data, data_len, 0);
179 print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data,
180 const size_t data_len)
182 const struct in_pktinfo *info = cmsg_data;
184 if (sizeof(*info) > data_len)
187 tprints(", {ipi_ifindex=");
188 print_ifindex(info->ipi_ifindex);
189 tprintf(", ipi_spec_dst=inet_addr(\"%s\"), ipi_addr=inet_addr(\"%s\")}",
190 inet_ntoa(info->ipi_spec_dst), inet_ntoa(info->ipi_addr));
194 print_cmsg_ip_ttl(struct tcb *tcp, const void *cmsg_data,
195 const size_t data_len)
197 const unsigned int *ttl = cmsg_data;
199 if (sizeof(*ttl) > data_len)
202 tprintf(", {ttl=%u}", *ttl);
206 print_cmsg_ip_tos(struct tcb *tcp, const void *cmsg_data,
207 const size_t data_len)
209 const uint8_t *tos = cmsg_data;
211 if (sizeof(*tos) > data_len)
214 tprintf(", {tos=%x}", *tos);
218 print_cmsg_ip_checksum(struct tcb *tcp, const void *cmsg_data,
219 const size_t data_len)
221 const uint32_t *csum = cmsg_data;
223 if (sizeof(*csum) > data_len)
226 tprintf(", {csum=%u}", *csum);
230 print_cmsg_ip_opts(struct tcb *tcp, const void *cmsg_data,
231 const size_t data_len)
233 const unsigned char *opts = cmsg_data;
239 tprints(", {opts=0x");
240 for (i = 0; i < data_len; ++i)
241 tprintf("%02x", opts[i]);
246 print_cmsg_ip_recverr(struct tcb *tcp, const void *cmsg_data,
247 const size_t data_len)
257 struct sockaddr_in offender;
260 if (sizeof(*err) > data_len)
263 tprintf(", {ee_errno=%u, ee_origin=%u, ee_type=%u, ee_code=%u"
264 ", ee_info=%u, ee_data=%u, offender=",
265 err->ee_errno, err->ee_origin, err->ee_type,
266 err->ee_code, err->ee_info, err->ee_data);
267 print_sockaddr(tcp, &err->offender, sizeof(err->offender));
272 print_cmsg_ip_origdstaddr(struct tcb *tcp, const void *cmsg_data,
273 const size_t data_len)
275 if (sizeof(struct sockaddr_in) > data_len)
279 print_sockaddr(tcp, cmsg_data, data_len);
283 print_cmsg_type_data(struct tcb *tcp, const int cmsg_level, const int cmsg_type,
284 const void *cmsg_data, const size_t data_len)
286 switch (cmsg_level) {
288 printxval(scmvals, cmsg_type, "SCM_???");
291 print_scm_rights(tcp, cmsg_data, data_len);
293 case SCM_CREDENTIALS:
294 print_scm_creds(tcp, cmsg_data, data_len);
297 print_scm_security(tcp, cmsg_data, data_len);
302 printxval(ip_cmsg_types, cmsg_type, "IP_???");
305 print_cmsg_ip_pktinfo(tcp, cmsg_data, data_len);
308 print_cmsg_ip_ttl(tcp, cmsg_data, data_len);
311 print_cmsg_ip_tos(tcp, cmsg_data, data_len);
315 print_cmsg_ip_opts(tcp, cmsg_data, data_len);
318 print_cmsg_ip_recverr(tcp, cmsg_data, data_len);
321 print_cmsg_ip_origdstaddr(tcp, cmsg_data, data_len);
324 print_cmsg_ip_checksum(tcp, cmsg_data, data_len);
327 print_scm_security(tcp, cmsg_data, data_len);
332 tprintf("%u", cmsg_type);
337 decode_msg_control(struct tcb *tcp, unsigned long addr, size_t len)
339 const size_t cmsg_size =
340 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
341 (current_wordsize < sizeof(long)) ? sizeof(struct cmsghdr32) :
343 sizeof(struct cmsghdr);
347 tprints(", msg_control=");
349 char *buf = len < cmsg_size ? NULL : malloc(len);
350 if (!buf || umoven(tcp, addr, len, buf) < 0) {
356 union_cmsghdr u = { .ptr = buf };
359 while (len >= cmsg_size) {
361 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
362 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_len :
366 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
367 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_level :
371 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
372 (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_type :
378 tprintf("{cmsg_len=%lu, cmsg_level=", (unsigned long) cmsg_len);
379 printxval(socketlayers, cmsg_level, "SOL_???");
380 tprints(", cmsg_type=");
385 print_cmsg_type_data(tcp, cmsg_level, cmsg_type,
386 (const void *) (u.ptr + cmsg_size),
387 cmsg_len > cmsg_size ? cmsg_len - cmsg_size: 0);
390 if (cmsg_len < cmsg_size) {
394 cmsg_len = (cmsg_len + current_wordsize - 1) &
395 (size_t) ~(current_wordsize - 1);
396 if (cmsg_len >= len) {
410 print_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
412 tprints("{msg_name=");
413 decode_sockaddr(tcp, (long)msg->msg_name, msg->msg_namelen);
414 tprintf(", msg_namelen=%d", msg->msg_namelen);
416 tprints(", msg_iov=");
417 tprint_iov_upto(tcp, (unsigned long) msg->msg_iovlen,
418 (unsigned long) msg->msg_iov, IOV_DECODE_STR, data_size);
419 tprintf(", msg_iovlen=%lu", (unsigned long) msg->msg_iovlen);
421 decode_msg_control(tcp, (unsigned long) msg->msg_control,
422 msg->msg_controllen);
423 tprintf(", msg_controllen=%lu", (unsigned long) msg->msg_controllen);
425 tprints(", msg_flags=");
426 printflags(msg_flags, msg->msg_flags, "MSG_???");
431 uint32_t /* void* */ msg_name;
432 uint32_t /* socklen_t */msg_namelen;
433 uint32_t /* iovec* */ msg_iov;
434 uint32_t /* size_t */ msg_iovlen;
435 uint32_t /* void* */ msg_control;
436 uint32_t /* size_t */ msg_controllen;
437 uint32_t /* int */ msg_flags;
440 struct msghdr32 msg_hdr;
441 uint32_t /* unsigned */ msg_len;
444 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
446 copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32)
448 to_msg->msg_name = (void*)(long)from_msg32->msg_name;
449 to_msg->msg_namelen = from_msg32->msg_namelen;
450 to_msg->msg_iov = (void*)(long)from_msg32->msg_iov;
451 to_msg->msg_iovlen = from_msg32->msg_iovlen;
452 to_msg->msg_control = (void*)(long)from_msg32->msg_control;
453 to_msg->msg_controllen = from_msg32->msg_controllen;
454 to_msg->msg_flags = from_msg32->msg_flags;
459 fetch_msghdr(struct tcb *tcp, long addr, struct msghdr *msg)
461 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
462 if (current_wordsize == 4) {
463 struct msghdr32 msg32;
465 if (umove(tcp, addr, &msg32) < 0)
467 copy_from_msghdr32(msg, &msg32);
470 if (umove(tcp, addr, msg) < 0)
476 fetch_mmsghdr(struct tcb *tcp, long addr, unsigned int idx, struct mmsghdr *mmsg)
478 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
479 if (current_wordsize == 4) {
480 struct mmsghdr32 mmsg32;
482 addr += sizeof(struct mmsghdr32) * idx;
483 if (umove(tcp, addr, &mmsg32) < 0)
486 copy_from_msghdr32(&mmsg->msg_hdr, &mmsg32.msg_hdr);
487 mmsg->msg_len = mmsg32.msg_len;
491 addr += sizeof(*mmsg) * idx;
492 if (umove(tcp, addr, mmsg) < 0)
499 decode_msghdr(struct tcb *tcp, long addr, unsigned long data_size)
503 if (verbose(tcp) && fetch_msghdr(tcp, addr, &msg))
504 print_msghdr(tcp, &msg, data_size);
510 dumpiov_in_msghdr(struct tcb *tcp, long addr, unsigned long data_size)
514 if (fetch_msghdr(tcp, addr, &msg))
515 dumpiov_upto(tcp, msg.msg_iovlen, (long)msg.msg_iov, data_size);
519 decode_mmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
523 if (fetch_mmsghdr(tcp, addr, idx, &mmsg)) {
525 print_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
526 tprintf(", %u}", mmsg.msg_len);
533 decode_mmsg(struct tcb *tcp, unsigned long msg_len)
537 printaddr(tcp->u_arg[1]);
539 unsigned int len = tcp->u_rval;
543 for (i = 0; i < len; ++i) {
546 decode_mmsghdr(tcp, tcp->u_arg[1], i, msg_len);
551 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
553 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
557 dumpiov_in_mmsghdr(struct tcb *tcp, long addr)
559 unsigned int len = tcp->u_rval;
563 for (i = 0; i < len; ++i) {
564 if (fetch_mmsghdr(tcp, addr, i, &mmsg)) {
565 tprintf(" = %lu buffers in vector %u\n",
566 (unsigned long)mmsg.msg_hdr.msg_iovlen, i);
567 dumpiov_upto(tcp, mmsg.msg_hdr.msg_iovlen,
568 (long)mmsg.msg_hdr.msg_iov, mmsg.msg_len);
574 * low bits of the socket type define real socket type,
575 * other bits are socket type flags.
578 tprint_sock_type(unsigned int flags)
580 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
584 flags &= ~SOCK_TYPE_MASK;
589 printflags(sock_type_flags, flags, "SOCK_???");
594 printxval(addrfams, tcp->u_arg[0], "AF_???");
596 tprint_sock_type(tcp->u_arg[1]);
598 switch (tcp->u_arg[0]) {
601 printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
605 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
608 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
610 printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
615 tprintf("%lu", tcp->u_arg[2]);
619 return RVAL_DECODED | RVAL_FD;
624 printfd(tcp, tcp->u_arg[0]);
626 decode_sockaddr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
627 tprintf(", %lu", tcp->u_arg[2]);
634 printfd(tcp, tcp->u_arg[0]);
636 tprintf("%lu", tcp->u_arg[1]);
642 do_sockname(struct tcb *tcp, int flags_arg)
645 printfd(tcp, tcp->u_arg[0]);
651 if (!tcp->u_arg[2] || !verbose(tcp) || syserror(tcp) ||
652 umove(tcp, tcp->u_arg[2], &len) < 0) {
653 printaddr(tcp->u_arg[1]);
655 printaddr(tcp->u_arg[2]);
657 decode_sockaddr(tcp, tcp->u_arg[1], len);
658 tprintf(", [%d]", len);
661 if (flags_arg >= 0) {
663 printflags(sock_type_flags, tcp->u_arg[flags_arg],
671 do_sockname(tcp, -1);
683 printfd(tcp, tcp->u_arg[0]);
685 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
686 tprintf(", %lu, ", tcp->u_arg[2]);
688 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
695 printfd(tcp, tcp->u_arg[0]);
697 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
698 tprintf(", %lu, ", tcp->u_arg[2]);
700 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
703 decode_sockaddr(tcp, tcp->u_arg[4], tcp->u_arg[5]);
705 tprintf(", %lu", tcp->u_arg[5]);
712 printfd(tcp, tcp->u_arg[0]);
714 decode_msghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
717 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
726 printfd(tcp, tcp->u_arg[0]);
729 printaddr(tcp->u_arg[1]);
730 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
731 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
735 decode_mmsg(tcp, (unsigned long) -1L);
743 printfd(tcp, tcp->u_arg[0]);
747 printaddr(tcp->u_arg[1]);
749 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
751 tprintf(", %lu, ", tcp->u_arg[2]);
752 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
762 printfd(tcp, tcp->u_arg[0]);
767 printaddr(tcp->u_arg[1]);
769 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
772 tprintf(", %lu, ", tcp->u_arg[2]);
774 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
776 if (syserror(tcp) || !tcp->u_arg[4] || !tcp->u_arg[5] ||
777 umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
778 /* from address, len */
779 printaddr(tcp->u_arg[4]);
781 printaddr(tcp->u_arg[5]);
785 decode_sockaddr(tcp, tcp->u_arg[4], fromlen);
787 tprintf(", [%u]", fromlen);
795 printfd(tcp, tcp->u_arg[0]);
799 printaddr(tcp->u_arg[1]);
801 decode_msghdr(tcp, tcp->u_arg[1], tcp->u_rval);
804 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
811 static char str[sizeof("left") + TIMESPEC_TEXT_BUFSIZE];
814 printfd(tcp, tcp->u_arg[0]);
817 /* Abusing tcp->auxstr as temp storage.
818 * Will be used and cleared on syscall exit.
820 tcp->auxstr = sprint_timespec(tcp, tcp->u_arg[4]);
822 printaddr(tcp->u_arg[1]);
823 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
824 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
826 print_timespec(tcp, tcp->u_arg[4]);
833 /* timeout on entrance */
834 tprints(tcp->auxstr);
839 if (tcp->u_rval == 0) {
840 tcp->auxstr = "Timeout";
845 /* timeout on exit */
846 snprintf(str, sizeof(str), "left %s",
847 sprint_timespec(tcp, tcp->u_arg[4]));
853 #include "xlat/shutdown_modes.h"
857 printfd(tcp, tcp->u_arg[0]);
859 printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
864 SYS_FUNC(getsockname)
866 return do_sockname(tcp, -1);
870 printpair_fd(struct tcb *tcp, const int i0, const int i1)
880 decode_pair_fd(struct tcb *tcp, const long addr)
884 if (umove_or_printaddr(tcp, addr, &pair))
887 printpair_fd(tcp, pair[0], pair[1]);
891 do_pipe(struct tcb *tcp, int flags_arg)
894 decode_pair_fd(tcp, tcp->u_arg[0]);
895 if (flags_arg >= 0) {
897 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
906 if (exiting(tcp) && !syserror(tcp))
907 printpair_fd(tcp, tcp->u_rval, getrval2(tcp));
910 return do_pipe(tcp, -1);
916 return do_pipe(tcp, 1);
922 printxval(addrfams, tcp->u_arg[0], "AF_???");
924 tprint_sock_type(tcp->u_arg[1]);
925 tprintf(", %lu", tcp->u_arg[2]);
928 decode_pair_fd(tcp, tcp->u_arg[3]);
933 #include "xlat/sockoptions.h"
934 #include "xlat/sockipoptions.h"
935 #include "xlat/getsockipoptions.h"
936 #include "xlat/setsockipoptions.h"
937 #include "xlat/sockipv6options.h"
938 #include "xlat/getsockipv6options.h"
939 #include "xlat/setsockipv6options.h"
940 #include "xlat/sockipxoptions.h"
941 #include "xlat/sockrawoptions.h"
942 #include "xlat/sockpacketoptions.h"
943 #include "xlat/socksctpoptions.h"
944 #include "xlat/socktcpoptions.h"
947 print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level,
948 unsigned int name, bool is_getsockopt)
952 printxval(socketlayers, level, "SOL_??");
957 printxval(sockoptions, name, "SO_???");
960 printxvals(name, "IP_???", sockipoptions,
961 is_getsockopt ? getsockipoptions : setsockipoptions, NULL);
964 printxvals(name, "IPV6_???", sockipv6options,
965 is_getsockopt ? getsockipv6options : setsockipv6options, NULL);
968 printxval(sockipxoptions, name, "IPX_???");
971 printxval(sockpacketoptions, name, "PACKET_???");
974 printxval(socktcpoptions, name, "TCP_???");
977 printxval(socksctpoptions, name, "SCTP_???");
980 printxval(sockrawoptions, name, "RAW_???");
983 /* Other SOL_* protocol levels still need work. */
993 print_linger(struct tcb *tcp, long addr, int len)
995 struct linger linger;
997 if (len != sizeof(linger) ||
998 umove(tcp, addr, &linger) < 0) {
1003 tprintf("{onoff=%d, linger=%d}",
1010 print_ucred(struct tcb *tcp, long addr, int len)
1014 if (len != sizeof(uc) ||
1015 umove(tcp, addr, &uc) < 0) {
1018 tprintf("{pid=%u, uid=%u, gid=%u}",
1024 #endif /* SO_PEERCRED */
1026 #ifdef PACKET_STATISTICS
1028 print_tpacket_stats(struct tcb *tcp, long addr, int len)
1030 struct tpacket_stats stats;
1032 if (len != sizeof(stats) ||
1033 umove(tcp, addr, &stats) < 0) {
1036 tprintf("{packets=%u, drops=%u}",
1041 #endif /* PACKET_STATISTICS */
1043 #include "xlat/icmpfilterflags.h"
1046 print_icmp_filter(struct tcb *tcp, const long addr, int len)
1048 struct icmp_filter filter = {};
1050 if (len > (int) sizeof(filter))
1051 len = sizeof(filter);
1052 else if (len <= 0) {
1057 if (umoven_or_printaddr(tcp, addr, len, &filter))
1061 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
1066 print_getsockopt(struct tcb *tcp, unsigned int level, unsigned int name,
1069 if (addr && verbose(tcp))
1074 print_linger(tcp, addr, len);
1078 print_ucred(tcp, addr, len);
1086 #ifdef PACKET_STATISTICS
1087 case PACKET_STATISTICS:
1088 print_tpacket_stats(tcp, addr, len);
1097 print_icmp_filter(tcp, addr, len);
1103 /* default arg printing */
1106 if (len == sizeof(int)) {
1107 printnum_int(tcp, addr, "%d");
1109 printstr(tcp, addr, len);
1115 tprintf(", [%d]", len);
1118 SYS_FUNC(getsockopt)
1120 if (entering(tcp)) {
1121 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1122 tcp->u_arg[1], tcp->u_arg[2], true);
1126 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
1127 printaddr(tcp->u_arg[3]);
1129 printaddr(tcp->u_arg[4]);
1131 print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1132 tcp->u_arg[3], len);
1138 #ifdef IP_ADD_MEMBERSHIP
1140 print_mreq(struct tcb *tcp, long addr, unsigned int len)
1142 struct ip_mreq mreq;
1144 if (len < sizeof(mreq)) {
1145 printstr(tcp, addr, len);
1148 if (umove_or_printaddr(tcp, addr, &mreq))
1151 tprints("{imr_multiaddr=inet_addr(");
1152 print_quoted_string(inet_ntoa(mreq.imr_multiaddr),
1153 16, QUOTE_0_TERMINATED);
1154 tprints("), imr_interface=inet_addr(");
1155 print_quoted_string(inet_ntoa(mreq.imr_interface),
1156 16, QUOTE_0_TERMINATED);
1159 #endif /* IP_ADD_MEMBERSHIP */
1161 #ifdef IPV6_ADD_MEMBERSHIP
1163 print_mreq6(struct tcb *tcp, long addr, unsigned int len)
1165 struct ipv6_mreq mreq;
1167 if (len < sizeof(mreq))
1170 if (umove_or_printaddr(tcp, addr, &mreq))
1173 const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr;
1174 char address[INET6_ADDRSTRLEN];
1176 if (!inet_ntop(AF_INET6, in6, address, sizeof(address)))
1179 tprints("{ipv6mr_multiaddr=inet_pton(");
1180 print_quoted_string(address, sizeof(address), QUOTE_0_TERMINATED);
1181 tprints("), ipv6mr_interface=");
1182 print_ifindex(mreq.ipv6mr_interface);
1187 printstr(tcp, addr, len);
1189 #endif /* IPV6_ADD_MEMBERSHIP */
1191 #ifdef MCAST_JOIN_GROUP
1193 print_group_req(struct tcb *tcp, long addr, int len)
1195 struct group_req greq;
1197 if (len != sizeof(greq) ||
1198 umove(tcp, addr, &greq) < 0) {
1203 tprintf("{gr_interface=%u, gr_group=", greq.gr_interface);
1204 print_sockaddr(tcp, &greq.gr_group, sizeof(greq.gr_group));
1208 #endif /* MCAST_JOIN_GROUP */
1210 #ifdef PACKET_RX_RING
1212 print_tpacket_req(struct tcb *tcp, long addr, int len)
1214 struct tpacket_req req;
1216 if (len != sizeof(req) ||
1217 umove(tcp, addr, &req) < 0) {
1220 tprintf("{block_size=%u, block_nr=%u, "
1221 "frame_size=%u, frame_nr=%u}",
1228 #endif /* PACKET_RX_RING */
1230 #ifdef PACKET_ADD_MEMBERSHIP
1231 # include "xlat/packet_mreq_type.h"
1234 print_packet_mreq(struct tcb *tcp, long addr, int len)
1236 struct packet_mreq mreq;
1238 if (len != sizeof(mreq) ||
1239 umove(tcp, addr, &mreq) < 0) {
1244 tprintf("{mr_ifindex=%u, mr_type=", mreq.mr_ifindex);
1245 printxval(packet_mreq_type, mreq.mr_type, "PACKET_MR_???");
1246 tprintf(", mr_alen=%u, mr_address=", mreq.mr_alen);
1247 if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address))
1248 mreq.mr_alen = ARRAY_SIZE(mreq.mr_address);
1249 for (i = 0; i < mreq.mr_alen; ++i)
1250 tprintf("%02x", mreq.mr_address[i]);
1254 #endif /* PACKET_ADD_MEMBERSHIP */
1257 print_setsockopt(struct tcb *tcp, unsigned int level, unsigned int name,
1260 if (addr && verbose(tcp))
1265 print_linger(tcp, addr, len);
1272 #ifdef IP_ADD_MEMBERSHIP
1273 case IP_ADD_MEMBERSHIP:
1274 case IP_DROP_MEMBERSHIP:
1275 print_mreq(tcp, addr, len);
1277 #endif /* IP_ADD_MEMBERSHIP */
1278 #ifdef MCAST_JOIN_GROUP
1279 case MCAST_JOIN_GROUP:
1280 case MCAST_LEAVE_GROUP:
1281 print_group_req(tcp, addr, len);
1283 #endif /* MCAST_JOIN_GROUP */
1289 #ifdef IPV6_ADD_MEMBERSHIP
1290 case IPV6_ADD_MEMBERSHIP:
1291 case IPV6_DROP_MEMBERSHIP:
1292 # ifdef IPV6_JOIN_ANYCAST
1293 case IPV6_JOIN_ANYCAST:
1295 # ifdef IPV6_LEAVE_ANYCAST
1296 case IPV6_LEAVE_ANYCAST:
1298 print_mreq6(tcp, addr, len);
1300 #endif /* IPV6_ADD_MEMBERSHIP */
1306 #ifdef PACKET_RX_RING
1307 case PACKET_RX_RING:
1308 # ifdef PACKET_TX_RING
1309 case PACKET_TX_RING:
1311 print_tpacket_req(tcp, addr, len);
1313 #endif /* PACKET_RX_RING */
1314 #ifdef PACKET_ADD_MEMBERSHIP
1315 case PACKET_ADD_MEMBERSHIP:
1316 case PACKET_DROP_MEMBERSHIP:
1317 print_packet_mreq(tcp, addr, len);
1319 #endif /* PACKET_ADD_MEMBERSHIP */
1326 print_icmp_filter(tcp, addr, len);
1332 /* default arg printing */
1335 if (len == sizeof(int)) {
1336 printnum_int(tcp, addr, "%d");
1338 printstr(tcp, addr, len);
1344 tprintf(", %d", len);
1347 SYS_FUNC(setsockopt)
1349 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1350 tcp->u_arg[1], tcp->u_arg[2], false);
1351 print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1352 tcp->u_arg[3], tcp->u_arg[4]);
1354 return RVAL_DECODED;