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