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 # include "xlat/ethernet_protocols.h"
90 #undef XLAT_MACROS_ONLY
91 #include "xlat/irda_protocols.h"
92 #include "xlat/can_protocols.h"
93 #include "xlat/bt_protocols.h"
94 #include "xlat/isdn_protocols.h"
95 #include "xlat/phonet_protocols.h"
96 #include "xlat/caif_protocols.h"
97 #include "xlat/nfc_protocols.h"
98 #include "xlat/kcm_protocols.h"
99 #include "xlat/smc_protocols.h"
101 const size_t inet_protocols_size = ARRAY_SIZE(inet_protocols) - 1;
104 decode_sockbuf(struct tcb *const tcp, const int fd, const kernel_ulong_t addr,
105 const kernel_ulong_t addrlen)
108 switch (verbose(tcp) ? getfdproto(tcp, fd) : SOCK_PROTO_UNKNOWN) {
109 case SOCK_PROTO_NETLINK:
110 decode_netlink(tcp, fd, addr, addrlen);
113 printstrn(tcp, addr, addrlen);
118 * low bits of the socket type define real socket type,
119 * other bits are socket type flags.
122 tprint_sock_type(unsigned int flags)
124 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
127 print_xlat_ex(flags & SOCK_TYPE_MASK, str, XLAT_STYLE_DEFAULT);
128 flags &= ~SOCK_TYPE_MASK;
133 printflags(sock_type_flags, flags, "SOCK_???");
138 printxval(addrfams, tcp->u_arg[0], "AF_???");
140 tprint_sock_type(tcp->u_arg[1]);
142 switch (tcp->u_arg[0]) {
145 printxval_search(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
149 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
154 printxval_searchn(ethernet_protocols, ethernet_protocols_size,
155 ntohs(tcp->u_arg[2]), "ETH_P_???");
160 printxval_index(can_protocols, tcp->u_arg[2], "IRDAPROTO_???");
164 printxval_index(can_protocols, tcp->u_arg[2], "CAN_???");
168 printxval_index(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
172 printxval(addrfams, tcp->u_arg[2], "AF_???");
176 printxval(isdn_protocols, tcp->u_arg[2], "ISDN_P_???");
180 printxval_index(phonet_protocols, tcp->u_arg[2], "PN_PROTO_???");
184 printxval_index(caif_protocols, tcp->u_arg[2], "CAIFPROTO_???");
188 printxval_index(nfc_protocols, tcp->u_arg[2],
189 "NFC_SOCKPROTO_???");
193 printxval_index(kcm_protocols, tcp->u_arg[2], "KCMPROTO_???");
197 printxval_index(smc_protocols, tcp->u_arg[2], "SMCPROTO_???");
201 tprintf("%" PRI_klu, tcp->u_arg[2]);
205 return RVAL_DECODED | RVAL_FD;
209 fetch_socklen(struct tcb *const tcp, int *const plen,
210 const kernel_ulong_t sockaddr, const kernel_ulong_t socklen)
212 return verbose(tcp) && sockaddr && socklen
213 && umove(tcp, socklen, plen) == 0;
217 decode_sockname(struct tcb *tcp)
222 printfd(tcp, tcp->u_arg[0]);
224 if (fetch_socklen(tcp, &ulen, tcp->u_arg[1], tcp->u_arg[2])) {
225 set_tcb_priv_ulong(tcp, ulen);
228 printaddr(tcp->u_arg[1]);
230 printaddr(tcp->u_arg[2]);
235 ulen = get_tcb_priv_ulong(tcp);
237 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &rlen) < 0) {
238 printaddr(tcp->u_arg[1]);
239 tprintf(", [%d]", ulen);
241 decode_sockaddr(tcp, tcp->u_arg[1], ulen > rlen ? rlen : ulen);
243 tprintf(", [%d->%d]", ulen, rlen);
245 tprintf(", [%d]", rlen);
253 return decode_sockname(tcp) | RVAL_FD;
258 int rc = decode_sockname(tcp);
260 if (rc & RVAL_DECODED) {
262 printflags(sock_type_flags, tcp->u_arg[3], "SOCK_???");
270 printfd(tcp, tcp->u_arg[0]);
272 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
273 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
275 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
282 printfd(tcp, tcp->u_arg[0]);
284 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
285 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
287 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
289 const int addrlen = tcp->u_arg[5];
291 decode_sockaddr(tcp, tcp->u_arg[4], addrlen);
293 tprintf(", %d", addrlen);
301 printfd(tcp, tcp->u_arg[0]);
305 printaddr(tcp->u_arg[1]);
307 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1],
311 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
312 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
322 printfd(tcp, tcp->u_arg[0]);
324 if (fetch_socklen(tcp, &ulen, tcp->u_arg[4], tcp->u_arg[5])) {
325 set_tcb_priv_ulong(tcp, ulen);
330 printaddr(tcp->u_arg[1]);
332 decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1],
336 tprintf(", %" PRI_klu ", ", tcp->u_arg[2]);
338 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
341 ulen = get_tcb_priv_ulong(tcp);
343 if (!fetch_socklen(tcp, &rlen, tcp->u_arg[4], tcp->u_arg[5])) {
345 printaddr(tcp->u_arg[4]);
348 printaddr(tcp->u_arg[5]);
353 printaddr(tcp->u_arg[4]);
355 tprintf(", [%d]", ulen);
359 decode_sockaddr(tcp, tcp->u_arg[4], ulen > rlen ? rlen : ulen);
362 tprintf(", [%d->%d]", ulen, rlen);
364 tprintf(", [%d]", rlen);
369 SYS_FUNC(getsockname)
371 return decode_sockname(tcp);
375 printpair_fd(struct tcb *tcp, const int i0, const int i1)
385 decode_pair_fd(struct tcb *const tcp, const kernel_ulong_t addr)
389 if (umove_or_printaddr(tcp, addr, &pair))
392 printpair_fd(tcp, pair[0], pair[1]);
396 do_pipe(struct tcb *tcp, int flags_arg)
399 decode_pair_fd(tcp, tcp->u_arg[0]);
400 if (flags_arg >= 0) {
402 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
410 #if HAVE_ARCH_GETRVAL2
411 if (exiting(tcp) && !syserror(tcp))
412 printpair_fd(tcp, tcp->u_rval, getrval2(tcp));
415 return do_pipe(tcp, -1);
421 return do_pipe(tcp, 1);
427 printxval(addrfams, tcp->u_arg[0], "AF_???");
429 tprint_sock_type(tcp->u_arg[1]);
430 tprintf(", %" PRI_klu, tcp->u_arg[2]);
433 decode_pair_fd(tcp, tcp->u_arg[3]);
438 #include "xlat/sock_options.h"
439 #include "xlat/getsock_options.h"
440 #include "xlat/setsock_options.h"
441 #include "xlat/sock_ip_options.h"
442 #include "xlat/getsock_ip_options.h"
443 #include "xlat/setsock_ip_options.h"
444 #include "xlat/sock_ipv6_options.h"
445 #include "xlat/getsock_ipv6_options.h"
446 #include "xlat/setsock_ipv6_options.h"
447 #include "xlat/sock_ipx_options.h"
448 #include "xlat/sock_netlink_options.h"
449 #include "xlat/sock_packet_options.h"
450 #include "xlat/sock_raw_options.h"
451 #include "xlat/sock_sctp_options.h"
452 #include "xlat/sock_tcp_options.h"
453 #include "xlat/sock_udp_options.h"
454 #include "xlat/sock_irda_options.h"
455 #include "xlat/sock_llc_options.h"
456 #include "xlat/sock_dccp_options.h"
457 #include "xlat/sock_tipc_options.h"
458 #include "xlat/sock_rxrpc_options.h"
459 #include "xlat/sock_pppol2tp_options.h"
460 #include "xlat/sock_bluetooth_options.h"
461 #include "xlat/sock_pnp_options.h"
462 #include "xlat/sock_rds_options.h"
463 #include "xlat/sock_iucv_options.h"
464 #include "xlat/sock_caif_options.h"
465 #include "xlat/sock_alg_options.h"
466 #include "xlat/sock_nfcllcp_options.h"
467 #include "xlat/sock_kcm_options.h"
468 #include "xlat/sock_tls_options.h"
469 #include "xlat/sock_xdp_options.h"
472 print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level,
473 unsigned int name, bool is_getsockopt)
477 printxval_search(socketlayers, level, "SOL_??");
482 printxvals(name, "SO_???", sock_options,
483 is_getsockopt ? getsock_options :
484 setsock_options, NULL);
487 printxvals(name, "IP_???", sock_ip_options,
488 is_getsockopt ? getsock_ip_options :
489 setsock_ip_options, NULL);
492 printxvals(name, "IPV6_???", sock_ipv6_options,
493 is_getsockopt ? getsock_ipv6_options :
494 setsock_ipv6_options, NULL);
497 printxval(sock_ipx_options, name, "IPX_???");
500 printxval(sock_packet_options, name, "PACKET_???");
503 printxval_index(sock_tcp_options, name, "TCP_???");
506 printxval(sock_sctp_options, name, "SCTP_???");
509 printxval(sock_raw_options, name, "RAW_???");
512 printxval(sock_netlink_options, name, "NETLINK_???");
515 printxval(sock_udp_options, name, "UDP_???");
518 printxval_index(sock_irda_options, name, "IRLMP_???");
521 printxval_index(sock_llc_options, name, "LLC_OPT_???");
524 printxval_search(sock_dccp_options, name, "DCCP_SOCKOPT_???");
527 printxval_search(sock_tipc_options, name, "TIPC_???");
530 printxval_index(sock_rxrpc_options, name, "RXRPC_???");
533 printxval_index(sock_pppol2tp_options, name, "PPPOL2TP_SO_???");
536 printxval_search(sock_bluetooth_options, name, "BT_???");
539 printxval(sock_pnp_options, name, "PNPIPE_???");
542 printxval_search(sock_rds_options, name, "RDS_???");
545 printxval(sock_iucv_options, name, "SO_???");
548 printxval(sock_caif_options, name, "CAIFSO_???");
551 printxval_index(sock_alg_options, name, "ALG_???");
554 printxval_index(sock_nfcllcp_options, name, "NFC_LLCP_???");
557 printxval(sock_kcm_options, name, "KCM_???");
560 printxval(sock_tls_options, name, "TLS_???");
563 printxval_index(sock_xdp_options, name, "XDP_???");
566 /* Other SOL_* protocol levels still need work. */
576 print_get_linger(struct tcb *const tcp, const kernel_ulong_t addr,
579 struct linger linger;
582 * The kernel cannot return len > sizeof(linger) because struct linger
583 * cannot change, but extra safety won't harm either.
585 if (len > sizeof(linger))
586 len = sizeof(linger);
587 if (umoven_or_printaddr(tcp, addr, len, &linger))
590 if (len < sizeof(linger.l_onoff)) {
591 tprints("{l_onoff=");
592 print_quoted_string((void *) &linger.l_onoff,
593 len, QUOTE_FORCE_HEX);
595 PRINT_FIELD_D("{", linger, l_onoff);
597 if (len > offsetof(struct linger, l_linger)) {
598 len -= offsetof(struct linger, l_linger);
599 if (len < sizeof(linger.l_linger)) {
600 tprints(", l_linger=");
601 print_quoted_string((void *) &linger.l_linger,
602 len, QUOTE_FORCE_HEX);
604 PRINT_FIELD_D(", ", linger, l_linger);
612 print_get_ucred(struct tcb *const tcp, const kernel_ulong_t addr,
618 * The kernel is very unlikely to return len > sizeof(uc)
619 * because struct ucred is very unlikely to change,
620 * but extra safety won't harm either.
622 if (len > sizeof(uc))
625 if (umoven_or_printaddr(tcp, addr, len, &uc))
628 if (len < sizeof(uc.pid)) {
630 print_quoted_string((void *) &uc.pid,
631 len, QUOTE_FORCE_HEX);
633 PRINT_FIELD_D("{", uc, pid);
635 if (len > offsetof(struct ucred, uid)) {
636 len -= offsetof(struct ucred, uid);
637 if (len < sizeof(uc.uid)) {
639 print_quoted_string((void *) &uc.uid,
640 len, QUOTE_FORCE_HEX);
642 PRINT_FIELD_UID(", ", uc, uid);
644 if (len > offsetof(struct ucred, gid) -
645 offsetof(struct ucred, uid)) {
646 len -= offsetof(struct ucred, gid) -
647 offsetof(struct ucred, uid);
648 if (len < sizeof(uc.gid)) {
650 print_quoted_string((void *) &uc.gid,
654 PRINT_FIELD_UID(", ", uc, gid);
663 #ifdef PACKET_STATISTICS
665 print_tpacket_stats(struct tcb *const tcp, const kernel_ulong_t addr,
669 unsigned int tp_packets, tp_drops, tp_freeze_q_cnt;
673 * The kernel may return len > sizeof(stats) if the kernel structure
674 * grew as it happened when tpacket_stats_v3 was introduced.
676 if (len > sizeof(stats))
679 if (umoven_or_printaddr(tcp, addr, len, &stats))
682 if (len < sizeof(stats.tp_packets)) {
683 tprints("{tp_packets=");
684 print_quoted_string((void *) &stats.tp_packets,
685 len, QUOTE_FORCE_HEX);
687 PRINT_FIELD_U("{", stats, tp_packets);
689 if (len > offsetof(struct tp_stats, tp_drops)) {
690 len -= offsetof(struct tp_stats, tp_drops);
691 if (len < sizeof(stats.tp_drops)) {
692 tprints(", tp_drops=");
693 print_quoted_string((void *) &stats.tp_drops,
694 len, QUOTE_FORCE_HEX);
696 PRINT_FIELD_U(", ", stats, tp_drops);
698 if (len > offsetof(struct tp_stats, tp_freeze_q_cnt) -
699 offsetof(struct tp_stats, tp_drops)) {
700 len -= offsetof(struct tp_stats, tp_freeze_q_cnt) -
701 offsetof(struct tp_stats, tp_drops);
702 if (len < sizeof(stats.tp_freeze_q_cnt)) {
703 tprints(", tp_freeze_q_cnt=");
704 print_quoted_string((void *) &stats.tp_freeze_q_cnt,
708 PRINT_FIELD_U(", ", stats, tp_freeze_q_cnt);
716 #endif /* PACKET_STATISTICS */
718 #include "xlat/icmpfilterflags.h"
721 print_icmp_filter(struct tcb *const tcp, const kernel_ulong_t addr, int len)
723 struct icmp_filter filter = {};
725 if (len > (int) sizeof(filter))
726 len = sizeof(filter);
732 if (umoven_or_printaddr(tcp, addr, len, &filter))
736 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
741 print_uint32(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
743 tprintf("%u", *(uint32_t *) elem_buf);
749 print_getsockopt(struct tcb *const tcp, const unsigned int level,
750 const unsigned int name, const kernel_ulong_t addr,
751 const int ulen, const int rlen)
753 if (ulen <= 0 || rlen <= 0) {
755 * As the kernel neither accepts nor returns a negative
756 * length in case of successful getsockopt syscall
757 * invocation, negative values must have been forged
764 if (addr && verbose(tcp))
769 print_get_linger(tcp, addr, rlen);
772 print_get_ucred(tcp, addr, rlen);
774 case SO_ATTACH_FILTER:
776 * The length returned by the kernel in case of
777 * successful getsockopt syscall invocation is struct
778 * sock_fprog.len that has type unsigned short,
779 * anything else must have been forged by userspace.
781 if ((unsigned short) rlen == (unsigned int) rlen)
782 print_sock_fprog(tcp, addr, rlen);
791 #ifdef PACKET_STATISTICS
792 case PACKET_STATISTICS:
793 print_tpacket_stats(tcp, addr, rlen);
802 print_icmp_filter(tcp, addr, rlen);
809 case NETLINK_LIST_MEMBERSHIPS: {
811 print_array(tcp, addr, MIN(ulen, rlen) / sizeof(buf),
813 tfetch_mem, print_uint32, 0);
817 printnum_int(tcp, addr, "%d");
823 /* default arg printing */
826 if (rlen == sizeof(int)) {
827 printnum_int(tcp, addr, "%d");
829 printstrn(tcp, addr, rlen);
841 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
842 tcp->u_arg[1], tcp->u_arg[2], true);
844 if (verbose(tcp) && tcp->u_arg[4]
845 && umove(tcp, tcp->u_arg[4], &ulen) == 0) {
846 set_tcb_priv_ulong(tcp, ulen);
849 printaddr(tcp->u_arg[3]);
851 printaddr(tcp->u_arg[4]);
855 ulen = get_tcb_priv_ulong(tcp);
857 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &rlen) < 0) {
858 printaddr(tcp->u_arg[3]);
859 tprintf(", [%d]", ulen);
861 print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
862 tcp->u_arg[3], ulen, rlen);
864 tprintf(", [%d->%d]", ulen, rlen);
866 tprintf(", [%d]", rlen);
873 print_set_linger(struct tcb *const tcp, const kernel_ulong_t addr,
876 struct linger linger;
878 if (len < (int) sizeof(linger)) {
880 } else if (!umove_or_printaddr(tcp, addr, &linger)) {
881 PRINT_FIELD_D("{", linger, l_onoff);
882 PRINT_FIELD_D(", ", linger, l_linger);
887 #ifdef IP_ADD_MEMBERSHIP
889 print_mreq(struct tcb *const tcp, const kernel_ulong_t addr,
894 if (len < (int) sizeof(mreq)) {
896 } else if (!umove_or_printaddr(tcp, addr, &mreq)) {
897 PRINT_FIELD_INET4_ADDR("{", mreq, imr_multiaddr);
898 PRINT_FIELD_INET4_ADDR(", ", mreq, imr_interface);
902 #endif /* IP_ADD_MEMBERSHIP */
904 #ifdef IPV6_ADD_MEMBERSHIP
906 print_mreq6(struct tcb *const tcp, const kernel_ulong_t addr,
909 struct ipv6_mreq mreq;
911 if (len < (int) sizeof(mreq)) {
913 } else if (!umove_or_printaddr(tcp, addr, &mreq)) {
914 PRINT_FIELD_INET_ADDR("{", mreq, ipv6mr_multiaddr, AF_INET6);
915 PRINT_FIELD_IFINDEX(", ", mreq, ipv6mr_interface);
919 #endif /* IPV6_ADD_MEMBERSHIP */
921 #ifdef PACKET_RX_RING
923 print_tpacket_req(struct tcb *const tcp, const kernel_ulong_t addr, const int len)
925 struct tpacket_req req;
927 if (len != sizeof(req) ||
928 umove(tcp, addr, &req) < 0) {
931 PRINT_FIELD_U("{", req, tp_block_size);
932 PRINT_FIELD_U(", ", req, tp_block_nr);
933 PRINT_FIELD_U(", ", req, tp_frame_size);
934 PRINT_FIELD_U(", ", req, tp_frame_nr);
938 #endif /* PACKET_RX_RING */
940 #ifdef PACKET_ADD_MEMBERSHIP
941 # include "xlat/packet_mreq_type.h"
944 print_packet_mreq(struct tcb *const tcp, const kernel_ulong_t addr, const int len)
946 struct packet_mreq mreq;
948 if (len != sizeof(mreq) ||
949 umove(tcp, addr, &mreq) < 0) {
954 PRINT_FIELD_IFINDEX("{", mreq, mr_ifindex);
955 PRINT_FIELD_XVAL(", ", mreq, mr_type, packet_mreq_type,
957 PRINT_FIELD_U(", ", mreq, mr_alen);
958 tprints(", mr_address=");
959 if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address))
960 mreq.mr_alen = ARRAY_SIZE(mreq.mr_address);
961 for (i = 0; i < mreq.mr_alen; ++i)
962 tprintf("%02x", mreq.mr_address[i]);
966 #endif /* PACKET_ADD_MEMBERSHIP */
969 print_setsockopt(struct tcb *const tcp, const unsigned int level,
970 const unsigned int name, const kernel_ulong_t addr,
973 if (addr && verbose(tcp))
978 print_set_linger(tcp, addr, len);
980 case SO_ATTACH_FILTER:
981 case SO_ATTACH_REUSEPORT_CBPF:
982 if ((unsigned int) len == get_sock_fprog_size())
983 decode_sock_fprog(tcp, addr);
992 #ifdef IP_ADD_MEMBERSHIP
993 case IP_ADD_MEMBERSHIP:
994 case IP_DROP_MEMBERSHIP:
995 print_mreq(tcp, addr, len);
997 #endif /* IP_ADD_MEMBERSHIP */
998 #ifdef MCAST_JOIN_GROUP
999 case MCAST_JOIN_GROUP:
1000 case MCAST_LEAVE_GROUP:
1001 print_group_req(tcp, addr, len);
1003 #endif /* MCAST_JOIN_GROUP */
1009 #ifdef IPV6_ADD_MEMBERSHIP
1010 case IPV6_ADD_MEMBERSHIP:
1011 case IPV6_DROP_MEMBERSHIP:
1012 # ifdef IPV6_JOIN_ANYCAST
1013 case IPV6_JOIN_ANYCAST:
1015 # ifdef IPV6_LEAVE_ANYCAST
1016 case IPV6_LEAVE_ANYCAST:
1018 print_mreq6(tcp, addr, len);
1020 #endif /* IPV6_ADD_MEMBERSHIP */
1021 #ifdef MCAST_JOIN_GROUP
1022 case MCAST_JOIN_GROUP:
1023 case MCAST_LEAVE_GROUP:
1024 print_group_req(tcp, addr, len);
1026 #endif /* MCAST_JOIN_GROUP */
1032 #ifdef PACKET_RX_RING
1033 case PACKET_RX_RING:
1034 # ifdef PACKET_TX_RING
1035 case PACKET_TX_RING:
1037 print_tpacket_req(tcp, addr, len);
1039 #endif /* PACKET_RX_RING */
1040 #ifdef PACKET_ADD_MEMBERSHIP
1041 case PACKET_ADD_MEMBERSHIP:
1042 case PACKET_DROP_MEMBERSHIP:
1043 print_packet_mreq(tcp, addr, len);
1045 #endif /* PACKET_ADD_MEMBERSHIP */
1052 print_icmp_filter(tcp, addr, len);
1058 if (len < (int) sizeof(int))
1061 printnum_int(tcp, addr, "%d");
1065 /* default arg printing */
1068 if (len == sizeof(int)) {
1069 printnum_int(tcp, addr, "%d");
1071 printstrn(tcp, addr, len);
1078 SYS_FUNC(setsockopt)
1080 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1081 tcp->u_arg[1], tcp->u_arg[2], false);
1082 print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1083 tcp->u_arg[3], tcp->u_arg[4]);
1084 tprintf(", %d", (int) tcp->u_arg[4]);
1086 return RVAL_DECODED;