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