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> |
Denys Vlasenko | 99aa181 | 2013-02-08 18:49:06 +0100 | [diff] [blame] | 49 | #if defined(__GLIBC__) |
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> |
Lubomir Rintel | c400a1c | 2014-10-03 11:40:28 +0200 | [diff] [blame] | 73 | #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
| 74 | # include <bluetooth/bluetooth.h> |
| 75 | # include <bluetooth/hci.h> |
| 76 | # include <bluetooth/l2cap.h> |
| 77 | # include <bluetooth/rfcomm.h> |
| 78 | # include <bluetooth/sco.h> |
| 79 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 80 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 81 | #include "xlat/addrfams.h" |
| 82 | #include "xlat/socktypes.h" |
| 83 | #include "xlat/sock_type_flags.h" |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 84 | #ifndef SOCK_TYPE_MASK |
| 85 | # define SOCK_TYPE_MASK 0xf |
| 86 | #endif |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 87 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 88 | #include "xlat/socketlayers.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 89 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 90 | #include "xlat/inet_protocols.h" |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 91 | |
Dmitry V. Levin | 9457304 | 2016-06-14 13:53:47 +0000 | [diff] [blame] | 92 | #if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG |
| 93 | # define NETLINK_SOCK_DIAG NETLINK_INET_DIAG |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 94 | #endif |
Dmitry V. Levin | 9457304 | 2016-06-14 13:53:47 +0000 | [diff] [blame] | 95 | #include "xlat/netlink_protocols.h" |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 96 | |
Lubomir Rintel | c400a1c | 2014-10-03 11:40:28 +0200 | [diff] [blame] | 97 | #if defined(HAVE_BLUETOOTH_BLUETOOTH_H) |
| 98 | # include "xlat/bt_protocols.h" |
| 99 | #endif |
| 100 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 101 | #include "xlat/msg_flags.h" |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 102 | |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 103 | #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */ |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 104 | # include "xlat/af_packet_types.h" |
| 105 | #endif |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 106 | |
Dmitry V. Levin | ae28093 | 2015-06-05 20:13:21 +0000 | [diff] [blame] | 107 | static void |
| 108 | print_ifindex(unsigned int ifindex) |
| 109 | { |
| 110 | #ifdef HAVE_IF_INDEXTONAME |
| 111 | char buf[IFNAMSIZ + 1]; |
| 112 | |
| 113 | if (if_indextoname(ifindex, buf)) { |
| 114 | tprints("if_nametoindex("); |
| 115 | print_quoted_string(buf, sizeof(buf), QUOTE_0_TERMINATED); |
| 116 | tprints(")"); |
| 117 | return; |
| 118 | } |
| 119 | #endif |
| 120 | tprintf("%u", ifindex); |
| 121 | } |
| 122 | |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 123 | typedef union { |
| 124 | char pad[128]; |
| 125 | struct sockaddr sa; |
| 126 | struct sockaddr_in sin; |
| 127 | struct sockaddr_un sau; |
| 128 | #ifdef HAVE_INET_NTOP |
| 129 | struct sockaddr_in6 sa6; |
| 130 | #endif |
| 131 | #if defined(AF_IPX) |
| 132 | struct sockaddr_ipx sipx; |
| 133 | #endif |
| 134 | #ifdef AF_PACKET |
| 135 | struct sockaddr_ll ll; |
| 136 | #endif |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 137 | struct sockaddr_nl nl; |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 138 | #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
| 139 | struct sockaddr_hci hci; |
| 140 | struct sockaddr_l2 l2; |
| 141 | struct sockaddr_rc rc; |
| 142 | struct sockaddr_sco sco; |
| 143 | #endif |
| 144 | } sockaddr_buf_t; |
| 145 | |
| 146 | static void |
| 147 | print_sockaddr(struct tcb *tcp, const sockaddr_buf_t *addr, const int addrlen) |
| 148 | { |
| 149 | tprints("{sa_family="); |
| 150 | printxval(addrfams, addr->sa.sa_family, "AF_???"); |
| 151 | tprints(", "); |
| 152 | |
| 153 | switch (addr->sa.sa_family) { |
| 154 | case AF_UNIX: |
| 155 | if (addrlen == 2) { |
| 156 | tprints("NULL"); |
| 157 | } else if (addr->sau.sun_path[0]) { |
| 158 | tprints("sun_path="); |
| 159 | print_quoted_string(addr->sau.sun_path, |
| 160 | sizeof(addr->sau.sun_path) + 1, |
| 161 | QUOTE_0_TERMINATED); |
| 162 | } else { |
| 163 | tprints("sun_path=@"); |
| 164 | print_quoted_string(addr->sau.sun_path + 1, |
| 165 | sizeof(addr->sau.sun_path), |
| 166 | QUOTE_0_TERMINATED); |
| 167 | } |
| 168 | break; |
| 169 | case AF_INET: |
| 170 | tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")", |
| 171 | ntohs(addr->sin.sin_port), inet_ntoa(addr->sin.sin_addr)); |
| 172 | break; |
| 173 | #ifdef HAVE_INET_NTOP |
| 174 | case AF_INET6: |
| 175 | { |
| 176 | char string_addr[100]; |
| 177 | inet_ntop(AF_INET6, &addr->sa6.sin6_addr, |
| 178 | string_addr, sizeof(string_addr)); |
| 179 | tprintf("sin6_port=htons(%u), inet_pton(AF_INET6" |
| 180 | ", \"%s\", &sin6_addr), sin6_flowinfo=%u", |
| 181 | ntohs(addr->sa6.sin6_port), string_addr, |
| 182 | addr->sa6.sin6_flowinfo); |
| 183 | # ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID |
| 184 | tprints(", sin6_scope_id="); |
| 185 | # if defined IN6_IS_ADDR_LINKLOCAL && defined IN6_IS_ADDR_MC_LINKLOCAL |
| 186 | if (IN6_IS_ADDR_LINKLOCAL(&addr->sa6.sin6_addr) |
| 187 | || IN6_IS_ADDR_MC_LINKLOCAL(&addr->sa6.sin6_addr)) |
| 188 | print_ifindex(addr->sa6.sin6_scope_id); |
| 189 | else |
| 190 | # endif |
| 191 | tprintf("%u", addr->sa6.sin6_scope_id); |
| 192 | # endif /* HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID */ |
| 193 | } |
| 194 | break; |
| 195 | #endif |
| 196 | #if defined(AF_IPX) |
| 197 | case AF_IPX: |
| 198 | { |
| 199 | int i; |
| 200 | tprintf("sipx_port=htons(%u), ", |
| 201 | ntohs(addr->sipx.sipx_port)); |
| 202 | /* Yes, I know, this does not look too |
| 203 | * strace-ish, but otherwise the IPX |
| 204 | * addresses just look monstrous... |
| 205 | * Anyways, feel free if you don't like |
| 206 | * this way.. :) |
| 207 | */ |
| 208 | tprintf("%08lx:", (unsigned long)ntohl(addr->sipx.sipx_network)); |
| 209 | for (i = 0; i < IPX_NODE_LEN; i++) |
| 210 | tprintf("%02x", addr->sipx.sipx_node[i]); |
| 211 | tprintf("/[%02x]", addr->sipx.sipx_type); |
| 212 | } |
| 213 | break; |
| 214 | #endif /* AF_IPX */ |
| 215 | #ifdef AF_PACKET |
| 216 | case AF_PACKET: |
| 217 | { |
| 218 | int i; |
| 219 | tprintf("proto=%#04x, if%d, pkttype=", |
| 220 | ntohs(addr->ll.sll_protocol), |
| 221 | addr->ll.sll_ifindex); |
| 222 | printxval(af_packet_types, addr->ll.sll_pkttype, "PACKET_???"); |
| 223 | tprintf(", addr(%d)={%d, ", |
| 224 | addr->ll.sll_halen, |
| 225 | addr->ll.sll_hatype); |
| 226 | for (i = 0; i < addr->ll.sll_halen; i++) |
| 227 | tprintf("%02x", addr->ll.sll_addr[i]); |
| 228 | } |
| 229 | break; |
| 230 | |
| 231 | #endif /* AF_PACKET */ |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 232 | case AF_NETLINK: |
| 233 | tprintf("pid=%d, groups=%08x", addr->nl.nl_pid, addr->nl.nl_groups); |
| 234 | break; |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 235 | #if defined(AF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H) |
| 236 | case AF_BLUETOOTH: |
| 237 | tprintf("{sco_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X} or " |
| 238 | "{rc_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, rc_channel=%d} or " |
| 239 | "{l2_psm=htobs(%d), l2_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, l2_cid=htobs(%d)} or " |
| 240 | "{hci_dev=htobs(%d)}", |
| 241 | addr->sco.sco_bdaddr.b[0], addr->sco.sco_bdaddr.b[1], |
| 242 | addr->sco.sco_bdaddr.b[2], addr->sco.sco_bdaddr.b[3], |
| 243 | addr->sco.sco_bdaddr.b[4], addr->sco.sco_bdaddr.b[5], |
| 244 | addr->rc.rc_bdaddr.b[0], addr->rc.rc_bdaddr.b[1], |
| 245 | addr->rc.rc_bdaddr.b[2], addr->rc.rc_bdaddr.b[3], |
| 246 | addr->rc.rc_bdaddr.b[4], addr->rc.rc_bdaddr.b[5], |
| 247 | addr->rc.rc_channel, |
| 248 | btohs(addr->l2.l2_psm), addr->l2.l2_bdaddr.b[0], |
| 249 | addr->l2.l2_bdaddr.b[1], addr->l2.l2_bdaddr.b[2], |
| 250 | addr->l2.l2_bdaddr.b[3], addr->l2.l2_bdaddr.b[4], |
| 251 | addr->l2.l2_bdaddr.b[5], btohs(addr->l2.l2_cid), |
| 252 | btohs(addr->hci.hci_dev)); |
| 253 | break; |
| 254 | #endif /* AF_BLUETOOTH && HAVE_BLUETOOTH_BLUETOOTH_H */ |
| 255 | /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 |
| 256 | AF_X25 AF_ROSE etc. still need to be done */ |
| 257 | |
| 258 | default: |
| 259 | tprints("sa_data="); |
| 260 | print_quoted_string(addr->sa.sa_data, |
| 261 | sizeof(addr->sa.sa_data), 0); |
| 262 | break; |
| 263 | } |
| 264 | tprints("}"); |
| 265 | } |
| 266 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 267 | void |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 268 | printsock(struct tcb *tcp, long addr, int addrlen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 269 | { |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 270 | sockaddr_buf_t addrbuf; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 271 | |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 272 | if (addrlen < 2) { |
Dmitry V. Levin | 52dc150 | 2015-07-30 13:53:42 +0000 | [diff] [blame] | 273 | printaddr(addr); |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 274 | return; |
| 275 | } |
| 276 | |
| 277 | if (addrlen > (int) sizeof(addrbuf)) |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 278 | addrlen = sizeof(addrbuf); |
| 279 | |
| 280 | memset(&addrbuf, 0, sizeof(addrbuf)); |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 281 | if (umoven_or_printaddr(tcp, addr, addrlen, addrbuf.pad)) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 282 | return; |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 283 | addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0'; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 284 | |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 285 | print_sockaddr(tcp, &addrbuf, addrlen); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Dmitry V. Levin | b36d132 | 2015-11-18 23:18:17 +0000 | [diff] [blame] | 288 | #include "xlat/scmvals.h" |
Dmitry V. Levin | 1f111cf | 2015-11-21 03:03:54 +0300 | [diff] [blame] | 289 | #include "xlat/ip_cmsg_types.h" |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 290 | |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 291 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 292 | struct cmsghdr32 { |
| 293 | uint32_t cmsg_len; |
| 294 | int cmsg_level; |
| 295 | int cmsg_type; |
| 296 | }; |
| 297 | #endif |
| 298 | |
| 299 | typedef union { |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 300 | char *ptr; |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 301 | struct cmsghdr *cmsg; |
| 302 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 303 | struct cmsghdr32 *cmsg32; |
| 304 | #endif |
| 305 | } union_cmsghdr; |
| 306 | |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 307 | static void |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 308 | print_scm_rights(struct tcb *tcp, const void *cmsg_data, |
| 309 | const size_t data_len) |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 310 | { |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 311 | const int *fds = cmsg_data; |
| 312 | const char *end = (const char *) cmsg_data + data_len; |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 313 | bool seen = false; |
| 314 | |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 315 | if (sizeof(*fds) > data_len) |
| 316 | return; |
| 317 | |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 318 | tprints(", ["); |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 319 | while ((const char *) fds < end) { |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 320 | if (seen) |
| 321 | tprints(", "); |
| 322 | else |
| 323 | seen = true; |
| 324 | printfd(tcp, *fds++); |
| 325 | } |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 326 | tprints("]"); |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 327 | } |
| 328 | |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 329 | static void |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 330 | print_scm_creds(struct tcb *tcp, const void *cmsg_data, |
| 331 | const size_t data_len) |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 332 | { |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 333 | const struct ucred *uc = cmsg_data; |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 334 | |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 335 | if (sizeof(*uc) > data_len) |
| 336 | return; |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 337 | |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 338 | tprintf(", {pid=%u, uid=%u, gid=%u}", |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 339 | (unsigned) uc->pid, (unsigned) uc->uid, (unsigned) uc->gid); |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 340 | } |
| 341 | |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 342 | static void |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 343 | print_scm_security(struct tcb *tcp, const void *cmsg_data, |
| 344 | const size_t data_len) |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 345 | { |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 346 | if (!data_len) |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 347 | return; |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 348 | |
Dmitry V. Levin | 513e96e | 2015-01-26 01:17:08 +0000 | [diff] [blame] | 349 | tprints(", "); |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 350 | print_quoted_string(cmsg_data, data_len, 0); |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 351 | } |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 352 | |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 353 | static void |
Dmitry V. Levin | 1f111cf | 2015-11-21 03:03:54 +0300 | [diff] [blame] | 354 | print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data, |
| 355 | const size_t data_len) |
| 356 | { |
| 357 | const struct in_pktinfo *info = cmsg_data; |
| 358 | |
| 359 | if (sizeof(*info) > data_len) |
| 360 | return; |
| 361 | |
| 362 | tprints(", {ipi_ifindex="); |
| 363 | print_ifindex(info->ipi_ifindex); |
| 364 | tprintf(", ipi_spec_dst=inet_addr(\"%s\"), ipi_addr=inet_addr(\"%s\")}", |
| 365 | inet_ntoa(info->ipi_spec_dst), inet_ntoa(info->ipi_addr)); |
| 366 | } |
| 367 | |
| 368 | static void |
| 369 | print_cmsg_ip_ttl(struct tcb *tcp, const void *cmsg_data, |
| 370 | const size_t data_len) |
| 371 | { |
| 372 | const unsigned int *ttl = cmsg_data; |
| 373 | |
| 374 | if (sizeof(*ttl) > data_len) |
| 375 | return; |
| 376 | |
| 377 | tprintf(", {ttl=%u}", *ttl); |
| 378 | } |
| 379 | |
| 380 | static void |
| 381 | print_cmsg_ip_tos(struct tcb *tcp, const void *cmsg_data, |
| 382 | const size_t data_len) |
| 383 | { |
| 384 | const uint8_t *tos = cmsg_data; |
| 385 | |
| 386 | if (sizeof(*tos) > data_len) |
| 387 | return; |
| 388 | |
| 389 | tprintf(", {tos=%x}", *tos); |
| 390 | } |
| 391 | |
| 392 | static void |
| 393 | print_cmsg_ip_checksum(struct tcb *tcp, const void *cmsg_data, |
| 394 | const size_t data_len) |
| 395 | { |
| 396 | const uint32_t *csum = cmsg_data; |
| 397 | |
| 398 | if (sizeof(*csum) > data_len) |
| 399 | return; |
| 400 | |
| 401 | tprintf(", {csum=%u}", *csum); |
| 402 | } |
| 403 | |
| 404 | static void |
| 405 | print_cmsg_ip_opts(struct tcb *tcp, const void *cmsg_data, |
| 406 | const size_t data_len) |
| 407 | { |
Dmitry V. Levin | a17f593 | 2015-11-22 23:07:52 +0000 | [diff] [blame] | 408 | const unsigned char *opts = cmsg_data; |
Dmitry V. Levin | 1f111cf | 2015-11-21 03:03:54 +0300 | [diff] [blame] | 409 | size_t i; |
| 410 | |
| 411 | if (!data_len) |
| 412 | return; |
| 413 | |
| 414 | tprints(", {opts=0x"); |
| 415 | for (i = 0; i < data_len; ++i) |
| 416 | tprintf("%02x", opts[i]); |
| 417 | tprints("}"); |
| 418 | } |
| 419 | |
| 420 | static void |
| 421 | print_cmsg_ip_recverr(struct tcb *tcp, const void *cmsg_data, |
| 422 | const size_t data_len) |
| 423 | { |
| 424 | const struct { |
| 425 | uint32_t ee_errno; |
| 426 | uint8_t ee_origin; |
| 427 | uint8_t ee_type; |
| 428 | uint8_t ee_code; |
| 429 | uint8_t ee_pad; |
| 430 | uint32_t ee_info; |
| 431 | uint32_t ee_data; |
| 432 | struct sockaddr_in offender; |
| 433 | } *err = cmsg_data; |
| 434 | |
| 435 | if (sizeof(*err) > data_len) |
| 436 | return; |
| 437 | |
| 438 | tprintf(", {ee_errno=%u, ee_origin=%u, ee_type=%u, ee_code=%u" |
| 439 | ", ee_info=%u, ee_data=%u, offender=", |
| 440 | err->ee_errno, err->ee_origin, err->ee_type, |
| 441 | err->ee_code, err->ee_info, err->ee_data); |
| 442 | print_sockaddr(tcp, (const void *) &err->offender, |
| 443 | sizeof(err->offender)); |
| 444 | tprints("}"); |
| 445 | } |
| 446 | |
| 447 | static void |
| 448 | print_cmsg_ip_origdstaddr(struct tcb *tcp, const void *cmsg_data, |
| 449 | const size_t data_len) |
| 450 | { |
| 451 | if (sizeof(struct sockaddr_in) > data_len) |
| 452 | return; |
| 453 | |
| 454 | tprints(", "); |
| 455 | print_sockaddr(tcp, cmsg_data, data_len); |
| 456 | } |
| 457 | |
| 458 | static void |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 459 | print_cmsg_type_data(struct tcb *tcp, const int cmsg_level, const int cmsg_type, |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 460 | const void *cmsg_data, const size_t data_len) |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 461 | { |
| 462 | switch (cmsg_level) { |
| 463 | case SOL_SOCKET: |
| 464 | printxval(scmvals, cmsg_type, "SCM_???"); |
| 465 | switch (cmsg_type) { |
| 466 | case SCM_RIGHTS: |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 467 | print_scm_rights(tcp, cmsg_data, data_len); |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 468 | break; |
| 469 | case SCM_CREDENTIALS: |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 470 | print_scm_creds(tcp, cmsg_data, data_len); |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 471 | break; |
| 472 | case SCM_SECURITY: |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 473 | print_scm_security(tcp, cmsg_data, data_len); |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 474 | break; |
| 475 | } |
| 476 | break; |
Dmitry V. Levin | 1f111cf | 2015-11-21 03:03:54 +0300 | [diff] [blame] | 477 | case SOL_IP: |
| 478 | printxval(ip_cmsg_types, cmsg_type, "IP_???"); |
| 479 | switch (cmsg_type) { |
| 480 | case IP_PKTINFO: |
| 481 | print_cmsg_ip_pktinfo(tcp, cmsg_data, data_len); |
| 482 | break; |
| 483 | case IP_TTL: |
| 484 | print_cmsg_ip_ttl(tcp, cmsg_data, data_len); |
| 485 | break; |
| 486 | case IP_TOS: |
| 487 | print_cmsg_ip_tos(tcp, cmsg_data, data_len); |
| 488 | break; |
| 489 | case IP_RECVOPTS: |
| 490 | case IP_RETOPTS: |
| 491 | print_cmsg_ip_opts(tcp, cmsg_data, data_len); |
| 492 | break; |
| 493 | case IP_RECVERR: |
| 494 | print_cmsg_ip_recverr(tcp, cmsg_data, data_len); |
| 495 | break; |
| 496 | case IP_ORIGDSTADDR: |
| 497 | print_cmsg_ip_origdstaddr(tcp, cmsg_data, data_len); |
| 498 | break; |
| 499 | case IP_CHECKSUM: |
| 500 | print_cmsg_ip_checksum(tcp, cmsg_data, data_len); |
| 501 | break; |
| 502 | case SCM_SECURITY: |
| 503 | print_scm_security(tcp, cmsg_data, data_len); |
| 504 | break; |
| 505 | } |
| 506 | break; |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 507 | default: |
| 508 | tprintf("%u", cmsg_type); |
| 509 | } |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | static void |
| 513 | printcmsghdr(struct tcb *tcp, unsigned long addr, size_t len) |
| 514 | { |
| 515 | const size_t cmsg_size = |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 516 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 517 | (current_wordsize < sizeof(long)) ? sizeof(struct cmsghdr32) : |
| 518 | #endif |
| 519 | sizeof(struct cmsghdr); |
| 520 | |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 521 | char *buf = len < cmsg_size ? NULL : malloc(len); |
| 522 | if (!buf || umoven(tcp, addr, len, buf) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 523 | tprints(", msg_control="); |
| 524 | printaddr(addr); |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 525 | free(buf); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 526 | return; |
| 527 | } |
| 528 | |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 529 | union_cmsghdr u = { .ptr = buf }; |
| 530 | |
| 531 | tprints(", ["); |
| 532 | while (len >= cmsg_size) { |
| 533 | size_t cmsg_len = |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 534 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 535 | (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_len : |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 536 | #endif |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 537 | u.cmsg->cmsg_len; |
| 538 | int cmsg_level = |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 539 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 540 | (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_level : |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 541 | #endif |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 542 | u.cmsg->cmsg_level; |
| 543 | int cmsg_type = |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 544 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 545 | (current_wordsize < sizeof(long)) ? u.cmsg32->cmsg_type : |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 546 | #endif |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 547 | u.cmsg->cmsg_type; |
Dmitry V. Levin | 05884d8 | 2015-01-24 01:08:57 +0000 | [diff] [blame] | 548 | |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 549 | if (u.ptr != buf) |
| 550 | tprints(", "); |
| 551 | tprintf("{cmsg_len=%lu, cmsg_level=", (unsigned long) cmsg_len); |
| 552 | printxval(socketlayers, cmsg_level, "SOL_???"); |
| 553 | tprints(", cmsg_type="); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 554 | |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 555 | if (cmsg_len > len) |
| 556 | cmsg_len = len; |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 557 | |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 558 | print_cmsg_type_data(tcp, cmsg_level, cmsg_type, |
Dmitry V. Levin | 1103b4e | 2015-11-21 03:59:09 +0000 | [diff] [blame] | 559 | (const void *) (u.ptr + cmsg_size), |
| 560 | cmsg_len > cmsg_size ? cmsg_len - cmsg_size: 0); |
Dmitry V. Levin | f54cb96 | 2015-11-19 00:29:19 +0000 | [diff] [blame] | 561 | tprints("}"); |
| 562 | |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 563 | if (cmsg_len < cmsg_size) { |
| 564 | len -= cmsg_size; |
| 565 | break; |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 566 | } |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 567 | cmsg_len = (cmsg_len + current_wordsize - 1) & |
| 568 | (size_t) ~(current_wordsize - 1); |
| 569 | if (cmsg_len >= len) { |
| 570 | len = 0; |
| 571 | break; |
| 572 | } |
| 573 | u.ptr += cmsg_len; |
| 574 | len -= cmsg_len; |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 575 | } |
Dmitry V. Levin | b85a7f3 | 2015-01-24 15:20:31 +0000 | [diff] [blame] | 576 | if (len) |
| 577 | tprints(", ..."); |
| 578 | tprints("]"); |
| 579 | free(buf); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 580 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 581 | |
| 582 | static void |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 583 | do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size) |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 584 | { |
| 585 | tprintf("{msg_name(%d)=", msg->msg_namelen); |
| 586 | printsock(tcp, (long)msg->msg_name, msg->msg_namelen); |
| 587 | |
| 588 | tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen); |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 589 | tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen, |
| 590 | (unsigned long)msg->msg_iov, 1, data_size); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 591 | |
| 592 | #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL |
| 593 | tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen); |
| 594 | if (msg->msg_controllen) |
| 595 | printcmsghdr(tcp, (unsigned long) msg->msg_control, |
| 596 | msg->msg_controllen); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 597 | tprints(", msg_flags="); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 598 | printflags(msg_flags, msg->msg_flags, "MSG_???"); |
| 599 | #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
| 600 | tprintf("msg_accrights=%#lx, msg_accrightslen=%u", |
| 601 | (unsigned long) msg->msg_accrights, msg->msg_accrightslen); |
| 602 | #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 603 | tprints("}"); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 604 | } |
| 605 | |
Denys Vlasenko | 3e759d4 | 2013-02-12 11:57:48 +0100 | [diff] [blame] | 606 | struct msghdr32 { |
| 607 | uint32_t /* void* */ msg_name; |
| 608 | uint32_t /* socklen_t */msg_namelen; |
| 609 | uint32_t /* iovec* */ msg_iov; |
| 610 | uint32_t /* size_t */ msg_iovlen; |
| 611 | uint32_t /* void* */ msg_control; |
| 612 | uint32_t /* size_t */ msg_controllen; |
| 613 | uint32_t /* int */ msg_flags; |
| 614 | }; |
| 615 | struct mmsghdr32 { |
| 616 | struct msghdr32 msg_hdr; |
| 617 | uint32_t /* unsigned */ msg_len; |
| 618 | }; |
| 619 | |
Masatake YAMATO | caf6a43 | 2014-11-07 01:23:25 +0900 | [diff] [blame] | 620 | #ifndef HAVE_STRUCT_MMSGHDR |
| 621 | struct mmsghdr { |
| 622 | struct msghdr msg_hdr; |
| 623 | unsigned msg_len; |
| 624 | }; |
| 625 | #endif |
| 626 | |
Masatake YAMATO | b248543 | 2014-11-07 01:23:24 +0900 | [diff] [blame] | 627 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 628 | static void |
| 629 | copy_from_msghdr32(struct msghdr *to_msg, struct msghdr32 *from_msg32) |
| 630 | { |
| 631 | to_msg->msg_name = (void*)(long)from_msg32->msg_name; |
| 632 | to_msg->msg_namelen = from_msg32->msg_namelen; |
| 633 | to_msg->msg_iov = (void*)(long)from_msg32->msg_iov; |
| 634 | to_msg->msg_iovlen = from_msg32->msg_iovlen; |
| 635 | to_msg->msg_control = (void*)(long)from_msg32->msg_control; |
| 636 | to_msg->msg_controllen = from_msg32->msg_controllen; |
| 637 | to_msg->msg_flags = from_msg32->msg_flags; |
| 638 | } |
| 639 | #endif |
| 640 | |
Masatake YAMATO | 02f9f6b | 2014-10-15 22:11:43 +0900 | [diff] [blame] | 641 | static bool |
| 642 | extractmsghdr(struct tcb *tcp, long addr, struct msghdr *msg) |
| 643 | { |
| 644 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 645 | if (current_wordsize == 4) { |
| 646 | struct msghdr32 msg32; |
| 647 | |
| 648 | if (umove(tcp, addr, &msg32) < 0) |
| 649 | return false; |
Masatake YAMATO | b248543 | 2014-11-07 01:23:24 +0900 | [diff] [blame] | 650 | copy_from_msghdr32(msg, &msg32); |
Masatake YAMATO | 02f9f6b | 2014-10-15 22:11:43 +0900 | [diff] [blame] | 651 | } else |
| 652 | #endif |
| 653 | if (umove(tcp, addr, msg) < 0) |
| 654 | return false; |
| 655 | return true; |
| 656 | } |
| 657 | |
Masatake YAMATO | a807dce | 2014-11-07 01:23:26 +0900 | [diff] [blame] | 658 | static bool |
| 659 | extractmmsghdr(struct tcb *tcp, long addr, unsigned int idx, struct mmsghdr *mmsg) |
| 660 | { |
| 661 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 662 | if (current_wordsize == 4) { |
| 663 | struct mmsghdr32 mmsg32; |
| 664 | |
| 665 | addr += sizeof(struct mmsghdr32) * idx; |
| 666 | if (umove(tcp, addr, &mmsg32) < 0) |
| 667 | return false; |
| 668 | |
| 669 | copy_from_msghdr32(&mmsg->msg_hdr, &mmsg32.msg_hdr); |
| 670 | mmsg->msg_len = mmsg32.msg_len; |
| 671 | } else |
| 672 | #endif |
| 673 | { |
| 674 | addr += sizeof(*mmsg) * idx; |
| 675 | if (umove(tcp, addr, mmsg) < 0) |
| 676 | return false; |
| 677 | } |
| 678 | return true; |
| 679 | } |
| 680 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 681 | static void |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 682 | printmsghdr(struct tcb *tcp, long addr, unsigned long data_size) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 683 | { |
| 684 | struct msghdr msg; |
| 685 | |
Dmitry V. Levin | 00244b9 | 2015-01-28 01:52:25 +0000 | [diff] [blame] | 686 | if (verbose(tcp) && extractmsghdr(tcp, addr, &msg)) |
Masatake YAMATO | 02f9f6b | 2014-10-15 22:11:43 +0900 | [diff] [blame] | 687 | do_msghdr(tcp, &msg, data_size); |
| 688 | else |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 689 | printaddr(addr); |
Masatake YAMATO | 02f9f6b | 2014-10-15 22:11:43 +0900 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | void |
Dmitry V. Levin | 93c9d1c | 2016-01-20 03:26:37 +0000 | [diff] [blame] | 693 | dumpiov_in_msghdr(struct tcb *tcp, long addr, unsigned long data_size) |
Masatake YAMATO | 02f9f6b | 2014-10-15 22:11:43 +0900 | [diff] [blame] | 694 | { |
| 695 | struct msghdr msg; |
| 696 | |
| 697 | if (extractmsghdr(tcp, addr, &msg)) |
Dmitry V. Levin | 93c9d1c | 2016-01-20 03:26:37 +0000 | [diff] [blame] | 698 | dumpiov_upto(tcp, msg.msg_iovlen, (long)msg.msg_iov, data_size); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 699 | } |
| 700 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 701 | static void |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 702 | printmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len) |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 703 | { |
Masatake YAMATO | caf6a43 | 2014-11-07 01:23:25 +0900 | [diff] [blame] | 704 | struct mmsghdr mmsg; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 705 | |
Masatake YAMATO | a807dce | 2014-11-07 01:23:26 +0900 | [diff] [blame] | 706 | if (extractmmsghdr(tcp, addr, idx, &mmsg)) { |
| 707 | tprints("{"); |
| 708 | do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len); |
| 709 | tprintf(", %u}", mmsg.msg_len); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 710 | } |
Masatake YAMATO | a807dce | 2014-11-07 01:23:26 +0900 | [diff] [blame] | 711 | else |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 712 | printaddr(addr); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 713 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 714 | |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 715 | static void |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 716 | decode_mmsg(struct tcb *tcp, unsigned long msg_len) |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 717 | { |
| 718 | /* mmsgvec */ |
| 719 | if (syserror(tcp)) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 720 | printaddr(tcp->u_arg[1]); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 721 | } else { |
| 722 | unsigned int len = tcp->u_rval; |
| 723 | unsigned int i; |
| 724 | |
| 725 | tprints("{"); |
| 726 | for (i = 0; i < len; ++i) { |
| 727 | if (i) |
| 728 | tprints(", "); |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 729 | printmmsghdr(tcp, tcp->u_arg[1], i, msg_len); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 730 | } |
| 731 | tprints("}"); |
| 732 | } |
| 733 | /* vlen */ |
| 734 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
| 735 | /* flags */ |
| 736 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 737 | } |
| 738 | |
Masatake YAMATO | a807dce | 2014-11-07 01:23:26 +0900 | [diff] [blame] | 739 | void |
| 740 | dumpiov_in_mmsghdr(struct tcb *tcp, long addr) |
| 741 | { |
| 742 | unsigned int len = tcp->u_rval; |
| 743 | unsigned int i; |
| 744 | struct mmsghdr mmsg; |
| 745 | |
| 746 | for (i = 0; i < len; ++i) { |
| 747 | if (extractmmsghdr(tcp, addr, i, &mmsg)) { |
| 748 | tprintf(" = %lu buffers in vector %u\n", |
| 749 | (unsigned long)mmsg.msg_hdr.msg_iovlen, i); |
Dmitry V. Levin | d44707d | 2016-01-20 04:56:25 +0000 | [diff] [blame] | 750 | dumpiov_upto(tcp, mmsg.msg_hdr.msg_iovlen, |
| 751 | (long)mmsg.msg_hdr.msg_iov, mmsg.msg_len); |
Masatake YAMATO | a807dce | 2014-11-07 01:23:26 +0900 | [diff] [blame] | 752 | } |
| 753 | } |
| 754 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 755 | |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 756 | /* |
| 757 | * low bits of the socket type define real socket type, |
| 758 | * other bits are socket type flags. |
| 759 | */ |
| 760 | static void |
Dmitry V. Levin | 9134aab | 2016-05-14 21:46:05 +0000 | [diff] [blame] | 761 | tprint_sock_type(unsigned int flags) |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 762 | { |
| 763 | const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK); |
| 764 | |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 765 | if (str) { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 766 | tprints(str); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 767 | flags &= ~SOCK_TYPE_MASK; |
| 768 | if (!flags) |
| 769 | return; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 770 | tprints("|"); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 771 | } |
| 772 | printflags(sock_type_flags, flags, "SOCK_???"); |
| 773 | } |
| 774 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 775 | SYS_FUNC(socket) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 776 | { |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 777 | printxval(addrfams, tcp->u_arg[0], "AF_???"); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 778 | tprints(", "); |
| 779 | tprint_sock_type(tcp->u_arg[1]); |
| 780 | tprints(", "); |
| 781 | switch (tcp->u_arg[0]) { |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 782 | case AF_INET: |
| 783 | #ifdef AF_INET6 |
| 784 | case AF_INET6: |
Roland McGrath | 8758e54 | 2003-06-23 23:39:59 +0000 | [diff] [blame] | 785 | #endif |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 786 | printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 787 | break; |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 788 | #ifdef AF_IPX |
| 789 | case AF_IPX: |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 790 | /* BTW: I don't believe this.. */ |
| 791 | tprints("["); |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 792 | printxval(addrfams, tcp->u_arg[2], "AF_???"); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 793 | tprints("]"); |
| 794 | break; |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 795 | #endif /* AF_IPX */ |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 796 | case AF_NETLINK: |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 797 | printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???"); |
| 798 | break; |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 799 | #if defined(AF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H) |
| 800 | case AF_BLUETOOTH: |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 801 | printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???"); |
| 802 | break; |
Lubomir Rintel | c400a1c | 2014-10-03 11:40:28 +0200 | [diff] [blame] | 803 | #endif |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 804 | default: |
| 805 | tprintf("%lu", tcp->u_arg[2]); |
| 806 | break; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 807 | } |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 808 | |
Dmitry V. Levin | 3d463be | 2015-08-02 01:41:26 +0000 | [diff] [blame] | 809 | return RVAL_DECODED | RVAL_FD; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 810 | } |
| 811 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 812 | SYS_FUNC(bind) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 813 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 814 | printfd(tcp, tcp->u_arg[0]); |
| 815 | tprints(", "); |
| 816 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 817 | tprintf(", %lu", tcp->u_arg[2]); |
| 818 | |
| 819 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 820 | } |
| 821 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 822 | SYS_FUNC(listen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 823 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 824 | printfd(tcp, tcp->u_arg[0]); |
| 825 | tprints(", "); |
| 826 | tprintf("%lu", tcp->u_arg[1]); |
| 827 | |
| 828 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 829 | } |
| 830 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 831 | static int |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 832 | do_sockname(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 833 | { |
| 834 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 835 | printfd(tcp, tcp->u_arg[0]); |
| 836 | tprints(", "); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 837 | return 0; |
| 838 | } |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 839 | |
| 840 | int len; |
| 841 | if (!tcp->u_arg[2] || !verbose(tcp) || syserror(tcp) || |
| 842 | umove(tcp, tcp->u_arg[2], &len) < 0) { |
| 843 | printaddr(tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 844 | tprints(", "); |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 845 | printaddr(tcp->u_arg[2]); |
| 846 | } else { |
| 847 | printsock(tcp, tcp->u_arg[1], len); |
| 848 | tprintf(", [%d]", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 849 | } |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 850 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 851 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 852 | tprints(", "); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 853 | printflags(sock_type_flags, tcp->u_arg[flags_arg], |
| 854 | "SOCK_???"); |
| 855 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 856 | return 0; |
| 857 | } |
| 858 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 859 | SYS_FUNC(accept) |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 860 | { |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 861 | do_sockname(tcp, -1); |
| 862 | return RVAL_FD; |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 863 | } |
| 864 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 865 | SYS_FUNC(accept4) |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 866 | { |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 867 | do_sockname(tcp, 3); |
| 868 | return RVAL_FD; |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 869 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 870 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 871 | SYS_FUNC(send) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 872 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 873 | printfd(tcp, tcp->u_arg[0]); |
| 874 | tprints(", "); |
| 875 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 876 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 877 | /* flags */ |
| 878 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 879 | |
| 880 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 881 | } |
| 882 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 883 | SYS_FUNC(sendto) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 884 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 885 | printfd(tcp, tcp->u_arg[0]); |
| 886 | tprints(", "); |
| 887 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 888 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 889 | /* flags */ |
| 890 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 891 | /* to address */ |
| 892 | tprints(", "); |
| 893 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
| 894 | /* to length */ |
| 895 | tprintf(", %lu", tcp->u_arg[5]); |
| 896 | |
| 897 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 898 | } |
| 899 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 900 | SYS_FUNC(sendmsg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 901 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 902 | printfd(tcp, tcp->u_arg[0]); |
| 903 | tprints(", "); |
| 904 | printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L); |
| 905 | /* flags */ |
| 906 | tprints(", "); |
| 907 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
| 908 | |
| 909 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 910 | } |
| 911 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 912 | SYS_FUNC(sendmmsg) |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 913 | { |
| 914 | if (entering(tcp)) { |
| 915 | /* sockfd */ |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 916 | printfd(tcp, tcp->u_arg[0]); |
| 917 | tprints(", "); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 918 | if (!verbose(tcp)) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 919 | printaddr(tcp->u_arg[1]); |
| 920 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 921 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 922 | } |
| 923 | } else { |
| 924 | if (verbose(tcp)) |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 925 | decode_mmsg(tcp, (unsigned long) -1L); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 926 | } |
| 927 | return 0; |
| 928 | } |
| 929 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 930 | SYS_FUNC(recv) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 931 | { |
| 932 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 933 | printfd(tcp, tcp->u_arg[0]); |
| 934 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 935 | } else { |
| 936 | if (syserror(tcp)) |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 937 | printaddr(tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 938 | else |
| 939 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 940 | |
| 941 | tprintf(", %lu, ", tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 942 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 943 | } |
| 944 | return 0; |
| 945 | } |
| 946 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 947 | SYS_FUNC(recvfrom) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 948 | { |
| 949 | int fromlen; |
| 950 | |
| 951 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 952 | printfd(tcp, tcp->u_arg[0]); |
| 953 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 954 | } else { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 955 | /* buf */ |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 956 | if (syserror(tcp)) { |
Dmitry V. Levin | 52dc150 | 2015-07-30 13:53:42 +0000 | [diff] [blame] | 957 | printaddr(tcp->u_arg[1]); |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 958 | } else { |
| 959 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 960 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 961 | /* len */ |
| 962 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 963 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 964 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 965 | tprints(", "); |
Dmitry V. Levin | 52dc150 | 2015-07-30 13:53:42 +0000 | [diff] [blame] | 966 | if (syserror(tcp) || !tcp->u_arg[4] || !tcp->u_arg[5] || |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 967 | umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 968 | /* from address, len */ |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 969 | printaddr(tcp->u_arg[4]); |
| 970 | tprints(", "); |
| 971 | printaddr(tcp->u_arg[5]); |
| 972 | return 0; |
| 973 | } |
Denys Vlasenko | 383386d | 2015-07-30 13:29:20 +0200 | [diff] [blame] | 974 | /* from address */ |
| 975 | printsock(tcp, tcp->u_arg[4], fromlen); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 976 | /* from length */ |
| 977 | tprintf(", [%u]", fromlen); |
| 978 | } |
| 979 | return 0; |
| 980 | } |
| 981 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 982 | SYS_FUNC(recvmsg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 983 | { |
| 984 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 985 | printfd(tcp, tcp->u_arg[0]); |
| 986 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 987 | } else { |
Dmitry V. Levin | 00244b9 | 2015-01-28 01:52:25 +0000 | [diff] [blame] | 988 | if (syserror(tcp)) |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 989 | printaddr(tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 990 | else |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 991 | printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 992 | /* flags */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 993 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 994 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 995 | } |
| 996 | return 0; |
| 997 | } |
| 998 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 999 | SYS_FUNC(recvmmsg) |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1000 | { |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1001 | static char str[sizeof("left") + TIMESPEC_TEXT_BUFSIZE]; |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1002 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 1003 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 1004 | printfd(tcp, tcp->u_arg[0]); |
| 1005 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1006 | if (verbose(tcp)) { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 1007 | /* Abusing tcp->auxstr as temp storage. |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1008 | * Will be used and cleared on syscall exit. |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 1009 | */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1010 | tcp->auxstr = sprint_timespec(tcp, tcp->u_arg[4]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1011 | } else { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 1012 | printaddr(tcp->u_arg[1]); |
| 1013 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1014 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1015 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1016 | print_timespec(tcp, tcp->u_arg[4]); |
| 1017 | } |
| 1018 | return 0; |
| 1019 | } else { |
| 1020 | if (verbose(tcp)) { |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 1021 | decode_mmsg(tcp, 0); |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1022 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1023 | /* timeout on entrance */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1024 | tprints(tcp->auxstr); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1025 | tcp->auxstr = NULL; |
| 1026 | } |
| 1027 | if (syserror(tcp)) |
| 1028 | return 0; |
| 1029 | if (tcp->u_rval == 0) { |
| 1030 | tcp->auxstr = "Timeout"; |
| 1031 | return RVAL_STR; |
| 1032 | } |
| 1033 | if (!verbose(tcp)) |
| 1034 | return 0; |
| 1035 | /* timeout on exit */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1036 | snprintf(str, sizeof(str), "left %s", |
| 1037 | sprint_timespec(tcp, tcp->u_arg[4])); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1038 | tcp->auxstr = str; |
| 1039 | return RVAL_STR; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1040 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1041 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1042 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 1043 | #include "xlat/shutdown_modes.h" |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1044 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1045 | SYS_FUNC(shutdown) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1046 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 1047 | printfd(tcp, tcp->u_arg[0]); |
| 1048 | tprints(", "); |
| 1049 | printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???"); |
| 1050 | |
| 1051 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1054 | SYS_FUNC(getsockname) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1055 | { |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 1056 | return do_sockname(tcp, -1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1057 | } |
| 1058 | |
Dmitry V. Levin | 2a4f052 | 2015-08-02 01:54:48 +0000 | [diff] [blame] | 1059 | static void |
| 1060 | printpair_fd(struct tcb *tcp, const int i0, const int i1) |
| 1061 | { |
| 1062 | tprints("["); |
| 1063 | printfd(tcp, i0); |
| 1064 | tprints(", "); |
| 1065 | printfd(tcp, i1); |
| 1066 | tprints("]"); |
| 1067 | } |
| 1068 | |
| 1069 | static void |
| 1070 | decode_pair_fd(struct tcb *tcp, const long addr) |
| 1071 | { |
| 1072 | int pair[2]; |
| 1073 | |
| 1074 | if (umove_or_printaddr(tcp, addr, &pair)) |
| 1075 | return; |
| 1076 | |
| 1077 | printpair_fd(tcp, pair[0], pair[1]); |
| 1078 | } |
| 1079 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1080 | static int |
| 1081 | do_pipe(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1082 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1083 | if (exiting(tcp)) { |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 1084 | decode_pair_fd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1085 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1086 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1087 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 1088 | } |
| 1089 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1090 | return 0; |
| 1091 | } |
| 1092 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1093 | SYS_FUNC(pipe) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1094 | { |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 1095 | #ifdef HAVE_GETRVAL2 |
| 1096 | if (exiting(tcp) && !syserror(tcp)) |
| 1097 | printpair_fd(tcp, tcp->u_rval, getrval2(tcp)); |
| 1098 | return 0; |
| 1099 | #else |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1100 | return do_pipe(tcp, -1); |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 1101 | #endif |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1102 | } |
| 1103 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1104 | SYS_FUNC(pipe2) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1105 | { |
| 1106 | return do_pipe(tcp, 1); |
| 1107 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1108 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1109 | SYS_FUNC(socketpair) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1110 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1111 | if (entering(tcp)) { |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 1112 | printxval(addrfams, tcp->u_arg[0], "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1113 | tprints(", "); |
Dmitry V. Levin | 1e42f2d | 2014-09-10 17:48:28 +0000 | [diff] [blame] | 1114 | tprint_sock_type(tcp->u_arg[1]); |
Dmitry V. Levin | 033fb91 | 2014-03-11 22:50:39 +0000 | [diff] [blame] | 1115 | tprintf(", %lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1116 | } else { |
Dmitry V. Levin | b679508 | 2015-07-06 22:33:39 +0000 | [diff] [blame] | 1117 | tprints(", "); |
Dmitry V. Levin | 2a4f052 | 2015-08-02 01:54:48 +0000 | [diff] [blame] | 1118 | decode_pair_fd(tcp, tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1119 | } |
| 1120 | return 0; |
| 1121 | } |
| 1122 | |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1123 | #include "xlat/sockoptions.h" |
| 1124 | #include "xlat/sockipoptions.h" |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1125 | #include "xlat/getsockipoptions.h" |
| 1126 | #include "xlat/setsockipoptions.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1127 | #include "xlat/sockipv6options.h" |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1128 | #include "xlat/getsockipv6options.h" |
| 1129 | #include "xlat/setsockipv6options.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1130 | #include "xlat/sockipxoptions.h" |
| 1131 | #include "xlat/sockrawoptions.h" |
| 1132 | #include "xlat/sockpacketoptions.h" |
| 1133 | #include "xlat/socksctpoptions.h" |
| 1134 | #include "xlat/socktcpoptions.h" |
| 1135 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1136 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 1137 | print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level, |
| 1138 | unsigned int name, bool is_getsockopt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1139 | { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1140 | printfd(tcp, fd); |
| 1141 | tprints(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1142 | printxval(socketlayers, level, "SOL_??"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1143 | tprints(", "); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1144 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1145 | switch (level) { |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1146 | case SOL_SOCKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1147 | printxval(sockoptions, name, "SO_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1148 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1149 | case SOL_IP: |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1150 | printxvals(name, "IP_???", sockipoptions, |
| 1151 | is_getsockopt ? getsockipoptions : setsockipoptions, NULL); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1152 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1153 | case SOL_IPV6: |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1154 | printxvals(name, "IPV6_???", sockipv6options, |
| 1155 | is_getsockopt ? getsockipv6options : setsockipv6options, NULL); |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 1156 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1157 | case SOL_IPX: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1158 | printxval(sockipxoptions, name, "IPX_???"); |
| 1159 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1160 | case SOL_PACKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1161 | printxval(sockpacketoptions, name, "PACKET_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1162 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1163 | case SOL_TCP: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1164 | printxval(socktcpoptions, name, "TCP_???"); |
| 1165 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1166 | case SOL_SCTP: |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 1167 | printxval(socksctpoptions, name, "SCTP_???"); |
| 1168 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1169 | case SOL_RAW: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1170 | printxval(sockrawoptions, name, "RAW_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1171 | break; |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1172 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1173 | /* Other SOL_* protocol levels still need work. */ |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1174 | |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1175 | default: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1176 | tprintf("%u", name); |
| 1177 | } |
| 1178 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1179 | tprints(", "); |
| 1180 | } |
| 1181 | |
| 1182 | #ifdef SO_LINGER |
| 1183 | static void |
| 1184 | print_linger(struct tcb *tcp, long addr, int len) |
| 1185 | { |
| 1186 | struct linger linger; |
| 1187 | |
| 1188 | if (len != sizeof(linger) || |
| 1189 | umove(tcp, addr, &linger) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1190 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1191 | return; |
| 1192 | } |
| 1193 | |
| 1194 | tprintf("{onoff=%d, linger=%d}", |
| 1195 | linger.l_onoff, |
| 1196 | linger.l_linger); |
| 1197 | } |
| 1198 | #endif /* SO_LINGER */ |
| 1199 | |
| 1200 | #ifdef SO_PEERCRED |
| 1201 | static void |
| 1202 | print_ucred(struct tcb *tcp, long addr, int len) |
| 1203 | { |
| 1204 | struct ucred uc; |
| 1205 | |
| 1206 | if (len != sizeof(uc) || |
| 1207 | umove(tcp, addr, &uc) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1208 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1209 | } else { |
| 1210 | tprintf("{pid=%u, uid=%u, gid=%u}", |
| 1211 | (unsigned) uc.pid, |
| 1212 | (unsigned) uc.uid, |
| 1213 | (unsigned) uc.gid); |
| 1214 | } |
| 1215 | } |
| 1216 | #endif /* SO_PEERCRED */ |
| 1217 | |
| 1218 | #ifdef PACKET_STATISTICS |
| 1219 | static void |
| 1220 | print_tpacket_stats(struct tcb *tcp, long addr, int len) |
| 1221 | { |
| 1222 | struct tpacket_stats stats; |
| 1223 | |
| 1224 | if (len != sizeof(stats) || |
| 1225 | umove(tcp, addr, &stats) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1226 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1227 | } else { |
| 1228 | tprintf("{packets=%u, drops=%u}", |
| 1229 | stats.tp_packets, |
| 1230 | stats.tp_drops); |
| 1231 | } |
| 1232 | } |
| 1233 | #endif /* PACKET_STATISTICS */ |
| 1234 | |
Dmitry V. Levin | fba9db2 | 2016-06-15 21:29:07 +0000 | [diff] [blame] | 1235 | #include "xlat/icmpfilterflags.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1236 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1237 | static void |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1238 | print_icmp_filter(struct tcb *tcp, const long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1239 | { |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1240 | struct icmp_filter filter = {}; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1241 | |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1242 | if (len > (int) sizeof(filter)) |
| 1243 | len = sizeof(filter); |
| 1244 | else if (len <= 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1245 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1246 | return; |
| 1247 | } |
| 1248 | |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1249 | if (umoven_or_printaddr(tcp, addr, len, &filter)) |
| 1250 | return; |
| 1251 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1252 | tprints("~("); |
| 1253 | printflags(icmpfilterflags, ~filter.data, "ICMP_???"); |
| 1254 | tprints(")"); |
| 1255 | } |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1256 | |
| 1257 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 1258 | print_getsockopt(struct tcb *tcp, unsigned int level, unsigned int name, |
| 1259 | long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1260 | { |
| 1261 | if (addr && verbose(tcp)) |
| 1262 | switch (level) { |
| 1263 | case SOL_SOCKET: |
| 1264 | switch (name) { |
| 1265 | #ifdef SO_LINGER |
| 1266 | case SO_LINGER: |
| 1267 | print_linger(tcp, addr, len); |
| 1268 | goto done; |
| 1269 | #endif |
| 1270 | #ifdef SO_PEERCRED |
| 1271 | case SO_PEERCRED: |
| 1272 | print_ucred(tcp, addr, len); |
| 1273 | goto done; |
| 1274 | #endif |
| 1275 | } |
| 1276 | break; |
| 1277 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1278 | case SOL_PACKET: |
| 1279 | switch (name) { |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1280 | #ifdef PACKET_STATISTICS |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1281 | case PACKET_STATISTICS: |
| 1282 | print_tpacket_stats(tcp, addr, len); |
| 1283 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1284 | #endif |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1285 | } |
| 1286 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1287 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1288 | case SOL_RAW: |
| 1289 | switch (name) { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1290 | case ICMP_FILTER: |
| 1291 | print_icmp_filter(tcp, addr, len); |
| 1292 | goto done; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1293 | } |
| 1294 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1295 | } |
| 1296 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1297 | /* default arg printing */ |
| 1298 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1299 | if (verbose(tcp)) { |
| 1300 | if (len == sizeof(int)) { |
| 1301 | printnum_int(tcp, addr, "%d"); |
| 1302 | } else { |
| 1303 | printstr(tcp, addr, len); |
| 1304 | } |
| 1305 | } else { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1306 | printaddr(addr); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1307 | } |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1308 | done: |
| 1309 | tprintf(", [%d]", len); |
| 1310 | } |
| 1311 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1312 | SYS_FUNC(getsockopt) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1313 | { |
| 1314 | if (entering(tcp)) { |
| 1315 | print_sockopt_fd_level_name(tcp, tcp->u_arg[0], |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1316 | tcp->u_arg[1], tcp->u_arg[2], true); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1317 | } else { |
| 1318 | int len; |
| 1319 | |
| 1320 | if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 1321 | printaddr(tcp->u_arg[3]); |
| 1322 | tprints(", "); |
| 1323 | printaddr(tcp->u_arg[4]); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1324 | } else { |
| 1325 | print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 1326 | tcp->u_arg[3], len); |
| 1327 | } |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1328 | } |
| 1329 | return 0; |
| 1330 | } |
| 1331 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1332 | #ifdef IP_ADD_MEMBERSHIP |
| 1333 | static void |
| 1334 | print_mreq(struct tcb *tcp, long addr, unsigned int len) |
| 1335 | { |
| 1336 | struct ip_mreq mreq; |
| 1337 | |
| 1338 | if (len < sizeof(mreq)) { |
| 1339 | printstr(tcp, addr, len); |
| 1340 | return; |
| 1341 | } |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1342 | if (umove_or_printaddr(tcp, addr, &mreq)) |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1343 | return; |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1344 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1345 | tprints("{imr_multiaddr=inet_addr("); |
| 1346 | print_quoted_string(inet_ntoa(mreq.imr_multiaddr), |
| 1347 | 16, QUOTE_0_TERMINATED); |
| 1348 | tprints("), imr_interface=inet_addr("); |
| 1349 | print_quoted_string(inet_ntoa(mreq.imr_interface), |
| 1350 | 16, QUOTE_0_TERMINATED); |
| 1351 | tprints(")}"); |
| 1352 | } |
| 1353 | #endif /* IP_ADD_MEMBERSHIP */ |
| 1354 | |
| 1355 | #ifdef IPV6_ADD_MEMBERSHIP |
| 1356 | static void |
| 1357 | print_mreq6(struct tcb *tcp, long addr, unsigned int len) |
| 1358 | { |
| 1359 | struct ipv6_mreq mreq; |
| 1360 | |
| 1361 | if (len < sizeof(mreq)) |
| 1362 | goto fail; |
| 1363 | |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1364 | if (umove_or_printaddr(tcp, addr, &mreq)) |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1365 | return; |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1366 | |
| 1367 | #ifdef HAVE_INET_NTOP |
| 1368 | const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr; |
| 1369 | char address[INET6_ADDRSTRLEN]; |
| 1370 | |
| 1371 | if (!inet_ntop(AF_INET6, in6, address, sizeof(address))) |
| 1372 | goto fail; |
| 1373 | |
| 1374 | tprints("{ipv6mr_multiaddr=inet_pton("); |
| 1375 | print_quoted_string(address, sizeof(address), QUOTE_0_TERMINATED); |
| 1376 | tprints("), ipv6mr_interface="); |
| 1377 | print_ifindex(mreq.ipv6mr_interface); |
| 1378 | tprints("}"); |
| 1379 | return; |
| 1380 | #endif /* HAVE_INET_NTOP */ |
| 1381 | |
| 1382 | fail: |
| 1383 | printstr(tcp, addr, len); |
| 1384 | } |
| 1385 | #endif /* IPV6_ADD_MEMBERSHIP */ |
| 1386 | |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1387 | #ifdef MCAST_JOIN_GROUP |
| 1388 | static void |
| 1389 | print_group_req(struct tcb *tcp, long addr, int len) |
| 1390 | { |
| 1391 | struct group_req greq; |
| 1392 | |
| 1393 | if (len != sizeof(greq) || |
| 1394 | umove(tcp, addr, &greq) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1395 | printaddr(addr); |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1396 | return; |
| 1397 | } |
| 1398 | |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 1399 | tprintf("{gr_interface=%u, gr_group=", greq.gr_interface); |
| 1400 | print_sockaddr(tcp, (const void *) &greq.gr_group, |
| 1401 | sizeof(greq.gr_group)); |
| 1402 | tprintf("}"); |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1403 | |
| 1404 | } |
| 1405 | #endif /* MCAST_JOIN_GROUP */ |
| 1406 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1407 | #ifdef PACKET_RX_RING |
| 1408 | static void |
| 1409 | print_tpacket_req(struct tcb *tcp, long addr, int len) |
| 1410 | { |
| 1411 | struct tpacket_req req; |
| 1412 | |
| 1413 | if (len != sizeof(req) || |
| 1414 | umove(tcp, addr, &req) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1415 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1416 | } else { |
| 1417 | tprintf("{block_size=%u, block_nr=%u, " |
| 1418 | "frame_size=%u, frame_nr=%u}", |
| 1419 | req.tp_block_size, |
| 1420 | req.tp_block_nr, |
| 1421 | req.tp_frame_size, |
| 1422 | req.tp_frame_nr); |
| 1423 | } |
| 1424 | } |
| 1425 | #endif /* PACKET_RX_RING */ |
| 1426 | |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 1427 | #ifdef PACKET_ADD_MEMBERSHIP |
| 1428 | # include "xlat/packet_mreq_type.h" |
| 1429 | |
| 1430 | static void |
| 1431 | print_packet_mreq(struct tcb *tcp, long addr, int len) |
| 1432 | { |
| 1433 | struct packet_mreq mreq; |
| 1434 | |
| 1435 | if (len != sizeof(mreq) || |
| 1436 | umove(tcp, addr, &mreq) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1437 | printaddr(addr); |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 1438 | } else { |
| 1439 | unsigned int i; |
| 1440 | |
| 1441 | tprintf("{mr_ifindex=%u, mr_type=", mreq.mr_ifindex); |
| 1442 | printxval(packet_mreq_type, mreq.mr_type, "PACKET_MR_???"); |
| 1443 | tprintf(", mr_alen=%u, mr_address=", mreq.mr_alen); |
| 1444 | if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address)) |
| 1445 | mreq.mr_alen = ARRAY_SIZE(mreq.mr_address); |
| 1446 | for (i = 0; i < mreq.mr_alen; ++i) |
| 1447 | tprintf("%02x", mreq.mr_address[i]); |
| 1448 | tprints("}"); |
| 1449 | } |
| 1450 | } |
| 1451 | #endif /* PACKET_ADD_MEMBERSHIP */ |
| 1452 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1453 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 1454 | print_setsockopt(struct tcb *tcp, unsigned int level, unsigned int name, |
| 1455 | long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1456 | { |
| 1457 | if (addr && verbose(tcp)) |
| 1458 | switch (level) { |
| 1459 | case SOL_SOCKET: |
| 1460 | switch (name) { |
| 1461 | #ifdef SO_LINGER |
| 1462 | case SO_LINGER: |
| 1463 | print_linger(tcp, addr, len); |
| 1464 | goto done; |
| 1465 | #endif |
| 1466 | } |
| 1467 | break; |
| 1468 | |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1469 | case SOL_IP: |
| 1470 | switch (name) { |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1471 | #ifdef IP_ADD_MEMBERSHIP |
| 1472 | case IP_ADD_MEMBERSHIP: |
| 1473 | case IP_DROP_MEMBERSHIP: |
| 1474 | print_mreq(tcp, addr, len); |
| 1475 | goto done; |
| 1476 | #endif /* IP_ADD_MEMBERSHIP */ |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1477 | #ifdef MCAST_JOIN_GROUP |
| 1478 | case MCAST_JOIN_GROUP: |
| 1479 | case MCAST_LEAVE_GROUP: |
| 1480 | print_group_req(tcp, addr, len); |
| 1481 | goto done; |
| 1482 | #endif /* MCAST_JOIN_GROUP */ |
| 1483 | } |
Dmitry V. Levin | 3910d0f | 2015-02-08 01:19:06 +0000 | [diff] [blame] | 1484 | break; |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1485 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1486 | case SOL_IPV6: |
| 1487 | switch (name) { |
| 1488 | #ifdef IPV6_ADD_MEMBERSHIP |
| 1489 | case IPV6_ADD_MEMBERSHIP: |
| 1490 | case IPV6_DROP_MEMBERSHIP: |
| 1491 | # ifdef IPV6_JOIN_ANYCAST |
| 1492 | case IPV6_JOIN_ANYCAST: |
| 1493 | # endif |
| 1494 | # ifdef IPV6_LEAVE_ANYCAST |
| 1495 | case IPV6_LEAVE_ANYCAST: |
| 1496 | # endif |
| 1497 | print_mreq6(tcp, addr, len); |
| 1498 | goto done; |
| 1499 | #endif /* IPV6_ADD_MEMBERSHIP */ |
| 1500 | } |
| 1501 | break; |
| 1502 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1503 | case SOL_PACKET: |
| 1504 | switch (name) { |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1505 | #ifdef PACKET_RX_RING |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1506 | case PACKET_RX_RING: |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1507 | # ifdef PACKET_TX_RING |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1508 | case PACKET_TX_RING: |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1509 | # endif |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1510 | print_tpacket_req(tcp, addr, len); |
| 1511 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1512 | #endif /* PACKET_RX_RING */ |
| 1513 | #ifdef PACKET_ADD_MEMBERSHIP |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 1514 | case PACKET_ADD_MEMBERSHIP: |
| 1515 | case PACKET_DROP_MEMBERSHIP: |
| 1516 | print_packet_mreq(tcp, addr, len); |
| 1517 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1518 | #endif /* PACKET_ADD_MEMBERSHIP */ |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1519 | } |
| 1520 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1521 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1522 | case SOL_RAW: |
| 1523 | switch (name) { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1524 | case ICMP_FILTER: |
| 1525 | print_icmp_filter(tcp, addr, len); |
| 1526 | goto done; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1527 | } |
| 1528 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1529 | } |
| 1530 | |
| 1531 | /* default arg printing */ |
| 1532 | |
| 1533 | if (verbose(tcp)) { |
| 1534 | if (len == sizeof(int)) { |
| 1535 | printnum_int(tcp, addr, "%d"); |
| 1536 | } else { |
| 1537 | printstr(tcp, addr, len); |
| 1538 | } |
| 1539 | } else { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1540 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1541 | } |
| 1542 | done: |
| 1543 | tprintf(", %d", len); |
| 1544 | } |
| 1545 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1546 | SYS_FUNC(setsockopt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1547 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 1548 | print_sockopt_fd_level_name(tcp, tcp->u_arg[0], |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1549 | tcp->u_arg[1], tcp->u_arg[2], false); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 1550 | print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 1551 | tcp->u_arg[3], tcp->u_arg[4]); |
| 1552 | |
| 1553 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1554 | } |