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> |
| 34 | #include <sys/un.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 35 | #if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 36 | # define in6_addr in6_addr_libc |
| 37 | # define ipv6_mreq ipv6_mreq_libc |
| 38 | # define sockaddr_in6 sockaddr_in6_libc |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 39 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 40 | #include <netinet/in.h> |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 41 | #ifdef HAVE_NETINET_TCP_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 42 | # include <netinet/tcp.h> |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 43 | #endif |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 44 | #ifdef HAVE_NETINET_UDP_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 45 | # include <netinet/udp.h> |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 46 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 47 | #ifdef HAVE_NETINET_SCTP_H |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 48 | # include <netinet/sctp.h> |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 49 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 50 | #include <arpa/inet.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 51 | #include <net/if.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | #include <asm/types.h> |
Denys Vlasenko | 99aa181 | 2013-02-08 18:49:06 +0100 | [diff] [blame] | 53 | #if defined(__GLIBC__) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 54 | # include <netipx/ipx.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | #else |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 56 | # include <linux/ipx.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 58 | |
Denys Vlasenko | 99aa181 | 2013-02-08 18:49:06 +0100 | [diff] [blame] | 59 | #if defined(__GLIBC__) && defined(HAVE_SIN6_SCOPE_ID_LINUX) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 60 | # if defined(HAVE_LINUX_IN6_H) |
| 61 | # if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 62 | # undef in6_addr |
| 63 | # undef ipv6_mreq |
| 64 | # undef sockaddr_in6 |
| 65 | # define in6_addr in6_addr_kernel |
| 66 | # define ipv6_mreq ipv6_mreq_kernel |
| 67 | # define sockaddr_in6 sockaddr_in6_kernel |
| 68 | # endif |
| 69 | # include <linux/in6.h> |
| 70 | # if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 71 | # undef in6_addr |
| 72 | # undef ipv6_mreq |
| 73 | # undef sockaddr_in6 |
| 74 | # define in6_addr in6_addr_libc |
| 75 | # define ipv6_mreq ipv6_mreq_libc |
| 76 | # define sockaddr_in6 sockaddr_in6_kernel |
| 77 | # endif |
| 78 | # endif |
Wichert Akkerman | 2f473da | 1999-11-01 19:53:31 +0000 | [diff] [blame] | 79 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 80 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 81 | #if defined(HAVE_SYS_UIO_H) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 82 | # include <sys/uio.h> |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 83 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 84 | #if defined(HAVE_LINUX_NETLINK_H) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 85 | # include <linux/netlink.h> |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 86 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 87 | #if defined(HAVE_LINUX_IF_PACKET_H) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 88 | # include <linux/if_packet.h> |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 89 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 90 | #if defined(HAVE_LINUX_ICMP_H) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 91 | # include <linux/icmp.h> |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 92 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 93 | #ifndef PF_UNSPEC |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 94 | # define PF_UNSPEC AF_UNSPEC |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 95 | #endif |
| 96 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 97 | #include "xlat/domains.h" |
| 98 | #include "xlat/addrfams.h" |
| 99 | #include "xlat/socktypes.h" |
| 100 | #include "xlat/sock_type_flags.h" |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 101 | #ifndef SOCK_TYPE_MASK |
| 102 | # define SOCK_TYPE_MASK 0xf |
| 103 | #endif |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 104 | #include "xlat/socketlayers.h" |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 105 | /*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 106 | falls into "inet_protocols" array below!!!! This is intended!!! ***/ |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 107 | #include "xlat/inet_protocols.h" |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 108 | |
| 109 | #ifdef PF_NETLINK |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 110 | #include "xlat/netlink_protocols.h" |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 111 | #endif |
| 112 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 113 | #include "xlat/msg_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 114 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 115 | #include "xlat/sockoptions.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 116 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 117 | #if !defined(SOL_IP) && defined(IPPROTO_IP) |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 118 | #define SOL_IP IPPROTO_IP |
| 119 | #endif |
| 120 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 121 | #ifdef SOL_IP |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 122 | #include "xlat/sockipoptions.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 123 | #endif /* SOL_IP */ |
| 124 | |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 125 | #ifdef SOL_IPV6 |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 126 | #include "xlat/sockipv6options.h" |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 127 | #endif /* SOL_IPV6 */ |
| 128 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 129 | #ifdef SOL_IPX |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 130 | #include "xlat/sockipxoptions.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 131 | #endif /* SOL_IPX */ |
| 132 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 133 | #ifdef SOL_RAW |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 134 | #include "xlat/sockrawoptions.h" |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 135 | #endif /* SOL_RAW */ |
| 136 | |
| 137 | #ifdef SOL_PACKET |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 138 | #include "xlat/sockpacketoptions.h" |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 139 | #endif /* SOL_PACKET */ |
| 140 | |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 141 | #ifdef SOL_SCTP |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 142 | #include "xlat/socksctpoptions.h" |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 143 | #endif |
| 144 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 145 | #if !defined(SOL_TCP) && defined(IPPROTO_TCP) |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 146 | #define SOL_TCP IPPROTO_TCP |
| 147 | #endif |
| 148 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 149 | #ifdef SOL_TCP |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 150 | #include "xlat/socktcpoptions.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 151 | #endif /* SOL_TCP */ |
| 152 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 153 | #ifdef SOL_RAW |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 154 | #include "xlat/icmpfilterflags.h" |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 155 | #endif /* SOL_RAW */ |
| 156 | |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 157 | #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */ |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 158 | #include "xlat/af_packet_types.h" |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 159 | #endif /* defined(AF_PACKET) */ |
| 160 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 161 | void |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 162 | printsock(struct tcb *tcp, long addr, int addrlen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 163 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 164 | union { |
| 165 | char pad[128]; |
| 166 | struct sockaddr sa; |
| 167 | struct sockaddr_in sin; |
| 168 | struct sockaddr_un sau; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 169 | #ifdef HAVE_INET_NTOP |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 170 | struct sockaddr_in6 sa6; |
| 171 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 172 | #if defined(AF_IPX) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 173 | struct sockaddr_ipx sipx; |
| 174 | #endif |
| 175 | #ifdef AF_PACKET |
| 176 | struct sockaddr_ll ll; |
| 177 | #endif |
| 178 | #ifdef AF_NETLINK |
| 179 | struct sockaddr_nl nl; |
| 180 | #endif |
| 181 | } addrbuf; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 182 | char string_addr[100]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 183 | |
| 184 | if (addr == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 185 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 186 | return; |
| 187 | } |
| 188 | if (!verbose(tcp)) { |
| 189 | tprintf("%#lx", addr); |
| 190 | return; |
| 191 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 192 | |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 193 | if (addrlen < 2 || addrlen > sizeof(addrbuf)) |
| 194 | addrlen = sizeof(addrbuf); |
| 195 | |
| 196 | memset(&addrbuf, 0, sizeof(addrbuf)); |
| 197 | if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 198 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 199 | return; |
| 200 | } |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 201 | addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0'; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 202 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 203 | tprints("{sa_family="); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 204 | printxval(addrfams, addrbuf.sa.sa_family, "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 205 | tprints(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 206 | |
| 207 | switch (addrbuf.sa.sa_family) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 208 | case AF_UNIX: |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 209 | if (addrlen == 2) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 210 | tprints("NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 211 | } else if (addrbuf.sau.sun_path[0]) { |
Dmitry V. Levin | c86340e | 2012-02-22 00:23:52 +0000 | [diff] [blame] | 212 | tprints("sun_path="); |
Dmitry V. Levin | 16fbe97 | 2007-10-13 21:03:17 +0000 | [diff] [blame] | 213 | printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path)); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 214 | } else { |
Dmitry V. Levin | c86340e | 2012-02-22 00:23:52 +0000 | [diff] [blame] | 215 | tprints("sun_path=@"); |
Dmitry V. Levin | 16fbe97 | 2007-10-13 21:03:17 +0000 | [diff] [blame] | 216 | printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1)); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 217 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 218 | break; |
| 219 | case AF_INET: |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 220 | tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 221 | ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 222 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 223 | #ifdef HAVE_INET_NTOP |
| 224 | case AF_INET6: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 225 | 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] | 226 | tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u", |
| 227 | ntohs(addrbuf.sa6.sin6_port), string_addr, |
| 228 | addrbuf.sa6.sin6_flowinfo); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 229 | #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 230 | { |
| 231 | #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 232 | int numericscope = 0; |
| 233 | if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr) |
| 234 | || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) { |
| 235 | char scopebuf[IFNAMSIZ + 1]; |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 236 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 237 | if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL) |
| 238 | numericscope++; |
| 239 | else |
| 240 | tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf); |
| 241 | } else |
| 242 | numericscope++; |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 243 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 244 | if (numericscope) |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 245 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 246 | tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id); |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 247 | } |
| 248 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 249 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 250 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 251 | #if defined(AF_IPX) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 252 | case AF_IPX: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 253 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 254 | int i; |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 255 | tprintf("sipx_port=htons(%u), ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 256 | ntohs(addrbuf.sipx.sipx_port)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 257 | /* Yes, I know, this does not look too |
| 258 | * strace-ish, but otherwise the IPX |
| 259 | * addresses just look monstrous... |
| 260 | * Anyways, feel free if you don't like |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 261 | * this way.. :) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 262 | */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 263 | tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network)); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 264 | for (i = 0; i < IPX_NODE_LEN; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 265 | tprintf("%02x", addrbuf.sipx.sipx_node[i]); |
| 266 | tprintf("/[%02x]", addrbuf.sipx.sipx_type); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 267 | } |
| 268 | break; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 269 | #endif /* AF_IPX */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 270 | #ifdef AF_PACKET |
| 271 | case AF_PACKET: |
| 272 | { |
| 273 | int i; |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 274 | tprintf("proto=%#04x, if%d, pkttype=", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 275 | ntohs(addrbuf.ll.sll_protocol), |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 276 | addrbuf.ll.sll_ifindex); |
| 277 | printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?"); |
| 278 | tprintf(", addr(%d)={%d, ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 279 | addrbuf.ll.sll_halen, |
| 280 | addrbuf.ll.sll_hatype); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 281 | for (i = 0; i < addrbuf.ll.sll_halen; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 282 | tprintf("%02x", addrbuf.ll.sll_addr[i]); |
| 283 | } |
| 284 | break; |
| 285 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 286 | #endif /* AF_PACKET */ |
Roland McGrath | 36ef1bc | 2003-11-06 23:41:23 +0000 | [diff] [blame] | 287 | #ifdef AF_NETLINK |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 288 | case AF_NETLINK: |
| 289 | tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); |
| 290 | break; |
| 291 | #endif /* AF_NETLINK */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 292 | /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 293 | AF_X25 AF_ROSE etc. still need to be done */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 294 | |
| 295 | default: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 296 | tprints("sa_data="); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 297 | printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 298 | sizeof addrbuf.sa.sa_data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 299 | break; |
| 300 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 301 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | #if HAVE_SENDMSG |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 305 | #include "xlat/scmvals.h" |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 306 | |
| 307 | static void |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 308 | printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len) |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 309 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 310 | struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ? |
| 311 | NULL : malloc(len); |
| 312 | if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) { |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 313 | tprintf(", msg_control=%#lx", addr); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 314 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 315 | return; |
| 316 | } |
| 317 | |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 318 | tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 319 | printxval(socketlayers, cmsg->cmsg_level, "SOL_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 320 | tprints(", cmsg_type="); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 321 | |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 322 | if (cmsg->cmsg_level == SOL_SOCKET) { |
| 323 | unsigned long cmsg_len; |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 324 | |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 325 | printxval(scmvals, cmsg->cmsg_type, "SCM_???"); |
| 326 | cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len; |
| 327 | |
| 328 | if (cmsg->cmsg_type == SCM_RIGHTS |
| 329 | && CMSG_LEN(sizeof(int)) <= cmsg_len) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 330 | int *fds = (int *) CMSG_DATA(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 331 | int first = 1; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 332 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 333 | tprints(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 334 | while ((char *) fds < ((char *) cmsg + cmsg_len)) { |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 335 | if (!first) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 336 | tprints(", "); |
Dmitry V. Levin | f23b097 | 2014-05-29 21:35:34 +0000 | [diff] [blame] | 337 | printfd(tcp, *fds++); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 338 | first = 0; |
| 339 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 340 | tprints("}}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 341 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 342 | return; |
| 343 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 344 | if (cmsg->cmsg_type == SCM_CREDENTIALS |
| 345 | && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 346 | struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 347 | |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 348 | tprintf("{pid=%ld, uid=%ld, gid=%ld}}", |
| 349 | (long)uc->pid, (long)uc->uid, (long)uc->gid); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 350 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 351 | return; |
| 352 | } |
| 353 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 354 | free(cmsg); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 355 | tprints(", ...}"); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 356 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 357 | |
| 358 | static void |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 359 | do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size) |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 360 | { |
| 361 | tprintf("{msg_name(%d)=", msg->msg_namelen); |
| 362 | printsock(tcp, (long)msg->msg_name, msg->msg_namelen); |
| 363 | |
| 364 | tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen); |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 365 | tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen, |
| 366 | (unsigned long)msg->msg_iov, 1, data_size); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 367 | |
| 368 | #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL |
| 369 | tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen); |
| 370 | if (msg->msg_controllen) |
| 371 | printcmsghdr(tcp, (unsigned long) msg->msg_control, |
| 372 | msg->msg_controllen); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 373 | tprints(", msg_flags="); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 374 | printflags(msg_flags, msg->msg_flags, "MSG_???"); |
| 375 | #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
| 376 | tprintf("msg_accrights=%#lx, msg_accrightslen=%u", |
| 377 | (unsigned long) msg->msg_accrights, msg->msg_accrightslen); |
| 378 | #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 379 | tprints("}"); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 380 | } |
| 381 | |
Denys Vlasenko | 3e759d4 | 2013-02-12 11:57:48 +0100 | [diff] [blame] | 382 | struct msghdr32 { |
| 383 | uint32_t /* void* */ msg_name; |
| 384 | uint32_t /* socklen_t */msg_namelen; |
| 385 | uint32_t /* iovec* */ msg_iov; |
| 386 | uint32_t /* size_t */ msg_iovlen; |
| 387 | uint32_t /* void* */ msg_control; |
| 388 | uint32_t /* size_t */ msg_controllen; |
| 389 | uint32_t /* int */ msg_flags; |
| 390 | }; |
| 391 | struct mmsghdr32 { |
| 392 | struct msghdr32 msg_hdr; |
| 393 | uint32_t /* unsigned */ msg_len; |
| 394 | }; |
| 395 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 396 | static void |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 397 | printmsghdr(struct tcb *tcp, long addr, unsigned long data_size) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 398 | { |
| 399 | struct msghdr msg; |
| 400 | |
Denys Vlasenko | 3e759d4 | 2013-02-12 11:57:48 +0100 | [diff] [blame] | 401 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 402 | if (current_wordsize == 4) { |
| 403 | struct msghdr32 msg32; |
| 404 | |
| 405 | if (umove(tcp, addr, &msg32) < 0) { |
| 406 | tprintf("%#lx", addr); |
| 407 | return; |
| 408 | } |
| 409 | msg.msg_name = (void*)(long)msg32.msg_name; |
| 410 | msg.msg_namelen = msg32.msg_namelen; |
| 411 | msg.msg_iov = (void*)(long)msg32.msg_iov; |
| 412 | msg.msg_iovlen = msg32.msg_iovlen; |
| 413 | msg.msg_control = (void*)(long)msg32.msg_control; |
| 414 | msg.msg_controllen = msg32.msg_controllen; |
| 415 | msg.msg_flags = msg32.msg_flags; |
| 416 | } else |
| 417 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 418 | if (umove(tcp, addr, &msg) < 0) { |
| 419 | tprintf("%#lx", addr); |
| 420 | return; |
| 421 | } |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 422 | do_msghdr(tcp, &msg, data_size); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 425 | static void |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 426 | 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] | 427 | { |
| 428 | struct mmsghdr { |
| 429 | struct msghdr msg_hdr; |
| 430 | unsigned msg_len; |
| 431 | } mmsg; |
| 432 | |
Denys Vlasenko | 3e759d4 | 2013-02-12 11:57:48 +0100 | [diff] [blame] | 433 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 434 | if (current_wordsize == 4) { |
| 435 | struct mmsghdr32 mmsg32; |
| 436 | |
| 437 | addr += sizeof(mmsg32) * idx; |
| 438 | if (umove(tcp, addr, &mmsg32) < 0) { |
| 439 | tprintf("%#lx", addr); |
| 440 | return; |
| 441 | } |
| 442 | mmsg.msg_hdr.msg_name = (void*)(long)mmsg32.msg_hdr.msg_name; |
| 443 | mmsg.msg_hdr.msg_namelen = mmsg32.msg_hdr.msg_namelen; |
| 444 | mmsg.msg_hdr.msg_iov = (void*)(long)mmsg32.msg_hdr.msg_iov; |
| 445 | mmsg.msg_hdr.msg_iovlen = mmsg32.msg_hdr.msg_iovlen; |
| 446 | mmsg.msg_hdr.msg_control = (void*)(long)mmsg32.msg_hdr.msg_control; |
| 447 | mmsg.msg_hdr.msg_controllen = mmsg32.msg_hdr.msg_controllen; |
| 448 | mmsg.msg_hdr.msg_flags = mmsg32.msg_hdr.msg_flags; |
| 449 | mmsg.msg_len = mmsg32.msg_len; |
| 450 | } else |
| 451 | #endif |
| 452 | { |
| 453 | addr += sizeof(mmsg) * idx; |
| 454 | if (umove(tcp, addr, &mmsg) < 0) { |
| 455 | tprintf("%#lx", addr); |
| 456 | return; |
| 457 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 458 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 459 | tprints("{"); |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 460 | do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 461 | tprintf(", %u}", mmsg.msg_len); |
| 462 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 463 | |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 464 | static void |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 465 | decode_mmsg(struct tcb *tcp, unsigned long msg_len) |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 466 | { |
| 467 | /* mmsgvec */ |
| 468 | if (syserror(tcp)) { |
| 469 | tprintf("%#lx", tcp->u_arg[1]); |
| 470 | } else { |
| 471 | unsigned int len = tcp->u_rval; |
| 472 | unsigned int i; |
| 473 | |
| 474 | tprints("{"); |
| 475 | for (i = 0; i < len; ++i) { |
| 476 | if (i) |
| 477 | tprints(", "); |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 478 | printmmsghdr(tcp, tcp->u_arg[1], i, msg_len); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 479 | } |
| 480 | tprints("}"); |
| 481 | } |
| 482 | /* vlen */ |
| 483 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
| 484 | /* flags */ |
| 485 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 486 | } |
| 487 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 488 | #endif /* HAVE_SENDMSG */ |
| 489 | |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 490 | /* |
| 491 | * low bits of the socket type define real socket type, |
| 492 | * other bits are socket type flags. |
| 493 | */ |
| 494 | static void |
| 495 | tprint_sock_type(struct tcb *tcp, int flags) |
| 496 | { |
| 497 | const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK); |
| 498 | |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 499 | if (str) { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 500 | tprints(str); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 501 | flags &= ~SOCK_TYPE_MASK; |
| 502 | if (!flags) |
| 503 | return; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 504 | tprints("|"); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 505 | } |
| 506 | printflags(sock_type_flags, flags, "SOCK_???"); |
| 507 | } |
| 508 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 509 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 510 | sys_socket(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 511 | { |
| 512 | if (entering(tcp)) { |
| 513 | printxval(domains, tcp->u_arg[0], "PF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 514 | tprints(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 515 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 516 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 517 | switch (tcp->u_arg[0]) { |
| 518 | case PF_INET: |
Roland McGrath | 8758e54 | 2003-06-23 23:39:59 +0000 | [diff] [blame] | 519 | #ifdef PF_INET6 |
| 520 | case PF_INET6: |
| 521 | #endif |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 522 | printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 523 | break; |
| 524 | #ifdef PF_IPX |
| 525 | case PF_IPX: |
| 526 | /* BTW: I don't believe this.. */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 527 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 528 | printxval(domains, tcp->u_arg[2], "PF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 529 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 530 | break; |
| 531 | #endif /* PF_IPX */ |
Masatake YAMATO | 2394a3d | 2014-03-11 23:37:37 +0900 | [diff] [blame] | 532 | #ifdef PF_NETLINK |
| 533 | case PF_NETLINK: |
| 534 | printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???"); |
| 535 | break; |
| 536 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 537 | default: |
| 538 | tprintf("%lu", tcp->u_arg[2]); |
| 539 | break; |
| 540 | } |
| 541 | } |
| 542 | return 0; |
| 543 | } |
| 544 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 545 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 546 | sys_bind(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 547 | { |
| 548 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 549 | printfd(tcp, tcp->u_arg[0]); |
| 550 | tprints(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 551 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 552 | tprintf(", %lu", tcp->u_arg[2]); |
| 553 | } |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 558 | sys_connect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 559 | { |
| 560 | return sys_bind(tcp); |
| 561 | } |
| 562 | |
| 563 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 564 | sys_listen(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 565 | { |
| 566 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 567 | printfd(tcp, tcp->u_arg[0]); |
| 568 | tprints(", "); |
| 569 | tprintf("%lu", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 570 | } |
| 571 | return 0; |
| 572 | } |
| 573 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 574 | static int |
| 575 | do_accept(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 576 | { |
| 577 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 578 | printfd(tcp, tcp->u_arg[0]); |
| 579 | tprints(", "); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 580 | return 0; |
| 581 | } |
| 582 | if (!tcp->u_arg[2]) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 583 | tprintf("%#lx, NULL", tcp->u_arg[1]); |
| 584 | else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 585 | int len; |
| 586 | if (tcp->u_arg[1] == 0 || syserror(tcp) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 587 | || umove(tcp, tcp->u_arg[2], &len) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 588 | tprintf("%#lx", tcp->u_arg[1]); |
| 589 | } else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 590 | printsock(tcp, tcp->u_arg[1], len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 591 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 592 | tprints(", "); |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 593 | printnum_int(tcp, tcp->u_arg[2], "%u"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 594 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 595 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 596 | tprints(", "); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 597 | printflags(sock_type_flags, tcp->u_arg[flags_arg], |
| 598 | "SOCK_???"); |
| 599 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 600 | return 0; |
| 601 | } |
| 602 | |
| 603 | int |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 604 | sys_accept(struct tcb *tcp) |
| 605 | { |
| 606 | return do_accept(tcp, -1); |
| 607 | } |
| 608 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 609 | int |
| 610 | sys_accept4(struct tcb *tcp) |
| 611 | { |
| 612 | return do_accept(tcp, 3); |
| 613 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 614 | |
| 615 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 616 | sys_send(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 617 | { |
| 618 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 619 | printfd(tcp, tcp->u_arg[0]); |
| 620 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 621 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 622 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 623 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 624 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 625 | } |
| 626 | return 0; |
| 627 | } |
| 628 | |
| 629 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 630 | sys_sendto(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 631 | { |
| 632 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 633 | printfd(tcp, tcp->u_arg[0]); |
| 634 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 635 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 636 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 637 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 638 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 639 | /* to address */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 640 | tprints(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 641 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 642 | /* to length */ |
| 643 | tprintf(", %lu", tcp->u_arg[5]); |
| 644 | } |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | #ifdef HAVE_SENDMSG |
| 649 | |
| 650 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 651 | sys_sendmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 652 | { |
| 653 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 654 | printfd(tcp, tcp->u_arg[0]); |
| 655 | tprints(", "); |
Dmitry V. Levin | 043b5f8 | 2012-05-01 20:30:02 +0000 | [diff] [blame] | 656 | printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 657 | /* flags */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 658 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 659 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 660 | } |
| 661 | return 0; |
| 662 | } |
| 663 | |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 664 | int |
| 665 | sys_sendmmsg(struct tcb *tcp) |
| 666 | { |
| 667 | if (entering(tcp)) { |
| 668 | /* sockfd */ |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 669 | printfd(tcp, tcp->u_arg[0]); |
| 670 | tprints(", "); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 671 | if (!verbose(tcp)) { |
| 672 | tprintf("%#lx, %u, ", |
| 673 | tcp->u_arg[1], (unsigned int) tcp->u_arg[2]); |
| 674 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 675 | } |
| 676 | } else { |
| 677 | if (verbose(tcp)) |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 678 | decode_mmsg(tcp, (unsigned long) -1L); |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 679 | } |
| 680 | return 0; |
| 681 | } |
| 682 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 683 | #endif /* HAVE_SENDMSG */ |
| 684 | |
| 685 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 686 | sys_recv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 687 | { |
| 688 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 689 | printfd(tcp, tcp->u_arg[0]); |
| 690 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 691 | } else { |
| 692 | if (syserror(tcp)) |
| 693 | tprintf("%#lx", tcp->u_arg[1]); |
| 694 | else |
| 695 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 696 | |
| 697 | tprintf(", %lu, ", tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 698 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 699 | } |
| 700 | return 0; |
| 701 | } |
| 702 | |
| 703 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 704 | sys_recvfrom(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 705 | { |
| 706 | int fromlen; |
| 707 | |
| 708 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 709 | printfd(tcp, tcp->u_arg[0]); |
| 710 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 711 | } else { |
| 712 | if (syserror(tcp)) { |
| 713 | tprintf("%#lx, %lu, %lu, %#lx, %#lx", |
| 714 | tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], |
| 715 | tcp->u_arg[4], tcp->u_arg[5]); |
| 716 | return 0; |
| 717 | } |
| 718 | /* buf */ |
| 719 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 720 | /* len */ |
| 721 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 722 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 723 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 724 | /* from address, len */ |
| 725 | if (!tcp->u_arg[4] || !tcp->u_arg[5]) { |
| 726 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 727 | tprints(", NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 728 | else |
| 729 | tprintf(", %#lx", tcp->u_arg[4]); |
| 730 | if (tcp->u_arg[5] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 731 | tprints(", NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 732 | else |
| 733 | tprintf(", %#lx", tcp->u_arg[5]); |
| 734 | return 0; |
| 735 | } |
| 736 | if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 737 | tprints(", {...}, [?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 738 | return 0; |
| 739 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 740 | tprints(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 741 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 742 | /* from length */ |
| 743 | tprintf(", [%u]", fromlen); |
| 744 | } |
| 745 | return 0; |
| 746 | } |
| 747 | |
| 748 | #ifdef HAVE_SENDMSG |
| 749 | |
| 750 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 751 | sys_recvmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 752 | { |
| 753 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 754 | printfd(tcp, tcp->u_arg[0]); |
| 755 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 756 | } else { |
| 757 | if (syserror(tcp) || !verbose(tcp)) |
| 758 | tprintf("%#lx", tcp->u_arg[1]); |
| 759 | else |
Denys Vlasenko | e0bc222 | 2012-04-28 14:26:18 +0200 | [diff] [blame] | 760 | printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 761 | /* flags */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 762 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 763 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 764 | } |
| 765 | return 0; |
| 766 | } |
| 767 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 768 | int |
| 769 | sys_recvmmsg(struct tcb *tcp) |
| 770 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 771 | /* +5 chars are for "left " prefix */ |
| 772 | static char str[5 + TIMESPEC_TEXT_BUFSIZE]; |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 773 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 774 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 775 | printfd(tcp, tcp->u_arg[0]); |
| 776 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 777 | if (verbose(tcp)) { |
| 778 | sprint_timespec(str, tcp, tcp->u_arg[4]); |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 779 | /* Abusing tcp->auxstr as temp storage. |
| 780 | * Will be used and freed on syscall exit. |
| 781 | */ |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 782 | tcp->auxstr = strdup(str); |
| 783 | } else { |
| 784 | tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]); |
| 785 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 786 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 787 | print_timespec(tcp, tcp->u_arg[4]); |
| 788 | } |
| 789 | return 0; |
| 790 | } else { |
| 791 | if (verbose(tcp)) { |
Dmitry V. Levin | 5ea9765 | 2012-05-01 20:41:40 +0000 | [diff] [blame] | 792 | decode_mmsg(tcp, 0); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 793 | /* timeout on entrance */ |
| 794 | tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}"); |
| 795 | free((void *) tcp->auxstr); |
| 796 | tcp->auxstr = NULL; |
| 797 | } |
| 798 | if (syserror(tcp)) |
| 799 | return 0; |
| 800 | if (tcp->u_rval == 0) { |
| 801 | tcp->auxstr = "Timeout"; |
| 802 | return RVAL_STR; |
| 803 | } |
| 804 | if (!verbose(tcp)) |
| 805 | return 0; |
| 806 | /* timeout on exit */ |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 807 | sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 808 | tcp->auxstr = str; |
| 809 | return RVAL_STR; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 810 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 811 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 812 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 813 | #endif /* HAVE_SENDMSG */ |
| 814 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame^] | 815 | #include "xlat/shutdown_modes.h" |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 816 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 817 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 818 | sys_shutdown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 819 | { |
| 820 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 821 | printfd(tcp, tcp->u_arg[0]); |
| 822 | tprints(", "); |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 823 | printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 824 | } |
| 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 829 | sys_getsockname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 830 | { |
| 831 | return sys_accept(tcp); |
| 832 | } |
| 833 | |
| 834 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 835 | sys_getpeername(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 836 | { |
| 837 | return sys_accept(tcp); |
| 838 | } |
| 839 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 840 | static int |
| 841 | do_pipe(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 842 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 843 | if (exiting(tcp)) { |
| 844 | if (syserror(tcp)) { |
| 845 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 846 | } else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 847 | #if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 848 | int fds[2]; |
| 849 | |
| 850 | if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 851 | tprints("[...]"); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 852 | else |
| 853 | tprintf("[%u, %u]", fds[0], fds[1]); |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 854 | #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 855 | tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
| 856 | #else |
| 857 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 858 | #endif |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 859 | } |
| 860 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 861 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 862 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 863 | } |
| 864 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 865 | return 0; |
| 866 | } |
| 867 | |
| 868 | int |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 869 | sys_pipe(struct tcb *tcp) |
| 870 | { |
| 871 | return do_pipe(tcp, -1); |
| 872 | } |
| 873 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 874 | int |
| 875 | sys_pipe2(struct tcb *tcp) |
| 876 | { |
| 877 | return do_pipe(tcp, 1); |
| 878 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 879 | |
| 880 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 881 | sys_socketpair(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 882 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 883 | int fds[2]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 884 | |
| 885 | if (entering(tcp)) { |
| 886 | printxval(domains, tcp->u_arg[0], "PF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 887 | tprints(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 888 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Dmitry V. Levin | 033fb91 | 2014-03-11 22:50:39 +0000 | [diff] [blame] | 889 | tprintf(", %lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 890 | } else { |
| 891 | if (syserror(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 892 | tprintf(", %#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 893 | return 0; |
| 894 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 895 | if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 896 | tprints(", [...]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 897 | else |
| 898 | tprintf(", [%u, %u]", fds[0], fds[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 899 | } |
| 900 | return 0; |
| 901 | } |
| 902 | |
| 903 | int |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 904 | sys_getsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 905 | { |
| 906 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 907 | printfd(tcp, tcp->u_arg[0]); |
| 908 | tprints(", "); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 909 | printxval(socketlayers, tcp->u_arg[1], "SOL_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 910 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 911 | switch (tcp->u_arg[1]) { |
| 912 | case SOL_SOCKET: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 913 | printxval(sockoptions, tcp->u_arg[2], "SO_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 914 | break; |
| 915 | #ifdef SOL_IP |
| 916 | case SOL_IP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 917 | printxval(sockipoptions, tcp->u_arg[2], "IP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 918 | break; |
| 919 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 920 | #ifdef SOL_IPV6 |
| 921 | case SOL_IPV6: |
| 922 | printxval(sockipv6options, tcp->u_arg[2], "IPV6_???"); |
| 923 | break; |
| 924 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 925 | #ifdef SOL_IPX |
| 926 | case SOL_IPX: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 927 | printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 928 | break; |
| 929 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 930 | #ifdef SOL_PACKET |
| 931 | case SOL_PACKET: |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 932 | printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 933 | break; |
| 934 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 935 | #ifdef SOL_TCP |
| 936 | case SOL_TCP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 937 | printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 938 | break; |
| 939 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 940 | #ifdef SOL_SCTP |
| 941 | case SOL_SCTP: |
| 942 | printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???"); |
| 943 | break; |
| 944 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 945 | |
| 946 | /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
| 947 | * etc. still need work */ |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 948 | default: |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 949 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 950 | break; |
| 951 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 952 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 953 | } else { |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 954 | int len; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 955 | if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 956 | tprintf("%#lx, %#lx", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 957 | tcp->u_arg[3], tcp->u_arg[4]); |
| 958 | return 0; |
| 959 | } |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 960 | |
| 961 | switch (tcp->u_arg[1]) { |
| 962 | case SOL_SOCKET: |
| 963 | switch (tcp->u_arg[2]) { |
| 964 | #ifdef SO_LINGER |
| 965 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 966 | if (len == sizeof(struct linger)) { |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 967 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 968 | if (umove(tcp, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 969 | tcp->u_arg[3], |
| 970 | &linger) < 0) |
| 971 | break; |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 972 | tprintf("{onoff=%d, linger=%d}, " |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 973 | "[%d]", |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 974 | linger.l_onoff, |
| 975 | linger.l_linger, |
| 976 | len); |
| 977 | return 0; |
| 978 | } |
| 979 | break; |
| 980 | #endif |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 981 | #ifdef SO_PEERCRED |
| 982 | case SO_PEERCRED: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 983 | if (len == sizeof(struct ucred)) { |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 984 | struct ucred uc; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 985 | if (umove(tcp, |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 986 | tcp->u_arg[3], |
| 987 | &uc) < 0) |
| 988 | break; |
| 989 | tprintf("{pid=%ld, uid=%ld, gid=%ld}, " |
| 990 | "[%d]", |
| 991 | (long)uc.pid, |
| 992 | (long)uc.uid, |
| 993 | (long)uc.gid, |
| 994 | len); |
| 995 | return 0; |
| 996 | } |
| 997 | break; |
| 998 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 999 | } |
| 1000 | break; |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 1001 | case SOL_PACKET: |
| 1002 | switch (tcp->u_arg[2]) { |
| 1003 | #ifdef PACKET_STATISTICS |
| 1004 | case PACKET_STATISTICS: |
| 1005 | if (len == sizeof(struct tpacket_stats)) { |
| 1006 | struct tpacket_stats stats; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1007 | if (umove(tcp, |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 1008 | tcp->u_arg[3], |
| 1009 | &stats) < 0) |
| 1010 | break; |
| 1011 | tprintf("{packets=%u, drops=%u}, " |
| 1012 | "[%d]", |
| 1013 | stats.tp_packets, |
| 1014 | stats.tp_drops, |
| 1015 | len); |
| 1016 | return 0; |
| 1017 | } |
| 1018 | break; |
| 1019 | #endif |
| 1020 | } |
| 1021 | break; |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1024 | if (len == sizeof(int)) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1025 | printnum_int(tcp, tcp->u_arg[3], "%d"); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1026 | } |
| 1027 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1028 | printstr(tcp, tcp->u_arg[3], len); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1029 | } |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 1030 | tprintf(", [%d]", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1031 | } |
| 1032 | return 0; |
| 1033 | } |
| 1034 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1035 | #if defined(ICMP_FILTER) |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1036 | static void printicmpfilter(struct tcb *tcp, long addr) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1037 | { |
| 1038 | struct icmp_filter filter; |
| 1039 | |
| 1040 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1041 | tprints("NULL"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1042 | return; |
| 1043 | } |
| 1044 | if (syserror(tcp) || !verbose(tcp)) { |
| 1045 | tprintf("%#lx", addr); |
| 1046 | return; |
| 1047 | } |
| 1048 | if (umove(tcp, addr, &filter) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1049 | tprints("{...}"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1050 | return; |
| 1051 | } |
| 1052 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1053 | tprints("~("); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1054 | printflags(icmpfilterflags, ~filter.data, "ICMP_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1055 | tprints(")"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1056 | } |
| 1057 | #endif /* ICMP_FILTER */ |
| 1058 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1059 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1060 | printsockopt(struct tcb *tcp, int level, int name, long addr, int len) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1061 | { |
| 1062 | printxval(socketlayers, level, "SOL_??"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1063 | tprints(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1064 | switch (level) { |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1065 | case SOL_SOCKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1066 | printxval(sockoptions, name, "SO_???"); |
| 1067 | switch (name) { |
| 1068 | #if defined(SO_LINGER) |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1069 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1070 | if (len == sizeof(struct linger)) { |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1071 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1072 | if (umove(tcp, addr, &linger) < 0) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1073 | break; |
| 1074 | tprintf(", {onoff=%d, linger=%d}", |
| 1075 | linger.l_onoff, |
| 1076 | linger.l_linger); |
| 1077 | return 0; |
| 1078 | } |
| 1079 | break; |
| 1080 | #endif |
| 1081 | } |
| 1082 | break; |
| 1083 | #ifdef SOL_IP |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1084 | case SOL_IP: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1085 | printxval(sockipoptions, name, "IP_???"); |
| 1086 | break; |
| 1087 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 1088 | #ifdef SOL_IPV6 |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1089 | case SOL_IPV6: |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 1090 | printxval(sockipv6options, name, "IPV6_???"); |
| 1091 | break; |
| 1092 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1093 | #ifdef SOL_IPX |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1094 | case SOL_IPX: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1095 | printxval(sockipxoptions, name, "IPX_???"); |
| 1096 | break; |
| 1097 | #endif |
| 1098 | #ifdef SOL_PACKET |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1099 | case SOL_PACKET: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1100 | printxval(sockpacketoptions, name, "PACKET_???"); |
| 1101 | /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */ |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 1102 | switch (name) { |
| 1103 | #ifdef PACKET_RX_RING |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1104 | case PACKET_RX_RING: |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 1105 | #endif |
| 1106 | #ifdef PACKET_TX_RING |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1107 | case PACKET_TX_RING: |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 1108 | #endif |
| 1109 | #if defined(PACKET_RX_RING) || defined(PACKET_TX_RING) |
| 1110 | if (len == sizeof(struct tpacket_req)) { |
| 1111 | struct tpacket_req req; |
| 1112 | if (umove(tcp, addr, &req) < 0) |
| 1113 | break; |
| 1114 | tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}", |
| 1115 | req.tp_block_size, |
| 1116 | req.tp_block_nr, |
| 1117 | req.tp_frame_size, |
| 1118 | req.tp_frame_nr); |
| 1119 | return 0; |
| 1120 | } |
| 1121 | break; |
| 1122 | #endif /* PACKET_RX_RING || PACKET_TX_RING */ |
| 1123 | } |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1124 | break; |
| 1125 | #endif |
| 1126 | #ifdef SOL_TCP |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1127 | case SOL_TCP: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1128 | printxval(socktcpoptions, name, "TCP_???"); |
| 1129 | break; |
| 1130 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 1131 | #ifdef SOL_SCTP |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1132 | case SOL_SCTP: |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 1133 | printxval(socksctpoptions, name, "SCTP_???"); |
| 1134 | break; |
| 1135 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1136 | #ifdef SOL_RAW |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1137 | case SOL_RAW: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1138 | printxval(sockrawoptions, name, "RAW_???"); |
| 1139 | switch (name) { |
| 1140 | #if defined(ICMP_FILTER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 1141 | case ICMP_FILTER: |
| 1142 | tprints(", "); |
| 1143 | printicmpfilter(tcp, addr); |
| 1144 | return 0; |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1145 | #endif |
| 1146 | } |
| 1147 | break; |
| 1148 | #endif |
| 1149 | |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1150 | /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1151 | * etc. still need work */ |
| 1152 | |
Denys Vlasenko | 989ebc9 | 2012-03-17 04:42:07 +0100 | [diff] [blame] | 1153 | default: |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1154 | tprintf("%u", name); |
| 1155 | } |
| 1156 | |
| 1157 | /* default arg printing */ |
| 1158 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1159 | tprints(", "); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1160 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1161 | if (len == sizeof(int)) { |
| 1162 | printnum_int(tcp, addr, "%d"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1163 | } |
| 1164 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1165 | printstr(tcp, addr, len); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1166 | } |
| 1167 | return 0; |
| 1168 | } |
| 1169 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1170 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1171 | sys_setsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1172 | { |
| 1173 | if (entering(tcp)) { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 1174 | printfd(tcp, tcp->u_arg[0]); |
| 1175 | tprints(", "); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1176 | printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1177 | tcp->u_arg[3], tcp->u_arg[4]); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1178 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1179 | } |
| 1180 | return 0; |
| 1181 | } |