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 | 9134aab | 2016-05-14 21:46:05 +0000 | [diff] [blame] | 773 | tprint_sock_type(unsigned 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)) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame^] | 933 | printaddr(tcp->u_arg[1]); |
| 934 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 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 { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame^] | 1026 | printaddr(tcp->u_arg[1]); |
| 1027 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1028 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1029 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1030 | print_timespec(tcp, tcp->u_arg[4]); |
| 1031 | } |
| 1032 | return 0; |
| 1033 | } else { |
| 1034 | if (verbose(tcp)) { |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 1035 | decode_mmsg(tcp, 0); |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1036 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1037 | /* timeout on entrance */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1038 | tprints(tcp->auxstr); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1039 | tcp->auxstr = NULL; |
| 1040 | } |
| 1041 | if (syserror(tcp)) |
| 1042 | return 0; |
| 1043 | if (tcp->u_rval == 0) { |
| 1044 | tcp->auxstr = "Timeout"; |
| 1045 | return RVAL_STR; |
| 1046 | } |
| 1047 | if (!verbose(tcp)) |
| 1048 | return 0; |
| 1049 | /* timeout on exit */ |
Dmitry V. Levin | 2950de3 | 2015-09-18 17:44:16 +0000 | [diff] [blame] | 1050 | snprintf(str, sizeof(str), "left %s", |
| 1051 | sprint_timespec(tcp, tcp->u_arg[4])); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1052 | tcp->auxstr = str; |
| 1053 | return RVAL_STR; |
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 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1056 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 1057 | #include "xlat/shutdown_modes.h" |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1058 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1059 | SYS_FUNC(shutdown) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1060 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 1061 | printfd(tcp, tcp->u_arg[0]); |
| 1062 | tprints(", "); |
| 1063 | printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???"); |
| 1064 | |
| 1065 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1068 | SYS_FUNC(getsockname) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1069 | { |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 1070 | return do_sockname(tcp, -1); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
Dmitry V. Levin | 2a4f052 | 2015-08-02 01:54:48 +0000 | [diff] [blame] | 1073 | static void |
| 1074 | printpair_fd(struct tcb *tcp, const int i0, const int i1) |
| 1075 | { |
| 1076 | tprints("["); |
| 1077 | printfd(tcp, i0); |
| 1078 | tprints(", "); |
| 1079 | printfd(tcp, i1); |
| 1080 | tprints("]"); |
| 1081 | } |
| 1082 | |
| 1083 | static void |
| 1084 | decode_pair_fd(struct tcb *tcp, const long addr) |
| 1085 | { |
| 1086 | int pair[2]; |
| 1087 | |
| 1088 | if (umove_or_printaddr(tcp, addr, &pair)) |
| 1089 | return; |
| 1090 | |
| 1091 | printpair_fd(tcp, pair[0], pair[1]); |
| 1092 | } |
| 1093 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1094 | static int |
| 1095 | do_pipe(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1096 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1097 | if (exiting(tcp)) { |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 1098 | decode_pair_fd(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1099 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1100 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1101 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 1102 | } |
| 1103 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1104 | return 0; |
| 1105 | } |
| 1106 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1107 | SYS_FUNC(pipe) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1108 | { |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 1109 | #ifdef HAVE_GETRVAL2 |
| 1110 | if (exiting(tcp) && !syserror(tcp)) |
| 1111 | printpair_fd(tcp, tcp->u_rval, getrval2(tcp)); |
| 1112 | return 0; |
| 1113 | #else |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1114 | return do_pipe(tcp, -1); |
Dmitry V. Levin | 9b38885 | 2016-02-12 16:37:31 +0000 | [diff] [blame] | 1115 | #endif |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1116 | } |
| 1117 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1118 | SYS_FUNC(pipe2) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1119 | { |
| 1120 | return do_pipe(tcp, 1); |
| 1121 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1122 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1123 | SYS_FUNC(socketpair) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1124 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1125 | if (entering(tcp)) { |
Dmitry V. Levin | 71fe62e | 2016-04-04 01:35:28 +0000 | [diff] [blame] | 1126 | printxval(addrfams, tcp->u_arg[0], "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1127 | tprints(", "); |
Dmitry V. Levin | 1e42f2d | 2014-09-10 17:48:28 +0000 | [diff] [blame] | 1128 | tprint_sock_type(tcp->u_arg[1]); |
Dmitry V. Levin | 033fb91 | 2014-03-11 22:50:39 +0000 | [diff] [blame] | 1129 | tprintf(", %lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1130 | } else { |
Dmitry V. Levin | b679508 | 2015-07-06 22:33:39 +0000 | [diff] [blame] | 1131 | tprints(", "); |
Dmitry V. Levin | 2a4f052 | 2015-08-02 01:54:48 +0000 | [diff] [blame] | 1132 | decode_pair_fd(tcp, tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1133 | } |
| 1134 | return 0; |
| 1135 | } |
| 1136 | |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1137 | #include "xlat/sockoptions.h" |
| 1138 | #include "xlat/sockipoptions.h" |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1139 | #include "xlat/getsockipoptions.h" |
| 1140 | #include "xlat/setsockipoptions.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1141 | #include "xlat/sockipv6options.h" |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1142 | #include "xlat/getsockipv6options.h" |
| 1143 | #include "xlat/setsockipv6options.h" |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1144 | #include "xlat/sockipxoptions.h" |
| 1145 | #include "xlat/sockrawoptions.h" |
| 1146 | #include "xlat/sockpacketoptions.h" |
| 1147 | #include "xlat/socksctpoptions.h" |
| 1148 | #include "xlat/socktcpoptions.h" |
| 1149 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1150 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 1151 | print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level, |
| 1152 | unsigned int name, bool is_getsockopt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1153 | { |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1154 | printfd(tcp, fd); |
| 1155 | tprints(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1156 | printxval(socketlayers, level, "SOL_??"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1157 | tprints(", "); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1158 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1159 | switch (level) { |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1160 | case SOL_SOCKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1161 | printxval(sockoptions, name, "SO_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1162 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1163 | case SOL_IP: |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1164 | printxvals(name, "IP_???", sockipoptions, |
| 1165 | is_getsockopt ? getsockipoptions : setsockipoptions, NULL); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1166 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1167 | case SOL_IPV6: |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1168 | printxvals(name, "IPV6_???", sockipv6options, |
| 1169 | is_getsockopt ? getsockipv6options : setsockipv6options, NULL); |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 1170 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1171 | case SOL_IPX: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1172 | printxval(sockipxoptions, name, "IPX_???"); |
| 1173 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1174 | case SOL_PACKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1175 | printxval(sockpacketoptions, name, "PACKET_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1176 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1177 | case SOL_TCP: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1178 | printxval(socktcpoptions, name, "TCP_???"); |
| 1179 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1180 | case SOL_SCTP: |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 1181 | printxval(socksctpoptions, name, "SCTP_???"); |
| 1182 | break; |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1183 | case SOL_RAW: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1184 | printxval(sockrawoptions, name, "RAW_???"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1185 | break; |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1186 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1187 | /* Other SOL_* protocol levels still need work. */ |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1188 | |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1189 | default: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1190 | tprintf("%u", name); |
| 1191 | } |
| 1192 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1193 | tprints(", "); |
| 1194 | } |
| 1195 | |
| 1196 | #ifdef SO_LINGER |
| 1197 | static void |
| 1198 | print_linger(struct tcb *tcp, long addr, int len) |
| 1199 | { |
| 1200 | struct linger linger; |
| 1201 | |
| 1202 | if (len != sizeof(linger) || |
| 1203 | umove(tcp, addr, &linger) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1204 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1205 | return; |
| 1206 | } |
| 1207 | |
| 1208 | tprintf("{onoff=%d, linger=%d}", |
| 1209 | linger.l_onoff, |
| 1210 | linger.l_linger); |
| 1211 | } |
| 1212 | #endif /* SO_LINGER */ |
| 1213 | |
| 1214 | #ifdef SO_PEERCRED |
| 1215 | static void |
| 1216 | print_ucred(struct tcb *tcp, long addr, int len) |
| 1217 | { |
| 1218 | struct ucred uc; |
| 1219 | |
| 1220 | if (len != sizeof(uc) || |
| 1221 | umove(tcp, addr, &uc) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1222 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1223 | } else { |
| 1224 | tprintf("{pid=%u, uid=%u, gid=%u}", |
| 1225 | (unsigned) uc.pid, |
| 1226 | (unsigned) uc.uid, |
| 1227 | (unsigned) uc.gid); |
| 1228 | } |
| 1229 | } |
| 1230 | #endif /* SO_PEERCRED */ |
| 1231 | |
| 1232 | #ifdef PACKET_STATISTICS |
| 1233 | static void |
| 1234 | print_tpacket_stats(struct tcb *tcp, long addr, int len) |
| 1235 | { |
| 1236 | struct tpacket_stats stats; |
| 1237 | |
| 1238 | if (len != sizeof(stats) || |
| 1239 | umove(tcp, addr, &stats) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1240 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1241 | } else { |
| 1242 | tprintf("{packets=%u, drops=%u}", |
| 1243 | stats.tp_packets, |
| 1244 | stats.tp_drops); |
| 1245 | } |
| 1246 | } |
| 1247 | #endif /* PACKET_STATISTICS */ |
| 1248 | |
| 1249 | #ifdef ICMP_FILTER |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1250 | # include "xlat/icmpfilterflags.h" |
| 1251 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1252 | static void |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1253 | print_icmp_filter(struct tcb *tcp, const long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1254 | { |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1255 | struct icmp_filter filter = {}; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1256 | |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1257 | if (len > (int) sizeof(filter)) |
| 1258 | len = sizeof(filter); |
| 1259 | else if (len <= 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1260 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1261 | return; |
| 1262 | } |
| 1263 | |
Dmitry V. Levin | eb5c233 | 2016-05-06 00:06:15 +0000 | [diff] [blame] | 1264 | if (umoven_or_printaddr(tcp, addr, len, &filter)) |
| 1265 | return; |
| 1266 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1267 | tprints("~("); |
| 1268 | printflags(icmpfilterflags, ~filter.data, "ICMP_???"); |
| 1269 | tprints(")"); |
| 1270 | } |
| 1271 | #endif /* ICMP_FILTER */ |
| 1272 | |
| 1273 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 1274 | print_getsockopt(struct tcb *tcp, unsigned int level, unsigned int name, |
| 1275 | long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 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) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame^] | 1339 | printaddr(tcp->u_arg[3]); |
| 1340 | tprints(", "); |
| 1341 | printaddr(tcp->u_arg[4]); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1342 | } else { |
| 1343 | print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 1344 | tcp->u_arg[3], len); |
| 1345 | } |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1346 | } |
| 1347 | return 0; |
| 1348 | } |
| 1349 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1350 | #ifdef IP_ADD_MEMBERSHIP |
| 1351 | static void |
| 1352 | print_mreq(struct tcb *tcp, long addr, unsigned int len) |
| 1353 | { |
| 1354 | struct ip_mreq mreq; |
| 1355 | |
| 1356 | if (len < sizeof(mreq)) { |
| 1357 | printstr(tcp, addr, len); |
| 1358 | return; |
| 1359 | } |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1360 | if (umove_or_printaddr(tcp, addr, &mreq)) |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1361 | return; |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1362 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1363 | tprints("{imr_multiaddr=inet_addr("); |
| 1364 | print_quoted_string(inet_ntoa(mreq.imr_multiaddr), |
| 1365 | 16, QUOTE_0_TERMINATED); |
| 1366 | tprints("), imr_interface=inet_addr("); |
| 1367 | print_quoted_string(inet_ntoa(mreq.imr_interface), |
| 1368 | 16, QUOTE_0_TERMINATED); |
| 1369 | tprints(")}"); |
| 1370 | } |
| 1371 | #endif /* IP_ADD_MEMBERSHIP */ |
| 1372 | |
| 1373 | #ifdef IPV6_ADD_MEMBERSHIP |
| 1374 | static void |
| 1375 | print_mreq6(struct tcb *tcp, long addr, unsigned int len) |
| 1376 | { |
| 1377 | struct ipv6_mreq mreq; |
| 1378 | |
| 1379 | if (len < sizeof(mreq)) |
| 1380 | goto fail; |
| 1381 | |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1382 | if (umove_or_printaddr(tcp, addr, &mreq)) |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1383 | return; |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1384 | |
| 1385 | #ifdef HAVE_INET_NTOP |
| 1386 | const struct in6_addr *in6 = &mreq.ipv6mr_multiaddr; |
| 1387 | char address[INET6_ADDRSTRLEN]; |
| 1388 | |
| 1389 | if (!inet_ntop(AF_INET6, in6, address, sizeof(address))) |
| 1390 | goto fail; |
| 1391 | |
| 1392 | tprints("{ipv6mr_multiaddr=inet_pton("); |
| 1393 | print_quoted_string(address, sizeof(address), QUOTE_0_TERMINATED); |
| 1394 | tprints("), ipv6mr_interface="); |
| 1395 | print_ifindex(mreq.ipv6mr_interface); |
| 1396 | tprints("}"); |
| 1397 | return; |
| 1398 | #endif /* HAVE_INET_NTOP */ |
| 1399 | |
| 1400 | fail: |
| 1401 | printstr(tcp, addr, len); |
| 1402 | } |
| 1403 | #endif /* IPV6_ADD_MEMBERSHIP */ |
| 1404 | |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1405 | #ifdef MCAST_JOIN_GROUP |
| 1406 | static void |
| 1407 | print_group_req(struct tcb *tcp, long addr, int len) |
| 1408 | { |
| 1409 | struct group_req greq; |
| 1410 | |
| 1411 | if (len != sizeof(greq) || |
| 1412 | umove(tcp, addr, &greq) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1413 | printaddr(addr); |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1414 | return; |
| 1415 | } |
| 1416 | |
Dmitry V. Levin | 1019f00 | 2015-11-21 02:38:59 +0000 | [diff] [blame] | 1417 | tprintf("{gr_interface=%u, gr_group=", greq.gr_interface); |
| 1418 | print_sockaddr(tcp, (const void *) &greq.gr_group, |
| 1419 | sizeof(greq.gr_group)); |
| 1420 | tprintf("}"); |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1421 | |
| 1422 | } |
| 1423 | #endif /* MCAST_JOIN_GROUP */ |
| 1424 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1425 | #ifdef PACKET_RX_RING |
| 1426 | static void |
| 1427 | print_tpacket_req(struct tcb *tcp, long addr, int len) |
| 1428 | { |
| 1429 | struct tpacket_req req; |
| 1430 | |
| 1431 | if (len != sizeof(req) || |
| 1432 | umove(tcp, addr, &req) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1433 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1434 | } else { |
| 1435 | tprintf("{block_size=%u, block_nr=%u, " |
| 1436 | "frame_size=%u, frame_nr=%u}", |
| 1437 | req.tp_block_size, |
| 1438 | req.tp_block_nr, |
| 1439 | req.tp_frame_size, |
| 1440 | req.tp_frame_nr); |
| 1441 | } |
| 1442 | } |
| 1443 | #endif /* PACKET_RX_RING */ |
| 1444 | |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 1445 | #ifdef PACKET_ADD_MEMBERSHIP |
| 1446 | # include "xlat/packet_mreq_type.h" |
| 1447 | |
| 1448 | static void |
| 1449 | print_packet_mreq(struct tcb *tcp, long addr, int len) |
| 1450 | { |
| 1451 | struct packet_mreq mreq; |
| 1452 | |
| 1453 | if (len != sizeof(mreq) || |
| 1454 | umove(tcp, addr, &mreq) < 0) { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1455 | printaddr(addr); |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 1456 | } else { |
| 1457 | unsigned int i; |
| 1458 | |
| 1459 | tprintf("{mr_ifindex=%u, mr_type=", mreq.mr_ifindex); |
| 1460 | printxval(packet_mreq_type, mreq.mr_type, "PACKET_MR_???"); |
| 1461 | tprintf(", mr_alen=%u, mr_address=", mreq.mr_alen); |
| 1462 | if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address)) |
| 1463 | mreq.mr_alen = ARRAY_SIZE(mreq.mr_address); |
| 1464 | for (i = 0; i < mreq.mr_alen; ++i) |
| 1465 | tprintf("%02x", mreq.mr_address[i]); |
| 1466 | tprints("}"); |
| 1467 | } |
| 1468 | } |
| 1469 | #endif /* PACKET_ADD_MEMBERSHIP */ |
| 1470 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1471 | static void |
Dmitry V. Levin | f40ea79 | 2016-04-01 01:03:20 +0000 | [diff] [blame] | 1472 | print_setsockopt(struct tcb *tcp, unsigned int level, unsigned int name, |
| 1473 | long addr, int len) |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1474 | { |
| 1475 | if (addr && verbose(tcp)) |
| 1476 | switch (level) { |
| 1477 | case SOL_SOCKET: |
| 1478 | switch (name) { |
| 1479 | #ifdef SO_LINGER |
| 1480 | case SO_LINGER: |
| 1481 | print_linger(tcp, addr, len); |
| 1482 | goto done; |
| 1483 | #endif |
| 1484 | } |
| 1485 | break; |
| 1486 | |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1487 | case SOL_IP: |
| 1488 | switch (name) { |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1489 | #ifdef IP_ADD_MEMBERSHIP |
| 1490 | case IP_ADD_MEMBERSHIP: |
| 1491 | case IP_DROP_MEMBERSHIP: |
| 1492 | print_mreq(tcp, addr, len); |
| 1493 | goto done; |
| 1494 | #endif /* IP_ADD_MEMBERSHIP */ |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1495 | #ifdef MCAST_JOIN_GROUP |
| 1496 | case MCAST_JOIN_GROUP: |
| 1497 | case MCAST_LEAVE_GROUP: |
| 1498 | print_group_req(tcp, addr, len); |
| 1499 | goto done; |
| 1500 | #endif /* MCAST_JOIN_GROUP */ |
| 1501 | } |
Dmitry V. Levin | 3910d0f | 2015-02-08 01:19:06 +0000 | [diff] [blame] | 1502 | break; |
Dmitry V. Levin | a0a4909 | 2015-01-30 01:55:20 +0000 | [diff] [blame] | 1503 | |
Dmitry V. Levin | 7bee462 | 2015-06-08 14:19:46 +0000 | [diff] [blame] | 1504 | case SOL_IPV6: |
| 1505 | switch (name) { |
| 1506 | #ifdef IPV6_ADD_MEMBERSHIP |
| 1507 | case IPV6_ADD_MEMBERSHIP: |
| 1508 | case IPV6_DROP_MEMBERSHIP: |
| 1509 | # ifdef IPV6_JOIN_ANYCAST |
| 1510 | case IPV6_JOIN_ANYCAST: |
| 1511 | # endif |
| 1512 | # ifdef IPV6_LEAVE_ANYCAST |
| 1513 | case IPV6_LEAVE_ANYCAST: |
| 1514 | # endif |
| 1515 | print_mreq6(tcp, addr, len); |
| 1516 | goto done; |
| 1517 | #endif /* IPV6_ADD_MEMBERSHIP */ |
| 1518 | } |
| 1519 | break; |
| 1520 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1521 | case SOL_PACKET: |
| 1522 | switch (name) { |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1523 | #ifdef PACKET_RX_RING |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1524 | case PACKET_RX_RING: |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1525 | # ifdef PACKET_TX_RING |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1526 | case PACKET_TX_RING: |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1527 | # endif |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1528 | print_tpacket_req(tcp, addr, len); |
| 1529 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1530 | #endif /* PACKET_RX_RING */ |
| 1531 | #ifdef PACKET_ADD_MEMBERSHIP |
Dmitry V. Levin | 02f2f09 | 2015-01-29 03:26:53 +0000 | [diff] [blame] | 1532 | case PACKET_ADD_MEMBERSHIP: |
| 1533 | case PACKET_DROP_MEMBERSHIP: |
| 1534 | print_packet_mreq(tcp, addr, len); |
| 1535 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1536 | #endif /* PACKET_ADD_MEMBERSHIP */ |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1537 | } |
| 1538 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1539 | |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1540 | case SOL_RAW: |
| 1541 | switch (name) { |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1542 | #ifdef ICMP_FILTER |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1543 | case ICMP_FILTER: |
| 1544 | print_icmp_filter(tcp, addr, len); |
| 1545 | goto done; |
Dmitry V. Levin | 6d31c7a | 2015-01-29 04:42:37 +0000 | [diff] [blame] | 1546 | #endif |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1547 | } |
| 1548 | break; |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1549 | } |
| 1550 | |
| 1551 | /* default arg printing */ |
| 1552 | |
| 1553 | if (verbose(tcp)) { |
| 1554 | if (len == sizeof(int)) { |
| 1555 | printnum_int(tcp, addr, "%d"); |
| 1556 | } else { |
| 1557 | printstr(tcp, addr, len); |
| 1558 | } |
| 1559 | } else { |
Dmitry V. Levin | 6c277da | 2015-07-19 22:36:46 +0000 | [diff] [blame] | 1560 | printaddr(addr); |
Dmitry V. Levin | 0509c8e | 2015-01-29 03:11:41 +0000 | [diff] [blame] | 1561 | } |
| 1562 | done: |
| 1563 | tprintf(", %d", len); |
| 1564 | } |
| 1565 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 1566 | SYS_FUNC(setsockopt) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1567 | { |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 1568 | print_sockopt_fd_level_name(tcp, tcp->u_arg[0], |
Mike Frysinger | 54646b8 | 2015-08-19 13:29:27 -0400 | [diff] [blame] | 1569 | tcp->u_arg[1], tcp->u_arg[2], false); |
Dmitry V. Levin | 219b3a7 | 2015-07-19 22:52:47 +0000 | [diff] [blame] | 1570 | print_setsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
| 1571 | tcp->u_arg[3], tcp->u_arg[4]); |
| 1572 | |
| 1573 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1574 | } |