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