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