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>
6 * Copyright (c) 1999-2018 The strace developers.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "print_fields.h"
36 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #ifdef HAVE_NETINET_TCP_H
41 # include <netinet/tcp.h>
43 #ifdef HAVE_NETINET_UDP_H
44 # include <netinet/udp.h>
46 #ifdef HAVE_NETINET_SCTP_H
47 # include <netinet/sctp.h>
49 #include <arpa/inet.h>
51 #include <asm/types.h>
52 #ifdef HAVE_NETIPX_IPX_H
53 # include <netipx/ipx.h>
55 # include <linux/ipx.h>
58 #if defined(HAVE_LINUX_IP_VS_H)
59 # include <linux/ip_vs.h>
62 #if defined(HAVE_LINUX_NETFILTER_ARP_ARP_TABLES_H)
63 # include <linux/netfilter_arp/arp_tables.h>
65 #if defined(HAVE_LINUX_NETFILTER_BRIDGE_EBTABLES_H)
66 # include <linux/netfilter_bridge/ebtables.h>
68 #if defined(HAVE_LINUX_NETFILTER_IPV4_IP_TABLES_H)
69 # include <linux/netfilter_ipv4/ip_tables.h>
71 #if defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H)
72 # include <linux/netfilter_ipv6/ip6_tables.h>
74 #include <linux/if_packet.h>
75 #include <linux/icmp.h>
77 #include "xlat/socktypes.h"
78 #include "xlat/sock_type_flags.h"
79 #ifndef SOCK_TYPE_MASK
80 # define SOCK_TYPE_MASK 0xf
83 #include "xlat/socketlayers.h"
85 #include "xlat/inet_protocols.h"
87 #define XLAT_MACROS_ONLY
88 # include "xlat/addrfams.h"
89 #undef XLAT_MACROS_ONLY
90 #include "xlat/irda_protocols.h"
91 #include "xlat/can_protocols.h"
92 #include "xlat/bt_protocols.h"
93 #include "xlat/isdn_protocols.h"
94 #include "xlat/phonet_protocols.h"
95 #include "xlat/caif_protocols.h"
96 #include "xlat/nfc_protocols.h"
97 #include "xlat/kcm_protocols.h"
98 #include "xlat/smc_protocols.h"
100 const size_t inet_protocols_size = ARRAY_SIZE(inet_protocols) - 1;
103 decode_sockbuf(struct tcb *const tcp, const int fd, const kernel_ulong_t addr,
104 const kernel_ulong_t addrlen)
107 switch (verbose(tcp) ? getfdproto(tcp, fd) : SOCK_PROTO_UNKNOWN) {
108 case SOCK_PROTO_NETLINK:
109 decode_netlink(tcp, fd, addr, addrlen);
112 printstrn(tcp, addr, addrlen);
117 * low bits of the socket type define real socket type,
118 * other bits are socket type flags.
121 tprint_sock_type(unsigned int flags)
123 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
126 print_xlat_ex(flags & SOCK_TYPE_MASK, str, XLAT_STYLE_DEFAULT);
127 flags &= ~SOCK_TYPE_MASK;
132 printflags(sock_type_flags, flags, "SOCK_???");
137 printxval(addrfams, tcp->u_arg[0], "AF_???");
139 tprint_sock_type(tcp->u_arg[1]);
141 switch (tcp->u_arg[0]) {
144 printxval_search(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
148 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
152 printxval_index(can_protocols, tcp->u_arg[2], "IRDAPROTO_???");
156 printxval_index(can_protocols, tcp->u_arg[2], "CAN_???");
160 printxval_index(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
164 printxval(addrfams, tcp->u_arg[2], "AF_???");
168 printxval(isdn_protocols, tcp->u_arg[2], "ISDN_P_???");
172 printxval_index(phonet_protocols, tcp->u_arg[2], "PN_PROTO_???");
176 printxval_index(caif_protocols, tcp->u_arg[2], "CAIFPROTO_???");
180 printxval_index(nfc_protocols, tcp->u_arg[2],
181 "NFC_SOCKPROTO_???");
185 printxval_index(kcm_protocols, tcp->u_arg[2], "KCMPROTO_???");
189 printxval_index(smc_protocols, tcp->u_arg[2], "SMCPROTO_???");
193 tprintf("%" PRI_klu, tcp->u_arg[2]);
197 return RVAL_DECODED | RVAL_FD;
201 fetch_socklen(struct tcb *const tcp, int *const plen,
202 const kernel_ulong_t sockaddr, const kernel_ulong_t socklen)
204 return verbose(tcp) && sockaddr && socklen
205 && umove(tcp, socklen, plen) == 0;
209 decode_sockname(struct tcb *tcp)
214 printfd(tcp, tcp->u_arg[0]);
216 if (fetch_socklen(tcp, &ulen, tcp->u_arg[1], tcp->u_arg[2])) {
217 set_tcb_priv_ulong(tcp, ulen);
220 printaddr(tcp->u_arg[1]);
222 printaddr(tcp->u_arg[2]);
227 ulen = get_tcb_priv_ulong(tcp);
229 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &rlen) < 0) {
230 printaddr(tcp->u_arg[1]);
231 tprintf(", [%d]", ulen);
233 decode_sockaddr(tcp, tcp->u_arg[1], ulen > rlen ? rlen : ulen);
235 tprintf(", [%d->%d]", ulen, rlen);
237 tprintf(", [%d]", rlen);
245 return decode_sockname(tcp) | RVAL_FD;
250 int rc = decode_sockname(tcp);
252 if (rc & RVAL_DECODED) {
254 printflags(sock_type_flags, tcp->u_arg[3], "SOCK_???");
262 printfd(tcp, tcp->u_arg[0]);
264 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
265 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
267 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
274 printfd(tcp, tcp->u_arg[0]);
276 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
277 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
279 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
281 const int addrlen = tcp->u_arg[5];
283 decode_sockaddr(tcp, tcp->u_arg[4], addrlen);
285 tprintf(", %d", addrlen);
293 printfd(tcp, tcp->u_arg[0]);
297 printaddr(tcp->u_arg[1]);
299 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1],
303 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
304 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
314 printfd(tcp, tcp->u_arg[0]);
316 if (fetch_socklen(tcp, &ulen, tcp->u_arg[4], tcp->u_arg[5])) {
317 set_tcb_priv_ulong(tcp, ulen);
322 printaddr(tcp->u_arg[1]);
324 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1],
328 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
330 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
333 ulen = get_tcb_priv_ulong(tcp);
335 if (!fetch_socklen(tcp, &rlen, tcp->u_arg[4], tcp->u_arg[5])) {
337 printaddr(tcp->u_arg[4]);
340 printaddr(tcp->u_arg[5]);
345 printaddr(tcp->u_arg[4]);
347 tprintf(", [%d]", ulen);
351 decode_sockaddr(tcp, tcp->u_arg[4], ulen > rlen ? rlen : ulen);
354 tprintf(", [%d->%d]", ulen, rlen);
356 tprintf(", [%d]", rlen);
361 SYS_FUNC(getsockname)
363 return decode_sockname(tcp);
367 printpair_fd(struct tcb *tcp, const int i0, const int i1)
377 decode_pair_fd(struct tcb *const tcp, const kernel_ulong_t addr)
381 if (umove_or_printaddr(tcp, addr, &pair))
384 printpair_fd(tcp, pair[0], pair[1]);
388 do_pipe(struct tcb *tcp, int flags_arg)
391 decode_pair_fd(tcp, tcp->u_arg[0]);
392 if (flags_arg >= 0) {
394 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
402 #if HAVE_ARCH_GETRVAL2
403 if (exiting(tcp) && !syserror(tcp))
404 printpair_fd(tcp, tcp->u_rval, getrval2(tcp));
407 return do_pipe(tcp, -1);
413 return do_pipe(tcp, 1);
419 printxval(addrfams, tcp->u_arg[0], "AF_???");
421 tprint_sock_type(tcp->u_arg[1]);
422 tprintf(", %" PRI_klu, tcp->u_arg[2]);
425 decode_pair_fd(tcp, tcp->u_arg[3]);
430 #include "xlat/sock_options.h"
431 #include "xlat/getsock_options.h"
432 #include "xlat/setsock_options.h"
433 #include "xlat/sock_ip_options.h"
434 #include "xlat/getsock_ip_options.h"
435 #include "xlat/setsock_ip_options.h"
436 #include "xlat/sock_ipv6_options.h"
437 #include "xlat/getsock_ipv6_options.h"
438 #include "xlat/setsock_ipv6_options.h"
439 #include "xlat/sock_ipx_options.h"
440 #include "xlat/sock_netlink_options.h"
441 #include "xlat/sock_packet_options.h"
442 #include "xlat/sock_raw_options.h"
443 #include "xlat/sock_sctp_options.h"
444 #include "xlat/sock_tcp_options.h"
445 #include "xlat/sock_udp_options.h"
446 #include "xlat/sock_irda_options.h"
447 #include "xlat/sock_llc_options.h"
448 #include "xlat/sock_dccp_options.h"
449 #include "xlat/sock_tipc_options.h"
450 #include "xlat/sock_rxrpc_options.h"
451 #include "xlat/sock_pppol2tp_options.h"
452 #include "xlat/sock_bluetooth_options.h"
453 #include "xlat/sock_pnp_options.h"
454 #include "xlat/sock_rds_options.h"
455 #include "xlat/sock_iucv_options.h"
456 #include "xlat/sock_caif_options.h"
457 #include "xlat/sock_alg_options.h"
458 #include "xlat/sock_nfcllcp_options.h"
459 #include "xlat/sock_kcm_options.h"
460 #include "xlat/sock_tls_options.h"
461 #include "xlat/sock_xdp_options.h"
464 print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level,
465 unsigned int name, bool is_getsockopt)
469 printxval_search(socketlayers, level, "SOL_??");
474 printxvals(name, "SO_???", sock_options,
475 is_getsockopt ? getsock_options :
476 setsock_options, NULL);
479 printxvals(name, "IP_???", sock_ip_options,
480 is_getsockopt ? getsock_ip_options :
481 setsock_ip_options, NULL);
484 printxvals(name, "IPV6_???", sock_ipv6_options,
485 is_getsockopt ? getsock_ipv6_options :
486 setsock_ipv6_options, NULL);
489 printxval(sock_ipx_options, name, "IPX_???");
492 printxval(sock_packet_options, name, "PACKET_???");
495 printxval_index(sock_tcp_options, name, "TCP_???");
498 printxval(sock_sctp_options, name, "SCTP_???");
501 printxval(sock_raw_options, name, "RAW_???");
504 printxval(sock_netlink_options, name, "NETLINK_???");
507 printxval(sock_udp_options, name, "UDP_???");
510 printxval_index(sock_irda_options, name, "IRLMP_???");
513 printxval_index(sock_llc_options, name, "LLC_OPT_???");
516 printxval_search(sock_dccp_options, name, "DCCP_SOCKOPT_???");
519 printxval_search(sock_tipc_options, name, "TIPC_???");
522 printxval_index(sock_rxrpc_options, name, "RXRPC_???");
525 printxval_index(sock_pppol2tp_options, name, "PPPOL2TP_SO_???");
528 printxval_search(sock_bluetooth_options, name, "BT_???");
531 printxval(sock_pnp_options, name, "PNPIPE_???");
534 printxval_search(sock_rds_options, name, "RDS_???");
537 printxval(sock_iucv_options, name, "SO_???");
540 printxval(sock_caif_options, name, "CAIFSO_???");
543 printxval_index(sock_alg_options, name, "ALG_???");
546 printxval_index(sock_nfcllcp_options, name, "NFC_LLCP_???");
549 printxval(sock_kcm_options, name, "KCM_???");
552 printxval(sock_tls_options, name, "TLS_???");
555 printxval_index(sock_xdp_options, name, "XDP_???");
558 /* Other SOL_* protocol levels still need work. */
568 print_get_linger(struct tcb *const tcp, const kernel_ulong_t addr,
571 struct linger linger;
574 * The kernel cannot return len > sizeof(linger) because struct linger
575 * cannot change, but extra safety won't harm either.
577 if (len > sizeof(linger))
578 len = sizeof(linger);
579 if (umoven_or_printaddr(tcp, addr, len, &linger))
582 if (len < sizeof(linger.l_onoff)) {
583 tprints("{l_onoff=");
584 print_quoted_string((void *) &linger.l_onoff,
585 len, QUOTE_FORCE_HEX);
587 PRINT_FIELD_D("{", linger, l_onoff);
589 if (len > offsetof(struct linger, l_linger)) {
590 len -= offsetof(struct linger, l_linger);
591 if (len < sizeof(linger.l_linger)) {
592 tprints(", l_linger=");
593 print_quoted_string((void *) &linger.l_linger,
594 len, QUOTE_FORCE_HEX);
596 PRINT_FIELD_D(", ", linger, l_linger);
604 print_get_ucred(struct tcb *const tcp, const kernel_ulong_t addr,
610 * The kernel is very unlikely to return len > sizeof(uc)
611 * because struct ucred is very unlikely to change,
612 * but extra safety won't harm either.
614 if (len > sizeof(uc))
617 if (umoven_or_printaddr(tcp, addr, len, &uc))
620 if (len < sizeof(uc.pid)) {
622 print_quoted_string((void *) &uc.pid,
623 len, QUOTE_FORCE_HEX);
625 PRINT_FIELD_D("{", uc, pid);
627 if (len > offsetof(struct ucred, uid)) {
628 len -= offsetof(struct ucred, uid);
629 if (len < sizeof(uc.uid)) {
631 print_quoted_string((void *) &uc.uid,
632 len, QUOTE_FORCE_HEX);
634 PRINT_FIELD_UID(", ", uc, uid);
636 if (len > offsetof(struct ucred, gid) -
637 offsetof(struct ucred, uid)) {
638 len -= offsetof(struct ucred, gid) -
639 offsetof(struct ucred, uid);
640 if (len < sizeof(uc.gid)) {
642 print_quoted_string((void *) &uc.gid,
646 PRINT_FIELD_UID(", ", uc, gid);
655 #ifdef PACKET_STATISTICS
657 print_tpacket_stats(struct tcb *const tcp, const kernel_ulong_t addr,
661 unsigned int tp_packets, tp_drops, tp_freeze_q_cnt;
665 * The kernel may return len > sizeof(stats) if the kernel structure
666 * grew as it happened when tpacket_stats_v3 was introduced.
668 if (len > sizeof(stats))
671 if (umoven_or_printaddr(tcp, addr, len, &stats))
674 if (len < sizeof(stats.tp_packets)) {
675 tprints("{tp_packets=");
676 print_quoted_string((void *) &stats.tp_packets,
677 len, QUOTE_FORCE_HEX);
679 PRINT_FIELD_U("{", stats, tp_packets);
681 if (len > offsetof(struct tp_stats, tp_drops)) {
682 len -= offsetof(struct tp_stats, tp_drops);
683 if (len < sizeof(stats.tp_drops)) {
684 tprints(", tp_drops=");
685 print_quoted_string((void *) &stats.tp_drops,
686 len, QUOTE_FORCE_HEX);
688 PRINT_FIELD_U(", ", stats, tp_drops);
690 if (len > offsetof(struct tp_stats, tp_freeze_q_cnt) -
691 offsetof(struct tp_stats, tp_drops)) {
692 len -= offsetof(struct tp_stats, tp_freeze_q_cnt) -
693 offsetof(struct tp_stats, tp_drops);
694 if (len < sizeof(stats.tp_freeze_q_cnt)) {
695 tprints(", tp_freeze_q_cnt=");
696 print_quoted_string((void *) &stats.tp_freeze_q_cnt,
700 PRINT_FIELD_U(", ", stats, tp_freeze_q_cnt);
708 #endif /* PACKET_STATISTICS */
710 #include "xlat/icmpfilterflags.h"
713 print_icmp_filter(struct tcb *const tcp, const kernel_ulong_t addr, int len)
715 struct icmp_filter filter = {};
717 if (len > (int) sizeof(filter))
718 len = sizeof(filter);
724 if (umoven_or_printaddr(tcp, addr, len, &filter))
728 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
733 print_uint32(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
735 tprintf("%u", *(uint32_t *) elem_buf);
741 print_getsockopt(struct tcb *const tcp, const unsigned int level,
742 const unsigned int name, const kernel_ulong_t addr,
743 const int ulen, const int rlen)
745 if (ulen <= 0 || rlen <= 0) {
747 * As the kernel neither accepts nor returns a negative
748 * length in case of successful getsockopt syscall
749 * invocation, negative values must have been forged
756 if (addr && verbose(tcp))
761 print_get_linger(tcp, addr, rlen);
764 print_get_ucred(tcp, addr, rlen);
766 case SO_ATTACH_FILTER:
768 * The length returned by the kernel in case of
769 * successful getsockopt syscall invocation is struct
770 * sock_fprog.len that has type unsigned short,
771 * anything else must have been forged by userspace.
773 if ((unsigned short) rlen == (unsigned int) rlen)
774 print_sock_fprog(tcp, addr, rlen);
783 #ifdef PACKET_STATISTICS
784 case PACKET_STATISTICS:
785 print_tpacket_stats(tcp, addr, rlen);
794 print_icmp_filter(tcp, addr, rlen);
801 case NETLINK_LIST_MEMBERSHIPS: {
803 print_array(tcp, addr, MIN(ulen, rlen) / sizeof(buf),
805 tfetch_mem, print_uint32, 0);
809 printnum_int(tcp, addr, "%d");
815 /* default arg printing */
818 if (rlen == sizeof(int)) {
819 printnum_int(tcp, addr, "%d");
821 printstrn(tcp, addr, rlen);
833 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
834 tcp->u_arg[1], tcp->u_arg[2], true);
836 if (verbose(tcp) && tcp->u_arg[4]
837 && umove(tcp, tcp->u_arg[4], &ulen) == 0) {
838 set_tcb_priv_ulong(tcp, ulen);
841 printaddr(tcp->u_arg[3]);
843 printaddr(tcp->u_arg[4]);
847 ulen = get_tcb_priv_ulong(tcp);
849 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &rlen) < 0) {
850 printaddr(tcp->u_arg[3]);
851 tprintf(", [%d]", ulen);
853 print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
854 tcp->u_arg[3], ulen, rlen);
856 tprintf(", [%d->%d]", ulen, rlen);
858 tprintf(", [%d]", rlen);
865 print_set_linger(struct tcb *const tcp, const kernel_ulong_t addr,
868 struct linger linger;
870 if (len < (int) sizeof(linger)) {
872 } else if (!umove_or_printaddr(tcp, addr, &linger)) {
873 PRINT_FIELD_D("{", linger, l_onoff);
874 PRINT_FIELD_D(", ", linger, l_linger);
879 #ifdef IP_ADD_MEMBERSHIP
881 print_mreq(struct tcb *const tcp, const kernel_ulong_t addr,
886 if (len < (int) sizeof(mreq)) {
888 } else if (!umove_or_printaddr(tcp, addr, &mreq)) {
889 PRINT_FIELD_INET4_ADDR("{", mreq, imr_multiaddr);
890 PRINT_FIELD_INET4_ADDR(", ", mreq, imr_interface);
894 #endif /* IP_ADD_MEMBERSHIP */
896 #ifdef IPV6_ADD_MEMBERSHIP
898 print_mreq6(struct tcb *const tcp, const kernel_ulong_t addr,
901 struct ipv6_mreq mreq;
903 if (len < (int) sizeof(mreq)) {
905 } else if (!umove_or_printaddr(tcp, addr, &mreq)) {
906 PRINT_FIELD_INET_ADDR("{", mreq, ipv6mr_multiaddr, AF_INET6);
907 PRINT_FIELD_IFINDEX(", ", mreq, ipv6mr_interface);
911 #endif /* IPV6_ADD_MEMBERSHIP */
913 #ifdef PACKET_RX_RING
915 print_tpacket_req(struct tcb *const tcp, const kernel_ulong_t addr, const int len)
917 struct tpacket_req req;
919 if (len != sizeof(req) ||
920 umove(tcp, addr, &req) < 0) {
923 PRINT_FIELD_U("{", req, tp_block_size);
924 PRINT_FIELD_U(", ", req, tp_block_nr);
925 PRINT_FIELD_U(", ", req, tp_frame_size);
926 PRINT_FIELD_U(", ", req, tp_frame_nr);
930 #endif /* PACKET_RX_RING */
932 #ifdef PACKET_ADD_MEMBERSHIP
933 # include "xlat/packet_mreq_type.h"
936 print_packet_mreq(struct tcb *const tcp, const kernel_ulong_t addr, const int len)
938 struct packet_mreq mreq;
940 if (len != sizeof(mreq) ||
941 umove(tcp, addr, &mreq) < 0) {
946 PRINT_FIELD_IFINDEX("{", mreq, mr_ifindex);
947 PRINT_FIELD_XVAL(", ", mreq, mr_type, packet_mreq_type,
949 PRINT_FIELD_U(", ", mreq, mr_alen);
950 tprints(", mr_address=");
951 if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address))
952 mreq.mr_alen = ARRAY_SIZE(mreq.mr_address);
953 for (i = 0; i < mreq.mr_alen; ++i)
954 tprintf("%02x", mreq.mr_address[i]);
958 #endif /* PACKET_ADD_MEMBERSHIP */
961 print_setsockopt(struct tcb *const tcp, const unsigned int level,
962 const unsigned int name, const kernel_ulong_t addr,
965 if (addr && verbose(tcp))
970 print_set_linger(tcp, addr, len);
972 case SO_ATTACH_FILTER:
973 case SO_ATTACH_REUSEPORT_CBPF:
974 if ((unsigned int) len == get_sock_fprog_size())
975 decode_sock_fprog(tcp, addr);
984 #ifdef IP_ADD_MEMBERSHIP
985 case IP_ADD_MEMBERSHIP:
986 case IP_DROP_MEMBERSHIP:
987 print_mreq(tcp, addr, len);
989 #endif /* IP_ADD_MEMBERSHIP */
990 #ifdef MCAST_JOIN_GROUP
991 case MCAST_JOIN_GROUP:
992 case MCAST_LEAVE_GROUP:
993 print_group_req(tcp, addr, len);
995 #endif /* MCAST_JOIN_GROUP */
1001 #ifdef IPV6_ADD_MEMBERSHIP
1002 case IPV6_ADD_MEMBERSHIP:
1003 case IPV6_DROP_MEMBERSHIP:
1004 # ifdef IPV6_JOIN_ANYCAST
1005 case IPV6_JOIN_ANYCAST:
1007 # ifdef IPV6_LEAVE_ANYCAST
1008 case IPV6_LEAVE_ANYCAST:
1010 print_mreq6(tcp, addr, len);
1012 #endif /* IPV6_ADD_MEMBERSHIP */
1013 #ifdef MCAST_JOIN_GROUP
1014 case MCAST_JOIN_GROUP:
1015 case MCAST_LEAVE_GROUP:
1016 print_group_req(tcp, addr, len);
1018 #endif /* MCAST_JOIN_GROUP */
1024 #ifdef PACKET_RX_RING
1025 case PACKET_RX_RING:
1026 # ifdef PACKET_TX_RING
1027 case PACKET_TX_RING:
1029 print_tpacket_req(tcp, addr, len);
1031 #endif /* PACKET_RX_RING */
1032 #ifdef PACKET_ADD_MEMBERSHIP
1033 case PACKET_ADD_MEMBERSHIP:
1034 case PACKET_DROP_MEMBERSHIP:
1035 print_packet_mreq(tcp, addr, len);
1037 #endif /* PACKET_ADD_MEMBERSHIP */
1044 print_icmp_filter(tcp, addr, len);
1050 if (len < (int) sizeof(int))
1053 printnum_int(tcp, addr, "%d");
1057 /* default arg printing */
1060 if (len == sizeof(int)) {
1061 printnum_int(tcp, addr, "%d");
1063 printstrn(tcp, addr, len);
1070 SYS_FUNC(setsockopt)
1072 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1073 tcp->u_arg[1], tcp->u_arg[2], false);
1074 print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1075 tcp->u_arg[3], tcp->u_arg[4]);
1076 tprintf(", %d", (int) tcp->u_arg[4]);
1078 return RVAL_DECODED;