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, |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 1412 | (unsigned long)msg->msg_iov, 1); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 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 | |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 1470 | if (str) { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame^] | 1471 | tprints(str); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1472 | flags &= ~SOCK_TYPE_MASK; |
| 1473 | if (!flags) |
| 1474 | return; |
| 1475 | tprintf("|"); |
| 1476 | } |
| 1477 | printflags(sock_type_flags, flags, "SOCK_???"); |
| 1478 | } |
| 1479 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1480 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1481 | sys_socket(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1482 | { |
| 1483 | if (entering(tcp)) { |
| 1484 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 1485 | tprintf(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1486 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1487 | tprintf(", "); |
| 1488 | switch (tcp->u_arg[0]) { |
| 1489 | case PF_INET: |
Roland McGrath | 8758e54 | 2003-06-23 23:39:59 +0000 | [diff] [blame] | 1490 | #ifdef PF_INET6 |
| 1491 | case PF_INET6: |
| 1492 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1493 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 1494 | break; |
| 1495 | #ifdef PF_IPX |
| 1496 | case PF_IPX: |
| 1497 | /* BTW: I don't believe this.. */ |
| 1498 | tprintf("["); |
| 1499 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 1500 | tprintf("]"); |
| 1501 | break; |
| 1502 | #endif /* PF_IPX */ |
| 1503 | default: |
| 1504 | tprintf("%lu", tcp->u_arg[2]); |
| 1505 | break; |
| 1506 | } |
| 1507 | } |
| 1508 | return 0; |
| 1509 | } |
| 1510 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1511 | #ifdef SVR4 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1512 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1513 | sys_so_socket(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1514 | { |
| 1515 | if (entering(tcp)) { |
| 1516 | /* not sure really what these args are... but this |
| 1517 | * is how truss prints it |
| 1518 | */ |
| 1519 | tprintf("%ld, %ld, %ld, ", |
| 1520 | tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]); |
| 1521 | printpath(tcp, tcp->u_arg[3]); |
| 1522 | tprintf(", %ld", tcp->u_arg[4]); |
| 1523 | } |
| 1524 | return 0; |
| 1525 | } |
| 1526 | |
| 1527 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1528 | sys_so_socketpair(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1529 | { |
| 1530 | if (entering(tcp)) { |
Denys Vlasenko | 5ae2b7c | 2009-02-27 20:32:52 +0000 | [diff] [blame] | 1531 | /* not sure what this arg is */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1532 | tprintf("0x%lx", tcp->u_arg[0]); |
| 1533 | } |
| 1534 | return 0; |
| 1535 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 1536 | #endif /* SVR4 */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1537 | |
| 1538 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1539 | sys_bind(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1540 | { |
| 1541 | if (entering(tcp)) { |
| 1542 | tprintf("%ld, ", tcp->u_arg[0]); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1543 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1544 | tprintf(", %lu", tcp->u_arg[2]); |
| 1545 | } |
| 1546 | return 0; |
| 1547 | } |
| 1548 | |
| 1549 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1550 | sys_connect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1551 | { |
| 1552 | return sys_bind(tcp); |
| 1553 | } |
| 1554 | |
| 1555 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1556 | sys_listen(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1557 | { |
| 1558 | if (entering(tcp)) { |
| 1559 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1560 | } |
| 1561 | return 0; |
| 1562 | } |
| 1563 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1564 | static int |
| 1565 | do_accept(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1566 | { |
| 1567 | if (entering(tcp)) { |
| 1568 | tprintf("%ld, ", tcp->u_arg[0]); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1569 | return 0; |
| 1570 | } |
| 1571 | if (!tcp->u_arg[2]) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1572 | tprintf("%#lx, NULL", tcp->u_arg[1]); |
| 1573 | else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1574 | int len; |
| 1575 | if (tcp->u_arg[1] == 0 || syserror(tcp) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1576 | || umove(tcp, tcp->u_arg[2], &len) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1577 | tprintf("%#lx", tcp->u_arg[1]); |
| 1578 | } else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1579 | printsock(tcp, tcp->u_arg[1], len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1580 | } |
| 1581 | tprintf(", "); |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1582 | printnum_int(tcp, tcp->u_arg[2], "%u"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1583 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1584 | if (flags_arg >= 0) { |
| 1585 | tprintf(", "); |
| 1586 | printflags(sock_type_flags, tcp->u_arg[flags_arg], |
| 1587 | "SOCK_???"); |
| 1588 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1589 | return 0; |
| 1590 | } |
| 1591 | |
| 1592 | int |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1593 | sys_accept(struct tcb *tcp) |
| 1594 | { |
| 1595 | return do_accept(tcp, -1); |
| 1596 | } |
| 1597 | |
| 1598 | #ifdef LINUX |
| 1599 | int |
| 1600 | sys_accept4(struct tcb *tcp) |
| 1601 | { |
| 1602 | return do_accept(tcp, 3); |
| 1603 | } |
| 1604 | #endif |
| 1605 | |
| 1606 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1607 | sys_send(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1608 | { |
| 1609 | if (entering(tcp)) { |
| 1610 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1611 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1612 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1613 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1614 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1615 | } |
| 1616 | return 0; |
| 1617 | } |
| 1618 | |
| 1619 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1620 | sys_sendto(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1621 | { |
| 1622 | if (entering(tcp)) { |
| 1623 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1624 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1625 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1626 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1627 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1628 | /* to address */ |
| 1629 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1630 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1631 | /* to length */ |
| 1632 | tprintf(", %lu", tcp->u_arg[5]); |
| 1633 | } |
| 1634 | return 0; |
| 1635 | } |
| 1636 | |
| 1637 | #ifdef HAVE_SENDMSG |
| 1638 | |
| 1639 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1640 | sys_sendmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1641 | { |
| 1642 | if (entering(tcp)) { |
| 1643 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1644 | printmsghdr(tcp, tcp->u_arg[1]); |
| 1645 | /* flags */ |
| 1646 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1647 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1648 | } |
| 1649 | return 0; |
| 1650 | } |
| 1651 | |
| 1652 | #endif /* HAVE_SENDMSG */ |
| 1653 | |
| 1654 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1655 | sys_recv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1656 | { |
| 1657 | if (entering(tcp)) { |
| 1658 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1659 | } else { |
| 1660 | if (syserror(tcp)) |
| 1661 | tprintf("%#lx", tcp->u_arg[1]); |
| 1662 | else |
| 1663 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 1664 | |
| 1665 | tprintf(", %lu, ", tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1666 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1667 | } |
| 1668 | return 0; |
| 1669 | } |
| 1670 | |
| 1671 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1672 | sys_recvfrom(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1673 | { |
| 1674 | int fromlen; |
| 1675 | |
| 1676 | if (entering(tcp)) { |
| 1677 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1678 | } else { |
| 1679 | if (syserror(tcp)) { |
| 1680 | tprintf("%#lx, %lu, %lu, %#lx, %#lx", |
| 1681 | tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], |
| 1682 | tcp->u_arg[4], tcp->u_arg[5]); |
| 1683 | return 0; |
| 1684 | } |
| 1685 | /* buf */ |
| 1686 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 1687 | /* len */ |
| 1688 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1689 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1690 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1691 | /* from address, len */ |
| 1692 | if (!tcp->u_arg[4] || !tcp->u_arg[5]) { |
| 1693 | if (tcp->u_arg[4] == 0) |
| 1694 | tprintf(", NULL"); |
| 1695 | else |
| 1696 | tprintf(", %#lx", tcp->u_arg[4]); |
| 1697 | if (tcp->u_arg[5] == 0) |
| 1698 | tprintf(", NULL"); |
| 1699 | else |
| 1700 | tprintf(", %#lx", tcp->u_arg[5]); |
| 1701 | return 0; |
| 1702 | } |
| 1703 | if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
| 1704 | tprintf(", {...}, [?]"); |
| 1705 | return 0; |
| 1706 | } |
| 1707 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1708 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1709 | /* from length */ |
| 1710 | tprintf(", [%u]", fromlen); |
| 1711 | } |
| 1712 | return 0; |
| 1713 | } |
| 1714 | |
| 1715 | #ifdef HAVE_SENDMSG |
| 1716 | |
| 1717 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1718 | sys_recvmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1719 | { |
| 1720 | if (entering(tcp)) { |
| 1721 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1722 | } else { |
| 1723 | if (syserror(tcp) || !verbose(tcp)) |
| 1724 | tprintf("%#lx", tcp->u_arg[1]); |
| 1725 | else |
| 1726 | printmsghdr(tcp, tcp->u_arg[1]); |
| 1727 | /* flags */ |
| 1728 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1729 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1730 | } |
| 1731 | return 0; |
| 1732 | } |
| 1733 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1734 | #ifdef LINUX |
| 1735 | int |
| 1736 | sys_recvmmsg(struct tcb *tcp) |
| 1737 | { |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1738 | static char str[128]; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1739 | if (entering(tcp)) { |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1740 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1741 | tprintf("%ld, ", tcp->u_arg[0]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1742 | if (verbose(tcp)) { |
| 1743 | sprint_timespec(str, tcp, tcp->u_arg[4]); |
| 1744 | tcp->auxstr = strdup(str); |
| 1745 | } else { |
| 1746 | tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]); |
| 1747 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 1748 | tprintf(", "); |
| 1749 | print_timespec(tcp, tcp->u_arg[4]); |
| 1750 | } |
| 1751 | return 0; |
| 1752 | } else { |
| 1753 | if (verbose(tcp)) { |
| 1754 | if (syserror(tcp)) |
| 1755 | tprintf("%#lx", tcp->u_arg[1]); |
| 1756 | else |
| 1757 | printmmsghdr(tcp, tcp->u_arg[1]); |
| 1758 | tprintf(", %ld, ", tcp->u_arg[2]); |
| 1759 | /* flags */ |
| 1760 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 1761 | /* timeout on entrance */ |
| 1762 | tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}"); |
| 1763 | free((void *) tcp->auxstr); |
| 1764 | tcp->auxstr = NULL; |
| 1765 | } |
| 1766 | if (syserror(tcp)) |
| 1767 | return 0; |
| 1768 | if (tcp->u_rval == 0) { |
| 1769 | tcp->auxstr = "Timeout"; |
| 1770 | return RVAL_STR; |
| 1771 | } |
| 1772 | if (!verbose(tcp)) |
| 1773 | return 0; |
| 1774 | /* timeout on exit */ |
| 1775 | strcpy(str, "left "); |
| 1776 | sprint_timespec(str + strlen(str), tcp, tcp->u_arg[4]); |
| 1777 | tcp->auxstr = str; |
| 1778 | return RVAL_STR; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1779 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1780 | } |
| 1781 | #endif |
| 1782 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1783 | #endif /* HAVE_SENDMSG */ |
| 1784 | |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1785 | static const struct xlat shutdown_modes[] = { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1786 | { 0, "SHUT_RD" }, |
| 1787 | { 1, "SHUT_WR" }, |
| 1788 | { 2, "SHUT_RDWR" }, |
| 1789 | { 0, NULL } |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1790 | }; |
| 1791 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1792 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1793 | sys_shutdown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1794 | { |
| 1795 | if (entering(tcp)) { |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1796 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1797 | printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1798 | } |
| 1799 | return 0; |
| 1800 | } |
| 1801 | |
| 1802 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1803 | sys_getsockname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1804 | { |
| 1805 | return sys_accept(tcp); |
| 1806 | } |
| 1807 | |
| 1808 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1809 | sys_getpeername(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1810 | { |
| 1811 | return sys_accept(tcp); |
| 1812 | } |
| 1813 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1814 | static int |
| 1815 | do_pipe(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1816 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1817 | if (exiting(tcp)) { |
| 1818 | if (syserror(tcp)) { |
| 1819 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1820 | } else { |
| 1821 | #if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) |
| 1822 | int fds[2]; |
| 1823 | |
| 1824 | if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) |
| 1825 | tprintf("[...]"); |
| 1826 | else |
| 1827 | tprintf("[%u, %u]", fds[0], fds[1]); |
Roland McGrath | 6d1a65c | 2004-07-12 07:44:08 +0000 | [diff] [blame] | 1828 | #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] | 1829 | tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
| 1830 | #else |
| 1831 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1832 | #endif |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1833 | } |
| 1834 | if (flags_arg >= 0) { |
| 1835 | tprintf(", "); |
| 1836 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 1837 | } |
| 1838 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1839 | return 0; |
| 1840 | } |
| 1841 | |
| 1842 | int |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1843 | sys_pipe(struct tcb *tcp) |
| 1844 | { |
| 1845 | return do_pipe(tcp, -1); |
| 1846 | } |
| 1847 | |
| 1848 | #ifdef LINUX |
| 1849 | int |
| 1850 | sys_pipe2(struct tcb *tcp) |
| 1851 | { |
| 1852 | return do_pipe(tcp, 1); |
| 1853 | } |
| 1854 | #endif |
| 1855 | |
| 1856 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1857 | sys_socketpair(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1858 | { |
| 1859 | #ifdef LINUX |
| 1860 | int fds[2]; |
| 1861 | #endif |
| 1862 | |
| 1863 | if (entering(tcp)) { |
| 1864 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 1865 | tprintf(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1866 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1867 | tprintf(", "); |
| 1868 | switch (tcp->u_arg[0]) { |
| 1869 | case PF_INET: |
| 1870 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 1871 | break; |
| 1872 | #ifdef PF_IPX |
| 1873 | case PF_IPX: |
| 1874 | /* BTW: I don't believe this.. */ |
| 1875 | tprintf("["); |
| 1876 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 1877 | tprintf("]"); |
| 1878 | break; |
| 1879 | #endif /* PF_IPX */ |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1880 | default: |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1881 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1882 | break; |
| 1883 | } |
| 1884 | } else { |
| 1885 | if (syserror(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1886 | tprintf(", %#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1887 | return 0; |
| 1888 | } |
| 1889 | #ifdef LINUX |
| 1890 | if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1891 | tprintf(", [...]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1892 | else |
| 1893 | tprintf(", [%u, %u]", fds[0], fds[1]); |
| 1894 | #endif /* LINUX */ |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 1895 | #if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1896 | tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 1897 | #endif /* SUNOS4 || SVR4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1898 | } |
| 1899 | return 0; |
| 1900 | } |
| 1901 | |
| 1902 | int |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1903 | sys_getsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1904 | { |
| 1905 | if (entering(tcp)) { |
| 1906 | tprintf("%ld, ", tcp->u_arg[0]); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1907 | printxval(socketlayers, tcp->u_arg[1], "SOL_???"); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1908 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1909 | switch (tcp->u_arg[1]) { |
| 1910 | case SOL_SOCKET: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1911 | printxval(sockoptions, tcp->u_arg[2], "SO_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1912 | break; |
| 1913 | #ifdef SOL_IP |
| 1914 | case SOL_IP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1915 | printxval(sockipoptions, tcp->u_arg[2], "IP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1916 | break; |
| 1917 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 1918 | #ifdef SOL_IPV6 |
| 1919 | case SOL_IPV6: |
| 1920 | printxval(sockipv6options, tcp->u_arg[2], "IPV6_???"); |
| 1921 | break; |
| 1922 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1923 | #ifdef SOL_IPX |
| 1924 | case SOL_IPX: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1925 | printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1926 | break; |
| 1927 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1928 | #ifdef SOL_PACKET |
| 1929 | case SOL_PACKET: |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1930 | printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1931 | break; |
| 1932 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1933 | #ifdef SOL_TCP |
| 1934 | case SOL_TCP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1935 | printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1936 | break; |
| 1937 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 1938 | #ifdef SOL_SCTP |
| 1939 | case SOL_SCTP: |
| 1940 | printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???"); |
| 1941 | break; |
| 1942 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1943 | |
| 1944 | /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
| 1945 | * etc. still need work */ |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1946 | default: |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1947 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1948 | break; |
| 1949 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1950 | tprintf(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1951 | } else { |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 1952 | int len; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1953 | if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1954 | tprintf("%#lx, %#lx", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1955 | tcp->u_arg[3], tcp->u_arg[4]); |
| 1956 | return 0; |
| 1957 | } |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1958 | |
| 1959 | switch (tcp->u_arg[1]) { |
| 1960 | case SOL_SOCKET: |
| 1961 | switch (tcp->u_arg[2]) { |
| 1962 | #ifdef SO_LINGER |
| 1963 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1964 | if (len == sizeof(struct linger)) { |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1965 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1966 | if (umove(tcp, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1967 | tcp->u_arg[3], |
| 1968 | &linger) < 0) |
| 1969 | break; |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1970 | tprintf("{onoff=%d, linger=%d}, " |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 1971 | "[%d]", |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1972 | linger.l_onoff, |
| 1973 | linger.l_linger, |
| 1974 | len); |
| 1975 | return 0; |
| 1976 | } |
| 1977 | break; |
| 1978 | #endif |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1979 | #ifdef SO_PEERCRED |
| 1980 | case SO_PEERCRED: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1981 | if (len == sizeof(struct ucred)) { |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1982 | struct ucred uc; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1983 | if (umove(tcp, |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1984 | tcp->u_arg[3], |
| 1985 | &uc) < 0) |
| 1986 | break; |
| 1987 | tprintf("{pid=%ld, uid=%ld, gid=%ld}, " |
| 1988 | "[%d]", |
| 1989 | (long)uc.pid, |
| 1990 | (long)uc.uid, |
| 1991 | (long)uc.gid, |
| 1992 | len); |
| 1993 | return 0; |
| 1994 | } |
| 1995 | break; |
| 1996 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1997 | } |
| 1998 | break; |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 1999 | case SOL_PACKET: |
| 2000 | switch (tcp->u_arg[2]) { |
| 2001 | #ifdef PACKET_STATISTICS |
| 2002 | case PACKET_STATISTICS: |
| 2003 | if (len == sizeof(struct tpacket_stats)) { |
| 2004 | struct tpacket_stats stats; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2005 | if (umove(tcp, |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2006 | tcp->u_arg[3], |
| 2007 | &stats) < 0) |
| 2008 | break; |
| 2009 | tprintf("{packets=%u, drops=%u}, " |
| 2010 | "[%d]", |
| 2011 | stats.tp_packets, |
| 2012 | stats.tp_drops, |
| 2013 | len); |
| 2014 | return 0; |
| 2015 | } |
| 2016 | break; |
| 2017 | #endif |
| 2018 | } |
| 2019 | break; |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2020 | } |
| 2021 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2022 | if (len == sizeof(int)) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 2023 | printnum_int(tcp, tcp->u_arg[3], "%d"); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2024 | } |
| 2025 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2026 | printstr(tcp, tcp->u_arg[3], len); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2027 | } |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 2028 | tprintf(", [%d]", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2029 | } |
| 2030 | return 0; |
| 2031 | } |
| 2032 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2033 | #if defined(ICMP_FILTER) |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2034 | static void printicmpfilter(struct tcb *tcp, long addr) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2035 | { |
| 2036 | struct icmp_filter filter; |
| 2037 | |
| 2038 | if (!addr) { |
| 2039 | tprintf("NULL"); |
| 2040 | return; |
| 2041 | } |
| 2042 | if (syserror(tcp) || !verbose(tcp)) { |
| 2043 | tprintf("%#lx", addr); |
| 2044 | return; |
| 2045 | } |
| 2046 | if (umove(tcp, addr, &filter) < 0) { |
| 2047 | tprintf("{...}"); |
| 2048 | return; |
| 2049 | } |
| 2050 | |
| 2051 | tprintf("~("); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 2052 | printflags(icmpfilterflags, ~filter.data, "ICMP_???"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2053 | tprintf(")"); |
| 2054 | } |
| 2055 | #endif /* ICMP_FILTER */ |
| 2056 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2057 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2058 | printsockopt(struct tcb *tcp, int level, int name, long addr, int len) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2059 | { |
| 2060 | printxval(socketlayers, level, "SOL_??"); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2061 | tprintf(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2062 | switch (level) { |
| 2063 | case SOL_SOCKET: |
| 2064 | printxval(sockoptions, name, "SO_???"); |
| 2065 | switch (name) { |
| 2066 | #if defined(SO_LINGER) |
| 2067 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2068 | if (len == sizeof(struct linger)) { |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2069 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2070 | if (umove(tcp, addr, &linger) < 0) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2071 | break; |
| 2072 | tprintf(", {onoff=%d, linger=%d}", |
| 2073 | linger.l_onoff, |
| 2074 | linger.l_linger); |
| 2075 | return 0; |
| 2076 | } |
| 2077 | break; |
| 2078 | #endif |
| 2079 | } |
| 2080 | break; |
| 2081 | #ifdef SOL_IP |
| 2082 | case SOL_IP: |
| 2083 | printxval(sockipoptions, name, "IP_???"); |
| 2084 | break; |
| 2085 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 2086 | #ifdef SOL_IPV6 |
| 2087 | case SOL_IPV6: |
| 2088 | printxval(sockipv6options, name, "IPV6_???"); |
| 2089 | break; |
| 2090 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2091 | #ifdef SOL_IPX |
| 2092 | case SOL_IPX: |
| 2093 | printxval(sockipxoptions, name, "IPX_???"); |
| 2094 | break; |
| 2095 | #endif |
| 2096 | #ifdef SOL_PACKET |
| 2097 | case SOL_PACKET: |
| 2098 | printxval(sockpacketoptions, name, "PACKET_???"); |
| 2099 | /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */ |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2100 | switch (name) { |
| 2101 | #ifdef PACKET_RX_RING |
| 2102 | case PACKET_RX_RING: |
| 2103 | #endif |
| 2104 | #ifdef PACKET_TX_RING |
| 2105 | case PACKET_TX_RING: |
| 2106 | #endif |
| 2107 | #if defined(PACKET_RX_RING) || defined(PACKET_TX_RING) |
| 2108 | if (len == sizeof(struct tpacket_req)) { |
| 2109 | struct tpacket_req req; |
| 2110 | if (umove(tcp, addr, &req) < 0) |
| 2111 | break; |
| 2112 | tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}", |
| 2113 | req.tp_block_size, |
| 2114 | req.tp_block_nr, |
| 2115 | req.tp_frame_size, |
| 2116 | req.tp_frame_nr); |
| 2117 | return 0; |
| 2118 | } |
| 2119 | break; |
| 2120 | #endif /* PACKET_RX_RING || PACKET_TX_RING */ |
| 2121 | } |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2122 | break; |
| 2123 | #endif |
| 2124 | #ifdef SOL_TCP |
| 2125 | case SOL_TCP: |
| 2126 | printxval(socktcpoptions, name, "TCP_???"); |
| 2127 | break; |
| 2128 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 2129 | #ifdef SOL_SCTP |
| 2130 | case SOL_SCTP: |
| 2131 | printxval(socksctpoptions, name, "SCTP_???"); |
| 2132 | break; |
| 2133 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2134 | #ifdef SOL_RAW |
| 2135 | case SOL_RAW: |
| 2136 | printxval(sockrawoptions, name, "RAW_???"); |
| 2137 | switch (name) { |
| 2138 | #if defined(ICMP_FILTER) |
| 2139 | case ICMP_FILTER: |
| 2140 | tprintf(", "); |
| 2141 | printicmpfilter(tcp, addr); |
| 2142 | return 0; |
| 2143 | #endif |
| 2144 | } |
| 2145 | break; |
| 2146 | #endif |
| 2147 | |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2148 | /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2149 | * etc. still need work */ |
| 2150 | |
| 2151 | default: |
| 2152 | tprintf("%u", name); |
| 2153 | } |
| 2154 | |
| 2155 | /* default arg printing */ |
| 2156 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2157 | tprintf(", "); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2158 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2159 | if (len == sizeof(int)) { |
| 2160 | printnum_int(tcp, addr, "%d"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2161 | } |
| 2162 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2163 | printstr(tcp, addr, len); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2164 | } |
| 2165 | return 0; |
| 2166 | } |
| 2167 | |
| 2168 | |
Roland McGrath | c3ca0d8 | 2003-01-14 07:53:38 +0000 | [diff] [blame] | 2169 | #ifdef HAVE_STRUCT_OPTHDR |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2170 | |
| 2171 | void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2172 | print_sock_optmgmt(struct tcb *tcp, long addr, int len) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2173 | { |
| 2174 | int c = 0; |
| 2175 | struct opthdr hdr; |
| 2176 | |
John Hughes | 2c4e3a8 | 2002-05-24 10:19:44 +0000 | [diff] [blame] | 2177 | while (len >= (int) sizeof hdr) { |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2178 | if (umove(tcp, addr, &hdr) < 0) break; |
| 2179 | if (c++) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2180 | tprintf(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2181 | } |
| 2182 | else if (len > hdr.len + sizeof hdr) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2183 | tprintf("["); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2184 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2185 | tprintf("{"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2186 | addr += sizeof hdr; |
| 2187 | len -= sizeof hdr; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2188 | printsockopt(tcp, hdr.level, hdr.name, addr, hdr.len); |
John Hughes | 2c4e3a8 | 2002-05-24 10:19:44 +0000 | [diff] [blame] | 2189 | if (hdr.len > 0) { |
| 2190 | addr += hdr.len; |
| 2191 | len -= hdr.len; |
| 2192 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2193 | tprintf("}"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2194 | } |
| 2195 | if (len > 0) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2196 | if (c++) tprintf(", "); |
| 2197 | printstr(tcp, addr, len); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2198 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2199 | if (c > 1) tprintf("]"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2200 | } |
| 2201 | |
| 2202 | #endif |
| 2203 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2204 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2205 | sys_setsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2206 | { |
| 2207 | if (entering(tcp)) { |
| 2208 | tprintf("%ld, ", tcp->u_arg[0]); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2209 | printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2210 | tcp->u_arg[3], tcp->u_arg[4]); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2211 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2212 | } |
| 2213 | return 0; |
| 2214 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2215 | |
| 2216 | #if UNIXWARE >= 7 |
| 2217 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 2218 | static const struct xlat sock_version[] = { |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2219 | { __NETLIB_UW211_SVR4, "UW211_SVR4" }, |
| 2220 | { __NETLIB_UW211_XPG4, "UW211_XPG4" }, |
| 2221 | { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" }, |
| 2222 | { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" }, |
| 2223 | { __NETLIB_FP1_SVR4, "FP1_SVR4" }, |
| 2224 | { __NETLIB_FP1_XPG4, "FP1_XPG4" }, |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2225 | { 0, NULL }, |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2226 | }; |
| 2227 | |
| 2228 | |
| 2229 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2230 | netlib_call(struct tcb *tcp, int (*func)()) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2231 | { |
| 2232 | if (entering(tcp)) { |
| 2233 | int i; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2234 | printxval(sock_version, tcp->u_arg[0], "__NETLIB_???"); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2235 | tprintf(", "); |
| 2236 | --tcp->u_nargs; |
| 2237 | for (i = 0; i < tcp->u_nargs; i++) |
| 2238 | tcp->u_arg[i] = tcp->u_arg[i + 1]; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2239 | return func(tcp); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2240 | } |
| 2241 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2242 | return func(tcp); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2243 | } |
| 2244 | |
| 2245 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2246 | sys_xsocket(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2247 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2248 | return netlib_call(tcp, sys_socket); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2249 | } |
| 2250 | |
| 2251 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2252 | sys_xsocketpair(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2253 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2254 | return netlib_call(tcp, sys_socketpair); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2255 | } |
| 2256 | |
| 2257 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2258 | sys_xbind(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2259 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2260 | return netlib_call(tcp, sys_bind); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2261 | } |
| 2262 | |
| 2263 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2264 | sys_xconnect(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2265 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2266 | return netlib_call(tcp, sys_connect); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2270 | sys_xlisten(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2271 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2272 | return netlib_call(tcp, sys_listen); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2276 | sys_xaccept(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2277 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2278 | return netlib_call(tcp, sys_accept); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2279 | } |
| 2280 | |
| 2281 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2282 | sys_xsendmsg(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2283 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2284 | return netlib_call(tcp, sys_sendmsg); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2285 | } |
| 2286 | |
| 2287 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2288 | sys_xrecvmsg(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2289 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2290 | return netlib_call(tcp, sys_recvmsg); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2291 | } |
| 2292 | |
| 2293 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2294 | sys_xgetsockaddr(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2295 | { |
| 2296 | if (entering(tcp)) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2297 | printxval(sock_version, tcp->u_arg[0], "__NETLIB_???"); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2298 | tprintf(", "); |
| 2299 | if (tcp->u_arg[1] == 0) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2300 | tprintf("LOCALNAME, "); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2301 | } |
| 2302 | else if (tcp->u_arg[1] == 1) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2303 | tprintf("REMOTENAME, "); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2304 | } |
| 2305 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2306 | tprintf("%ld, ", tcp->u_arg[1]); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2307 | } |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2308 | tprintf("%ld, ", tcp->u_arg[2]); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2309 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2310 | else { |
| 2311 | if (tcp->u_arg[3] == 0 || syserror(tcp)) { |
| 2312 | tprintf("%#lx", tcp->u_arg[3]); |
| 2313 | } else { |
| 2314 | printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]); |
| 2315 | } |
| 2316 | tprintf(", "); |
| 2317 | printnum(tcp, tcp->u_arg[4], "%lu"); |
| 2318 | } |
| 2319 | |
| 2320 | return 0; |
| 2321 | |
| 2322 | } |
| 2323 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2324 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2325 | sys_xgetsockopt(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2326 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2327 | return netlib_call(tcp, sys_getsockopt); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2328 | } |
| 2329 | |
| 2330 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2331 | sys_xsetsockopt(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2332 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2333 | return netlib_call(tcp, sys_setsockopt); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2334 | } |
| 2335 | |
| 2336 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2337 | sys_xshutdown(struct tcb *tcp) |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2338 | { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2339 | return netlib_call(tcp, sys_shutdown); |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 2340 | } |
| 2341 | |
Dmitry V. Levin | e5e6085 | 2009-12-31 22:50:49 +0000 | [diff] [blame] | 2342 | #endif /* UNIXWARE */ |