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"
463 print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level,
464 unsigned int name, bool is_getsockopt)
468 printxval_search(socketlayers, level, "SOL_??");
473 printxvals(name, "SO_???", sock_options,
474 is_getsockopt ? getsock_options :
475 setsock_options, NULL);
478 printxvals(name, "IP_???", sock_ip_options,
479 is_getsockopt ? getsock_ip_options :
480 setsock_ip_options, NULL);
483 printxvals(name, "IPV6_???", sock_ipv6_options,
484 is_getsockopt ? getsock_ipv6_options :
485 setsock_ipv6_options, NULL);
488 printxval(sock_ipx_options, name, "IPX_???");
491 printxval(sock_packet_options, name, "PACKET_???");
494 printxval_index(sock_tcp_options, name, "TCP_???");
497 printxval(sock_sctp_options, name, "SCTP_???");
500 printxval(sock_raw_options, name, "RAW_???");
503 printxval(sock_netlink_options, name, "NETLINK_???");
506 printxval(sock_udp_options, name, "UDP_???");
509 printxval_index(sock_irda_options, name, "IRLMP_???");
512 printxval_index(sock_llc_options, name, "LLC_OPT_???");
515 printxval_search(sock_dccp_options, name, "DCCP_SOCKOPT_???");
518 printxval_search(sock_tipc_options, name, "TIPC_???");
521 printxval_index(sock_rxrpc_options, name, "RXRPC_???");
524 printxval_index(sock_pppol2tp_options, name, "PPPOL2TP_SO_???");
527 printxval_search(sock_bluetooth_options, name, "BT_???");
530 printxval(sock_pnp_options, name, "PNPIPE_???");
533 printxval_search(sock_rds_options, name, "RDS_???");
536 printxval(sock_iucv_options, name, "SO_???");
539 printxval(sock_caif_options, name, "CAIFSO_???");
542 printxval_index(sock_alg_options, name, "ALG_???");
545 printxval_index(sock_nfcllcp_options, name, "NFC_LLCP_???");
548 printxval(sock_kcm_options, name, "KCM_???");
551 printxval(sock_tls_options, name, "TLS_???");
554 /* Other SOL_* protocol levels still need work. */
564 print_get_linger(struct tcb *const tcp, const kernel_ulong_t addr,
567 struct linger linger;
570 * The kernel cannot return len > sizeof(linger) because struct linger
571 * cannot change, but extra safety won't harm either.
573 if (len > sizeof(linger))
574 len = sizeof(linger);
575 if (umoven_or_printaddr(tcp, addr, len, &linger))
578 if (len < sizeof(linger.l_onoff)) {
579 tprints("{l_onoff=");
580 print_quoted_string((void *) &linger.l_onoff,
581 len, QUOTE_FORCE_HEX);
583 PRINT_FIELD_D("{", linger, l_onoff);
585 if (len > offsetof(struct linger, l_linger)) {
586 len -= offsetof(struct linger, l_linger);
587 if (len < sizeof(linger.l_linger)) {
588 tprints(", l_linger=");
589 print_quoted_string((void *) &linger.l_linger,
590 len, QUOTE_FORCE_HEX);
592 PRINT_FIELD_D(", ", linger, l_linger);
600 print_get_ucred(struct tcb *const tcp, const kernel_ulong_t addr,
606 * The kernel is very unlikely to return len > sizeof(uc)
607 * because struct ucred is very unlikely to change,
608 * but extra safety won't harm either.
610 if (len > sizeof(uc))
613 if (umoven_or_printaddr(tcp, addr, len, &uc))
616 if (len < sizeof(uc.pid)) {
618 print_quoted_string((void *) &uc.pid,
619 len, QUOTE_FORCE_HEX);
621 PRINT_FIELD_D("{", uc, pid);
623 if (len > offsetof(struct ucred, uid)) {
624 len -= offsetof(struct ucred, uid);
625 if (len < sizeof(uc.uid)) {
627 print_quoted_string((void *) &uc.uid,
628 len, QUOTE_FORCE_HEX);
630 PRINT_FIELD_UID(", ", uc, uid);
632 if (len > offsetof(struct ucred, gid) -
633 offsetof(struct ucred, uid)) {
634 len -= offsetof(struct ucred, gid) -
635 offsetof(struct ucred, uid);
636 if (len < sizeof(uc.gid)) {
638 print_quoted_string((void *) &uc.gid,
642 PRINT_FIELD_UID(", ", uc, gid);
651 #ifdef PACKET_STATISTICS
653 print_tpacket_stats(struct tcb *const tcp, const kernel_ulong_t addr,
657 unsigned int tp_packets, tp_drops, tp_freeze_q_cnt;
661 * The kernel may return len > sizeof(stats) if the kernel structure
662 * grew as it happened when tpacket_stats_v3 was introduced.
664 if (len > sizeof(stats))
667 if (umoven_or_printaddr(tcp, addr, len, &stats))
670 if (len < sizeof(stats.tp_packets)) {
671 tprints("{tp_packets=");
672 print_quoted_string((void *) &stats.tp_packets,
673 len, QUOTE_FORCE_HEX);
675 PRINT_FIELD_U("{", stats, tp_packets);
677 if (len > offsetof(struct tp_stats, tp_drops)) {
678 len -= offsetof(struct tp_stats, tp_drops);
679 if (len < sizeof(stats.tp_drops)) {
680 tprints(", tp_drops=");
681 print_quoted_string((void *) &stats.tp_drops,
682 len, QUOTE_FORCE_HEX);
684 PRINT_FIELD_U(", ", stats, tp_drops);
686 if (len > offsetof(struct tp_stats, tp_freeze_q_cnt) -
687 offsetof(struct tp_stats, tp_drops)) {
688 len -= offsetof(struct tp_stats, tp_freeze_q_cnt) -
689 offsetof(struct tp_stats, tp_drops);
690 if (len < sizeof(stats.tp_freeze_q_cnt)) {
691 tprints(", tp_freeze_q_cnt=");
692 print_quoted_string((void *) &stats.tp_freeze_q_cnt,
696 PRINT_FIELD_U(", ", stats, tp_freeze_q_cnt);
704 #endif /* PACKET_STATISTICS */
706 #include "xlat/icmpfilterflags.h"
709 print_icmp_filter(struct tcb *const tcp, const kernel_ulong_t addr, int len)
711 struct icmp_filter filter = {};
713 if (len > (int) sizeof(filter))
714 len = sizeof(filter);
720 if (umoven_or_printaddr(tcp, addr, len, &filter))
724 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
729 print_uint32(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
731 tprintf("%u", *(uint32_t *) elem_buf);
737 print_getsockopt(struct tcb *const tcp, const unsigned int level,
738 const unsigned int name, const kernel_ulong_t addr,
739 const int ulen, const int rlen)
741 if (ulen <= 0 || rlen <= 0) {
743 * As the kernel neither accepts nor returns a negative
744 * length in case of successful getsockopt syscall
745 * invocation, negative values must have been forged
752 if (addr && verbose(tcp))
757 print_get_linger(tcp, addr, rlen);
760 print_get_ucred(tcp, addr, rlen);
762 case SO_ATTACH_FILTER:
764 * The length returned by the kernel in case of
765 * successful getsockopt syscall invocation is struct
766 * sock_fprog.len that has type unsigned short,
767 * anything else must have been forged by userspace.
769 if ((unsigned short) rlen == (unsigned int) rlen)
770 print_sock_fprog(tcp, addr, rlen);
779 #ifdef PACKET_STATISTICS
780 case PACKET_STATISTICS:
781 print_tpacket_stats(tcp, addr, rlen);
790 print_icmp_filter(tcp, addr, rlen);
797 case NETLINK_LIST_MEMBERSHIPS: {
799 print_array(tcp, addr, MIN(ulen, rlen) / sizeof(buf),
801 tfetch_mem, print_uint32, 0);
805 printnum_int(tcp, addr, "%d");
811 /* default arg printing */
814 if (rlen == sizeof(int)) {
815 printnum_int(tcp, addr, "%d");
817 printstrn(tcp, addr, rlen);
829 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
830 tcp->u_arg[1], tcp->u_arg[2], true);
832 if (verbose(tcp) && tcp->u_arg[4]
833 && umove(tcp, tcp->u_arg[4], &ulen) == 0) {
834 set_tcb_priv_ulong(tcp, ulen);
837 printaddr(tcp->u_arg[3]);
839 printaddr(tcp->u_arg[4]);
843 ulen = get_tcb_priv_ulong(tcp);
845 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &rlen) < 0) {
846 printaddr(tcp->u_arg[3]);
847 tprintf(", [%d]", ulen);
849 print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
850 tcp->u_arg[3], ulen, rlen);
852 tprintf(", [%d->%d]", ulen, rlen);
854 tprintf(", [%d]", rlen);
861 print_set_linger(struct tcb *const tcp, const kernel_ulong_t addr,
864 struct linger linger;
866 if (len < (int) sizeof(linger)) {
868 } else if (!umove_or_printaddr(tcp, addr, &linger)) {
869 PRINT_FIELD_D("{", linger, l_onoff);
870 PRINT_FIELD_D(", ", linger, l_linger);
875 #ifdef IP_ADD_MEMBERSHIP
877 print_mreq(struct tcb *const tcp, const kernel_ulong_t addr,
882 if (len < (int) sizeof(mreq)) {
884 } else if (!umove_or_printaddr(tcp, addr, &mreq)) {
885 PRINT_FIELD_INET4_ADDR("{", mreq, imr_multiaddr);
886 PRINT_FIELD_INET4_ADDR(", ", mreq, imr_interface);
890 #endif /* IP_ADD_MEMBERSHIP */
892 #ifdef IPV6_ADD_MEMBERSHIP
894 print_mreq6(struct tcb *const tcp, const kernel_ulong_t addr,
897 struct ipv6_mreq mreq;
899 if (len < (int) sizeof(mreq)) {
901 } else if (!umove_or_printaddr(tcp, addr, &mreq)) {
902 PRINT_FIELD_INET_ADDR("{", mreq, ipv6mr_multiaddr, AF_INET6);
903 PRINT_FIELD_IFINDEX(", ", mreq, ipv6mr_interface);
907 #endif /* IPV6_ADD_MEMBERSHIP */
909 #ifdef PACKET_RX_RING
911 print_tpacket_req(struct tcb *const tcp, const kernel_ulong_t addr, const int len)
913 struct tpacket_req req;
915 if (len != sizeof(req) ||
916 umove(tcp, addr, &req) < 0) {
919 PRINT_FIELD_U("{", req, tp_block_size);
920 PRINT_FIELD_U(", ", req, tp_block_nr);
921 PRINT_FIELD_U(", ", req, tp_frame_size);
922 PRINT_FIELD_U(", ", req, tp_frame_nr);
926 #endif /* PACKET_RX_RING */
928 #ifdef PACKET_ADD_MEMBERSHIP
929 # include "xlat/packet_mreq_type.h"
932 print_packet_mreq(struct tcb *const tcp, const kernel_ulong_t addr, const int len)
934 struct packet_mreq mreq;
936 if (len != sizeof(mreq) ||
937 umove(tcp, addr, &mreq) < 0) {
942 PRINT_FIELD_IFINDEX("{", mreq, mr_ifindex);
943 PRINT_FIELD_XVAL(", ", mreq, mr_type, packet_mreq_type,
945 PRINT_FIELD_U(", ", mreq, mr_alen);
946 tprints(", mr_address=");
947 if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address))
948 mreq.mr_alen = ARRAY_SIZE(mreq.mr_address);
949 for (i = 0; i < mreq.mr_alen; ++i)
950 tprintf("%02x", mreq.mr_address[i]);
954 #endif /* PACKET_ADD_MEMBERSHIP */
957 print_setsockopt(struct tcb *const tcp, const unsigned int level,
958 const unsigned int name, const kernel_ulong_t addr,
961 if (addr && verbose(tcp))
966 print_set_linger(tcp, addr, len);
968 case SO_ATTACH_FILTER:
969 case SO_ATTACH_REUSEPORT_CBPF:
970 if ((unsigned int) len == get_sock_fprog_size())
971 decode_sock_fprog(tcp, addr);
980 #ifdef IP_ADD_MEMBERSHIP
981 case IP_ADD_MEMBERSHIP:
982 case IP_DROP_MEMBERSHIP:
983 print_mreq(tcp, addr, len);
985 #endif /* IP_ADD_MEMBERSHIP */
986 #ifdef MCAST_JOIN_GROUP
987 case MCAST_JOIN_GROUP:
988 case MCAST_LEAVE_GROUP:
989 print_group_req(tcp, addr, len);
991 #endif /* MCAST_JOIN_GROUP */
997 #ifdef IPV6_ADD_MEMBERSHIP
998 case IPV6_ADD_MEMBERSHIP:
999 case IPV6_DROP_MEMBERSHIP:
1000 # ifdef IPV6_JOIN_ANYCAST
1001 case IPV6_JOIN_ANYCAST:
1003 # ifdef IPV6_LEAVE_ANYCAST
1004 case IPV6_LEAVE_ANYCAST:
1006 print_mreq6(tcp, addr, len);
1008 #endif /* IPV6_ADD_MEMBERSHIP */
1009 #ifdef MCAST_JOIN_GROUP
1010 case MCAST_JOIN_GROUP:
1011 case MCAST_LEAVE_GROUP:
1012 print_group_req(tcp, addr, len);
1014 #endif /* MCAST_JOIN_GROUP */
1020 #ifdef PACKET_RX_RING
1021 case PACKET_RX_RING:
1022 # ifdef PACKET_TX_RING
1023 case PACKET_TX_RING:
1025 print_tpacket_req(tcp, addr, len);
1027 #endif /* PACKET_RX_RING */
1028 #ifdef PACKET_ADD_MEMBERSHIP
1029 case PACKET_ADD_MEMBERSHIP:
1030 case PACKET_DROP_MEMBERSHIP:
1031 print_packet_mreq(tcp, addr, len);
1033 #endif /* PACKET_ADD_MEMBERSHIP */
1040 print_icmp_filter(tcp, addr, len);
1046 if (len < (int) sizeof(int))
1049 printnum_int(tcp, addr, "%d");
1053 /* default arg printing */
1056 if (len == sizeof(int)) {
1057 printnum_int(tcp, addr, "%d");
1059 printstrn(tcp, addr, len);
1066 SYS_FUNC(setsockopt)
1068 print_sockopt_fd_level_name(tcp, tcp->u_arg[0],
1069 tcp->u_arg[1], tcp->u_arg[2], false);
1070 print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
1071 tcp->u_arg[3], tcp->u_arg[4]);
1072 tprintf(", %d", (int) tcp->u_arg[4]);
1074 return RVAL_DECODED;