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