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. |
| 29 | * |
| 30 | * $Id$ |
| 31 | */ |
| 32 | |
| 33 | #include "defs.h" |
| 34 | |
| 35 | #include <sys/stat.h> |
| 36 | #include <sys/socket.h> |
| 37 | #include <sys/un.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 38 | |
| 39 | #if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 40 | #define in6_addr in6_addr_libc |
| 41 | #define ipv6_mreq ipv6_mreq_libc |
| 42 | #define sockaddr_in6 sockaddr_in6_libc |
| 43 | #endif |
| 44 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 45 | #include <netinet/in.h> |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 46 | #ifdef HAVE_NETINET_TCP_H |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 47 | #include <netinet/tcp.h> |
| 48 | #endif |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 49 | #ifdef HAVE_NETINET_UDP_H |
| 50 | #include <netinet/udp.h> |
| 51 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 52 | #ifdef HAVE_NETINET_SCTP_H |
| 53 | #include <netinet/sctp.h> |
| 54 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | #include <arpa/inet.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 56 | #include <net/if.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | #if defined(LINUX) |
| 58 | #include <asm/types.h> |
| 59 | #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3) |
| 60 | # include <netipx/ipx.h> |
| 61 | #else |
| 62 | # include <linux/ipx.h> |
| 63 | #endif |
| 64 | #endif /* LINUX */ |
| 65 | |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 66 | #if defined (__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX)) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 67 | #if defined(HAVE_LINUX_IN6_H) |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 68 | #if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 69 | #undef in6_addr |
| 70 | #undef ipv6_mreq |
| 71 | #undef sockaddr_in6 |
| 72 | #define in6_addr in6_addr_kernel |
| 73 | #define ipv6_mreq ipv6_mreq_kernel |
| 74 | #define sockaddr_in6 sockaddr_in6_kernel |
| 75 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 76 | #include <linux/in6.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 77 | #if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 78 | #undef in6_addr |
| 79 | #undef ipv6_mreq |
| 80 | #undef sockaddr_in6 |
| 81 | #define in6_addr in6_addr_libc |
| 82 | #define ipv6_mreq ipv6_mreq_libc |
| 83 | #define sockaddr_in6 sockaddr_in6_kernel |
| 84 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 85 | #endif |
Wichert Akkerman | 2f473da | 1999-11-01 19:53:31 +0000 | [diff] [blame] | 86 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 87 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 88 | #if defined(HAVE_SYS_UIO_H) |
| 89 | #include <sys/uio.h> |
| 90 | #endif |
| 91 | |
| 92 | #if defined(HAVE_LINUX_NETLINK_H) |
| 93 | #include <linux/netlink.h> |
| 94 | #endif |
| 95 | |
| 96 | #if defined(HAVE_LINUX_IF_PACKET_H) |
| 97 | #include <linux/if_packet.h> |
| 98 | #endif |
| 99 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 100 | #if defined(HAVE_LINUX_ICMP_H) |
| 101 | #include <linux/icmp.h> |
| 102 | #endif |
| 103 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 104 | #ifndef PF_UNSPEC |
| 105 | #define PF_UNSPEC AF_UNSPEC |
| 106 | #endif |
| 107 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 108 | #if UNIXWARE >= 7 |
| 109 | #define HAVE_SENDMSG 1 /* HACK - *FIXME* */ |
| 110 | #endif |
| 111 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 112 | #ifdef LINUX |
| 113 | /* Under Linux these are enums so we can't test for them with ifdef. */ |
| 114 | #define IPPROTO_EGP IPPROTO_EGP |
| 115 | #define IPPROTO_PUP IPPROTO_PUP |
| 116 | #define IPPROTO_IDP IPPROTO_IDP |
| 117 | #define IPPROTO_IGMP IPPROTO_IGMP |
| 118 | #define IPPROTO_RAW IPPROTO_RAW |
| 119 | #define IPPROTO_MAX IPPROTO_MAX |
| 120 | #endif |
| 121 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 122 | static const struct xlat domains[] = { |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 123 | #ifdef PF_AAL5 |
| 124 | { PF_AAL5, "PF_AAL5" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 125 | #endif |
| 126 | #ifdef PF_APPLETALK |
| 127 | { PF_APPLETALK, "PF_APPLETALK" }, |
| 128 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 129 | #ifdef PF_ASH |
| 130 | { PF_ASH, "PF_ASH" }, |
| 131 | #endif |
| 132 | #ifdef PF_ATMPVC |
| 133 | { PF_ATMPVC, "PF_ATMPVC" }, |
| 134 | #endif |
| 135 | #ifdef PF_ATMSVC |
| 136 | { PF_ATMSVC, "PF_ATMSVC" }, |
| 137 | #endif |
| 138 | #ifdef PF_AX25 |
| 139 | { PF_AX25, "PF_AX25" }, |
| 140 | #endif |
| 141 | #ifdef PF_BLUETOOTH |
| 142 | { PF_BLUETOOTH, "PF_BLUETOOTH" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 143 | #endif |
| 144 | #ifdef PF_BRIDGE |
| 145 | { PF_BRIDGE, "PF_BRIDGE" }, |
| 146 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 147 | #ifdef PF_DECnet |
| 148 | { PF_DECnet, "PF_DECnet" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 149 | #endif |
| 150 | #ifdef PF_DECNET |
| 151 | { PF_DECNET, "PF_DECNET" }, |
| 152 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 153 | #ifdef PF_ECONET |
| 154 | { PF_ECONET, "PF_ECONET" }, |
| 155 | #endif |
| 156 | #ifdef PF_FILE |
| 157 | { PF_FILE, "PF_FILE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 158 | #endif |
| 159 | #ifdef PF_IMPLINK |
| 160 | { PF_IMPLINK, "PF_IMPLINK" }, |
| 161 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 162 | #ifdef PF_INET |
| 163 | { PF_INET, "PF_INET" }, |
| 164 | #endif |
| 165 | #ifdef PF_INET6 |
| 166 | { PF_INET6, "PF_INET6" }, |
| 167 | #endif |
| 168 | #ifdef PF_IPX |
| 169 | { PF_IPX, "PF_IPX" }, |
| 170 | #endif |
| 171 | #ifdef PF_IRDA |
| 172 | { PF_IRDA, "PF_IRDA" }, |
| 173 | #endif |
| 174 | #ifdef PF_ISO |
| 175 | { PF_ISO, "PF_ISO" }, |
| 176 | #endif |
| 177 | #ifdef PF_KEY |
| 178 | { PF_KEY, "PF_KEY" }, |
| 179 | #endif |
| 180 | #ifdef PF_UNIX |
| 181 | { PF_UNIX, "PF_UNIX" }, |
| 182 | #endif |
| 183 | #ifdef PF_LOCAL |
| 184 | { PF_LOCAL, "PF_LOCAL" }, |
| 185 | #endif |
| 186 | #ifdef PF_NETBEUI |
| 187 | { PF_NETBEUI, "PF_NETBEUI" }, |
| 188 | #endif |
| 189 | #ifdef PF_NETLINK |
| 190 | { PF_NETLINK, "PF_NETLINK" }, |
| 191 | #endif |
| 192 | #ifdef PF_NETROM |
| 193 | { PF_NETROM, "PF_NETROM" }, |
| 194 | #endif |
| 195 | #ifdef PF_PACKET |
| 196 | { PF_PACKET, "PF_PACKET" }, |
| 197 | #endif |
| 198 | #ifdef PF_PPPOX |
| 199 | { PF_PPPOX, "PF_PPPOX" }, |
| 200 | #endif |
| 201 | #ifdef PF_ROSE |
| 202 | { PF_ROSE, "PF_ROSE" }, |
| 203 | #endif |
| 204 | #ifdef PF_ROUTE |
| 205 | { PF_ROUTE, "PF_ROUTE" }, |
| 206 | #endif |
| 207 | #ifdef PF_SECURITY |
| 208 | { PF_SECURITY, "PF_SECURITY" }, |
| 209 | #endif |
| 210 | #ifdef PF_SNA |
| 211 | { PF_SNA, "PF_SNA" }, |
| 212 | #endif |
| 213 | #ifdef PF_UNSPEC |
| 214 | { PF_UNSPEC, "PF_UNSPEC" }, |
| 215 | #endif |
| 216 | #ifdef PF_WANPIPE |
| 217 | { PF_WANPIPE, "PF_WANPIPE" }, |
| 218 | #endif |
| 219 | #ifdef PF_X25 |
| 220 | { PF_X25, "PF_X25" }, |
| 221 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 222 | { 0, NULL }, |
| 223 | }; |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 224 | const struct xlat addrfams[] = { |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 225 | #ifdef AF_APPLETALK |
| 226 | { AF_APPLETALK, "AF_APPLETALK" }, |
| 227 | #endif |
| 228 | #ifdef AF_ASH |
| 229 | { AF_ASH, "AF_ASH" }, |
| 230 | #endif |
| 231 | #ifdef AF_ATMPVC |
| 232 | { AF_ATMPVC, "AF_ATMPVC" }, |
| 233 | #endif |
| 234 | #ifdef AF_ATMSVC |
| 235 | { AF_ATMSVC, "AF_ATMSVC" }, |
| 236 | #endif |
| 237 | #ifdef AF_AX25 |
| 238 | { AF_AX25, "AF_AX25" }, |
| 239 | #endif |
| 240 | #ifdef AF_BLUETOOTH |
| 241 | { AF_BLUETOOTH, "AF_BLUETOOTH" }, |
| 242 | #endif |
| 243 | #ifdef AF_BRIDGE |
| 244 | { AF_BRIDGE, "AF_BRIDGE" }, |
| 245 | #endif |
| 246 | #ifdef AF_DECnet |
| 247 | { AF_DECnet, "AF_DECnet" }, |
| 248 | #endif |
| 249 | #ifdef AF_ECONET |
| 250 | { AF_ECONET, "AF_ECONET" }, |
| 251 | #endif |
| 252 | #ifdef AF_FILE |
| 253 | { AF_FILE, "AF_FILE" }, |
| 254 | #endif |
| 255 | #ifdef AF_IMPLINK |
| 256 | { AF_IMPLINK, "AF_IMPLINK" }, |
| 257 | #endif |
| 258 | #ifdef AF_INET |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 259 | { AF_INET, "AF_INET" }, |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 260 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 261 | #ifdef AF_INET6 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 262 | { AF_INET6, "AF_INET6" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 263 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 264 | #ifdef AF_IPX |
| 265 | { AF_IPX, "AF_IPX" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 266 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 267 | #ifdef AF_IRDA |
| 268 | { AF_IRDA, "AF_IRDA" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 269 | #endif |
| 270 | #ifdef AF_ISO |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 271 | { AF_ISO, "AF_ISO" }, |
| 272 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 273 | #ifdef AF_KEY |
| 274 | { AF_KEY, "AF_KEY" }, |
| 275 | #endif |
| 276 | #ifdef AF_UNIX |
| 277 | { AF_UNIX, "AF_UNIX" }, |
| 278 | #endif |
| 279 | #ifdef AF_LOCAL |
| 280 | { AF_LOCAL, "AF_LOCAL" }, |
| 281 | #endif |
| 282 | #ifdef AF_NETBEUI |
| 283 | { AF_NETBEUI, "AF_NETBEUI" }, |
| 284 | #endif |
| 285 | #ifdef AF_NETLINK |
| 286 | { AF_NETLINK, "AF_NETLINK" }, |
| 287 | #endif |
| 288 | #ifdef AF_NETROM |
| 289 | { AF_NETROM, "AF_NETROM" }, |
| 290 | #endif |
| 291 | #ifdef AF_PACKET |
| 292 | { AF_PACKET, "AF_PACKET" }, |
| 293 | #endif |
| 294 | #ifdef AF_PPPOX |
| 295 | { AF_PPPOX, "AF_PPPOX" }, |
| 296 | #endif |
| 297 | #ifdef AF_ROSE |
| 298 | { AF_ROSE, "AF_ROSE" }, |
| 299 | #endif |
| 300 | #ifdef AF_ROUTE |
| 301 | { AF_ROUTE, "AF_ROUTE" }, |
| 302 | #endif |
| 303 | #ifdef AF_SECURITY |
| 304 | { AF_SECURITY, "AF_SECURITY" }, |
| 305 | #endif |
| 306 | #ifdef AF_SNA |
| 307 | { AF_SNA, "AF_SNA" }, |
| 308 | #endif |
| 309 | #ifdef AF_UNSPEC |
| 310 | { AF_UNSPEC, "AF_UNSPEC" }, |
| 311 | #endif |
| 312 | #ifdef AF_WANPIPE |
| 313 | { AF_WANPIPE, "AF_WANPIPE" }, |
| 314 | #endif |
| 315 | #ifdef AF_X25 |
| 316 | { AF_X25, "AF_X25" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 317 | #endif |
| 318 | { 0, NULL }, |
| 319 | }; |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 320 | static const struct xlat socktypes[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 321 | { SOCK_STREAM, "SOCK_STREAM" }, |
| 322 | { SOCK_DGRAM, "SOCK_DGRAM" }, |
| 323 | #ifdef SOCK_RAW |
| 324 | { SOCK_RAW, "SOCK_RAW" }, |
| 325 | #endif |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 326 | #ifdef SOCK_RDM |
| 327 | { SOCK_RDM, "SOCK_RDM" }, |
| 328 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 329 | #ifdef SOCK_SEQPACKET |
| 330 | { SOCK_SEQPACKET,"SOCK_SEQPACKET"}, |
| 331 | #endif |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 332 | #ifdef SOCK_DCCP |
| 333 | { SOCK_DCCP, "SOCK_DCCP" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 334 | #endif |
| 335 | #ifdef SOCK_PACKET |
| 336 | { SOCK_PACKET, "SOCK_PACKET" }, |
| 337 | #endif |
| 338 | { 0, NULL }, |
| 339 | }; |
Dmitry V. Levin | d475c06 | 2011-03-03 01:02:41 +0000 | [diff] [blame] | 340 | static const struct xlat sock_type_flags[] = { |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 341 | #ifdef SOCK_CLOEXEC |
| 342 | { SOCK_CLOEXEC, "SOCK_CLOEXEC" }, |
| 343 | #endif |
| 344 | #ifdef SOCK_NONBLOCK |
| 345 | { SOCK_NONBLOCK,"SOCK_NONBLOCK" }, |
| 346 | #endif |
| 347 | { 0, NULL }, |
| 348 | }; |
| 349 | #ifndef SOCK_TYPE_MASK |
| 350 | # define SOCK_TYPE_MASK 0xf |
| 351 | #endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 352 | static const struct xlat socketlayers[] = { |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 353 | #if defined(SOL_IP) |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 354 | { SOL_IP, "SOL_IP" }, |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 355 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 356 | #if defined(SOL_ICMP) |
| 357 | { SOL_ICMP, "SOL_ICMP" }, |
| 358 | #endif |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 359 | #if defined(SOL_TCP) |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 360 | { SOL_TCP, "SOL_TCP" }, |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 361 | #endif |
| 362 | #if defined(SOL_UDP) |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 363 | { SOL_UDP, "SOL_UDP" }, |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 364 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 365 | #if defined(SOL_IPV6) |
| 366 | { SOL_IPV6, "SOL_IPV6" }, |
| 367 | #endif |
| 368 | #if defined(SOL_ICMPV6) |
| 369 | { SOL_ICMPV6, "SOL_ICMPV6" }, |
| 370 | #endif |
Holger Hans Peter Freyther | ce9e0f4 | 2011-01-14 11:08:11 +0100 | [diff] [blame] | 371 | #if defined(SOL_SCTP) |
| 372 | { SOL_SCTP, "SOL_SCTP" }, |
| 373 | #endif |
| 374 | #if defined(SOL_UDPLITE) |
| 375 | { SOL_UDPLITE, "SOL_UDPLITE" }, |
| 376 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 377 | #if defined(SOL_RAW) |
| 378 | { SOL_RAW, "SOL_RAW" }, |
| 379 | #endif |
| 380 | #if defined(SOL_IPX) |
| 381 | { SOL_IPX, "SOL_IPX" }, |
| 382 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 383 | #if defined(SOL_AX25) |
| 384 | { SOL_AX25, "SOL_AX25" }, |
| 385 | #endif |
| 386 | #if defined(SOL_ATALK) |
| 387 | { SOL_ATALK, "SOL_ATALK" }, |
| 388 | #endif |
| 389 | #if defined(SOL_NETROM) |
| 390 | { SOL_NETROM, "SOL_NETROM" }, |
| 391 | #endif |
| 392 | #if defined(SOL_ROSE) |
| 393 | { SOL_ROSE, "SOL_ROSE" }, |
| 394 | #endif |
| 395 | #if defined(SOL_DECNET) |
| 396 | { SOL_DECNET, "SOL_DECNET" }, |
| 397 | #endif |
| 398 | #if defined(SOL_X25) |
| 399 | { SOL_X25, "SOL_X25" }, |
| 400 | #endif |
| 401 | #if defined(SOL_PACKET) |
| 402 | { SOL_PACKET, "SOL_PACKET" }, |
| 403 | #endif |
| 404 | #if defined(SOL_ATM) |
| 405 | { SOL_ATM, "SOL_ATM" }, |
| 406 | #endif |
| 407 | #if defined(SOL_AAL) |
| 408 | { SOL_AAL, "SOL_AAL" }, |
| 409 | #endif |
| 410 | #if defined(SOL_IRDA) |
| 411 | { SOL_IRDA, "SOL_IRDA" }, |
| 412 | #endif |
Holger Hans Peter Freyther | ce9e0f4 | 2011-01-14 11:08:11 +0100 | [diff] [blame] | 413 | #if defined(SOL_NETBEUI) |
| 414 | { SOL_NETBEUI, "SOL_NETBEUI" }, |
| 415 | #endif |
| 416 | #if defined(SOL_LLC) |
| 417 | { SOL_LLC, "SOL_LLC" }, |
| 418 | #endif |
| 419 | #if defined(SOL_DCCP) |
| 420 | { SOL_DCCP, "SOL_DCCP" }, |
| 421 | #endif |
| 422 | #if defined(SOL_NETLINK) |
| 423 | { SOL_NETLINK, "SOL_NETLINK" }, |
| 424 | #endif |
| 425 | #if defined(SOL_TIPC) |
| 426 | { SOL_TIPC, "SOL_TIPC" }, |
| 427 | #endif |
| 428 | #if defined(SOL_RXRPC) |
| 429 | { SOL_RXRPC, "SOL_RXRPC" }, |
| 430 | #endif |
| 431 | #if defined(SOL_PPPOL2TP) |
| 432 | { SOL_PPPOL2TP, "SOL_PPPOL2TP" }, |
| 433 | #endif |
| 434 | #if defined(SOL_BLUETOOTH) |
| 435 | { SOL_BLUETOOTH,"SOL_BLUETOOTH" }, |
| 436 | #endif |
| 437 | #if defined(SOL_PNPIPE) |
| 438 | { SOL_PNPIPE, "SOL_PNPIPE" }, |
| 439 | #endif |
| 440 | #if defined(SOL_RDS) |
| 441 | { SOL_RDS, "SOL_RDS" }, |
| 442 | #endif |
| 443 | #if defined(SOL_IUVC) |
| 444 | { SOL_IUCV, "SOL_IUCV" }, |
| 445 | #endif |
| 446 | #if defined(SOL_CAIF) |
| 447 | { SOL_CAIF, "SOL_CAIF" }, |
| 448 | #endif |
John Hughes | 6156357 | 2001-03-27 16:47:36 +0000 | [diff] [blame] | 449 | { SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */ |
Dmitry V. Levin | d475c06 | 2011-03-03 01:02:41 +0000 | [diff] [blame] | 450 | /* The SOL_* array should remain not NULL-terminated. */ |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 451 | }; |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 452 | /*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above |
| 453 | falls into "protocols" array below!!!! This is intended!!! ***/ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 454 | static const struct xlat protocols[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 455 | { IPPROTO_IP, "IPPROTO_IP" }, |
| 456 | { IPPROTO_ICMP, "IPPROTO_ICMP" }, |
| 457 | { IPPROTO_TCP, "IPPROTO_TCP" }, |
| 458 | { IPPROTO_UDP, "IPPROTO_UDP" }, |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 459 | #ifdef IPPROTO_IGMP |
| 460 | { IPPROTO_IGMP, "IPPROTO_IGMP" }, |
| 461 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 462 | #ifdef IPPROTO_GGP |
| 463 | { IPPROTO_GGP, "IPPROTO_GGP" }, |
| 464 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 465 | #ifdef IPPROTO_IPIP |
| 466 | { IPPROTO_IPIP, "IPPROTO_IPIP" }, |
| 467 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 468 | #ifdef IPPROTO_EGP |
| 469 | { IPPROTO_EGP, "IPPROTO_EGP" }, |
| 470 | #endif |
| 471 | #ifdef IPPROTO_PUP |
| 472 | { IPPROTO_PUP, "IPPROTO_PUP" }, |
| 473 | #endif |
| 474 | #ifdef IPPROTO_IDP |
| 475 | { IPPROTO_IDP, "IPPROTO_IDP" }, |
| 476 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 477 | #ifdef IPPROTO_TP |
| 478 | { IPPROTO_TP, "IPPROTO_TP" }, |
| 479 | #endif |
| 480 | #ifdef IPPROTO_DCCP |
| 481 | { IPPROTO_DCCP, "IPPROTO_DCCP" }, |
| 482 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | #ifdef IPPROTO_IPV6 |
| 484 | { IPPROTO_IPV6, "IPPROTO_IPV6" }, |
| 485 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 486 | #ifdef IPPROTO_ROUTING |
| 487 | { IPPROTO_ROUTING, "IPPROTO_ROUTING" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 488 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 489 | #ifdef IPPROTO_FRAGMENT |
| 490 | { IPPROTO_FRAGMENT, "IPPROTO_FRAGMENT" }, |
| 491 | #endif |
| 492 | #ifdef IPPROTO_RSVP |
| 493 | { IPPROTO_RSVP, "IPPROTO_RSVP" }, |
| 494 | #endif |
| 495 | #ifdef IPPROTO_GRE |
| 496 | { IPPROTO_GRE, "IPPROTO_GRE" }, |
| 497 | #endif |
| 498 | #ifdef IPPROTO_ESP |
| 499 | { IPPROTO_ESP, "IPPROTO_ESP" }, |
| 500 | #endif |
| 501 | #ifdef IPPROTO_AH |
| 502 | { IPPROTO_AH, "IPPROTO_AH" }, |
| 503 | #endif |
| 504 | #ifdef IPPROTO_ICMPV6 |
| 505 | { IPPROTO_ICMPV6, "IPPROTO_ICMPV6" }, |
| 506 | #endif |
| 507 | #ifdef IPPROTO_NONE |
| 508 | { IPPROTO_NONE, "IPPROTO_NONE" }, |
| 509 | #endif |
| 510 | #ifdef IPPROTO_DSTOPTS |
| 511 | { IPPROTO_DSTOPTS, "IPPROTO_DSTOPTS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 512 | #endif |
| 513 | #ifdef IPPROTO_HELLO |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 514 | { IPPROTO_HELLO, "IPPROTO_HELLO" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 515 | #endif |
| 516 | #ifdef IPPROTO_ND |
| 517 | { IPPROTO_ND, "IPPROTO_ND" }, |
| 518 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 519 | #ifdef IPPROTO_MTP |
| 520 | { IPPROTO_MTP, "IPPROTO_MTP" }, |
| 521 | #endif |
| 522 | #ifdef IPPROTO_ENCAP |
| 523 | { IPPROTO_ENCAP, "IPPROTO_ENCAP" }, |
| 524 | #endif |
| 525 | #ifdef IPPROTO_PIM |
| 526 | { IPPROTO_PIM, "IPPROTO_PIM" }, |
| 527 | #endif |
| 528 | #ifdef IPPROTO_COMP |
| 529 | { IPPROTO_COMP, "IPPROTO_COMP" }, |
| 530 | #endif |
| 531 | #ifdef IPPROTO_SCTP |
| 532 | { IPPROTO_SCTP, "IPPROTO_SCTP" }, |
| 533 | #endif |
| 534 | #ifdef IPPROTO_UDPLITE |
| 535 | { IPPROTO_UDPLITE, "IPPROTO_UDPLITE" }, |
| 536 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 537 | #ifdef IPPROTO_RAW |
| 538 | { IPPROTO_RAW, "IPPROTO_RAW" }, |
| 539 | #endif |
| 540 | #ifdef IPPROTO_MAX |
| 541 | { IPPROTO_MAX, "IPPROTO_MAX" }, |
| 542 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 543 | { 0, NULL }, |
| 544 | }; |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 545 | static const struct xlat msg_flags[] = { |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 546 | { MSG_OOB, "MSG_OOB" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 547 | #ifdef MSG_DONTROUTE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 548 | { MSG_DONTROUTE, "MSG_DONTROUTE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 549 | #endif |
| 550 | #ifdef MSG_PEEK |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 551 | { MSG_PEEK, "MSG_PEEK" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 552 | #endif |
| 553 | #ifdef MSG_CTRUNC |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 554 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 555 | #endif |
| 556 | #ifdef MSG_PROXY |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 557 | { MSG_PROXY, "MSG_PROXY" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 558 | #endif |
| 559 | #ifdef MSG_EOR |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 560 | { MSG_EOR, "MSG_EOR" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 561 | #endif |
| 562 | #ifdef MSG_WAITALL |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 563 | { MSG_WAITALL, "MSG_WAITALL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 564 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 565 | #ifdef MSG_TRUNC |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 566 | { MSG_TRUNC, "MSG_TRUNC" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 567 | #endif |
| 568 | #ifdef MSG_CTRUNC |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 569 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 570 | #endif |
| 571 | #ifdef MSG_ERRQUEUE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 572 | { MSG_ERRQUEUE, "MSG_ERRQUEUE" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 573 | #endif |
| 574 | #ifdef MSG_DONTWAIT |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 575 | { MSG_DONTWAIT, "MSG_DONTWAIT" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 576 | #endif |
| 577 | #ifdef MSG_CONFIRM |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 578 | { MSG_CONFIRM, "MSG_CONFIRM" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 579 | #endif |
| 580 | #ifdef MSG_PROBE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 581 | { MSG_PROBE, "MSG_PROBE" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 582 | #endif |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 583 | #ifdef MSG_FIN |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 584 | { MSG_FIN, "MSG_FIN" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 585 | #endif |
| 586 | #ifdef MSG_SYN |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 587 | { MSG_SYN, "MSG_SYN" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 588 | #endif |
| 589 | #ifdef MSG_RST |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 590 | { MSG_RST, "MSG_RST" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 591 | #endif |
| 592 | #ifdef MSG_NOSIGNAL |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 593 | { MSG_NOSIGNAL, "MSG_NOSIGNAL" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 594 | #endif |
| 595 | #ifdef MSG_MORE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 596 | { MSG_MORE, "MSG_MORE" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 597 | #endif |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 598 | #ifdef MSG_CMSG_CLOEXEC |
| 599 | { MSG_CMSG_CLOEXEC, "MSG_CMSG_CLOEXEC" }, |
| 600 | #endif |
| 601 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 602 | }; |
| 603 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 604 | static const struct xlat sockoptions[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 605 | #ifdef SO_ACCEPTCONN |
Roland McGrath | 1bf4373 | 2004-08-31 07:16:14 +0000 | [diff] [blame] | 606 | { SO_ACCEPTCONN, "SO_ACCEPTCONN" }, |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 607 | #endif |
| 608 | #ifdef SO_ALLRAW |
| 609 | { SO_ALLRAW, "SO_ALLRAW" }, |
| 610 | #endif |
Roland McGrath | 1bf4373 | 2004-08-31 07:16:14 +0000 | [diff] [blame] | 611 | #ifdef SO_ATTACH_FILTER |
| 612 | { SO_ATTACH_FILTER, "SO_ATTACH_FILTER" }, |
| 613 | #endif |
| 614 | #ifdef SO_BINDTODEVICE |
| 615 | { SO_BINDTODEVICE, "SO_BINDTODEVICE" }, |
| 616 | #endif |
| 617 | #ifdef SO_BROADCAST |
| 618 | { SO_BROADCAST, "SO_BROADCAST" }, |
| 619 | #endif |
| 620 | #ifdef SO_BSDCOMPAT |
| 621 | { SO_BSDCOMPAT, "SO_BSDCOMPAT" }, |
| 622 | #endif |
| 623 | #ifdef SO_DEBUG |
| 624 | { SO_DEBUG, "SO_DEBUG" }, |
| 625 | #endif |
| 626 | #ifdef SO_DETACH_FILTER |
| 627 | { SO_DETACH_FILTER, "SO_DETACH_FILTER" }, |
| 628 | #endif |
| 629 | #ifdef SO_DONTROUTE |
| 630 | { SO_DONTROUTE, "SO_DONTROUTE" }, |
| 631 | #endif |
| 632 | #ifdef SO_ERROR |
| 633 | { SO_ERROR, "SO_ERROR" }, |
| 634 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 635 | #ifdef SO_ICS |
| 636 | { SO_ICS, "SO_ICS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 637 | #endif |
Roland McGrath | 1bf4373 | 2004-08-31 07:16:14 +0000 | [diff] [blame] | 638 | #ifdef SO_IMASOCKET |
| 639 | { SO_IMASOCKET, "SO_IMASOCKET" }, |
| 640 | #endif |
| 641 | #ifdef SO_KEEPALIVE |
| 642 | { SO_KEEPALIVE, "SO_KEEPALIVE" }, |
| 643 | #endif |
| 644 | #ifdef SO_LINGER |
| 645 | { SO_LINGER, "SO_LINGER" }, |
| 646 | #endif |
| 647 | #ifdef SO_LISTENING |
| 648 | { SO_LISTENING, "SO_LISTENING" }, |
| 649 | #endif |
| 650 | #ifdef SO_MGMT |
| 651 | { SO_MGMT, "SO_MGMT" }, |
| 652 | #endif |
| 653 | #ifdef SO_NO_CHECK |
| 654 | { SO_NO_CHECK, "SO_NO_CHECK" }, |
| 655 | #endif |
| 656 | #ifdef SO_OOBINLINE |
| 657 | { SO_OOBINLINE, "SO_OOBINLINE" }, |
| 658 | #endif |
| 659 | #ifdef SO_ORDREL |
| 660 | { SO_ORDREL, "SO_ORDREL" }, |
| 661 | #endif |
| 662 | #ifdef SO_PARALLELSVR |
| 663 | { SO_PARALLELSVR, "SO_PARALLELSVR" }, |
| 664 | #endif |
| 665 | #ifdef SO_PASSCRED |
| 666 | { SO_PASSCRED, "SO_PASSCRED" }, |
| 667 | #endif |
| 668 | #ifdef SO_PEERCRED |
| 669 | { SO_PEERCRED, "SO_PEERCRED" }, |
| 670 | #endif |
| 671 | #ifdef SO_PEERNAME |
| 672 | { SO_PEERNAME, "SO_PEERNAME" }, |
| 673 | #endif |
| 674 | #ifdef SO_PEERSEC |
| 675 | { SO_PEERSEC, "SO_PEERSEC" }, |
| 676 | #endif |
| 677 | #ifdef SO_PRIORITY |
| 678 | { SO_PRIORITY, "SO_PRIORITY" }, |
| 679 | #endif |
| 680 | #ifdef SO_PROTOTYPE |
| 681 | { SO_PROTOTYPE, "SO_PROTOTYPE" }, |
| 682 | #endif |
| 683 | #ifdef SO_RCVBUF |
| 684 | { SO_RCVBUF, "SO_RCVBUF" }, |
| 685 | #endif |
| 686 | #ifdef SO_RCVLOWAT |
| 687 | { SO_RCVLOWAT, "SO_RCVLOWAT" }, |
| 688 | #endif |
| 689 | #ifdef SO_RCVTIMEO |
| 690 | { SO_RCVTIMEO, "SO_RCVTIMEO" }, |
| 691 | #endif |
| 692 | #ifdef SO_RDWR |
| 693 | { SO_RDWR, "SO_RDWR" }, |
| 694 | #endif |
| 695 | #ifdef SO_REUSEADDR |
| 696 | { SO_REUSEADDR, "SO_REUSEADDR" }, |
| 697 | #endif |
| 698 | #ifdef SO_REUSEPORT |
| 699 | { SO_REUSEPORT, "SO_REUSEPORT" }, |
| 700 | #endif |
| 701 | #ifdef SO_SECURITY_AUTHENTICATION |
| 702 | { SO_SECURITY_AUTHENTICATION,"SO_SECURITY_AUTHENTICATION"}, |
| 703 | #endif |
| 704 | #ifdef SO_SECURITY_ENCRYPTION_NETWORK |
| 705 | { SO_SECURITY_ENCRYPTION_NETWORK,"SO_SECURITY_ENCRYPTION_NETWORK"}, |
| 706 | #endif |
| 707 | #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT |
| 708 | { SO_SECURITY_ENCRYPTION_TRANSPORT,"SO_SECURITY_ENCRYPTION_TRANSPORT"}, |
| 709 | #endif |
| 710 | #ifdef SO_SEMA |
| 711 | { SO_SEMA, "SO_SEMA" }, |
| 712 | #endif |
| 713 | #ifdef SO_SNDBUF |
| 714 | { SO_SNDBUF, "SO_SNDBUF" }, |
| 715 | #endif |
| 716 | #ifdef SO_SNDLOWAT |
| 717 | { SO_SNDLOWAT, "SO_SNDLOWAT" }, |
| 718 | #endif |
| 719 | #ifdef SO_SNDTIMEO |
| 720 | { SO_SNDTIMEO, "SO_SNDTIMEO" }, |
| 721 | #endif |
| 722 | #ifdef SO_TIMESTAMP |
| 723 | { SO_TIMESTAMP, "SO_TIMESTAMP" }, |
| 724 | #endif |
| 725 | #ifdef SO_TYPE |
| 726 | { SO_TYPE, "SO_TYPE" }, |
| 727 | #endif |
| 728 | #ifdef SO_USELOOPBACK |
| 729 | { SO_USELOOPBACK, "SO_USELOOPBACK" }, |
| 730 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 731 | { 0, NULL }, |
| 732 | }; |
| 733 | |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 734 | #if !defined (SOL_IP) && defined (IPPROTO_IP) |
| 735 | #define SOL_IP IPPROTO_IP |
| 736 | #endif |
| 737 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 738 | #ifdef SOL_IP |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 739 | static const struct xlat sockipoptions[] = { |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 740 | #ifdef IP_TOS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 741 | { IP_TOS, "IP_TOS" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 742 | #endif |
| 743 | #ifdef IP_TTL |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 744 | { IP_TTL, "IP_TTL" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 745 | #endif |
| 746 | #ifdef IP_HDRINCL |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 747 | { IP_HDRINCL, "IP_HDRINCL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 748 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 749 | #ifdef IP_OPTIONS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 750 | { IP_OPTIONS, "IP_OPTIONS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 751 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 752 | #ifdef IP_ROUTER_ALERT |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 753 | { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 754 | #endif |
| 755 | #ifdef IP_RECVOPTIONS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 756 | { IP_RECVOPTIONS, "IP_RECVOPTIONS" }, |
| 757 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 758 | #ifdef IP_RECVOPTS |
| 759 | { IP_RECVOPTS, "IP_RECVOPTS" }, |
| 760 | #endif |
| 761 | #ifdef IP_RECVRETOPTS |
| 762 | { IP_RECVRETOPTS, "IP_RECVRETOPTS" }, |
| 763 | #endif |
| 764 | #ifdef IP_RECVDSTADDR |
| 765 | { IP_RECVDSTADDR, "IP_RECVDSTADDR" }, |
| 766 | #endif |
| 767 | #ifdef IP_RETOPTS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 768 | { IP_RETOPTS, "IP_RETOPTS" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 769 | #endif |
| 770 | #ifdef IP_PKTINFO |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 771 | { IP_PKTINFO, "IP_PKTINFO" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 772 | #endif |
| 773 | #ifdef IP_PKTOPTIONS |
| 774 | { IP_PKTOPTIONS, "IP_PKTOPTIONS" }, |
| 775 | #endif |
| 776 | #ifdef IP_MTU_DISCOVER |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 777 | { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 778 | #endif |
| 779 | #ifdef IP_RECVERR |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 780 | { IP_RECVERR, "IP_RECVERR" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 781 | #endif |
| 782 | #ifdef IP_RECVTTL |
Roland McGrath | 04ac03a | 2005-07-04 23:30:27 +0000 | [diff] [blame] | 783 | { IP_RECVTTL, "IP_RECVTTL" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 784 | #endif |
| 785 | #ifdef IP_RECVTOS |
Roland McGrath | 04ac03a | 2005-07-04 23:30:27 +0000 | [diff] [blame] | 786 | { IP_RECVTOS, "IP_RECVTOS" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 787 | #endif |
| 788 | #ifdef IP_MTU |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 789 | { IP_MTU, "IP_MTU" }, |
| 790 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 791 | #ifdef IP_MULTICAST_IF |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 792 | { IP_MULTICAST_IF, "IP_MULTICAST_IF" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 793 | #endif |
| 794 | #ifdef IP_MULTICAST_TTL |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 795 | { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 796 | #endif |
| 797 | #ifdef IP_MULTICAST_LOOP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 798 | { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 799 | #endif |
| 800 | #ifdef IP_ADD_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 801 | { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 802 | #endif |
| 803 | #ifdef IP_DROP_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 804 | { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 805 | #endif |
| 806 | #ifdef IP_BROADCAST_IF |
| 807 | { IP_BROADCAST_IF, "IP_BROADCAST_IF" }, |
| 808 | #endif |
| 809 | #ifdef IP_RECVIFINDEX |
| 810 | { IP_RECVIFINDEX, "IP_RECVIFINDEX" }, |
| 811 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 812 | #ifdef IP_MSFILTER |
| 813 | { IP_MSFILTER, "IP_MSFILTER" }, |
| 814 | #endif |
| 815 | #ifdef MCAST_MSFILTER |
| 816 | { MCAST_MSFILTER, "MCAST_MSFILTER" }, |
| 817 | #endif |
| 818 | #ifdef IP_FREEBIND |
| 819 | { IP_FREEBIND, "IP_FREEBIND" }, |
| 820 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 821 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 822 | }; |
| 823 | #endif /* SOL_IP */ |
| 824 | |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 825 | #ifdef SOL_IPV6 |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 826 | static const struct xlat sockipv6options[] = { |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 827 | #ifdef IPV6_ADDRFORM |
| 828 | { IPV6_ADDRFORM, "IPV6_ADDRFORM" }, |
| 829 | #endif |
| 830 | #ifdef MCAST_FILTER |
| 831 | { MCAST_FILTER, "MCAST_FILTER" }, |
| 832 | #endif |
| 833 | #ifdef IPV6_PKTOPTIONS |
| 834 | { IPV6_PKTOPTIONS, "IPV6_PKTOPTIONS" }, |
| 835 | #endif |
| 836 | #ifdef IPV6_MTU |
| 837 | { IPV6_MTU, "IPV6_MTU" }, |
| 838 | #endif |
| 839 | #ifdef IPV6_V6ONLY |
| 840 | { IPV6_V6ONLY, "IPV6_V6ONLY" }, |
| 841 | #endif |
| 842 | #ifdef IPV6_PKTINFO |
| 843 | { IPV6_PKTINFO, "IPV6_PKTINFO" }, |
| 844 | #endif |
| 845 | #ifdef IPV6_HOPLIMIT |
| 846 | { IPV6_HOPLIMIT, "IPV6_HOPLIMIT" }, |
| 847 | #endif |
| 848 | #ifdef IPV6_RTHDR |
| 849 | { IPV6_RTHDR, "IPV6_RTHDR" }, |
| 850 | #endif |
| 851 | #ifdef IPV6_HOPOPTS |
| 852 | { IPV6_HOPOPTS, "IPV6_HOPOPTS" }, |
| 853 | #endif |
| 854 | #ifdef IPV6_DSTOPTS |
| 855 | { IPV6_DSTOPTS, "IPV6_DSTOPTS" }, |
| 856 | #endif |
| 857 | #ifdef IPV6_FLOWINFO |
| 858 | { IPV6_FLOWINFO, "IPV6_FLOWINFO" }, |
| 859 | #endif |
| 860 | #ifdef IPV6_UNICAST_HOPS |
| 861 | { IPV6_UNICAST_HOPS, "IPV6_UNICAST_HOPS" }, |
| 862 | #endif |
| 863 | #ifdef IPV6_MULTICAST_HOPS |
| 864 | { IPV6_MULTICAST_HOPS, "IPV6_MULTICAST_HOPS" }, |
| 865 | #endif |
| 866 | #ifdef IPV6_MULTICAST_LOOP |
| 867 | { IPV6_MULTICAST_LOOP, "IPV6_MULTICAST_LOOP" }, |
| 868 | #endif |
| 869 | #ifdef IPV6_MULTICAST_IF |
| 870 | { IPV6_MULTICAST_IF, "IPV6_MULTICAST_IF" }, |
| 871 | #endif |
| 872 | #ifdef IPV6_MTU_DISCOVER |
| 873 | { IPV6_MTU_DISCOVER, "IPV6_MTU_DISCOVER" }, |
| 874 | #endif |
| 875 | #ifdef IPV6_RECVERR |
| 876 | { IPV6_RECVERR, "IPV6_RECVERR" }, |
| 877 | #endif |
| 878 | #ifdef IPV6_FLOWINFO_SEND |
| 879 | { IPV6_FLOWINFO_SEND, "IPV6_FLOWINFO_SEND" }, |
| 880 | #endif |
Roland McGrath | c0b9e37 | 2005-07-04 23:33:38 +0000 | [diff] [blame] | 881 | #ifdef IPV6_ADD_MEMBERSHIP |
| 882 | { IPV6_ADD_MEMBERSHIP, "IPV6_ADD_MEMBERSHIP" }, |
| 883 | #endif |
| 884 | #ifdef IPV6_DROP_MEMBERSHIP |
| 885 | { IPV6_DROP_MEMBERSHIP, "IPV6_DROP_MEMBERSHIP" }, |
| 886 | #endif |
| 887 | #ifdef IPV6_ROUTER_ALERT |
| 888 | { IPV6_ROUTER_ALERT, "IPV6_ROUTER_ALERT" }, |
| 889 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 890 | { 0, NULL }, |
| 891 | }; |
| 892 | #endif /* SOL_IPV6 */ |
| 893 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 894 | #ifdef SOL_IPX |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 895 | static const struct xlat sockipxoptions[] = { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 896 | { IPX_TYPE, "IPX_TYPE" }, |
| 897 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 898 | }; |
| 899 | #endif /* SOL_IPX */ |
| 900 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 901 | #ifdef SOL_RAW |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 902 | static const struct xlat sockrawoptions[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 903 | #if defined(ICMP_FILTER) |
| 904 | { ICMP_FILTER, "ICMP_FILTER" }, |
| 905 | #endif |
| 906 | { 0, NULL }, |
| 907 | }; |
| 908 | #endif /* SOL_RAW */ |
| 909 | |
| 910 | #ifdef SOL_PACKET |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 911 | static const struct xlat sockpacketoptions[] = { |
Roland McGrath | c294b8f | 2007-11-01 21:37:33 +0000 | [diff] [blame] | 912 | #ifdef PACKET_ADD_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 913 | { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" }, |
Roland McGrath | c294b8f | 2007-11-01 21:37:33 +0000 | [diff] [blame] | 914 | #endif |
| 915 | #ifdef PACKET_DROP_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 916 | { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"}, |
Roland McGrath | c294b8f | 2007-11-01 21:37:33 +0000 | [diff] [blame] | 917 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 918 | #if defined(PACKET_RECV_OUTPUT) |
| 919 | { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" }, |
| 920 | #endif |
| 921 | #if defined(PACKET_RX_RING) |
| 922 | { PACKET_RX_RING, "PACKET_RX_RING" }, |
| 923 | #endif |
| 924 | #if defined(PACKET_STATISTICS) |
| 925 | { PACKET_STATISTICS, "PACKET_STATISTICS" }, |
| 926 | #endif |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 927 | #if defined(PACKET_COPY_THRESH) |
| 928 | { PACKET_COPY_THRESH, "PACKET_COPY_THRESH" }, |
| 929 | #endif |
| 930 | #if defined(PACKET_AUXDATA) |
| 931 | { PACKET_AUXDATA, "PACKET_AUXDATA" }, |
| 932 | #endif |
| 933 | #if defined(PACKET_ORIGDEV) |
| 934 | { PACKET_ORIGDEV, "PACKET_ORIGDEV" }, |
| 935 | #endif |
| 936 | #if defined(PACKET_VERSION) |
| 937 | { PACKET_VERSION, "PACKET_VERSION" }, |
| 938 | #endif |
| 939 | #if defined(PACKET_HDRLEN) |
| 940 | { PACKET_HDRLEN, "PACKET_HDRLEN" }, |
| 941 | #endif |
| 942 | #if defined(PACKET_RESERVE) |
| 943 | { PACKET_RESERVE, "PACKET_RESERVE" }, |
| 944 | #endif |
| 945 | #if defined(PACKET_TX_RING) |
| 946 | { PACKET_TX_RING, "PACKET_TX_RING" }, |
| 947 | #endif |
| 948 | #if defined(PACKET_LOSS) |
| 949 | { PACKET_LOSS, "PACKET_LOSS" }, |
| 950 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 951 | { 0, NULL }, |
| 952 | }; |
| 953 | #endif /* SOL_PACKET */ |
| 954 | |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 955 | #ifdef SOL_SCTP |
| 956 | static const struct xlat socksctpoptions[] = { |
| 957 | #if defined(SCTP_RTOINFO) |
| 958 | { SCTP_RTOINFO, "SCTP_RTOINFO" }, |
| 959 | #endif |
| 960 | #if defined(SCTP_ASSOCINFO) |
| 961 | { SCTP_ASSOCINFO, "SCTP_ASSOCINFO"}, |
| 962 | #endif |
| 963 | #if defined(SCTP_INITMSG) |
| 964 | { SCTP_INITMSG, "SCTP_INITMSG" }, |
| 965 | #endif |
| 966 | #if defined(SCTP_NODELAY) |
| 967 | { SCTP_NODELAY, "SCTP_NODELAY" }, |
| 968 | #endif |
| 969 | #if defined(SCTP_AUTOCLOSE) |
| 970 | { SCTP_AUTOCLOSE, "SCTP_AUTOCLOSE"}, |
| 971 | #endif |
| 972 | #if defined(SCTP_SET_PEER_PRIMARY_ADDR) |
| 973 | { SCTP_SET_PEER_PRIMARY_ADDR, "SCTP_SET_PEER_PRIMARY_ADDR"}, |
| 974 | #endif |
| 975 | #if defined(SCTP_PRIMARY_ADDR) |
| 976 | { SCTP_PRIMARY_ADDR, "SCTP_PRIMARY_ADDR" }, |
| 977 | #endif |
| 978 | #if defined(SCTP_ADAPTATION_LAYER) |
| 979 | { SCTP_ADAPTATION_LAYER, "SCTP_ADAPTATION_LAYER" }, |
| 980 | #endif |
| 981 | #if defined(SCTP_DISABLE_FRAGMENTS) |
| 982 | { SCTP_DISABLE_FRAGMENTS, "SCTP_DISABLE_FRAGMENTS"}, |
| 983 | #endif |
| 984 | #if defined(SCTP_PEER_ADDR_PARAMS) |
| 985 | { SCTP_PEER_ADDR_PARAMS, "SCTP_PEER_ADDR_PARAMS" }, |
| 986 | #endif |
| 987 | #if defined(SCTP_DEFAULT_SEND_PARAM) |
| 988 | { SCTP_DEFAULT_SEND_PARAM, "SCTP_DEFAULT_SEND_PARAM"}, |
| 989 | #endif |
| 990 | #if defined(SCTP_EVENTS) |
| 991 | { SCTP_EVENTS, "SCTP_EVENTS" }, |
| 992 | #endif |
| 993 | #if defined(SCTP_I_WANT_MAPPED_V4_ADDR) |
| 994 | { SCTP_I_WANT_MAPPED_V4_ADDR, "SCTP_I_WANT_MAPPED_V4_ADDR"}, |
| 995 | #endif |
| 996 | #if defined(SCTP_MAXSEG) |
| 997 | { SCTP_MAXSEG, "SCTP_MAXSEG" }, |
| 998 | #endif |
| 999 | #if defined(SCTP_STATUS) |
| 1000 | { SCTP_STATUS, "SCTP_STATUS" }, |
| 1001 | #endif |
| 1002 | #if defined(SCTP_GET_PEER_ADDR_INFO) |
| 1003 | { SCTP_GET_PEER_ADDR_INFO, "SCTP_GET_PEER_ADDR_INFO"}, |
| 1004 | #endif |
| 1005 | #if defined(SCTP_DELAYED_ACK) |
| 1006 | { SCTP_DELAYED_ACK, "SCTP_DELAYED_ACK" }, |
| 1007 | #endif |
| 1008 | #if defined(SCTP_CONTEXT) |
| 1009 | { SCTP_CONTEXT, "SCTP_CONTEXT" }, |
| 1010 | #endif |
| 1011 | #if defined(SCTP_FRAGMENT_INTERLEAVE) |
| 1012 | { SCTP_FRAGMENT_INTERLEAVE, "SCTP_FRAGMENT_INTERLEAVE"}, |
| 1013 | #endif |
| 1014 | #if defined(SCTP_PARTIAL_DELIVERY_POINT) |
| 1015 | { SCTP_PARTIAL_DELIVERY_POINT, "SCTP_PARTIAL_DELIVERY_POINT"}, |
| 1016 | #endif |
| 1017 | #if defined(SCTP_MAX_BURST) |
| 1018 | { SCTP_MAX_BURST, "SCTP_MAX_BURST" }, |
| 1019 | #endif |
| 1020 | #if defined(SCTP_AUTH_CHUNK) |
| 1021 | { SCTP_AUTH_CHUNK, "SCTP_AUTH_CHUNK" }, |
| 1022 | #endif |
| 1023 | #if defined(SCTP_HMAC_IDENT) |
| 1024 | { SCTP_HMAC_IDENT, "SCTP_HMAC_IDENT" }, |
| 1025 | #endif |
| 1026 | #if defined(SCTP_AUTH_KEY) |
| 1027 | { SCTP_AUTH_KEY, "SCTP_AUTH_KEY" }, |
| 1028 | #endif |
| 1029 | #if defined(SCTP_AUTH_ACTIVE_KEY) |
| 1030 | { SCTP_AUTH_ACTIVE_KEY, "SCTP_AUTH_ACTIVE_KEY" }, |
| 1031 | #endif |
| 1032 | #if defined(SCTP_AUTH_DELETE_KEY) |
| 1033 | { SCTP_AUTH_DELETE_KEY, "SCTP_AUTH_DELETE_KEY" }, |
| 1034 | #endif |
| 1035 | #if defined(SCTP_PEER_AUTH_CHUNKS) |
| 1036 | { SCTP_PEER_AUTH_CHUNKS, "SCTP_PEER_AUTH_CHUNKS" }, |
| 1037 | #endif |
| 1038 | #if defined(SCTP_LOCAL_AUTH_CHUNKS) |
| 1039 | { SCTP_LOCAL_AUTH_CHUNKS, "SCTP_LOCAL_AUTH_CHUNKS"}, |
| 1040 | #endif |
| 1041 | #if defined(SCTP_GET_ASSOC_NUMBER) |
| 1042 | { SCTP_GET_ASSOC_NUMBER, "SCTP_GET_ASSOC_NUMBER" }, |
| 1043 | #endif |
| 1044 | |
| 1045 | /* linux specific things */ |
| 1046 | #if defined(SCTP_SOCKOPT_BINDX_ADD) |
| 1047 | { SCTP_SOCKOPT_BINDX_ADD, "SCTP_SOCKOPT_BINDX_ADD" }, |
| 1048 | #endif |
| 1049 | #if defined(SCTP_SOCKOPT_BINDX_REM) |
| 1050 | { SCTP_SOCKOPT_BINDX_REM, "SCTP_SOCKOPT_BINDX_REM" }, |
| 1051 | #endif |
| 1052 | #if defined(SCTP_SOCKOPT_PEELOFF) |
| 1053 | { SCTP_SOCKOPT_PEELOFF, "SCTP_SOCKOPT_PEELOFF" }, |
| 1054 | #endif |
| 1055 | #if defined(SCTP_GET_PEER_ADDRS_NUM_OLD) |
| 1056 | { SCTP_GET_PEER_ADDRS_NUM_OLD, "SCTP_GET_PEER_ADDRS_NUM_OLD" }, |
| 1057 | #endif |
| 1058 | #if defined(SCTP_GET_PEER_ADDRS_OLD) |
| 1059 | { SCTP_GET_PEER_ADDRS_OLD, "SCTP_GET_PEER_ADDRS_OLD" }, |
| 1060 | #endif |
| 1061 | #if defined(SCTP_GET_LOCAL_ADDRS_NUM_OLD) |
| 1062 | { SCTP_GET_LOCAL_ADDRS_NUM_OLD, "SCTP_GET_LOCAL_ADDRS_NUM_OLD" }, |
| 1063 | #endif |
| 1064 | #if defined(SCTP_GET_LOCAL_ADDRS_OLD) |
| 1065 | { SCTP_GET_LOCAL_ADDRS_OLD, "SCTP_GET_LOCAL_ADDRS_OLD" }, |
| 1066 | #endif |
| 1067 | #if defined(SCTP_SOCKOPT_CONNECTX_OLD) |
| 1068 | { SCTP_SOCKOPT_CONNECTX_OLD, "SCTP_SOCKOPT_CONNECTX_OLD" }, |
| 1069 | #endif |
| 1070 | #if defined(SCTP_GET_PEER_ADDRS) |
| 1071 | { SCTP_GET_PEER_ADDRS, "SCTP_GET_PEER_ADDRS" }, |
| 1072 | #endif |
| 1073 | #if defined(SCTP_GET_LOCAL_ADDRS) |
| 1074 | { SCTP_GET_LOCAL_ADDRS, "SCTP_GET_LOCAL_ADDRS" }, |
| 1075 | #endif |
| 1076 | |
| 1077 | { 0, NULL }, |
| 1078 | }; |
| 1079 | #endif |
| 1080 | |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1081 | #if !defined (SOL_TCP) && defined (IPPROTO_TCP) |
| 1082 | #define SOL_TCP IPPROTO_TCP |
| 1083 | #endif |
| 1084 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1085 | #ifdef SOL_TCP |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1086 | static const struct xlat socktcpoptions[] = { |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1087 | { TCP_NODELAY, "TCP_NODELAY" }, |
| 1088 | { TCP_MAXSEG, "TCP_MAXSEG" }, |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1089 | #if defined(TCP_CORK) |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1090 | { TCP_CORK, "TCP_CORK" }, |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1091 | #endif |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1092 | #if defined(TCP_KEEPIDLE) |
| 1093 | { TCP_KEEPIDLE, "TCP_KEEPIDLE" }, |
| 1094 | #endif |
| 1095 | #if defined(TCP_KEEPINTVL) |
| 1096 | { TCP_KEEPINTVL, "TCP_KEEPINTVL" }, |
| 1097 | #endif |
| 1098 | #if defined(TCP_KEEPCNT) |
| 1099 | { TCP_KEEPCNT, "TCP_KEEPCNT" }, |
| 1100 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1101 | #if defined(TCP_NKEEP) |
| 1102 | { TCP_NKEEP, "TCP_NKEEP" }, |
| 1103 | #endif |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1104 | #if defined(TCP_SYNCNT) |
| 1105 | { TCP_SYNCNT, "TCP_SYNCNT" }, |
| 1106 | #endif |
| 1107 | #if defined(TCP_LINGER2) |
| 1108 | { TCP_LINGER2, "TCP_LINGER2" }, |
| 1109 | #endif |
| 1110 | #if defined(TCP_DEFER_ACCEPT) |
| 1111 | { TCP_DEFER_ACCEPT, "TCP_DEFER_ACCEPT" }, |
| 1112 | #endif |
| 1113 | #if defined(TCP_WINDOW_CLAMP) |
| 1114 | { TCP_WINDOW_CLAMP, "TCP_WINDOW_CLAMP" }, |
| 1115 | #endif |
| 1116 | #if defined(TCP_INFO) |
| 1117 | { TCP_INFO, "TCP_INFO" }, |
| 1118 | #endif |
| 1119 | #if defined(TCP_QUICKACK) |
| 1120 | { TCP_QUICKACK, "TCP_QUICKACK" }, |
| 1121 | #endif |
| 1122 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1123 | }; |
| 1124 | #endif /* SOL_TCP */ |
| 1125 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1126 | #ifdef SOL_RAW |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1127 | static const struct xlat icmpfilterflags[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1128 | #if defined(ICMP_ECHOREPLY) |
| 1129 | { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" }, |
| 1130 | #endif |
| 1131 | #if defined(ICMP_DEST_UNREACH) |
| 1132 | { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" }, |
| 1133 | #endif |
| 1134 | #if defined(ICMP_SOURCE_QUENCH) |
| 1135 | { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" }, |
| 1136 | #endif |
| 1137 | #if defined(ICMP_REDIRECT) |
| 1138 | { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" }, |
| 1139 | #endif |
| 1140 | #if defined(ICMP_ECHO) |
| 1141 | { (1<<ICMP_ECHO), "ICMP_ECHO" }, |
| 1142 | #endif |
| 1143 | #if defined(ICMP_TIME_EXCEEDED) |
| 1144 | { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" }, |
| 1145 | #endif |
| 1146 | #if defined(ICMP_PARAMETERPROB) |
| 1147 | { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" }, |
| 1148 | #endif |
| 1149 | #if defined(ICMP_TIMESTAMP) |
| 1150 | { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" }, |
| 1151 | #endif |
| 1152 | #if defined(ICMP_TIMESTAMPREPLY) |
| 1153 | { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" }, |
| 1154 | #endif |
| 1155 | #if defined(ICMP_INFO_REQUEST) |
| 1156 | { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" }, |
| 1157 | #endif |
| 1158 | #if defined(ICMP_INFO_REPLY) |
| 1159 | { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" }, |
| 1160 | #endif |
| 1161 | #if defined(ICMP_ADDRESS) |
| 1162 | { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" }, |
| 1163 | #endif |
| 1164 | #if defined(ICMP_ADDRESSREPLY) |
| 1165 | { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" }, |
| 1166 | #endif |
| 1167 | { 0, NULL }, |
| 1168 | }; |
| 1169 | #endif /* SOL_RAW */ |
| 1170 | |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1171 | #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1172 | static const struct xlat af_packet_types[] = { |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1173 | #if defined(PACKET_HOST) |
| 1174 | { PACKET_HOST, "PACKET_HOST" }, |
| 1175 | #endif |
| 1176 | #if defined(PACKET_BROADCAST) |
| 1177 | { PACKET_BROADCAST, "PACKET_BROADCAST" }, |
| 1178 | #endif |
| 1179 | #if defined(PACKET_MULTICAST) |
| 1180 | { PACKET_MULTICAST, "PACKET_MULTICAST" }, |
| 1181 | #endif |
| 1182 | #if defined(PACKET_OTHERHOST) |
| 1183 | { PACKET_OTHERHOST, "PACKET_OTHERHOST" }, |
| 1184 | #endif |
| 1185 | #if defined(PACKET_OUTGOING) |
| 1186 | { PACKET_OUTGOING, "PACKET_OUTGOING" }, |
| 1187 | #endif |
| 1188 | #if defined(PACKET_LOOPBACK) |
| 1189 | { PACKET_LOOPBACK, "PACKET_LOOPBACK" }, |
| 1190 | #endif |
| 1191 | #if defined(PACKET_FASTROUTE) |
| 1192 | { PACKET_FASTROUTE, "PACKET_FASTROUTE" }, |
| 1193 | #endif |
| 1194 | { 0, NULL }, |
| 1195 | }; |
| 1196 | #endif /* defined(AF_PACKET) */ |
| 1197 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1198 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1199 | void |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1200 | printsock(struct tcb *tcp, long addr, int addrlen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1201 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1202 | union { |
| 1203 | char pad[128]; |
| 1204 | struct sockaddr sa; |
| 1205 | struct sockaddr_in sin; |
| 1206 | struct sockaddr_un sau; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1207 | #ifdef HAVE_INET_NTOP |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1208 | struct sockaddr_in6 sa6; |
| 1209 | #endif |
| 1210 | #if defined(LINUX) && defined(AF_IPX) |
| 1211 | struct sockaddr_ipx sipx; |
| 1212 | #endif |
| 1213 | #ifdef AF_PACKET |
| 1214 | struct sockaddr_ll ll; |
| 1215 | #endif |
| 1216 | #ifdef AF_NETLINK |
| 1217 | struct sockaddr_nl nl; |
| 1218 | #endif |
| 1219 | } addrbuf; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1220 | char string_addr[100]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1221 | |
| 1222 | if (addr == 0) { |
| 1223 | tprintf("NULL"); |
| 1224 | return; |
| 1225 | } |
| 1226 | if (!verbose(tcp)) { |
| 1227 | tprintf("%#lx", addr); |
| 1228 | return; |
| 1229 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1230 | |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1231 | if (addrlen < 2 || addrlen > sizeof(addrbuf)) |
| 1232 | addrlen = sizeof(addrbuf); |
| 1233 | |
| 1234 | memset(&addrbuf, 0, sizeof(addrbuf)); |
| 1235 | if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1236 | tprintf("{...}"); |
| 1237 | return; |
| 1238 | } |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1239 | addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0'; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1240 | |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 1241 | tprintf("{sa_family="); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1242 | printxval(addrfams, addrbuf.sa.sa_family, "AF_???"); |
| 1243 | tprintf(", "); |
| 1244 | |
| 1245 | switch (addrbuf.sa.sa_family) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1246 | case AF_UNIX: |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1247 | if (addrlen == 2) { |
| 1248 | tprintf("NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1249 | } else if (addrbuf.sau.sun_path[0]) { |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1250 | tprintf("path="); |
Dmitry V. Levin | 16fbe97 | 2007-10-13 21:03:17 +0000 | [diff] [blame] | 1251 | printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path)); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1252 | } else { |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1253 | tprintf("path=@"); |
Dmitry V. Levin | 16fbe97 | 2007-10-13 21:03:17 +0000 | [diff] [blame] | 1254 | printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1)); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1255 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1256 | break; |
| 1257 | case AF_INET: |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 1258 | tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1259 | ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1260 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1261 | #ifdef HAVE_INET_NTOP |
| 1262 | case AF_INET6: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1263 | 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] | 1264 | tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u", |
| 1265 | ntohs(addrbuf.sa6.sin6_port), string_addr, |
| 1266 | addrbuf.sa6.sin6_flowinfo); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1267 | #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 1268 | { |
| 1269 | #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^] | 1270 | int numericscope = 0; |
| 1271 | if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr) |
| 1272 | || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) { |
| 1273 | char scopebuf[IFNAMSIZ + 1]; |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1274 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1275 | if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL) |
| 1276 | numericscope++; |
| 1277 | else |
| 1278 | tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf); |
| 1279 | } else |
| 1280 | numericscope++; |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1281 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1282 | if (numericscope) |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 1283 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1284 | tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id); |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 1285 | } |
| 1286 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1287 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1288 | #endif |
Wichert Akkerman | dbb440e | 1999-05-11 15:06:44 +0000 | [diff] [blame] | 1289 | #if defined(AF_IPX) && defined(linux) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1290 | case AF_IPX: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1291 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1292 | int i; |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 1293 | tprintf("sipx_port=htons(%u), ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1294 | ntohs(addrbuf.sipx.sipx_port)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1295 | /* Yes, I know, this does not look too |
| 1296 | * strace-ish, but otherwise the IPX |
| 1297 | * addresses just look monstrous... |
| 1298 | * Anyways, feel free if you don't like |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1299 | * this way.. :) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1300 | */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1301 | tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network)); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1302 | for (i = 0; i < IPX_NODE_LEN; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1303 | tprintf("%02x", addrbuf.sipx.sipx_node[i]); |
| 1304 | tprintf("/[%02x]", addrbuf.sipx.sipx_type); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1305 | } |
| 1306 | break; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1307 | #endif /* AF_IPX && linux */ |
| 1308 | #ifdef AF_PACKET |
| 1309 | case AF_PACKET: |
| 1310 | { |
| 1311 | int i; |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1312 | tprintf("proto=%#04x, if%d, pkttype=", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1313 | ntohs(addrbuf.ll.sll_protocol), |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1314 | addrbuf.ll.sll_ifindex); |
| 1315 | printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?"); |
| 1316 | tprintf(", addr(%d)={%d, ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1317 | addrbuf.ll.sll_halen, |
| 1318 | addrbuf.ll.sll_hatype); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1319 | for (i = 0; i < addrbuf.ll.sll_halen; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1320 | tprintf("%02x", addrbuf.ll.sll_addr[i]); |
| 1321 | } |
| 1322 | break; |
| 1323 | |
| 1324 | #endif /* AF_APACKET */ |
Roland McGrath | 36ef1bc | 2003-11-06 23:41:23 +0000 | [diff] [blame] | 1325 | #ifdef AF_NETLINK |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1326 | case AF_NETLINK: |
| 1327 | tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); |
| 1328 | break; |
| 1329 | #endif /* AF_NETLINK */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1330 | /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1331 | AF_X25 AF_ROSE etc. still need to be done */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1332 | |
| 1333 | default: |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 1334 | tprintf("sa_data="); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1335 | printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1336 | sizeof addrbuf.sa.sa_data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1337 | break; |
| 1338 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1339 | tprintf("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1340 | } |
| 1341 | |
| 1342 | #if HAVE_SENDMSG |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1343 | static const struct xlat scmvals[] = { |
| 1344 | #ifdef SCM_RIGHTS |
| 1345 | { SCM_RIGHTS, "SCM_RIGHTS" }, |
| 1346 | #endif |
| 1347 | #ifdef SCM_CREDENTIALS |
| 1348 | { SCM_CREDENTIALS, "SCM_CREDENTIALS" }, |
| 1349 | #endif |
| 1350 | { 0, NULL } |
| 1351 | }; |
| 1352 | |
| 1353 | static void |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 1354 | printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len) |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1355 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1356 | struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ? |
| 1357 | NULL : malloc(len); |
| 1358 | if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) { |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1359 | tprintf(", msg_control=%#lx", addr); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1360 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1361 | return; |
| 1362 | } |
| 1363 | |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 1364 | tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1365 | printxval(socketlayers, cmsg->cmsg_level, "SOL_???"); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1366 | tprintf(", cmsg_type="); |
| 1367 | |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1368 | if (cmsg->cmsg_level == SOL_SOCKET) { |
| 1369 | unsigned long cmsg_len; |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 1370 | |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1371 | printxval(scmvals, cmsg->cmsg_type, "SCM_???"); |
| 1372 | cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len; |
| 1373 | |
| 1374 | if (cmsg->cmsg_type == SCM_RIGHTS |
| 1375 | && CMSG_LEN(sizeof(int)) <= cmsg_len) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1376 | int *fds = (int *) CMSG_DATA(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1377 | int first = 1; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1378 | |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1379 | tprintf(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1380 | while ((char *) fds < ((char *) cmsg + cmsg_len)) { |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1381 | if (!first) |
| 1382 | tprintf(", "); |
| 1383 | tprintf("%d", *fds++); |
| 1384 | first = 0; |
| 1385 | } |
| 1386 | tprintf("}}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1387 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1388 | return; |
| 1389 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1390 | if (cmsg->cmsg_type == SCM_CREDENTIALS |
| 1391 | && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1392 | struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1393 | |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1394 | tprintf("{pid=%ld, uid=%ld, gid=%ld}}", |
| 1395 | (long)uc->pid, (long)uc->uid, (long)uc->gid); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1396 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1397 | return; |
| 1398 | } |
| 1399 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1400 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1401 | tprintf(", ...}"); |
| 1402 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1403 | |
| 1404 | static void |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1405 | do_msghdr(struct tcb *tcp, struct msghdr *msg) |
| 1406 | { |
| 1407 | tprintf("{msg_name(%d)=", msg->msg_namelen); |
| 1408 | printsock(tcp, (long)msg->msg_name, msg->msg_namelen); |
| 1409 | |
| 1410 | tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen); |
| 1411 | tprint_iov(tcp, (unsigned long)msg->msg_iovlen, |
| 1412 | (unsigned long)msg->msg_iov); |
| 1413 | |
| 1414 | #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL |
| 1415 | tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen); |
| 1416 | if (msg->msg_controllen) |
| 1417 | printcmsghdr(tcp, (unsigned long) msg->msg_control, |
| 1418 | msg->msg_controllen); |
| 1419 | tprintf(", msg_flags="); |
| 1420 | printflags(msg_flags, msg->msg_flags, "MSG_???"); |
| 1421 | #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
| 1422 | tprintf("msg_accrights=%#lx, msg_accrightslen=%u", |
| 1423 | (unsigned long) msg->msg_accrights, msg->msg_accrightslen); |
| 1424 | #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
| 1425 | tprintf("}"); |
| 1426 | } |
| 1427 | |
| 1428 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1429 | printmsghdr(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1430 | { |
| 1431 | struct msghdr msg; |
| 1432 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1433 | if (umove(tcp, addr, &msg) < 0) { |
| 1434 | tprintf("%#lx", addr); |
| 1435 | return; |
| 1436 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1437 | do_msghdr(tcp, &msg); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1438 | } |
| 1439 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1440 | #ifdef LINUX |
| 1441 | static void |
| 1442 | printmmsghdr(struct tcb *tcp, long addr) |
| 1443 | { |
| 1444 | struct mmsghdr { |
| 1445 | struct msghdr msg_hdr; |
| 1446 | unsigned msg_len; |
| 1447 | } mmsg; |
| 1448 | |
| 1449 | if (umove(tcp, addr, &mmsg) < 0) { |
| 1450 | tprintf("%#lx", addr); |
| 1451 | return; |
| 1452 | } |
| 1453 | tprintf("{"); |
| 1454 | do_msghdr(tcp, &mmsg.msg_hdr); |
| 1455 | tprintf(", %u}", mmsg.msg_len); |
| 1456 | } |
| 1457 | #endif |
| 1458 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1459 | #endif /* HAVE_SENDMSG */ |
| 1460 | |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1461 | /* |
| 1462 | * low bits of the socket type define real socket type, |
| 1463 | * other bits are socket type flags. |
| 1464 | */ |
| 1465 | static void |
| 1466 | tprint_sock_type(struct tcb *tcp, int flags) |
| 1467 | { |
| 1468 | const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK); |
| 1469 | |
| 1470 | if (str) |
| 1471 | { |
| 1472 | tprintf("%s", str); |
| 1473 | flags &= ~SOCK_TYPE_MASK; |
| 1474 | if (!flags) |
| 1475 | return; |
| 1476 | tprintf("|"); |
| 1477 | } |
| 1478 | printflags(sock_type_flags, flags, "SOCK_???"); |
| 1479 | } |
| 1480 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1481 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1482 | sys_socket(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1483 | { |
| 1484 | if (entering(tcp)) { |
| 1485 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 1486 | tprintf(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1487 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1488 | tprintf(", "); |
| 1489 | switch (tcp->u_arg[0]) { |
| 1490 | case PF_INET: |
Roland McGrath | 8758e54 | 2003-06-23 23:39:59 +0000 | [diff] [blame] | 1491 | #ifdef PF_INET6 |
| 1492 | case PF_INET6: |
| 1493 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1494 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 1495 | break; |
| 1496 | #ifdef PF_IPX |
| 1497 | case PF_IPX: |
| 1498 | /* BTW: I don't believe this.. */ |
| 1499 | tprintf("["); |
| 1500 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 1501 | tprintf("]"); |
| 1502 | break; |
| 1503 | #endif /* PF_IPX */ |
| 1504 | default: |
| 1505 | tprintf("%lu", tcp->u_arg[2]); |
| 1506 | break; |
| 1507 | } |
| 1508 | } |
| 1509 | return 0; |
| 1510 | } |
| 1511 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1512 | #ifdef SVR4 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1513 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1514 | sys_so_socket(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1515 | { |
| 1516 | if (entering(tcp)) { |
| 1517 | /* not sure really what these args are... but this |
| 1518 | * is how truss prints it |
| 1519 | */ |
| 1520 | tprintf("%ld, %ld, %ld, ", |
| 1521 | tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); |
| 1522 | printpath(tcp, tcp->u_arg[3]); |
| 1523 | tprintf(", %ld", tcp->u_arg[4]); |
| 1524 | } |
| 1525 | return 0; |
| 1526 | } |
| 1527 | |
| 1528 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1529 | sys_so_socketpair(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1530 | { |
| 1531 | if (entering(tcp)) { |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1532 | /* not sure what this arg is */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1533 | tprintf("0x%lx", tcp->u_arg[0]); |
| 1534 | } |
| 1535 | return 0; |
| 1536 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1537 | #endif /* SVR4 */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1538 | |
| 1539 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1540 | sys_bind(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1541 | { |
| 1542 | if (entering(tcp)) { |
| 1543 | tprintf("%ld, ", tcp->u_arg[0]); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1544 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1545 | tprintf(", %lu", tcp->u_arg[2]); |
| 1546 | } |
| 1547 | return 0; |
| 1548 | } |
| 1549 | |
| 1550 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1551 | sys_connect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1552 | { |
| 1553 | return sys_bind(tcp); |
| 1554 | } |
| 1555 | |
| 1556 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1557 | sys_listen(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1558 | { |
| 1559 | if (entering(tcp)) { |
| 1560 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1561 | } |
| 1562 | return 0; |
| 1563 | } |
| 1564 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1565 | static int |
| 1566 | do_accept(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1567 | { |
| 1568 | if (entering(tcp)) { |
| 1569 | tprintf("%ld, ", tcp->u_arg[0]); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1570 | return 0; |
| 1571 | } |
| 1572 | if (!tcp->u_arg[2]) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1573 | tprintf("%#lx, NULL", tcp->u_arg[1]); |
| 1574 | else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1575 | int len; |
| 1576 | if (tcp->u_arg[1] == 0 || syserror(tcp) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1577 | || umove(tcp, tcp->u_arg[2], &len) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1578 | tprintf("%#lx", tcp->u_arg[1]); |
| 1579 | } else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1580 | printsock(tcp, tcp->u_arg[1], len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1581 | } |
| 1582 | tprintf(", "); |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1583 | printnum_int(tcp, tcp->u_arg[2], "%u"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1584 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1585 | if (flags_arg >= 0) { |
| 1586 | tprintf(", "); |
| 1587 | printflags(sock_type_flags, tcp->u_arg[flags_arg], |
| 1588 | "SOCK_???"); |
| 1589 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1590 | return 0; |
| 1591 | } |
| 1592 | |
| 1593 | int |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1594 | sys_accept(struct tcb *tcp) |
| 1595 | { |
| 1596 | return do_accept(tcp, -1); |
| 1597 | } |
| 1598 | |
| 1599 | #ifdef LINUX |
| 1600 | int |
| 1601 | sys_accept4(struct tcb *tcp) |
| 1602 | { |
| 1603 | return do_accept(tcp, 3); |
| 1604 | } |
| 1605 | #endif |
| 1606 | |
| 1607 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1608 | sys_send(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1609 | { |
| 1610 | if (entering(tcp)) { |
| 1611 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1612 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1613 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1614 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1615 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1616 | } |
| 1617 | return 0; |
| 1618 | } |
| 1619 | |
| 1620 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1621 | sys_sendto(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1622 | { |
| 1623 | if (entering(tcp)) { |
| 1624 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1625 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1626 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1627 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1628 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1629 | /* to address */ |
| 1630 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1631 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1632 | /* to length */ |
| 1633 | tprintf(", %lu", tcp->u_arg[5]); |
| 1634 | } |
| 1635 | return 0; |
| 1636 | } |
| 1637 | |
| 1638 | #ifdef HAVE_SENDMSG |
| 1639 | |
| 1640 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1641 | sys_sendmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1642 | { |
| 1643 | if (entering(tcp)) { |
| 1644 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1645 | printmsghdr(tcp, tcp->u_arg[1]); |
| 1646 | /* flags */ |
| 1647 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1648 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1649 | } |
| 1650 | return 0; |
| 1651 | } |
| 1652 | |
| 1653 | #endif /* HAVE_SENDMSG */ |
| 1654 | |
| 1655 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1656 | sys_recv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1657 | { |
| 1658 | if (entering(tcp)) { |
| 1659 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1660 | } else { |
| 1661 | if (syserror(tcp)) |
| 1662 | tprintf("%#lx", tcp->u_arg[1]); |
| 1663 | else |
| 1664 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 1665 | |
| 1666 | tprintf(", %lu, ", tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1667 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1668 | } |
| 1669 | return 0; |
| 1670 | } |
| 1671 | |
| 1672 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1673 | sys_recvfrom(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1674 | { |
| 1675 | int fromlen; |
| 1676 | |
| 1677 | if (entering(tcp)) { |
| 1678 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1679 | } else { |
| 1680 | if (syserror(tcp)) { |
| 1681 | tprintf("%#lx, %lu, %lu, %#lx, %#lx", |
| 1682 | tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], |
| 1683 | tcp->u_arg[4], tcp->u_arg[5]); |
| 1684 | return 0; |
| 1685 | } |
| 1686 | /* buf */ |
| 1687 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 1688 | /* len */ |
| 1689 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1690 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1691 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1692 | /* from address, len */ |
| 1693 | if (!tcp->u_arg[4] || !tcp->u_arg[5]) { |
| 1694 | if (tcp->u_arg[4] == 0) |
| 1695 | tprintf(", NULL"); |
| 1696 | else |
| 1697 | tprintf(", %#lx", tcp->u_arg[4]); |
| 1698 | if (tcp->u_arg[5] == 0) |
| 1699 | tprintf(", NULL"); |
| 1700 | else |
| 1701 | tprintf(", %#lx", tcp->u_arg[5]); |
| 1702 | return 0; |
| 1703 | } |
| 1704 | if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
| 1705 | tprintf(", {...}, [?]"); |
| 1706 | return 0; |
| 1707 | } |
| 1708 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1709 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1710 | /* from length */ |
| 1711 | tprintf(", [%u]", fromlen); |
| 1712 | } |
| 1713 | return 0; |
| 1714 | } |
| 1715 | |
| 1716 | #ifdef HAVE_SENDMSG |
| 1717 | |
| 1718 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1719 | sys_recvmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1720 | { |
| 1721 | if (entering(tcp)) { |
| 1722 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1723 | } else { |
| 1724 | if (syserror(tcp) || !verbose(tcp)) |
| 1725 | tprintf("%#lx", tcp->u_arg[1]); |
| 1726 | else |
| 1727 | printmsghdr(tcp, tcp->u_arg[1]); |
| 1728 | /* flags */ |
| 1729 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1730 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1731 | } |
| 1732 | return 0; |
| 1733 | } |
| 1734 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1735 | #ifdef LINUX |
| 1736 | int |
| 1737 | sys_recvmmsg(struct tcb *tcp) |
| 1738 | { |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1739 | static char str[128]; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1740 | if (entering(tcp)) { |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1741 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1742 | tprintf("%ld, ", tcp->u_arg[0]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1743 | if (verbose(tcp)) { |
| 1744 | sprint_timespec(str, tcp, tcp->u_arg[4]); |
| 1745 | tcp->auxstr = strdup(str); |
| 1746 | } else { |
| 1747 | tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]); |
| 1748 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 1749 | tprintf(", "); |
| 1750 | print_timespec(tcp, tcp->u_arg[4]); |
| 1751 | } |
| 1752 | return 0; |
| 1753 | } else { |
| 1754 | if (verbose(tcp)) { |
| 1755 | if (syserror(tcp)) |
| 1756 | tprintf("%#lx", tcp->u_arg[1]); |
| 1757 | else |
| 1758 | printmmsghdr(tcp, tcp->u_arg[1]); |
| 1759 | tprintf(", %ld, ", tcp->u_arg[2]); |
| 1760 | /* flags */ |
| 1761 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 1762 | /* timeout on entrance */ |
| 1763 | tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}"); |
| 1764 | free((void *) tcp->auxstr); |
| 1765 | tcp->auxstr = NULL; |
| 1766 | } |
| 1767 | if (syserror(tcp)) |
| 1768 | return 0; |
| 1769 | if (tcp->u_rval == 0) { |
| 1770 | tcp->auxstr = "Timeout"; |
| 1771 | return RVAL_STR; |
| 1772 | } |
| 1773 | if (!verbose(tcp)) |
| 1774 | return 0; |
| 1775 | /* timeout on exit */ |
| 1776 | strcpy(str, "left "); |
| 1777 | sprint_timespec(str + strlen(str), tcp, tcp->u_arg[4]); |
| 1778 | tcp->auxstr = str; |
| 1779 | return RVAL_STR; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1780 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1781 | } |
| 1782 | #endif |
| 1783 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1784 | #endif /* HAVE_SENDMSG */ |
| 1785 | |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1786 | static const struct xlat shutdown_modes[] = { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1787 | { 0, "SHUT_RD" }, |
| 1788 | { 1, "SHUT_WR" }, |
| 1789 | { 2, "SHUT_RDWR" }, |
| 1790 | { 0, NULL } |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1791 | }; |
| 1792 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1793 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1794 | sys_shutdown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1795 | { |
| 1796 | if (entering(tcp)) { |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1797 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1798 | printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1799 | } |
| 1800 | return 0; |
| 1801 | } |
| 1802 | |
| 1803 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1804 | sys_getsockname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1805 | { |
| 1806 | return sys_accept(tcp); |
| 1807 | } |
| 1808 | |
| 1809 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1810 | sys_getpeername(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1811 | { |
| 1812 | return sys_accept(tcp); |
| 1813 | } |
| 1814 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1815 | static int |
| 1816 | do_pipe(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1817 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1818 | if (exiting(tcp)) { |
| 1819 | if (syserror(tcp)) { |
| 1820 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1821 | } else { |
| 1822 | #if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) |
| 1823 | int fds[2]; |
| 1824 | |
| 1825 | if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) |
| 1826 | tprintf("[...]"); |
| 1827 | else |
| 1828 | tprintf("[%u, %u]", fds[0], fds[1]); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 1829 | #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(SVR4) || defined(FREEBSD) || defined(IA64) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1830 | tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
| 1831 | #else |
| 1832 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1833 | #endif |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1834 | } |
| 1835 | if (flags_arg >= 0) { |
| 1836 | tprintf(", "); |
| 1837 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 1838 | } |
| 1839 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1840 | return 0; |
| 1841 | } |
| 1842 | |
| 1843 | int |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1844 | sys_pipe(struct tcb *tcp) |
| 1845 | { |
| 1846 | return do_pipe(tcp, -1); |
| 1847 | } |
| 1848 | |
| 1849 | #ifdef LINUX |
| 1850 | int |
| 1851 | sys_pipe2(struct tcb *tcp) |
| 1852 | { |
| 1853 | return do_pipe(tcp, 1); |
| 1854 | } |
| 1855 | #endif |
| 1856 | |
| 1857 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1858 | sys_socketpair(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1859 | { |
| 1860 | #ifdef LINUX |
| 1861 | int fds[2]; |
| 1862 | #endif |
| 1863 | |
| 1864 | if (entering(tcp)) { |
| 1865 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 1866 | tprintf(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1867 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1868 | tprintf(", "); |
| 1869 | switch (tcp->u_arg[0]) { |
| 1870 | case PF_INET: |
| 1871 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 1872 | break; |
| 1873 | #ifdef PF_IPX |
| 1874 | case PF_IPX: |
| 1875 | /* BTW: I don't believe this.. */ |
| 1876 | tprintf("["); |
| 1877 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 1878 | tprintf("]"); |
| 1879 | break; |
| 1880 | #endif /* PF_IPX */ |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1881 | default: |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1882 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1883 | break; |
| 1884 | } |
| 1885 | } else { |
| 1886 | if (syserror(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1887 | tprintf(", %#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1888 | return 0; |
| 1889 | } |
| 1890 | #ifdef LINUX |
| 1891 | if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1892 | tprintf(", [...]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1893 | else |
| 1894 | tprintf(", [%u, %u]", fds[0], fds[1]); |
| 1895 | #endif /* LINUX */ |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 1896 | #if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1897 | tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 1898 | #endif /* SUNOS4 || SVR4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1899 | } |
| 1900 | return 0; |
| 1901 | } |
| 1902 | |
| 1903 | int |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1904 | sys_getsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1905 | { |
| 1906 | if (entering(tcp)) { |
| 1907 | tprintf("%ld, ", tcp->u_arg[0]); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1908 | printxval(socketlayers, tcp->u_arg[1], "SOL_???"); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1909 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1910 | switch (tcp->u_arg[1]) { |
| 1911 | case SOL_SOCKET: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1912 | printxval(sockoptions, tcp->u_arg[2], "SO_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1913 | break; |
| 1914 | #ifdef SOL_IP |
| 1915 | case SOL_IP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1916 | printxval(sockipoptions, tcp->u_arg[2], "IP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1917 | break; |
| 1918 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 1919 | #ifdef SOL_IPV6 |
| 1920 | case SOL_IPV6: |
| 1921 | printxval(sockipv6options, tcp->u_arg[2], "IPV6_???"); |
| 1922 | break; |
| 1923 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1924 | #ifdef SOL_IPX |
| 1925 | case SOL_IPX: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1926 | printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1927 | break; |
| 1928 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1929 | #ifdef SOL_PACKET |
| 1930 | case SOL_PACKET: |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1931 | printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1932 | break; |
| 1933 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1934 | #ifdef SOL_TCP |
| 1935 | case SOL_TCP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1936 | printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1937 | break; |
| 1938 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 1939 | #ifdef SOL_SCTP |
| 1940 | case SOL_SCTP: |
| 1941 | printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???"); |
| 1942 | break; |
| 1943 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1944 | |
| 1945 | /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
| 1946 | * etc. still need work */ |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1947 | default: |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1948 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1949 | break; |
| 1950 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1951 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1952 | } else { |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 1953 | int len; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1954 | if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1955 | tprintf("%#lx, %#lx", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1956 | tcp->u_arg[3], tcp->u_arg[4]); |
| 1957 | return 0; |
| 1958 | } |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1959 | |
| 1960 | switch (tcp->u_arg[1]) { |
| 1961 | case SOL_SOCKET: |
| 1962 | switch (tcp->u_arg[2]) { |
| 1963 | #ifdef SO_LINGER |
| 1964 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1965 | if (len == sizeof(struct linger)) { |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1966 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1967 | if (umove(tcp, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1968 | tcp->u_arg[3], |
| 1969 | &linger) < 0) |
| 1970 | break; |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1971 | tprintf("{onoff=%d, linger=%d}, " |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 1972 | "[%d]", |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1973 | linger.l_onoff, |
| 1974 | linger.l_linger, |
| 1975 | len); |
| 1976 | return 0; |
| 1977 | } |
| 1978 | break; |
| 1979 | #endif |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1980 | #ifdef SO_PEERCRED |
| 1981 | case SO_PEERCRED: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1982 | if (len == sizeof(struct ucred)) { |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1983 | struct ucred uc; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 1984 | if (umove(tcp, |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1985 | tcp->u_arg[3], |
| 1986 | &uc) < 0) |
| 1987 | break; |
| 1988 | tprintf("{pid=%ld, uid=%ld, gid=%ld}, " |
| 1989 | "[%d]", |
| 1990 | (long)uc.pid, |
| 1991 | (long)uc.uid, |
| 1992 | (long)uc.gid, |
| 1993 | len); |
| 1994 | return 0; |
| 1995 | } |
| 1996 | break; |
| 1997 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1998 | } |
| 1999 | break; |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2000 | case SOL_PACKET: |
| 2001 | switch (tcp->u_arg[2]) { |
| 2002 | #ifdef PACKET_STATISTICS |
| 2003 | case PACKET_STATISTICS: |
| 2004 | if (len == sizeof(struct tpacket_stats)) { |
| 2005 | struct tpacket_stats stats; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2006 | if (umove(tcp, |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2007 | tcp->u_arg[3], |
| 2008 | &stats) < 0) |
| 2009 | break; |
| 2010 | tprintf("{packets=%u, drops=%u}, " |
| 2011 | "[%d]", |
| 2012 | stats.tp_packets, |
| 2013 | stats.tp_drops, |
| 2014 | len); |
| 2015 | return 0; |
| 2016 | } |
| 2017 | break; |
| 2018 | #endif |
| 2019 | } |
| 2020 | break; |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2021 | } |
| 2022 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2023 | if (len == sizeof(int)) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 2024 | printnum_int(tcp, tcp->u_arg[3], "%d"); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2025 | } |
| 2026 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2027 | printstr(tcp, tcp->u_arg[3], len); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2028 | } |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 2029 | tprintf(", [%d]", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2030 | } |
| 2031 | return 0; |
| 2032 | } |
| 2033 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2034 | #if defined(ICMP_FILTER) |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2035 | static void printicmpfilter(struct tcb *tcp, long addr) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2036 | { |
| 2037 | struct icmp_filter filter; |
| 2038 | |
| 2039 | if (!addr) { |
| 2040 | tprintf("NULL"); |
| 2041 | return; |
| 2042 | } |
| 2043 | if (syserror(tcp) || !verbose(tcp)) { |
| 2044 | tprintf("%#lx", addr); |
| 2045 | return; |
| 2046 | } |
| 2047 | if (umove(tcp, addr, &filter) < 0) { |
| 2048 | tprintf("{...}"); |
| 2049 | return; |
| 2050 | } |
| 2051 | |
| 2052 | tprintf("~("); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 2053 | printflags(icmpfilterflags, ~filter.data, "ICMP_???"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2054 | tprintf(")"); |
| 2055 | } |
| 2056 | #endif /* ICMP_FILTER */ |
| 2057 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2058 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2059 | printsockopt(struct tcb *tcp, int level, int name, long addr, int len) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2060 | { |
| 2061 | printxval(socketlayers, level, "SOL_??"); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2062 | tprintf(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2063 | switch (level) { |
| 2064 | case SOL_SOCKET: |
| 2065 | printxval(sockoptions, name, "SO_???"); |
| 2066 | switch (name) { |
| 2067 | #if defined(SO_LINGER) |
| 2068 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2069 | if (len == sizeof(struct linger)) { |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2070 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2071 | if (umove(tcp, addr, &linger) < 0) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2072 | break; |
| 2073 | tprintf(", {onoff=%d, linger=%d}", |
| 2074 | linger.l_onoff, |
| 2075 | linger.l_linger); |
| 2076 | return 0; |
| 2077 | } |
| 2078 | break; |
| 2079 | #endif |
| 2080 | } |
| 2081 | break; |
| 2082 | #ifdef SOL_IP |
| 2083 | case SOL_IP: |
| 2084 | printxval(sockipoptions, name, "IP_???"); |
| 2085 | break; |
| 2086 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 2087 | #ifdef SOL_IPV6 |
| 2088 | case SOL_IPV6: |
| 2089 | printxval(sockipv6options, name, "IPV6_???"); |
| 2090 | break; |
| 2091 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2092 | #ifdef SOL_IPX |
| 2093 | case SOL_IPX: |
| 2094 | printxval(sockipxoptions, name, "IPX_???"); |
| 2095 | break; |
| 2096 | #endif |
| 2097 | #ifdef SOL_PACKET |
| 2098 | case SOL_PACKET: |
| 2099 | printxval(sockpacketoptions, name, "PACKET_???"); |
| 2100 | /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */ |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2101 | switch (name) { |
| 2102 | #ifdef PACKET_RX_RING |
| 2103 | case PACKET_RX_RING: |
| 2104 | #endif |
| 2105 | #ifdef PACKET_TX_RING |
| 2106 | case PACKET_TX_RING: |
| 2107 | #endif |
| 2108 | #if defined(PACKET_RX_RING) || defined(PACKET_TX_RING) |
| 2109 | if (len == sizeof(struct tpacket_req)) { |
| 2110 | struct tpacket_req req; |
| 2111 | if (umove(tcp, addr, &req) < 0) |
| 2112 | break; |
| 2113 | tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}", |
| 2114 | req.tp_block_size, |
| 2115 | req.tp_block_nr, |
| 2116 | req.tp_frame_size, |
| 2117 | req.tp_frame_nr); |
| 2118 | return 0; |
| 2119 | } |
| 2120 | break; |
| 2121 | #endif /* PACKET_RX_RING || PACKET_TX_RING */ |
| 2122 | } |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2123 | break; |
| 2124 | #endif |
| 2125 | #ifdef SOL_TCP |
| 2126 | case SOL_TCP: |
| 2127 | printxval(socktcpoptions, name, "TCP_???"); |
| 2128 | break; |
| 2129 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 2130 | #ifdef SOL_SCTP |
| 2131 | case SOL_SCTP: |
| 2132 | printxval(socksctpoptions, name, "SCTP_???"); |
| 2133 | break; |
| 2134 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2135 | #ifdef SOL_RAW |
| 2136 | case SOL_RAW: |
| 2137 | printxval(sockrawoptions, name, "RAW_???"); |
| 2138 | switch (name) { |
| 2139 | #if defined(ICMP_FILTER) |
| 2140 | case ICMP_FILTER: |
| 2141 | tprintf(", "); |
| 2142 | printicmpfilter(tcp, addr); |
| 2143 | return 0; |
| 2144 | #endif |
| 2145 | } |
| 2146 | break; |
| 2147 | #endif |
| 2148 | |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2149 | /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2150 | * etc. still need work */ |
| 2151 | |
| 2152 | default: |
| 2153 | tprintf("%u", name); |
| 2154 | } |
| 2155 | |
| 2156 | /* default arg printing */ |
| 2157 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2158 | tprintf(", "); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2159 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2160 | if (len == sizeof(int)) { |
| 2161 | printnum_int(tcp, addr, "%d"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2162 | } |
| 2163 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2164 | printstr(tcp, addr, len); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2165 | } |
| 2166 | return 0; |
| 2167 | } |
| 2168 | |
| 2169 | |
Roland McGrath | c3ca0d8 | 2003-01-14 07:53:38 +0000 | [diff] [blame] | 2170 | #ifdef HAVE_STRUCT_OPTHDR |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2171 | |
| 2172 | void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2173 | print_sock_optmgmt(struct tcb *tcp, long addr, int len) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2174 | { |
| 2175 | int c = 0; |
| 2176 | struct opthdr hdr; |
| 2177 | |
John Hughes | 2c4e3a8 | 2002-05-24 10:19:44 +0000 | [diff] [blame] | 2178 | while (len >= (int) sizeof hdr) { |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2179 | if (umove(tcp, addr, &hdr) < 0) break; |
| 2180 | if (c++) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2181 | tprintf(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2182 | } |
| 2183 | else if (len > hdr.len + sizeof hdr) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2184 | tprintf("["); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2185 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2186 | tprintf("{"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2187 | addr += sizeof hdr; |
| 2188 | len -= sizeof hdr; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2189 | printsockopt(tcp, hdr.level, hdr.name, addr, hdr.len); |
John Hughes | 2c4e3a8 | 2002-05-24 10:19:44 +0000 | [diff] [blame] | 2190 | if (hdr.len > 0) { |
| 2191 | addr += hdr.len; |
| 2192 | len -= hdr.len; |
| 2193 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2194 | tprintf("}"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2195 | } |
| 2196 | if (len > 0) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2197 | if (c++) tprintf(", "); |
| 2198 | printstr(tcp, addr, len); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2199 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2200 | if (c > 1) tprintf("]"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | #endif |
| 2204 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2205 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2206 | sys_setsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2207 | { |
| 2208 | if (entering(tcp)) { |
| 2209 | tprintf("%ld, ", tcp->u_arg[0]); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2210 | printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2211 | tcp->u_arg[3], tcp->u_arg[4]); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2212 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2213 | } |
| 2214 | return 0; |
| 2215 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2216 | |
| 2217 | #if UNIXWARE >= 7 |
| 2218 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 2219 | static const struct xlat sock_version[] = { |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2220 | { __NETLIB_UW211_SVR4, "UW211_SVR4" }, |
| 2221 | { __NETLIB_UW211_XPG4, "UW211_XPG4" }, |
| 2222 | { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" }, |
| 2223 | { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" }, |
| 2224 | { __NETLIB_FP1_SVR4, "FP1_SVR4" }, |
| 2225 | { __NETLIB_FP1_XPG4, "FP1_XPG4" }, |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2226 | { 0, NULL }, |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2227 | }; |
| 2228 | |
| 2229 | |
| 2230 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2231 | netlib_call(struct tcb *tcp, int (*func)()) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2232 | { |
| 2233 | if (entering(tcp)) { |
| 2234 | int i; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2235 | printxval(sock_version, tcp->u_arg[0], "__NETLIB_???"); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2236 | tprintf(", "); |
| 2237 | --tcp->u_nargs; |
| 2238 | for (i = 0; i < tcp->u_nargs; i++) |
| 2239 | tcp->u_arg[i] = tcp->u_arg[i + 1]; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2240 | return func(tcp); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2241 | } |
| 2242 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2243 | return func(tcp); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2244 | } |
| 2245 | |
| 2246 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2247 | sys_xsocket(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2248 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2249 | return netlib_call(tcp, sys_socket); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2250 | } |
| 2251 | |
| 2252 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2253 | sys_xsocketpair(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2254 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2255 | return netlib_call(tcp, sys_socketpair); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2256 | } |
| 2257 | |
| 2258 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2259 | sys_xbind(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2260 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2261 | return netlib_call(tcp, sys_bind); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2262 | } |
| 2263 | |
| 2264 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2265 | sys_xconnect(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2266 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2267 | return netlib_call(tcp, sys_connect); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2268 | } |
| 2269 | |
| 2270 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2271 | sys_xlisten(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2272 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2273 | return netlib_call(tcp, sys_listen); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2274 | } |
| 2275 | |
| 2276 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2277 | sys_xaccept(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2278 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2279 | return netlib_call(tcp, sys_accept); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2280 | } |
| 2281 | |
| 2282 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2283 | sys_xsendmsg(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2284 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2285 | return netlib_call(tcp, sys_sendmsg); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2286 | } |
| 2287 | |
| 2288 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2289 | sys_xrecvmsg(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2290 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2291 | return netlib_call(tcp, sys_recvmsg); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2292 | } |
| 2293 | |
| 2294 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2295 | sys_xgetsockaddr(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2296 | { |
| 2297 | if (entering(tcp)) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2298 | printxval(sock_version, tcp->u_arg[0], "__NETLIB_???"); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2299 | tprintf(", "); |
| 2300 | if (tcp->u_arg[1] == 0) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2301 | tprintf("LOCALNAME, "); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2302 | } |
| 2303 | else if (tcp->u_arg[1] == 1) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2304 | tprintf("REMOTENAME, "); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2305 | } |
| 2306 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2307 | tprintf("%ld, ", tcp->u_arg[1]); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2308 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2309 | tprintf("%ld, ", tcp->u_arg[2]); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2310 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2311 | else { |
| 2312 | if (tcp->u_arg[3] == 0 || syserror(tcp)) { |
| 2313 | tprintf("%#lx", tcp->u_arg[3]); |
| 2314 | } else { |
| 2315 | printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]); |
| 2316 | } |
| 2317 | tprintf(", "); |
| 2318 | printnum(tcp, tcp->u_arg[4], "%lu"); |
| 2319 | } |
| 2320 | |
| 2321 | return 0; |
| 2322 | |
| 2323 | } |
| 2324 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2325 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2326 | sys_xgetsockopt(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2327 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2328 | return netlib_call(tcp, sys_getsockopt); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2329 | } |
| 2330 | |
| 2331 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2332 | sys_xsetsockopt(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2333 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2334 | return netlib_call(tcp, sys_setsockopt); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2335 | } |
| 2336 | |
| 2337 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2338 | sys_xshutdown(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2339 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame^] | 2340 | return netlib_call(tcp, sys_shutdown); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2341 | } |
| 2342 | |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 2343 | #endif /* UNIXWARE */ |