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