Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 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> |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 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. |
| 18 | * |
| 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. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "defs.h" |
Dmitry V. Levin | 4b38ce9 | 2016-06-27 00:02:41 +0000 | [diff] [blame] | 32 | #include "msghdr.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 33 | #include <sys/stat.h> |
| 34 | #include <sys/socket.h> |
Dmitry V. Levin | b2fa2be | 2014-11-21 20:46:16 +0000 | [diff] [blame] | 35 | #include <sys/uio.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 36 | #include <sys/un.h> |
| 37 | #include <netinet/in.h> |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 38 | #ifdef HAVE_NETINET_TCP_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 39 | # include <netinet/tcp.h> |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 40 | #endif |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 41 | #ifdef HAVE_NETINET_UDP_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 42 | # include <netinet/udp.h> |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 43 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 44 | #ifdef HAVE_NETINET_SCTP_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 45 | # include <netinet/sctp.h> |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 46 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | #include <arpa/inet.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 48 | #include <net/if.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | #include <asm/types.h> |
Dmitry V. Levin | ebda41a | 2016-06-19 22:02:45 +0000 | [diff] [blame] | 50 | #ifdef HAVE_NETIPX_IPX_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 51 | # include <netipx/ipx.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | #else |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 53 | # include <linux/ipx.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 54 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 56 | #if defined(HAVE_LINUX_IP_VS_H) |
| 57 | # include <linux/ip_vs.h> |
| 58 | #endif |
Dmitry V. Levin | b10ee4e | 2016-06-14 13:53:47 +0000 | [diff] [blame] | 59 | #include <linux/netlink.h> |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 60 | #if defined(HAVE_LINUX_NETFILTER_ARP_ARP_TABLES_H) |
| 61 | # include <linux/netfilter_arp/arp_tables.h> |
| 62 | #endif |
| 63 | #if defined(HAVE_LINUX_NETFILTER_BRIDGE_EBTABLES_H) |
| 64 | # include <linux/netfilter_bridge/ebtables.h> |
| 65 | #endif |
| 66 | #if defined(HAVE_LINUX_NETFILTER_IPV4_IP_TABLES_H) |
| 67 | # include <linux/netfilter_ipv4/ip_tables.h> |
| 68 | #endif |
| 69 | #if defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H) |
| 70 | # include <linux/netfilter_ipv6/ip6_tables.h> |
| 71 | #endif |
Dmitry V. Levin | 4f689a1 | 2016-06-15 21:35:48 +0000 | [diff] [blame] | 72 | #include <linux/if_packet.h> |
Dmitry V. Levin | d06010b | 2016-06-15 21:27:41 +0000 | [diff] [blame] | 73 | #include <linux/icmp.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 74 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 75 | #include "xlat/socktypes.h" |
| 76 | #include "xlat/sock_type_flags.h" |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 77 | #ifndef SOCK_TYPE_MASK |
| 78 | # define SOCK_TYPE_MASK 0xf |
| 79 | #endif |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 80 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 81 | #include "xlat/socketlayers.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 82 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 83 | #include "xlat/inet_protocols.h" |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 84 | |
Dmitry V. Levin | 9457304 | 2016-06-14 13:53:47 +0000 | [diff] [blame] | 85 | #if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG |
| 86 | # define NETLINK_SOCK_DIAG NETLINK_INET_DIAG |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 87 | #endif |
Dmitry V. Levin | 9457304 | 2016-06-14 13:53:47 +0000 | [diff] [blame] | 88 | #include "xlat/netlink_protocols.h" |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 89 | |
Dmitry V. Levin | e96aee7 | 2016-06-25 13:47:54 +0000 | [diff] [blame] | 90 | #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
| 91 | # include <bluetooth/bluetooth.h> |
Lubomir Rintel | c400a1c | 2014-10-03 11:40:28 +0200 | [diff] [blame] | 92 | # include "xlat/bt_protocols.h" |
| 93 | #endif |
| 94 | |
Dmitry V. Levin | 45ae937 | 2016-06-23 17:38:18 +0000 | [diff] [blame] | 95 | void |
Dmitry V. Levin | ae28093 | 2015-06-05 20:13:21 +0000 | [diff] [blame] | 96 | print_ifindex(unsigned int ifindex) |
| 97 | { |
| 98 | #ifdef HAVE_IF_INDEXTONAME |
| 99 | char buf[IFNAMSIZ + 1]; |
| 100 | |
| 101 | if (if_indextoname(ifindex, buf)) { |
| 102 | tprints("if_nametoindex("); |
| 103 | print_quoted_string(buf, sizeof(buf), QUOTE_0_TERMINATED); |
| 104 | tprints(")"); |
| 105 | return; |
| 106 | } |
| 107 | #endif |
| 108 | tprintf("%u", ifindex); |
| 109 | } |
| 110 | |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 111 | static void |
| 112 | decode_sockbuf(struct tcb *tcp, int fd, long addr, long addrlen) |
| 113 | { |
| 114 | |
| 115 | switch (verbose(tcp) ? getfdproto(tcp, fd) : SOCK_PROTO_UNKNOWN) { |
| 116 | case SOCK_PROTO_NETLINK: |
| 117 | decode_netlink(tcp, addr, addrlen); |
| 118 | break; |
| 119 | default: |
| 120 | printstr(tcp, addr, addrlen); |
| 121 | } |
| 122 | } |
| 123 | |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 124 | /* |
| 125 | * low bits of the socket type define real socket type, |
| 126 | * other bits are socket type flags. |
| 127 | */ |
| 128 | static void |
Dmitry V. Levin | 9134aab | 2016-05-14 21:46:05 +0000 | [diff] [blame] | 129 | tprint_sock_type(unsigned int flags) |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 130 | { |
| 131 | const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK); |
| 132 | |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 133 | if (str) { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 134 | tprints(str); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 135 | flags &= ~SOCK_TYPE_MASK; |
| 136 | if (!flags) |
| 137 | return; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 138 | tprints("|"); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 139 | } |
| 140 | printflags(sock_type_flags, flags, "SOCK_???"); |
| 141 | } |
| 142 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 143 | SYS_FUNC(socket) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 144 | { |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 145 | printxval(addrfams, tcp->u_arg[0], "AF_???"); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 146 | tprints(", "); |
| 147 | tprint_sock_type(tcp->u_arg[1]); |
| 148 | tprints(", "); |
| 149 | switch (tcp->u_arg[0]) { |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 150 | case AF_INET: |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 151 | case AF_INET6: |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 152 | printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 153 | break; |
Dmitry V. Levin | eb1c22b | 2016-06-19 22:02:45 +0000 | [diff] [blame] | 154 | |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 155 | case AF_NETLINK: |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 156 | printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???"); |
| 157 | break; |
Dmitry V. Levin | bc4102e | 2016-06-19 22:02:45 +0000 | [diff] [blame] | 158 | |
Dmitry V. Levin | 43369fc | 2016-06-21 16:43:30 +0000 | [diff] [blame] | 159 | #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 160 | case AF_BLUETOOTH: |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 161 | printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???"); |
| 162 | break; |
Lubomir Rintel | c400a1c | 2014-10-03 11:40:28 +0200 | [diff] [blame] | 163 | #endif |
Dmitry V. Levin | bc4102e | 2016-06-19 22:02:45 +0000 | [diff] [blame] | 164 | |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 165 | default: |
| 166 | tprintf("%lu", tcp->u_arg[2]); |
| 167 | break; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 168 | } |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 169 | |
Dmitry V. Levin | 3d463be | 2015-08-02 01:41:26 +0000 | [diff] [blame] | 170 | return RVAL_DECODED | RVAL_FD; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 173 | SYS_FUNC(bind) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 175 | printfd(tcp, tcp->u_arg[0]); |
| 176 | tprints(", "); |
Dmitry V. Levin | 42e566a | 2016-06-25 11:31:48 +0000 | [diff] [blame] | 177 | decode_sockaddr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 178 | tprintf(", %lu", tcp->u_arg[2]); |
| 179 | |
| 180 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 183 | SYS_FUNC(listen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 184 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 185 | printfd(tcp, tcp->u_arg[0]); |
| 186 | tprints(", "); |
| 187 | tprintf("%lu", tcp->u_arg[1]); |
| 188 | |
| 189 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 192 | static int |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 193 | do_sockname(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 194 | { |
| 195 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 196 | printfd(tcp, tcp->u_arg[0]); |
| 197 | tprints(", "); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 198 | return 0; |
| 199 | } |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 200 | |
| 201 | int len; |
| 202 | if (!tcp->u_arg[2] || !verbose(tcp) || syserror(tcp) || |
| 203 | umove(tcp, tcp->u_arg[2], &len) < 0) { |
| 204 | printaddr(tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 205 | tprints(", "); |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 206 | printaddr(tcp->u_arg[2]); |
| 207 | } else { |
Dmitry V. Levin | 42e566a | 2016-06-25 11:31:48 +0000 | [diff] [blame] | 208 | decode_sockaddr(tcp, tcp->u_arg[1], len); |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 209 | tprintf(", [%d]", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 210 | } |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 211 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 212 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 213 | tprints(", "); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 214 | printflags(sock_type_flags, tcp->u_arg[flags_arg], |
| 215 | "SOCK_???"); |
| 216 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 217 | return 0; |
| 218 | } |
| 219 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 220 | SYS_FUNC(accept) |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 221 | { |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 222 | do_sockname(tcp, -1); |
| 223 | return RVAL_FD; |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 224 | } |
| 225 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 226 | SYS_FUNC(accept4) |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 227 | { |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 228 | do_sockname(tcp, 3); |
| 229 | return RVAL_FD; |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 230 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 231 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 232 | SYS_FUNC(send) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 233 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 234 | printfd(tcp, tcp->u_arg[0]); |
| 235 | tprints(", "); |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 236 | decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 237 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 238 | /* flags */ |
| 239 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 240 | |
| 241 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 242 | } |
| 243 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 244 | SYS_FUNC(sendto) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 245 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 246 | printfd(tcp, tcp->u_arg[0]); |
| 247 | tprints(", "); |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 248 | decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 249 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 250 | /* flags */ |
| 251 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 252 | /* to address */ |
| 253 | tprints(", "); |
Dmitry V. Levin | 42e566a | 2016-06-25 11:31:48 +0000 | [diff] [blame] | 254 | decode_sockaddr(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 255 | /* to length */ |
| 256 | tprintf(", %lu", tcp->u_arg[5]); |
| 257 | |
| 258 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 259 | } |
| 260 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 261 | SYS_FUNC(sendmsg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 262 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 263 | printfd(tcp, tcp->u_arg[0]); |
| 264 | tprints(", "); |
Dmitry V. Levin | 3e514c0 | 2016-06-26 23:57:29 +0000 | [diff] [blame] | 265 | decode_msghdr(tcp, tcp->u_arg[1], (unsigned long) -1L); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 266 | /* flags */ |
| 267 | tprints(", "); |
| 268 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
| 269 | |
| 270 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 271 | } |
| 272 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 273 | SYS_FUNC(sendmmsg) |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 274 | { |
| 275 | if (entering(tcp)) { |
| 276 | /* sockfd */ |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 277 | printfd(tcp, tcp->u_arg[0]); |
| 278 | tprints(", "); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 279 | if (!verbose(tcp)) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 280 | printaddr(tcp->u_arg[1]); |
Dmitry V. Levin | 9a8216e | 2016-06-27 00:02:50 +0000 | [diff] [blame] | 281 | /* vlen */ |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 282 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
Dmitry V. Levin | 9a8216e | 2016-06-27 00:02:50 +0000 | [diff] [blame] | 283 | /* flags */ |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 284 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Dmitry V. Levin | 9a8216e | 2016-06-27 00:02:50 +0000 | [diff] [blame] | 285 | return RVAL_DECODED; |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 286 | } |
| 287 | } else { |
Dmitry V. Levin | 9a8216e | 2016-06-27 00:02:50 +0000 | [diff] [blame] | 288 | decode_mmsgvec(tcp, tcp->u_arg[1], tcp->u_rval, false); |
| 289 | /* vlen */ |
| 290 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
| 291 | /* flags */ |
| 292 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 293 | } |
| 294 | return 0; |
| 295 | } |
| 296 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 297 | SYS_FUNC(recv) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 298 | { |
| 299 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 300 | printfd(tcp, tcp->u_arg[0]); |
| 301 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 302 | } else { |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 303 | if (syserror(tcp)) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 304 | printaddr(tcp->u_arg[1]); |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 305 | } else { |
| 306 | decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], |
| 307 | tcp->u_rval); |
| 308 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 309 | |
| 310 | tprintf(", %lu, ", tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 311 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 312 | } |
| 313 | return 0; |
| 314 | } |
| 315 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 316 | SYS_FUNC(recvfrom) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | { |
| 318 | int fromlen; |
| 319 | |
| 320 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 321 | printfd(tcp, tcp->u_arg[0]); |
| 322 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 323 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 324 | /* buf */ |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 325 | if (syserror(tcp)) { |
Dmitry V. Levin | 52dc150 | 2015-07-30 13:53:42 +0000 | [diff] [blame] | 326 | printaddr(tcp->u_arg[1]); |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 327 | } else { |
Fabien Siron | 2850f74 | 2016-07-06 15:49:22 +0000 | [diff] [blame] | 328 | decode_sockbuf(tcp, tcp->u_arg[0], tcp->u_arg[1], |
| 329 | tcp->u_rval); |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 330 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 331 | /* len */ |
| 332 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 333 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 334 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 335 | tprints(", "); |
Dmitry V. Levin | 52dc150 | 2015-07-30 13:53:42 +0000 | [diff] [blame] | 336 | if (syserror(tcp) || !tcp->u_arg[4] || !tcp->u_arg[5] || |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 337 | umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 338 | /* from address, len */ |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 339 | printaddr(tcp->u_arg[4]); |
| 340 | tprints(", "); |
| 341 | printaddr(tcp->u_arg[5]); |
| 342 | return 0; |
| 343 | } |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 344 | /* from address */ |
Dmitry V. Levin | 42e566a | 2016-06-25 11:31:48 +0000 | [diff] [blame] | 345 | decode_sockaddr(tcp, tcp->u_arg[4], fromlen); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 346 | /* from length */ |
| 347 | tprintf(", [%u]", fromlen); |
| 348 | } |
| 349 | return 0; |
| 350 | } |
| 351 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 352 | SYS_FUNC(recvmsg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 353 | { |
| 354 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 355 | printfd(tcp, tcp->u_arg[0]); |
| 356 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 357 | } else { |
Dmitry V. Levin | 00244b9 | 2015-01-28 01:52:25 +0000 | [diff] [blame] | 358 | if (syserror(tcp)) |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 359 | printaddr(tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 360 | else |
Dmitry V. Levin | 3e514c0 | 2016-06-26 23:57:29 +0000 | [diff] [blame] | 361 | decode_msghdr(tcp, tcp->u_arg[1], tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 362 | /* flags */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 363 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 364 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 365 | } |
| 366 | return 0; |
| 367 | } |
| 368 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 369 | SYS_FUNC(recvmmsg) |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 370 | { |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 371 | static char str[sizeof("left") + TIMESPEC_TEXT_BUFSIZE]; |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 372 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 373 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 374 | printfd(tcp, tcp->u_arg[0]); |
| 375 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 376 | if (verbose(tcp)) { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 377 | /* Abusing tcp->auxstr as temp storage. |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 378 | * Will be used and cleared on syscall exit. |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 379 | */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 380 | tcp->auxstr = sprint_timespec(tcp, tcp->u_arg[4]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 381 | } else { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 382 | printaddr(tcp->u_arg[1]); |
Dmitry V. Levin | 9a8216e | 2016-06-27 00:02:50 +0000 | [diff] [blame] | 383 | /* vlen */ |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 384 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
Dmitry V. Levin | 9a8216e | 2016-06-27 00:02:50 +0000 | [diff] [blame] | 385 | /* flags */ |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 386 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 387 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 388 | print_timespec(tcp, tcp->u_arg[4]); |
| 389 | } |
| 390 | return 0; |
| 391 | } else { |
| 392 | if (verbose(tcp)) { |
Dmitry V. Levin | 9a8216e | 2016-06-27 00:02:50 +0000 | [diff] [blame] | 393 | decode_mmsgvec(tcp, tcp->u_arg[1], tcp->u_rval, true); |
| 394 | /* vlen */ |
| 395 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
| 396 | /* flags */ |
| 397 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 398 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 399 | /* timeout on entrance */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 400 | tprints(tcp->auxstr); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 401 | tcp->auxstr = NULL; |
| 402 | } |
| 403 | if (syserror(tcp)) |
| 404 | return 0; |
| 405 | if (tcp->u_rval == 0) { |
| 406 | tcp->auxstr = "Timeout"; |
| 407 | return RVAL_STR; |
| 408 | } |
| 409 | if (!verbose(tcp)) |
| 410 | return 0; |
| 411 | /* timeout on exit */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 412 | snprintf(str, sizeof(str), "left %s", |
| 413 | sprint_timespec(tcp, tcp->u_arg[4])); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 414 | tcp->auxstr = str; |
| 415 | return RVAL_STR; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 416 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 417 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 418 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 419 | #include "xlat/shutdown_modes.h" |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 420 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 421 | SYS_FUNC(shutdown) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 422 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 423 | printfd(tcp, tcp->u_arg[0]); |
| 424 | tprints(", "); |
| 425 | printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???"); |
| 426 | |
| 427 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 428 | } |
| 429 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 430 | SYS_FUNC(getsockname) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 431 | { |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 432 | return do_sockname(tcp, -1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 433 | } |
| 434 | |
Dmitry V. Levin | 2a4f052 | 2015-08-02 01:54:48 +0000 | [diff] [blame] | 435 | static void |
| 436 | printpair_fd(struct tcb *tcp, const int i0, const int i1) |
| 437 | { |
| 438 | tprints("["); |
| 439 | printfd(tcp, i0); |
| 440 | tprints(", "); |
| 441 | printfd(tcp, i1); |
| 442 | tprints("]"); |
| 443 | } |
| 444 | |
| 445 | static void |
| 446 | decode_pair_fd(struct tcb *tcp, const long addr) |
| 447 | { |
| 448 | int pair[2]; |
| 449 | |
| 450 | if (umove_or_printaddr(tcp, addr, &pair)) |
| 451 | return; |
| 452 | |
| 453 | printpair_fd(tcp, pair[0], pair[1]); |
| 454 | } |
| 455 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 456 | static int |
| 457 | do_pipe(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 458 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 459 | if (exiting(tcp)) { |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 460 | decode_pair_fd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 461 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 462 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 463 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 464 | } |
| 465 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 466 | return 0; |
| 467 | } |
| 468 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 469 | SYS_FUNC(pipe) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 470 | { |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 471 | #ifdef HAVE_GETRVAL2 |
| 472 | if (exiting(tcp) && !syserror(tcp)) |
| 473 | printpair_fd(tcp, tcp->u_rval, getrval2(tcp)); |
| 474 | return 0; |
| 475 | #else |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 476 | return do_pipe(tcp, -1); |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 477 | #endif |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 478 | } |
| 479 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 480 | SYS_FUNC(pipe2) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 481 | { |
| 482 | return do_pipe(tcp, 1); |
| 483 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 484 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 485 | SYS_FUNC(socketpair) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 486 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 487 | if (entering(tcp)) { |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 488 | printxval(addrfams, tcp->u_arg[0], "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 489 | tprints(", "); |
Dmitry V. Levin | 1e42f2d | 2014-09-10 17:48:28 +0000 | [diff] [blame] | 490 | tprint_sock_type(tcp->u_arg[1]); |
Dmitry V. Levin | 033fb91 | 2014-03-11 22:50:39 +0000 | [diff] [blame] | 491 | tprintf(", %lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 492 | } else { |
Dmitry V. Levin | b679508 | 2015-07-06 22:33:39 +0000 | [diff] [blame] | 493 | tprints(", "); |
Dmitry V. Levin | 2a4f052 | 2015-08-02 01:54:48 +0000 | [diff] [blame] | 494 | decode_pair_fd(tcp, tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 495 | } |
| 496 | return 0; |
| 497 | } |
| 498 | |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 499 | #include "xlat/sockoptions.h" |
| 500 | #include "xlat/sockipoptions.h" |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 501 | #include "xlat/getsockipoptions.h" |
| 502 | #include "xlat/setsockipoptions.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 503 | #include "xlat/sockipv6options.h" |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 504 | #include "xlat/getsockipv6options.h" |
| 505 | #include "xlat/setsockipv6options.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 506 | #include "xlat/sockipxoptions.h" |
| 507 | #include "xlat/sockrawoptions.h" |
| 508 | #include "xlat/sockpacketoptions.h" |
| 509 | #include "xlat/socksctpoptions.h" |
| 510 | #include "xlat/socktcpoptions.h" |
| 511 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 512 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 513 | print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level, |
| 514 | unsigned int name, bool is_getsockopt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 515 | { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 516 | printfd(tcp, fd); |
| 517 | tprints(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 518 | printxval(socketlayers, level, "SOL_??"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 519 | tprints(", "); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 520 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 521 | switch (level) { |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 522 | case SOL_SOCKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 523 | printxval(sockoptions, name, "SO_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 524 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 525 | case SOL_IP: |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 526 | printxvals(name, "IP_???", sockipoptions, |
| 527 | is_getsockopt ? getsockipoptions : setsockipoptions, NULL); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 528 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 529 | case SOL_IPV6: |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 530 | printxvals(name, "IPV6_???", sockipv6options, |
| 531 | is_getsockopt ? getsockipv6options : setsockipv6options, NULL); |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 532 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 533 | case SOL_IPX: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 534 | printxval(sockipxoptions, name, "IPX_???"); |
| 535 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 536 | case SOL_PACKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 537 | printxval(sockpacketoptions, name, "PACKET_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 538 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 539 | case SOL_TCP: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 540 | printxval(socktcpoptions, name, "TCP_???"); |
| 541 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 542 | case SOL_SCTP: |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 543 | printxval(socksctpoptions, name, "SCTP_???"); |
| 544 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 545 | case SOL_RAW: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 546 | printxval(sockrawoptions, name, "RAW_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 547 | break; |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 548 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 549 | /* Other SOL_* protocol levels still need work. */ |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 550 | |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 551 | default: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 552 | tprintf("%u", name); |
| 553 | } |
| 554 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 555 | tprints(", "); |
| 556 | } |
| 557 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 558 | static void |
| 559 | print_linger(struct tcb *tcp, long addr, int len) |
| 560 | { |
| 561 | struct linger linger; |
| 562 | |
| 563 | if (len != sizeof(linger) || |
| 564 | umove(tcp, addr, &linger) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 565 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 566 | return; |
| 567 | } |
| 568 | |
| 569 | tprintf("{onoff=%d, linger=%d}", |
| 570 | linger.l_onoff, |
| 571 | linger.l_linger); |
| 572 | } |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 573 | |
| 574 | #ifdef SO_PEERCRED |
| 575 | static void |
| 576 | print_ucred(struct tcb *tcp, long addr, int len) |
| 577 | { |
| 578 | struct ucred uc; |
| 579 | |
| 580 | if (len != sizeof(uc) || |
| 581 | umove(tcp, addr, &uc) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 582 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 583 | } else { |
| 584 | tprintf("{pid=%u, uid=%u, gid=%u}", |
| 585 | (unsigned) uc.pid, |
| 586 | (unsigned) uc.uid, |
| 587 | (unsigned) uc.gid); |
| 588 | } |
| 589 | } |
| 590 | #endif /* SO_PEERCRED */ |
| 591 | |
| 592 | #ifdef PACKET_STATISTICS |
| 593 | static void |
| 594 | print_tpacket_stats(struct tcb *tcp, long addr, int len) |
| 595 | { |
| 596 | struct tpacket_stats stats; |
| 597 | |
| 598 | if (len != sizeof(stats) || |
| 599 | umove(tcp, addr, &stats) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 600 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 601 | } else { |
| 602 | tprintf("{packets=%u, drops=%u}", |
| 603 | stats.tp_packets, |
| 604 | stats.tp_drops); |
| 605 | } |
| 606 | } |
| 607 | #endif /* PACKET_STATISTICS */ |
| 608 | |
Dmitry V. Levin | fba9db2 | 2016-06-15 21:29:07 +0000 | [diff] [blame] | 609 | #include "xlat/icmpfilterflags.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 610 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 611 | static void |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 612 | print_icmp_filter(struct tcb *tcp, const long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 613 | { |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 614 | struct icmp_filter filter = {}; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 615 | |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 616 | if (len > (int) sizeof(filter)) |
| 617 | len = sizeof(filter); |
| 618 | else if (len <= 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 619 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 620 | return; |
| 621 | } |
| 622 | |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 623 | if (umoven_or_printaddr(tcp, addr, len, &filter)) |
| 624 | return; |
| 625 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 626 | tprints("~("); |
| 627 | printflags(icmpfilterflags, ~filter.data, "ICMP_???"); |
| 628 | tprints(")"); |
| 629 | } |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 630 | |
| 631 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 632 | print_getsockopt(struct tcb *tcp, unsigned int level, unsigned int name, |
| 633 | long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 634 | { |
| 635 | if (addr && verbose(tcp)) |
| 636 | switch (level) { |
| 637 | case SOL_SOCKET: |
| 638 | switch (name) { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 639 | case SO_LINGER: |
| 640 | print_linger(tcp, addr, len); |
| 641 | goto done; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 642 | #ifdef SO_PEERCRED |
| 643 | case SO_PEERCRED: |
| 644 | print_ucred(tcp, addr, len); |
| 645 | goto done; |
| 646 | #endif |
| 647 | } |
| 648 | break; |
| 649 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 650 | case SOL_PACKET: |
| 651 | switch (name) { |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 652 | #ifdef PACKET_STATISTICS |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 653 | case PACKET_STATISTICS: |
| 654 | print_tpacket_stats(tcp, addr, len); |
| 655 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 656 | #endif |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 657 | } |
| 658 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 659 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 660 | case SOL_RAW: |
| 661 | switch (name) { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 662 | case ICMP_FILTER: |
| 663 | print_icmp_filter(tcp, addr, len); |
| 664 | goto done; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 665 | } |
| 666 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 667 | } |
| 668 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 669 | /* default arg printing */ |
| 670 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 671 | if (verbose(tcp)) { |
| 672 | if (len == sizeof(int)) { |
| 673 | printnum_int(tcp, addr, "%d"); |
| 674 | } else { |
| 675 | printstr(tcp, addr, len); |
| 676 | } |
| 677 | } else { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 678 | printaddr(addr); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 679 | } |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 680 | done: |
| 681 | tprintf(", [%d]", len); |
| 682 | } |
| 683 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 684 | SYS_FUNC(getsockopt) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 685 | { |
| 686 | if (entering(tcp)) { |
| 687 | print_sockopt_fd_level_name(tcp, tcp->u_arg[0], |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 688 | tcp->u_arg[1], tcp->u_arg[2], true); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 689 | } else { |
| 690 | int len; |
| 691 | |
| 692 | if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 693 | printaddr(tcp->u_arg[3]); |
| 694 | tprints(", "); |
| 695 | printaddr(tcp->u_arg[4]); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 696 | } else { |
| 697 | print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 698 | tcp->u_arg[3], len); |
| 699 | } |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 700 | } |
| 701 | return 0; |
| 702 | } |
| 703 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 704 | #ifdef IP_ADD_MEMBERSHIP |
| 705 | static void |
| 706 | print_mreq(struct tcb *tcp, long addr, unsigned int len) |
| 707 | { |
| 708 | struct ip_mreq mreq; |
| 709 | |
| 710 | if (len < sizeof(mreq)) { |
| 711 | printstr(tcp, addr, len); |
| 712 | return; |
| 713 | } |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 714 | if (umove_or_printaddr(tcp, addr, &mreq)) |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 715 | return; |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 716 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 717 | tprints("{imr_multiaddr=inet_addr("); |
| 718 | print_quoted_string(inet_ntoa(mreq.imr_multiaddr), |
| 719 | 16, QUOTE_0_TERMINATED); |
| 720 | tprints("), imr_interface=inet_addr("); |
| 721 | print_quoted_string(inet_ntoa(mreq.imr_interface), |
| 722 | 16, QUOTE_0_TERMINATED); |
| 723 | tprints(")}"); |
| 724 | } |
| 725 | #endif /* IP_ADD_MEMBERSHIP */ |
| 726 | |
| 727 | #ifdef IPV6_ADD_MEMBERSHIP |
| 728 | static void |
| 729 | print_mreq6(struct tcb *tcp, long addr, unsigned int len) |
| 730 | { |
| 731 | struct ipv6_mreq mreq; |
| 732 | |
| 733 | if (len < sizeof(mreq)) |
| 734 | goto fail; |
| 735 | |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 736 | if (umove_or_printaddr(tcp, addr, &mreq)) |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 737 | return; |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 738 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 739 | const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr; |
| 740 | char address[INET6_ADDRSTRLEN]; |
| 741 | |
| 742 | if (!inet_ntop(AF_INET6, in6, address, sizeof(address))) |
| 743 | goto fail; |
| 744 | |
| 745 | tprints("{ipv6mr_multiaddr=inet_pton("); |
| 746 | print_quoted_string(address, sizeof(address), QUOTE_0_TERMINATED); |
| 747 | tprints("), ipv6mr_interface="); |
| 748 | print_ifindex(mreq.ipv6mr_interface); |
| 749 | tprints("}"); |
| 750 | return; |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 751 | |
| 752 | fail: |
| 753 | printstr(tcp, addr, len); |
| 754 | } |
| 755 | #endif /* IPV6_ADD_MEMBERSHIP */ |
| 756 | |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 757 | #ifdef MCAST_JOIN_GROUP |
| 758 | static void |
| 759 | print_group_req(struct tcb *tcp, long addr, int len) |
| 760 | { |
| 761 | struct group_req greq; |
| 762 | |
| 763 | if (len != sizeof(greq) || |
| 764 | umove(tcp, addr, &greq) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 765 | printaddr(addr); |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 766 | return; |
| 767 | } |
| 768 | |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 769 | tprintf("{gr_interface=%u, gr_group=", greq.gr_interface); |
Dmitry V. Levin | 3bf9c19 | 2016-06-21 16:45:40 +0000 | [diff] [blame] | 770 | print_sockaddr(tcp, &greq.gr_group, sizeof(greq.gr_group)); |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 771 | tprintf("}"); |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 772 | |
| 773 | } |
| 774 | #endif /* MCAST_JOIN_GROUP */ |
| 775 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 776 | #ifdef PACKET_RX_RING |
| 777 | static void |
| 778 | print_tpacket_req(struct tcb *tcp, long addr, int len) |
| 779 | { |
| 780 | struct tpacket_req req; |
| 781 | |
| 782 | if (len != sizeof(req) || |
| 783 | umove(tcp, addr, &req) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 784 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 785 | } else { |
| 786 | tprintf("{block_size=%u, block_nr=%u, " |
| 787 | "frame_size=%u, frame_nr=%u}", |
| 788 | req.tp_block_size, |
| 789 | req.tp_block_nr, |
| 790 | req.tp_frame_size, |
| 791 | req.tp_frame_nr); |
| 792 | } |
| 793 | } |
| 794 | #endif /* PACKET_RX_RING */ |
| 795 | |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 796 | #ifdef PACKET_ADD_MEMBERSHIP |
| 797 | # include "xlat/packet_mreq_type.h" |
| 798 | |
| 799 | static void |
| 800 | print_packet_mreq(struct tcb *tcp, long addr, int len) |
| 801 | { |
| 802 | struct packet_mreq mreq; |
| 803 | |
| 804 | if (len != sizeof(mreq) || |
| 805 | umove(tcp, addr, &mreq) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 806 | printaddr(addr); |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 807 | } else { |
| 808 | unsigned int i; |
| 809 | |
| 810 | tprintf("{mr_ifindex=%u, mr_type=", mreq.mr_ifindex); |
| 811 | printxval(packet_mreq_type, mreq.mr_type, "PACKET_MR_???"); |
| 812 | tprintf(", mr_alen=%u, mr_address=", mreq.mr_alen); |
| 813 | if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address)) |
| 814 | mreq.mr_alen = ARRAY_SIZE(mreq.mr_address); |
| 815 | for (i = 0; i < mreq.mr_alen; ++i) |
| 816 | tprintf("%02x", mreq.mr_address[i]); |
| 817 | tprints("}"); |
| 818 | } |
| 819 | } |
| 820 | #endif /* PACKET_ADD_MEMBERSHIP */ |
| 821 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 822 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 823 | print_setsockopt(struct tcb *tcp, unsigned int level, unsigned int name, |
| 824 | long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 825 | { |
| 826 | if (addr && verbose(tcp)) |
| 827 | switch (level) { |
| 828 | case SOL_SOCKET: |
| 829 | switch (name) { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 830 | case SO_LINGER: |
| 831 | print_linger(tcp, addr, len); |
| 832 | goto done; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 833 | } |
| 834 | break; |
| 835 | |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 836 | case SOL_IP: |
| 837 | switch (name) { |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 838 | #ifdef IP_ADD_MEMBERSHIP |
| 839 | case IP_ADD_MEMBERSHIP: |
| 840 | case IP_DROP_MEMBERSHIP: |
| 841 | print_mreq(tcp, addr, len); |
| 842 | goto done; |
| 843 | #endif /* IP_ADD_MEMBERSHIP */ |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 844 | #ifdef MCAST_JOIN_GROUP |
| 845 | case MCAST_JOIN_GROUP: |
| 846 | case MCAST_LEAVE_GROUP: |
| 847 | print_group_req(tcp, addr, len); |
| 848 | goto done; |
| 849 | #endif /* MCAST_JOIN_GROUP */ |
| 850 | } |
Dmitry V. Levin | 3910d0f | 2015-02-08 01:19:06 +0000 | [diff] [blame] | 851 | break; |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 852 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 853 | case SOL_IPV6: |
| 854 | switch (name) { |
| 855 | #ifdef IPV6_ADD_MEMBERSHIP |
| 856 | case IPV6_ADD_MEMBERSHIP: |
| 857 | case IPV6_DROP_MEMBERSHIP: |
| 858 | # ifdef IPV6_JOIN_ANYCAST |
| 859 | case IPV6_JOIN_ANYCAST: |
| 860 | # endif |
| 861 | # ifdef IPV6_LEAVE_ANYCAST |
| 862 | case IPV6_LEAVE_ANYCAST: |
| 863 | # endif |
| 864 | print_mreq6(tcp, addr, len); |
| 865 | goto done; |
| 866 | #endif /* IPV6_ADD_MEMBERSHIP */ |
| 867 | } |
| 868 | break; |
| 869 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 870 | case SOL_PACKET: |
| 871 | switch (name) { |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 872 | #ifdef PACKET_RX_RING |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 873 | case PACKET_RX_RING: |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 874 | # ifdef PACKET_TX_RING |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 875 | case PACKET_TX_RING: |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 876 | # endif |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 877 | print_tpacket_req(tcp, addr, len); |
| 878 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 879 | #endif /* PACKET_RX_RING */ |
| 880 | #ifdef PACKET_ADD_MEMBERSHIP |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 881 | case PACKET_ADD_MEMBERSHIP: |
| 882 | case PACKET_DROP_MEMBERSHIP: |
| 883 | print_packet_mreq(tcp, addr, len); |
| 884 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 885 | #endif /* PACKET_ADD_MEMBERSHIP */ |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 886 | } |
| 887 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 888 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 889 | case SOL_RAW: |
| 890 | switch (name) { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 891 | case ICMP_FILTER: |
| 892 | print_icmp_filter(tcp, addr, len); |
| 893 | goto done; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 894 | } |
| 895 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | /* default arg printing */ |
| 899 | |
| 900 | if (verbose(tcp)) { |
| 901 | if (len == sizeof(int)) { |
| 902 | printnum_int(tcp, addr, "%d"); |
| 903 | } else { |
| 904 | printstr(tcp, addr, len); |
| 905 | } |
| 906 | } else { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 907 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 908 | } |
| 909 | done: |
| 910 | tprintf(", %d", len); |
| 911 | } |
| 912 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 913 | SYS_FUNC(setsockopt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 914 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 915 | print_sockopt_fd_level_name(tcp, tcp->u_arg[0], |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 916 | tcp->u_arg[1], tcp->u_arg[2], false); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 917 | print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 918 | tcp->u_arg[3], tcp->u_arg[4]); |
| 919 | |
| 920 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 921 | } |