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> |
| 38 | #include <netinet/in.h> |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 39 | #ifdef FREEBSD |
| 40 | #include <netinet/tcp.h> |
| 41 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 42 | #include <arpa/inet.h> |
| 43 | #if defined(LINUX) |
| 44 | #include <asm/types.h> |
| 45 | #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3) |
| 46 | # include <netipx/ipx.h> |
| 47 | #else |
| 48 | # include <linux/ipx.h> |
| 49 | #endif |
| 50 | #endif /* LINUX */ |
| 51 | |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 52 | #if defined (__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 53 | #if defined(HAVE_LINUX_IN6_H) |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 54 | #include <linux/in6.h> |
| 55 | #endif |
Wichert Akkerman | 2f473da | 1999-11-01 19:53:31 +0000 | [diff] [blame] | 56 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 57 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 58 | #if defined(HAVE_SYS_UIO_H) |
| 59 | #include <sys/uio.h> |
| 60 | #endif |
| 61 | |
| 62 | #if defined(HAVE_LINUX_NETLINK_H) |
| 63 | #include <linux/netlink.h> |
| 64 | #endif |
| 65 | |
| 66 | #if defined(HAVE_LINUX_IF_PACKET_H) |
| 67 | #include <linux/if_packet.h> |
| 68 | #endif |
| 69 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 70 | #if defined(HAVE_LINUX_ICMP_H) |
| 71 | #include <linux/icmp.h> |
| 72 | #endif |
| 73 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 74 | #ifndef PF_UNSPEC |
| 75 | #define PF_UNSPEC AF_UNSPEC |
| 76 | #endif |
| 77 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 78 | #if UNIXWARE >= 7 |
| 79 | #define HAVE_SENDMSG 1 /* HACK - *FIXME* */ |
| 80 | #endif |
| 81 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 | #ifdef LINUX |
| 83 | /* Under Linux these are enums so we can't test for them with ifdef. */ |
| 84 | #define IPPROTO_EGP IPPROTO_EGP |
| 85 | #define IPPROTO_PUP IPPROTO_PUP |
| 86 | #define IPPROTO_IDP IPPROTO_IDP |
| 87 | #define IPPROTO_IGMP IPPROTO_IGMP |
| 88 | #define IPPROTO_RAW IPPROTO_RAW |
| 89 | #define IPPROTO_MAX IPPROTO_MAX |
| 90 | #endif |
| 91 | |
| 92 | static struct xlat domains[] = { |
| 93 | { PF_UNSPEC, "PF_UNSPEC" }, |
| 94 | { PF_UNIX, "PF_UNIX" }, |
| 95 | { PF_INET, "PF_INET" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 96 | #ifdef PF_NETLINK |
| 97 | { PF_NETLINK, "PF_NETLINK" }, |
| 98 | #endif |
| 99 | #ifdef PF_PACKET |
| 100 | { PF_PACKET, "PF_PACKET" }, |
| 101 | #endif |
| 102 | #ifdef PF_INET6 |
| 103 | { PF_INET6, "PF_INET6" }, |
| 104 | #endif |
| 105 | #ifdef PF_ATMSVC |
| 106 | { PF_ATMSVC, "PF_INET6" }, |
| 107 | #endif |
| 108 | #ifdef PF_INET6 |
| 109 | { PF_INET6, "PF_INET6" }, |
| 110 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 111 | #ifdef PF_LOCAL |
| 112 | { PF_LOCAL, "PS_LOCAL" }, |
| 113 | #endif |
| 114 | #ifdef PF_ISO |
| 115 | { PF_ISO, "PF_ISO" }, |
| 116 | #endif |
| 117 | #ifdef PF_AX25 |
| 118 | { PF_AX25, "PF_AX25" }, |
| 119 | #endif |
| 120 | #ifdef PF_IPX |
| 121 | { PF_IPX, "PF_IPX" }, |
| 122 | #endif |
| 123 | #ifdef PF_APPLETALK |
| 124 | { PF_APPLETALK, "PF_APPLETALK" }, |
| 125 | #endif |
| 126 | #ifdef PF_NETROM |
| 127 | { PF_NETROM, "PF_NETROM" }, |
| 128 | #endif |
| 129 | #ifdef PF_BRIDGE |
| 130 | { PF_BRIDGE, "PF_BRIDGE" }, |
| 131 | #endif |
| 132 | #ifdef PF_AAL5 |
| 133 | { PF_AAL5, "PF_AAL5" }, |
| 134 | #endif |
| 135 | #ifdef PF_X25 |
| 136 | { PF_X25, "PF_X25" }, |
| 137 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 138 | #ifdef PF_ROSE |
| 139 | { PF_ROSE, "PF_ROSE" }, |
| 140 | #endif |
| 141 | #ifdef PF_DECNET |
| 142 | { PF_DECNET, "PF_DECNET" }, |
| 143 | #endif |
| 144 | #ifdef PF_NETBEUI |
| 145 | { PF_NETBEUI, "PF_NETBEUI" }, |
| 146 | #endif |
| 147 | #ifdef PF_IMPLINK |
| 148 | { PF_IMPLINK, "PF_IMPLINK" }, |
| 149 | #endif |
| 150 | { 0, NULL }, |
| 151 | }; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 152 | static struct xlat addrfams[] = { |
| 153 | { AF_UNSPEC, "AF_UNSPEC" }, |
| 154 | { AF_UNIX, "AF_UNIX" }, |
| 155 | { AF_INET, "AF_INET" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 156 | #ifdef AF_INET6 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 157 | { AF_INET6, "AF_INET6" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 158 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 159 | { AF_DECnet, "AF_DECnet" }, |
| 160 | #ifdef PF_ATMSVC |
| 161 | { AF_ATMSVC, "AF_ATMSVC" }, |
| 162 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 163 | #ifdef AF_PACKET |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 164 | { AF_PACKET, "AF_PACKET" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 165 | #endif |
| 166 | #ifdef AF_NETLINK |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 167 | { AF_NETLINK, "AF_NETLINK" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 168 | #endif |
| 169 | #ifdef AF_ISO |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 170 | { AF_ISO, "AF_ISO" }, |
| 171 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 172 | #ifdef AF_IMPLINK |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 173 | { AF_IMPLINK, "AF_IMPLINK" }, |
| 174 | #endif |
| 175 | { 0, NULL }, |
| 176 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 177 | static struct xlat socktypes[] = { |
| 178 | { SOCK_STREAM, "SOCK_STREAM" }, |
| 179 | { SOCK_DGRAM, "SOCK_DGRAM" }, |
| 180 | #ifdef SOCK_RAW |
| 181 | { SOCK_RAW, "SOCK_RAW" }, |
| 182 | #endif |
| 183 | #ifdef SOCK_SEQPACKET |
| 184 | { SOCK_SEQPACKET,"SOCK_SEQPACKET"}, |
| 185 | #endif |
| 186 | #ifdef SOCK_RDM |
| 187 | { SOCK_RDM, "SOCK_RDM" }, |
| 188 | #endif |
| 189 | #ifdef SOCK_PACKET |
| 190 | { SOCK_PACKET, "SOCK_PACKET" }, |
| 191 | #endif |
| 192 | { 0, NULL }, |
| 193 | }; |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame^] | 194 | static struct xlat socketlayers[] = { |
| 195 | { SOL_IP, "SOL_IP" }, |
| 196 | #if defined(SOL_ICMP) |
| 197 | { SOL_ICMP, "SOL_ICMP" }, |
| 198 | #endif |
| 199 | { SOL_TCP, "SOL_TCP" }, |
| 200 | { SOL_UDP, "SOL_UDP" }, |
| 201 | #if defined(SOL_IPV6) |
| 202 | { SOL_IPV6, "SOL_IPV6" }, |
| 203 | #endif |
| 204 | #if defined(SOL_ICMPV6) |
| 205 | { SOL_ICMPV6, "SOL_ICMPV6" }, |
| 206 | #endif |
| 207 | #if defined(SOL_RAW) |
| 208 | { SOL_RAW, "SOL_RAW" }, |
| 209 | #endif |
| 210 | #if defined(SOL_IPX) |
| 211 | { SOL_IPX, "SOL_IPX" }, |
| 212 | #endif |
| 213 | #if defined(SOL_IPX) |
| 214 | { SOL_IPX, "SOL_IPX" }, |
| 215 | #endif |
| 216 | #if defined(SOL_AX25) |
| 217 | { SOL_AX25, "SOL_AX25" }, |
| 218 | #endif |
| 219 | #if defined(SOL_ATALK) |
| 220 | { SOL_ATALK, "SOL_ATALK" }, |
| 221 | #endif |
| 222 | #if defined(SOL_NETROM) |
| 223 | { SOL_NETROM, "SOL_NETROM" }, |
| 224 | #endif |
| 225 | #if defined(SOL_ROSE) |
| 226 | { SOL_ROSE, "SOL_ROSE" }, |
| 227 | #endif |
| 228 | #if defined(SOL_DECNET) |
| 229 | { SOL_DECNET, "SOL_DECNET" }, |
| 230 | #endif |
| 231 | #if defined(SOL_X25) |
| 232 | { SOL_X25, "SOL_X25" }, |
| 233 | #endif |
| 234 | #if defined(SOL_PACKET) |
| 235 | { SOL_PACKET, "SOL_PACKET" }, |
| 236 | #endif |
| 237 | #if defined(SOL_ATM) |
| 238 | { SOL_ATM, "SOL_ATM" }, |
| 239 | #endif |
| 240 | #if defined(SOL_AAL) |
| 241 | { SOL_AAL, "SOL_AAL" }, |
| 242 | #endif |
| 243 | #if defined(SOL_IRDA) |
| 244 | { SOL_IRDA, "SOL_IRDA" }, |
| 245 | #endif |
| 246 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | static struct xlat protocols[] = { |
| 248 | { IPPROTO_IP, "IPPROTO_IP" }, |
| 249 | { IPPROTO_ICMP, "IPPROTO_ICMP" }, |
| 250 | { IPPROTO_TCP, "IPPROTO_TCP" }, |
| 251 | { IPPROTO_UDP, "IPPROTO_UDP" }, |
| 252 | #ifdef IPPROTO_GGP |
| 253 | { IPPROTO_GGP, "IPPROTO_GGP" }, |
| 254 | #endif |
| 255 | #ifdef IPPROTO_EGP |
| 256 | { IPPROTO_EGP, "IPPROTO_EGP" }, |
| 257 | #endif |
| 258 | #ifdef IPPROTO_PUP |
| 259 | { IPPROTO_PUP, "IPPROTO_PUP" }, |
| 260 | #endif |
| 261 | #ifdef IPPROTO_IDP |
| 262 | { IPPROTO_IDP, "IPPROTO_IDP" }, |
| 263 | #endif |
| 264 | #ifdef IPPROTO_IPV6 |
| 265 | { IPPROTO_IPV6, "IPPROTO_IPV6" }, |
| 266 | #endif |
| 267 | #ifdef IPPROTO_ICMPV6 |
| 268 | { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"}, |
| 269 | #endif |
| 270 | #ifdef IPPROTO_IGMP |
| 271 | { IPPROTO_IGMP, "IPPROTO_IGMP" }, |
| 272 | #endif |
| 273 | #ifdef IPPROTO_HELLO |
| 274 | { IPPROTO_HELLO,"IPPROTO_HELLO" }, |
| 275 | #endif |
| 276 | #ifdef IPPROTO_ND |
| 277 | { IPPROTO_ND, "IPPROTO_ND" }, |
| 278 | #endif |
| 279 | #ifdef IPPROTO_RAW |
| 280 | { IPPROTO_RAW, "IPPROTO_RAW" }, |
| 281 | #endif |
| 282 | #ifdef IPPROTO_MAX |
| 283 | { IPPROTO_MAX, "IPPROTO_MAX" }, |
| 284 | #endif |
| 285 | #ifdef IPPROTO_IPIP |
| 286 | { IPPROTO_IPIP, "IPPROTO_IPIP" }, |
| 287 | #endif |
| 288 | { 0, NULL }, |
| 289 | }; |
| 290 | static struct xlat msg_flags[] = { |
| 291 | { MSG_OOB, "MSG_OOB" }, |
| 292 | #ifdef MSG_DONTROUTE |
| 293 | { MSG_DONTROUTE,"MSG_DONTROUTE" }, |
| 294 | #endif |
| 295 | #ifdef MSG_PEEK |
| 296 | { MSG_PEEK, "MSG_PEEK" }, |
| 297 | #endif |
| 298 | #ifdef MSG_CTRUNC |
| 299 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
| 300 | #endif |
| 301 | #ifdef MSG_PROXY |
| 302 | { MSG_PROXY, "MSG_PROXY" }, |
| 303 | #endif |
| 304 | #ifdef MSG_EOR |
| 305 | { MSG_EOR, "MSG_EOR" }, |
| 306 | #endif |
| 307 | #ifdef MSG_WAITALL |
| 308 | { MSG_WAITALL, "MSG_WAITALL" }, |
| 309 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 310 | #ifdef MSG_TRUNC |
| 311 | { MSG_TRUNC, "MSG_TRUNC" }, |
| 312 | #endif |
| 313 | #ifdef MSG_CTRUNC |
| 314 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
| 315 | #endif |
| 316 | #ifdef MSG_ERRQUEUE |
| 317 | { MSG_ERRQUEUE, "MSG_ERRQUEUE" }, |
| 318 | #endif |
| 319 | #ifdef MSG_DONTWAIT |
| 320 | { MSG_DONTWAIT, "MSG_DONTWAIT" }, |
| 321 | #endif |
| 322 | #ifdef MSG_CONFIRM |
| 323 | { MSG_CONFIRM, "MSG_CONFIRM" }, |
| 324 | #endif |
| 325 | #ifdef MSG_PROBE |
| 326 | { MSG_PROBE, "MSG_PROBE" }, |
| 327 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 328 | { 0, NULL }, |
| 329 | }; |
| 330 | |
| 331 | static struct xlat sockoptions[] = { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 332 | #ifdef SO_PEERCRED |
| 333 | { SO_PEERCRED, "SO_PEERCRED" }, |
| 334 | #endif |
| 335 | #ifdef SO_PASSCRED |
| 336 | { SO_PASSCRED, "SO_PASSCRED" }, |
| 337 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 338 | #ifdef SO_DEBUG |
| 339 | { SO_DEBUG, "SO_DEBUG" }, |
| 340 | #endif |
| 341 | #ifdef SO_REUSEADDR |
| 342 | { SO_REUSEADDR, "SO_REUSEADDR" }, |
| 343 | #endif |
| 344 | #ifdef SO_KEEPALIVE |
| 345 | { SO_KEEPALIVE, "SO_KEEPALIVE" }, |
| 346 | #endif |
| 347 | #ifdef SO_DONTROUTE |
| 348 | { SO_DONTROUTE, "SO_DONTROUTE" }, |
| 349 | #endif |
| 350 | #ifdef SO_BROADCAST |
| 351 | { SO_BROADCAST, "SO_BROADCAST" }, |
| 352 | #endif |
| 353 | #ifdef SO_LINGER |
| 354 | { SO_LINGER, "SO_LINGER" }, |
| 355 | #endif |
| 356 | #ifdef SO_OOBINLINE |
| 357 | { SO_OOBINLINE, "SO_OOBINLINE" }, |
| 358 | #endif |
| 359 | #ifdef SO_TYPE |
| 360 | { SO_TYPE, "SO_TYPE" }, |
| 361 | #endif |
| 362 | #ifdef SO_ERROR |
| 363 | { SO_ERROR, "SO_ERROR" }, |
| 364 | #endif |
| 365 | #ifdef SO_SNDBUF |
| 366 | { SO_SNDBUF, "SO_SNDBUF" }, |
| 367 | #endif |
| 368 | #ifdef SO_RCVBUF |
| 369 | { SO_RCVBUF, "SO_RCVBUF" }, |
| 370 | #endif |
| 371 | #ifdef SO_NO_CHECK |
| 372 | { SO_NO_CHECK, "SO_NO_CHECK" }, |
| 373 | #endif |
| 374 | #ifdef SO_PRIORITY |
| 375 | { SO_PRIORITY, "SO_PRIORITY" }, |
| 376 | #endif |
| 377 | #ifdef SO_ACCEPTCONN |
| 378 | { SO_ACCEPTCONN,"SO_ACCEPTCONN" }, |
| 379 | #endif |
| 380 | #ifdef SO_USELOOPBACK |
| 381 | { SO_USELOOPBACK,"SO_USELOOPBACK"}, |
| 382 | #endif |
| 383 | #ifdef SO_SNDLOWAT |
| 384 | { SO_SNDLOWAT, "SO_SNDLOWAT" }, |
| 385 | #endif |
| 386 | #ifdef SO_RCVLOWAT |
| 387 | { SO_RCVLOWAT, "SO_RCVLOWAT" }, |
| 388 | #endif |
| 389 | #ifdef SO_SNDTIMEO |
| 390 | { SO_SNDTIMEO, "SO_SNDTIMEO" }, |
| 391 | #endif |
| 392 | #ifdef SO_RCVTIMEO |
| 393 | { SO_RCVTIMEO, "SO_RCVTIMEO" }, |
| 394 | #endif |
| 395 | #ifdef SO_BSDCOMPAT |
| 396 | { SO_BSDCOMPAT, "SO_BSDCOMPAT" }, |
| 397 | #endif |
| 398 | #ifdef SO_REUSEPORT |
| 399 | { SO_REUSEPORT, "SO_REUSEPORT" }, |
| 400 | #endif |
| 401 | #ifdef SO_RCVLOWAT |
| 402 | { SO_RCVLOWAT, "SO_RCVLOWAT" }, |
| 403 | #endif |
| 404 | #ifdef SO_SNDLOWAT |
| 405 | { SO_SNDLOWAT, "SO_SNDLOWAT" }, |
| 406 | #endif |
| 407 | #ifdef SO_RCVTIMEO |
| 408 | { SO_RCVTIMEO, "SO_RCVTIMEO" }, |
| 409 | #endif |
| 410 | #ifdef SO_SNDTIMEO |
| 411 | { SO_SNDTIMEO, "SO_SNDTIMEO" }, |
| 412 | #endif |
| 413 | { 0, NULL }, |
| 414 | }; |
| 415 | |
| 416 | #ifdef SOL_IP |
| 417 | static struct xlat sockipoptions[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 418 | { IP_TOS, "IP_TOS" }, |
| 419 | { IP_TTL, "IP_TTL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 420 | #if defined(IP_HDRINCL) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 421 | { IP_HDRINCL, "IP_HDRINCL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 422 | #endif |
| 423 | #if defined(IP_OPTIONS) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 424 | { IP_OPTIONS, "IP_OPTIONS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 425 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 426 | { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" }, |
| 427 | #if defined(IP_RECVOPTIONS) |
| 428 | { IP_RECVOPTIONS, "IP_RECVOPTIONS" }, |
| 429 | #endif |
| 430 | { IP_RETOPTS, "IP_RETOPTS" }, |
| 431 | { IP_PKTINFO, "IP_PKTINFO" }, |
| 432 | { IP_PKTOPTIONS, "IP_PKTOPTIONS" }, |
| 433 | { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, |
| 434 | { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, |
| 435 | { IP_RECVERR, "IP_RECVERR" }, |
| 436 | { IP_RECVTTL, "IP_RECRECVTTL" }, |
| 437 | { IP_RECVTOS, "IP_RECRECVTOS" }, |
| 438 | #if defined(IP_MTU) |
| 439 | { IP_MTU, "IP_MTU" }, |
| 440 | #endif |
| 441 | { IP_MULTICAST_IF, "IP_MULTICAST_IF" }, |
| 442 | { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" }, |
| 443 | { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" }, |
| 444 | { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" }, |
| 445 | { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" }, |
| 446 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 447 | }; |
| 448 | #endif /* SOL_IP */ |
| 449 | |
| 450 | #ifdef SOL_IPX |
| 451 | static struct xlat sockipxoptions[] = { |
| 452 | { IPX_TYPE, "IPX_TYPE" }, |
| 453 | { 0, NULL }, |
| 454 | }; |
| 455 | #endif /* SOL_IPX */ |
| 456 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 457 | #ifdef SOL_RAW |
| 458 | static struct xlat sockrawoptions[] = { |
| 459 | #if defined(ICMP_FILTER) |
| 460 | { ICMP_FILTER, "ICMP_FILTER" }, |
| 461 | #endif |
| 462 | { 0, NULL }, |
| 463 | }; |
| 464 | #endif /* SOL_RAW */ |
| 465 | |
| 466 | #ifdef SOL_PACKET |
| 467 | static struct xlat sockpacketoptions[] = { |
| 468 | { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" }, |
| 469 | { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"}, |
| 470 | #if defined(PACKET_RECV_OUTPUT) |
| 471 | { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" }, |
| 472 | #endif |
| 473 | #if defined(PACKET_RX_RING) |
| 474 | { PACKET_RX_RING, "PACKET_RX_RING" }, |
| 475 | #endif |
| 476 | #if defined(PACKET_STATISTICS) |
| 477 | { PACKET_STATISTICS, "PACKET_STATISTICS" }, |
| 478 | #endif |
| 479 | { 0, NULL }, |
| 480 | }; |
| 481 | #endif /* SOL_PACKET */ |
| 482 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | #ifdef SOL_TCP |
| 484 | static struct xlat socktcpoptions[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 485 | { TCP_NODELAY, "TCP_NODELAY" }, |
| 486 | { TCP_MAXSEG, "TCP_MAXSEG" }, |
| 487 | #if defined(TCP_CORK) |
| 488 | { TCP_CORK, "TCP_CORK" }, |
| 489 | #endif |
| 490 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 491 | }; |
| 492 | #endif /* SOL_TCP */ |
| 493 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 494 | #ifdef SOL_RAW |
| 495 | static struct xlat icmpfilterflags[] = { |
| 496 | #if defined(ICMP_ECHOREPLY) |
| 497 | { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" }, |
| 498 | #endif |
| 499 | #if defined(ICMP_DEST_UNREACH) |
| 500 | { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" }, |
| 501 | #endif |
| 502 | #if defined(ICMP_SOURCE_QUENCH) |
| 503 | { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" }, |
| 504 | #endif |
| 505 | #if defined(ICMP_REDIRECT) |
| 506 | { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" }, |
| 507 | #endif |
| 508 | #if defined(ICMP_ECHO) |
| 509 | { (1<<ICMP_ECHO), "ICMP_ECHO" }, |
| 510 | #endif |
| 511 | #if defined(ICMP_TIME_EXCEEDED) |
| 512 | { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" }, |
| 513 | #endif |
| 514 | #if defined(ICMP_PARAMETERPROB) |
| 515 | { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" }, |
| 516 | #endif |
| 517 | #if defined(ICMP_TIMESTAMP) |
| 518 | { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" }, |
| 519 | #endif |
| 520 | #if defined(ICMP_TIMESTAMPREPLY) |
| 521 | { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" }, |
| 522 | #endif |
| 523 | #if defined(ICMP_INFO_REQUEST) |
| 524 | { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" }, |
| 525 | #endif |
| 526 | #if defined(ICMP_INFO_REPLY) |
| 527 | { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" }, |
| 528 | #endif |
| 529 | #if defined(ICMP_ADDRESS) |
| 530 | { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" }, |
| 531 | #endif |
| 532 | #if defined(ICMP_ADDRESSREPLY) |
| 533 | { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" }, |
| 534 | #endif |
| 535 | { 0, NULL }, |
| 536 | }; |
| 537 | #endif /* SOL_RAW */ |
| 538 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 539 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 540 | void |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 541 | printsock(tcp, addr, addrlen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 542 | struct tcb *tcp; |
| 543 | long addr; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 544 | int addrlen; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 545 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 546 | union { |
| 547 | char pad[128]; |
| 548 | struct sockaddr sa; |
| 549 | struct sockaddr_in sin; |
| 550 | struct sockaddr_un sau; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 551 | #ifdef HAVE_INET_NTOP |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 552 | struct sockaddr_in6 sa6; |
| 553 | #endif |
| 554 | #if defined(LINUX) && defined(AF_IPX) |
| 555 | struct sockaddr_ipx sipx; |
| 556 | #endif |
| 557 | #ifdef AF_PACKET |
| 558 | struct sockaddr_ll ll; |
| 559 | #endif |
| 560 | #ifdef AF_NETLINK |
| 561 | struct sockaddr_nl nl; |
| 562 | #endif |
| 563 | } addrbuf; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 564 | char string_addr[100]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 565 | |
| 566 | if (addr == 0) { |
| 567 | tprintf("NULL"); |
| 568 | return; |
| 569 | } |
| 570 | if (!verbose(tcp)) { |
| 571 | tprintf("%#lx", addr); |
| 572 | return; |
| 573 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 574 | if ((addrlen<2) || (addrlen>sizeof(addrbuf))) |
| 575 | addrlen=sizeof(addrbuf); |
| 576 | |
| 577 | if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 578 | tprintf("{...}"); |
| 579 | return; |
| 580 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 581 | |
| 582 | tprintf("{sin_family="); |
| 583 | printxval(addrfams, addrbuf.sa.sa_family, "AF_???"); |
| 584 | tprintf(", "); |
| 585 | |
| 586 | switch (addrbuf.sa.sa_family) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 587 | case AF_UNIX: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 588 | if (addrlen==2) { |
| 589 | tprintf("<nil>"); |
| 590 | } else if (addrbuf.sau.sun_path[0]) { |
| 591 | tprintf("path=\"%*.*s\"", addrlen-2, addrlen-2, addrbuf.sau.sun_path); |
| 592 | } else { |
| 593 | tprintf("path=@%*.*s", addrlen-3, addrlen-3, addrbuf.sau.sun_path+1); |
| 594 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 595 | break; |
| 596 | case AF_INET: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 597 | tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 598 | ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 599 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 600 | #ifdef HAVE_INET_NTOP |
| 601 | case AF_INET6: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 602 | inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr)); |
| 603 | tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=htonl(%u)}", |
| 604 | ntohs(addrbuf.sa6.sin6_port), string_addr, ntohl(addrbuf.sa6.sin6_flowinfo)); |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 605 | break; |
| 606 | #endif |
Wichert Akkerman | dbb440e | 1999-05-11 15:06:44 +0000 | [diff] [blame] | 607 | #if defined(AF_IPX) && defined(linux) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 608 | case AF_IPX: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 609 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 610 | int i; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 611 | tprintf("{sipx_port=htons(%u), ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 612 | ntohs(addrbuf.sipx.sipx_port)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 613 | /* Yes, I know, this does not look too |
| 614 | * strace-ish, but otherwise the IPX |
| 615 | * addresses just look monstrous... |
| 616 | * Anyways, feel free if you don't like |
| 617 | * this way.. :) |
| 618 | */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 619 | tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 620 | for (i = 0; i<IPX_NODE_LEN; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 621 | tprintf("%02x", addrbuf.sipx.sipx_node[i]); |
| 622 | tprintf("/[%02x]", addrbuf.sipx.sipx_type); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 623 | } |
| 624 | break; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 625 | #endif /* AF_IPX && linux */ |
| 626 | #ifdef AF_PACKET |
| 627 | case AF_PACKET: |
| 628 | { |
| 629 | int i; |
| 630 | tprintf("proto=%#04x, if%d, pkttype=%d, addr(%d)={%d, ", |
| 631 | ntohs(addrbuf.ll.sll_protocol), |
| 632 | addrbuf.ll.sll_ifindex, |
| 633 | addrbuf.ll.sll_pkttype, |
| 634 | addrbuf.ll.sll_halen, |
| 635 | addrbuf.ll.sll_hatype); |
| 636 | for (i=0; i<addrbuf.ll.sll_addr[i]; i++) |
| 637 | tprintf("%02x", addrbuf.ll.sll_addr[i]); |
| 638 | } |
| 639 | break; |
| 640 | |
| 641 | #endif /* AF_APACKET */ |
| 642 | #ifdef AF_NETLINLK |
| 643 | case AF_NETLINK: |
| 644 | tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); |
| 645 | break; |
| 646 | #endif /* AF_NETLINK */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 647 | /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 648 | AF_X25 AF_ROSE etc. still need to be done */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 649 | |
| 650 | default: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 651 | tprintf("{sa_family=%u, sa_data=", addrbuf.sa.sa_family); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 652 | printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 653 | sizeof addrbuf.sa.sa_data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 654 | break; |
| 655 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 656 | tprintf("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | #if HAVE_SENDMSG |
| 660 | |
| 661 | static void |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 662 | printiovec(tcp, iovec, len) |
| 663 | struct tcb *tcp; |
| 664 | struct iovec *iovec; |
| 665 | long len; |
| 666 | { |
| 667 | struct iovec *iov; |
| 668 | int i; |
| 669 | |
| 670 | iov = (struct iovec *) malloc(len * sizeof *iov); |
| 671 | if (iov == NULL) { |
| 672 | fprintf(stderr, "No memory"); |
| 673 | return; |
| 674 | } |
| 675 | if (umoven(tcp, (long)iovec, |
| 676 | len * sizeof *iov, (char *) iov) < 0) { |
| 677 | tprintf("%#lx", (unsigned long)iovec); |
| 678 | } else { |
| 679 | tprintf("["); |
| 680 | for (i = 0; i < len; i++) { |
| 681 | if (i) |
| 682 | tprintf(", "); |
| 683 | tprintf("{"); |
| 684 | printstr(tcp, (long) iov[i].iov_base, |
| 685 | iov[i].iov_len); |
| 686 | tprintf(", %lu}", (unsigned long)iov[i].iov_len); |
| 687 | } |
| 688 | tprintf("]"); |
| 689 | } |
| 690 | free((char *) iov); |
| 691 | } |
| 692 | |
| 693 | static void |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 694 | printmsghdr(tcp, addr) |
| 695 | struct tcb *tcp; |
| 696 | long addr; |
| 697 | { |
| 698 | struct msghdr msg; |
| 699 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 700 | if (umove(tcp, addr, &msg) < 0) { |
| 701 | tprintf("%#lx", addr); |
| 702 | return; |
| 703 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 704 | tprintf("{msg_name(%d)=", msg.msg_namelen); |
| 705 | printsock(tcp, (long)msg.msg_name, msg.msg_namelen); |
| 706 | |
| 707 | tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen); |
| 708 | printiovec(tcp, msg.msg_iov, msg.msg_iovlen); |
| 709 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 710 | #ifdef HAVE_MSG_CONTROL |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 711 | tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen); |
| 712 | if (msg.msg_controllen) |
| 713 | tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control); |
| 714 | tprintf(", msg_flags="); |
| 715 | if (printflags(msg_flags, msg.msg_flags)==0) |
| 716 | tprintf("0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 717 | #else /* !HAVE_MSG_CONTROL */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 718 | tprintf("msg_accrights=%#lx, msg_accrightslen=%u", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 719 | (unsigned long) msg.msg_accrights, msg.msg_accrightslen); |
| 720 | #endif /* !HAVE_MSG_CONTROL */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 721 | tprintf("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | #endif /* HAVE_SENDMSG */ |
| 725 | |
| 726 | int |
| 727 | sys_socket(tcp) |
| 728 | struct tcb *tcp; |
| 729 | { |
| 730 | if (entering(tcp)) { |
| 731 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 732 | tprintf(", "); |
| 733 | printxval(socktypes, tcp->u_arg[1], "SOCK_???"); |
| 734 | tprintf(", "); |
| 735 | switch (tcp->u_arg[0]) { |
| 736 | case PF_INET: |
| 737 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 738 | break; |
| 739 | #ifdef PF_IPX |
| 740 | case PF_IPX: |
| 741 | /* BTW: I don't believe this.. */ |
| 742 | tprintf("["); |
| 743 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 744 | tprintf("]"); |
| 745 | break; |
| 746 | #endif /* PF_IPX */ |
| 747 | default: |
| 748 | tprintf("%lu", tcp->u_arg[2]); |
| 749 | break; |
| 750 | } |
| 751 | } |
| 752 | return 0; |
| 753 | } |
| 754 | |
| 755 | int |
| 756 | sys_bind(tcp) |
| 757 | struct tcb *tcp; |
| 758 | { |
| 759 | if (entering(tcp)) { |
| 760 | tprintf("%ld, ", tcp->u_arg[0]); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 761 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 762 | tprintf(", %lu", tcp->u_arg[2]); |
| 763 | } |
| 764 | return 0; |
| 765 | } |
| 766 | |
| 767 | int |
| 768 | sys_connect(tcp) |
| 769 | struct tcb *tcp; |
| 770 | { |
| 771 | return sys_bind(tcp); |
| 772 | } |
| 773 | |
| 774 | int |
| 775 | sys_listen(tcp) |
| 776 | struct tcb *tcp; |
| 777 | { |
| 778 | if (entering(tcp)) { |
| 779 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 780 | } |
| 781 | return 0; |
| 782 | } |
| 783 | |
| 784 | int |
| 785 | sys_accept(tcp) |
| 786 | struct tcb *tcp; |
| 787 | { |
| 788 | if (entering(tcp)) { |
| 789 | tprintf("%ld, ", tcp->u_arg[0]); |
| 790 | } else if (!tcp->u_arg[2]) |
| 791 | tprintf("%#lx, NULL", tcp->u_arg[1]); |
| 792 | else { |
| 793 | if (tcp->u_arg[1] == 0 || syserror(tcp)) { |
| 794 | tprintf("%#lx", tcp->u_arg[1]); |
| 795 | } else { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 796 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 797 | } |
| 798 | tprintf(", "); |
| 799 | printnum(tcp, tcp->u_arg[2], "%lu"); |
| 800 | } |
| 801 | return 0; |
| 802 | } |
| 803 | |
| 804 | int |
| 805 | sys_send(tcp) |
| 806 | struct tcb *tcp; |
| 807 | { |
| 808 | if (entering(tcp)) { |
| 809 | tprintf("%ld, ", tcp->u_arg[0]); |
| 810 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 811 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 812 | /* flags */ |
| 813 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 814 | tprintf("0"); |
| 815 | } |
| 816 | return 0; |
| 817 | } |
| 818 | |
| 819 | int |
| 820 | sys_sendto(tcp) |
| 821 | struct tcb *tcp; |
| 822 | { |
| 823 | if (entering(tcp)) { |
| 824 | tprintf("%ld, ", tcp->u_arg[0]); |
| 825 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 826 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 827 | /* flags */ |
| 828 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 829 | tprintf("0"); |
| 830 | /* to address */ |
| 831 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 832 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 833 | /* to length */ |
| 834 | tprintf(", %lu", tcp->u_arg[5]); |
| 835 | } |
| 836 | return 0; |
| 837 | } |
| 838 | |
| 839 | #ifdef HAVE_SENDMSG |
| 840 | |
| 841 | int |
| 842 | sys_sendmsg(tcp) |
| 843 | struct tcb *tcp; |
| 844 | { |
| 845 | if (entering(tcp)) { |
| 846 | tprintf("%ld, ", tcp->u_arg[0]); |
| 847 | printmsghdr(tcp, tcp->u_arg[1]); |
| 848 | /* flags */ |
| 849 | tprintf(", "); |
| 850 | if (printflags(msg_flags, tcp->u_arg[2]) == 0) |
| 851 | tprintf("0"); |
| 852 | } |
| 853 | return 0; |
| 854 | } |
| 855 | |
| 856 | #endif /* HAVE_SENDMSG */ |
| 857 | |
| 858 | int |
| 859 | sys_recv(tcp) |
| 860 | struct tcb *tcp; |
| 861 | { |
| 862 | if (entering(tcp)) { |
| 863 | tprintf("%ld, ", tcp->u_arg[0]); |
| 864 | } else { |
| 865 | if (syserror(tcp)) |
| 866 | tprintf("%#lx", tcp->u_arg[1]); |
| 867 | else |
| 868 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 869 | |
| 870 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 871 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 872 | tprintf("0"); |
| 873 | } |
| 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | int |
| 878 | sys_recvfrom(tcp) |
| 879 | struct tcb *tcp; |
| 880 | { |
| 881 | int fromlen; |
| 882 | |
| 883 | if (entering(tcp)) { |
| 884 | tprintf("%ld, ", tcp->u_arg[0]); |
| 885 | } else { |
| 886 | if (syserror(tcp)) { |
| 887 | tprintf("%#lx, %lu, %lu, %#lx, %#lx", |
| 888 | tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], |
| 889 | tcp->u_arg[4], tcp->u_arg[5]); |
| 890 | return 0; |
| 891 | } |
| 892 | /* buf */ |
| 893 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 894 | /* len */ |
| 895 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 896 | /* flags */ |
| 897 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 898 | tprintf("0"); |
| 899 | /* from address, len */ |
| 900 | if (!tcp->u_arg[4] || !tcp->u_arg[5]) { |
| 901 | if (tcp->u_arg[4] == 0) |
| 902 | tprintf(", NULL"); |
| 903 | else |
| 904 | tprintf(", %#lx", tcp->u_arg[4]); |
| 905 | if (tcp->u_arg[5] == 0) |
| 906 | tprintf(", NULL"); |
| 907 | else |
| 908 | tprintf(", %#lx", tcp->u_arg[5]); |
| 909 | return 0; |
| 910 | } |
| 911 | if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
| 912 | tprintf(", {...}, [?]"); |
| 913 | return 0; |
| 914 | } |
| 915 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 916 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 917 | /* from length */ |
| 918 | tprintf(", [%u]", fromlen); |
| 919 | } |
| 920 | return 0; |
| 921 | } |
| 922 | |
| 923 | #ifdef HAVE_SENDMSG |
| 924 | |
| 925 | int |
| 926 | sys_recvmsg(tcp) |
| 927 | struct tcb *tcp; |
| 928 | { |
| 929 | if (entering(tcp)) { |
| 930 | tprintf("%ld, ", tcp->u_arg[0]); |
| 931 | } else { |
| 932 | if (syserror(tcp) || !verbose(tcp)) |
| 933 | tprintf("%#lx", tcp->u_arg[1]); |
| 934 | else |
| 935 | printmsghdr(tcp, tcp->u_arg[1]); |
| 936 | /* flags */ |
| 937 | tprintf(", "); |
| 938 | if (printflags(msg_flags, tcp->u_arg[2]) == 0) |
| 939 | tprintf("0"); |
| 940 | } |
| 941 | return 0; |
| 942 | } |
| 943 | |
| 944 | #endif /* HAVE_SENDMSG */ |
| 945 | |
| 946 | int |
| 947 | sys_shutdown(tcp) |
| 948 | struct tcb *tcp; |
| 949 | { |
| 950 | if (entering(tcp)) { |
| 951 | tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]); |
| 952 | switch (tcp->u_arg[1]) { |
| 953 | case 0: |
| 954 | tprintf("%s", " /* receive */"); |
| 955 | break; |
| 956 | case 1: |
| 957 | tprintf("%s", " /* send */"); |
| 958 | break; |
| 959 | case 2: |
| 960 | tprintf("%s", " /* send and receive */"); |
| 961 | break; |
| 962 | } |
| 963 | } |
| 964 | return 0; |
| 965 | } |
| 966 | |
| 967 | int |
| 968 | sys_getsockname(tcp) |
| 969 | struct tcb *tcp; |
| 970 | { |
| 971 | return sys_accept(tcp); |
| 972 | } |
| 973 | |
| 974 | int |
| 975 | sys_getpeername(tcp) |
| 976 | struct tcb *tcp; |
| 977 | { |
| 978 | return sys_accept(tcp); |
| 979 | } |
| 980 | |
| 981 | int |
| 982 | sys_pipe(tcp) |
| 983 | struct tcb *tcp; |
| 984 | { |
| 985 | |
| 986 | #if defined(LINUX) && !defined(SPARC) |
| 987 | int fds[2]; |
| 988 | |
| 989 | if (exiting(tcp)) { |
| 990 | if (syserror(tcp)) { |
| 991 | tprintf("%#lx", tcp->u_arg[0]); |
| 992 | return 0; |
| 993 | } |
| 994 | if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) |
| 995 | tprintf("[...]"); |
| 996 | else |
| 997 | tprintf("[%u, %u]", fds[0], fds[1]); |
| 998 | } |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 999 | #elif defined(SPARC) || defined(SVR4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1000 | if (exiting(tcp)) |
| 1001 | tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1002 | #endif |
| 1003 | return 0; |
| 1004 | } |
| 1005 | |
| 1006 | int |
| 1007 | sys_socketpair(tcp) |
| 1008 | struct tcb *tcp; |
| 1009 | { |
| 1010 | #ifdef LINUX |
| 1011 | int fds[2]; |
| 1012 | #endif |
| 1013 | |
| 1014 | if (entering(tcp)) { |
| 1015 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 1016 | tprintf(", "); |
| 1017 | printxval(socktypes, tcp->u_arg[1], "SOCK_???"); |
| 1018 | tprintf(", "); |
| 1019 | switch (tcp->u_arg[0]) { |
| 1020 | case PF_INET: |
| 1021 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 1022 | break; |
| 1023 | #ifdef PF_IPX |
| 1024 | case PF_IPX: |
| 1025 | /* BTW: I don't believe this.. */ |
| 1026 | tprintf("["); |
| 1027 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 1028 | tprintf("]"); |
| 1029 | break; |
| 1030 | #endif /* PF_IPX */ |
| 1031 | default: |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1032 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1033 | break; |
| 1034 | } |
| 1035 | } else { |
| 1036 | if (syserror(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1037 | tprintf(", %#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1038 | return 0; |
| 1039 | } |
| 1040 | #ifdef LINUX |
| 1041 | if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1042 | tprintf(", [...]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1043 | else |
| 1044 | tprintf(", [%u, %u]", fds[0], fds[1]); |
| 1045 | #endif /* LINUX */ |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 1046 | #if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1047 | tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
Wichert Akkerman | 2e4ffe5 | 2000-09-03 23:57:48 +0000 | [diff] [blame] | 1048 | #endif /* SUNOS4 || SVR4 || FREEBSD */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1049 | } |
| 1050 | return 0; |
| 1051 | } |
| 1052 | |
| 1053 | int |
| 1054 | sys_getsockopt(tcp) |
| 1055 | struct tcb *tcp; |
| 1056 | { |
| 1057 | if (entering(tcp)) { |
| 1058 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1059 | switch (tcp->u_arg[1]) { |
| 1060 | case SOL_SOCKET: |
| 1061 | tprintf("SOL_SOCKET, "); |
| 1062 | printxval(sockoptions, tcp->u_arg[2], "SO_???"); |
| 1063 | tprintf(", "); |
| 1064 | break; |
| 1065 | #ifdef SOL_IP |
| 1066 | case SOL_IP: |
| 1067 | tprintf("SOL_IP, "); |
| 1068 | printxval(sockipoptions, tcp->u_arg[2], "IP_???"); |
| 1069 | tprintf(", "); |
| 1070 | break; |
| 1071 | #endif |
| 1072 | #ifdef SOL_IPX |
| 1073 | case SOL_IPX: |
| 1074 | tprintf("SOL_IPX, "); |
| 1075 | printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); |
| 1076 | tprintf(", "); |
| 1077 | break; |
| 1078 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1079 | #ifdef SOL_PACKET |
| 1080 | case SOL_PACKET: |
| 1081 | tprintf("SOL_PACKET, "); |
| 1082 | printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); |
| 1083 | tprintf(", "); |
| 1084 | break; |
| 1085 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1086 | #ifdef SOL_TCP |
| 1087 | case SOL_TCP: |
| 1088 | tprintf("SOL_TCP, "); |
| 1089 | printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); |
| 1090 | tprintf(", "); |
| 1091 | break; |
| 1092 | #endif |
| 1093 | |
| 1094 | /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
| 1095 | * etc. still need work */ |
| 1096 | default: |
| 1097 | /* XXX - should know socket family here */ |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame^] | 1098 | printxval(socketlayers, tcp->u_arg[1], "SOL_???"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1099 | tprintf(", %lu, ", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1100 | break; |
| 1101 | } |
| 1102 | } else { |
| 1103 | if (syserror(tcp)) { |
| 1104 | tprintf("%#lx, %#lx", |
| 1105 | tcp->u_arg[3], tcp->u_arg[4]); |
| 1106 | return 0; |
| 1107 | } |
| 1108 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1109 | tprintf(", "); |
| 1110 | printnum(tcp, tcp->u_arg[4], "%ld"); |
| 1111 | } |
| 1112 | return 0; |
| 1113 | } |
| 1114 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1115 | #if defined(ICMP_FILTER) |
| 1116 | static void printicmpfilter(tcp, addr) |
| 1117 | struct tcb *tcp; |
| 1118 | long addr; |
| 1119 | { |
| 1120 | struct icmp_filter filter; |
| 1121 | |
| 1122 | if (!addr) { |
| 1123 | tprintf("NULL"); |
| 1124 | return; |
| 1125 | } |
| 1126 | if (syserror(tcp) || !verbose(tcp)) { |
| 1127 | tprintf("%#lx", addr); |
| 1128 | return; |
| 1129 | } |
| 1130 | if (umove(tcp, addr, &filter) < 0) { |
| 1131 | tprintf("{...}"); |
| 1132 | return; |
| 1133 | } |
| 1134 | |
| 1135 | tprintf("~("); |
| 1136 | if (printflags(icmpfilterflags, ~filter.data) == 0) |
| 1137 | tprintf("0"); |
| 1138 | tprintf(")"); |
| 1139 | } |
| 1140 | #endif /* ICMP_FILTER */ |
| 1141 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1142 | int |
| 1143 | sys_setsockopt(tcp) |
| 1144 | struct tcb *tcp; |
| 1145 | { |
| 1146 | if (entering(tcp)) { |
| 1147 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1148 | switch (tcp->u_arg[1]) { |
| 1149 | case SOL_SOCKET: |
| 1150 | tprintf("SOL_SOCKET, "); |
| 1151 | printxval(sockoptions, tcp->u_arg[2], "SO_???"); |
| 1152 | tprintf(", "); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1153 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1154 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1155 | break; |
| 1156 | #ifdef SOL_IP |
| 1157 | case SOL_IP: |
| 1158 | tprintf("SOL_IP, "); |
| 1159 | printxval(sockipoptions, tcp->u_arg[2], "IP_???"); |
| 1160 | tprintf(", "); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1161 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1162 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1163 | break; |
| 1164 | #endif |
| 1165 | #ifdef SOL_IPX |
| 1166 | case SOL_IPX: |
| 1167 | tprintf("SOL_IPX, "); |
| 1168 | printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); |
| 1169 | tprintf(", "); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1170 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1171 | tprintf(", %lu", tcp->u_arg[4]); |
| 1172 | break; |
| 1173 | #endif |
| 1174 | #ifdef SOL_PACKET |
| 1175 | case SOL_PACKET: |
| 1176 | tprintf("SOL_PACKET, "); |
| 1177 | printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); |
| 1178 | tprintf(", "); |
| 1179 | /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */ |
| 1180 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1181 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1182 | break; |
| 1183 | #endif |
| 1184 | #ifdef SOL_TCP |
| 1185 | case SOL_TCP: |
| 1186 | tprintf("SOL_TCP, "); |
| 1187 | printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); |
| 1188 | tprintf(", "); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1189 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1190 | tprintf(", %lu", tcp->u_arg[4]); |
| 1191 | break; |
| 1192 | #endif |
| 1193 | #ifdef SOL_RAW |
| 1194 | case SOL_RAW: |
| 1195 | tprintf("SOL_RAW, "); |
| 1196 | printxval(sockrawoptions, tcp->u_arg[2], "RAW_???"); |
| 1197 | tprintf(", "); |
| 1198 | switch (tcp->u_arg[2]) { |
| 1199 | #if defined(ICMP_FILTER) |
| 1200 | case ICMP_FILTER: |
| 1201 | printicmpfilter(tcp, tcp->u_arg[3]); |
| 1202 | break; |
| 1203 | #endif |
| 1204 | default: |
| 1205 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1206 | break; |
| 1207 | } |
| 1208 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1209 | break; |
| 1210 | #endif |
| 1211 | |
| 1212 | /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
| 1213 | * etc. still need work */ |
| 1214 | default: |
| 1215 | /* XXX - should know socket family here */ |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame^] | 1216 | printxval(socketlayers, tcp->u_arg[1], "IPPROTO_???"); |
| 1217 | tprintf(", %lu, ", tcp->u_arg[2]); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1218 | printnum(tcp, tcp->u_arg[3], "%ld"); |
| 1219 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1220 | break; |
| 1221 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1222 | } |
| 1223 | return 0; |
| 1224 | } |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame] | 1225 | |
| 1226 | #if UNIXWARE >= 7 |
| 1227 | |
| 1228 | static struct xlat sock_version[] = { |
| 1229 | { __NETLIB_UW211_SVR4, "UW211_SVR4" }, |
| 1230 | { __NETLIB_UW211_XPG4, "UW211_XPG4" }, |
| 1231 | { __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" }, |
| 1232 | { __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" }, |
| 1233 | { __NETLIB_FP1_SVR4, "FP1_SVR4" }, |
| 1234 | { __NETLIB_FP1_XPG4, "FP1_XPG4" }, |
| 1235 | { 0, NULL }, |
| 1236 | }; |
| 1237 | |
| 1238 | |
| 1239 | int |
| 1240 | netlib_call(tcp, func) |
| 1241 | struct tcb *tcp; |
| 1242 | int (*func) (); |
| 1243 | { |
| 1244 | if (entering(tcp)) { |
| 1245 | int i; |
| 1246 | printxval (sock_version, tcp->u_arg[0], "__NETLIB_???"); |
| 1247 | tprintf(", "); |
| 1248 | --tcp->u_nargs; |
| 1249 | for (i = 0; i < tcp->u_nargs; i++) |
| 1250 | tcp->u_arg[i] = tcp->u_arg[i + 1]; |
| 1251 | return func (tcp); |
| 1252 | |
| 1253 | } |
| 1254 | |
| 1255 | return func (tcp); |
| 1256 | } |
| 1257 | |
| 1258 | int |
| 1259 | sys_xsocket(tcp) |
| 1260 | struct tcb *tcp; |
| 1261 | { |
| 1262 | return netlib_call (tcp, sys_socket); |
| 1263 | } |
| 1264 | |
| 1265 | int |
| 1266 | sys_xsocketpair(tcp) |
| 1267 | struct tcb *tcp; |
| 1268 | { |
| 1269 | return netlib_call (tcp, sys_socketpair); |
| 1270 | } |
| 1271 | |
| 1272 | int |
| 1273 | sys_xbind(tcp) |
| 1274 | struct tcb *tcp; |
| 1275 | { |
| 1276 | return netlib_call (tcp, sys_bind); |
| 1277 | } |
| 1278 | |
| 1279 | int |
| 1280 | sys_xconnect(tcp) |
| 1281 | struct tcb *tcp; |
| 1282 | { |
| 1283 | return netlib_call (tcp, sys_connect); |
| 1284 | } |
| 1285 | |
| 1286 | int |
| 1287 | sys_xlisten(tcp) |
| 1288 | struct tcb *tcp; |
| 1289 | { |
| 1290 | return netlib_call (tcp, sys_listen); |
| 1291 | } |
| 1292 | |
| 1293 | int |
| 1294 | sys_xaccept(tcp) |
| 1295 | struct tcb *tcp; |
| 1296 | { |
| 1297 | return netlib_call (tcp, sys_accept); |
| 1298 | } |
| 1299 | |
| 1300 | int |
| 1301 | sys_xsendmsg(tcp) |
| 1302 | struct tcb *tcp; |
| 1303 | { |
| 1304 | return netlib_call (tcp, sys_sendmsg); |
| 1305 | } |
| 1306 | |
| 1307 | int |
| 1308 | sys_xrecvmsg(tcp) |
| 1309 | struct tcb *tcp; |
| 1310 | { |
| 1311 | return netlib_call (tcp, sys_recvmsg); |
| 1312 | } |
| 1313 | |
| 1314 | int |
| 1315 | sys_xgetsockaddr(tcp) |
| 1316 | struct tcb *tcp; |
| 1317 | { |
| 1318 | if (entering(tcp)) { |
| 1319 | printxval (sock_version, tcp->u_arg[0], "__NETLIB_???"); |
| 1320 | tprintf(", "); |
| 1321 | if (tcp->u_arg[1] == 0) { |
| 1322 | tprintf ("LOCALNAME, "); |
| 1323 | } |
| 1324 | else if (tcp->u_arg[1] == 1) { |
| 1325 | tprintf ("REMOTENAME, "); |
| 1326 | } |
| 1327 | else { |
| 1328 | tprintf ("%ld, ", tcp->u_arg [1]); |
| 1329 | } |
| 1330 | tprintf ("%ld, ", tcp->u_arg [2]); |
| 1331 | } |
| 1332 | else { |
| 1333 | if (tcp->u_arg[3] == 0 || syserror(tcp)) { |
| 1334 | tprintf("%#lx", tcp->u_arg[3]); |
| 1335 | } else { |
| 1336 | printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]); |
| 1337 | } |
| 1338 | tprintf(", "); |
| 1339 | printnum(tcp, tcp->u_arg[4], "%lu"); |
| 1340 | } |
| 1341 | |
| 1342 | return 0; |
| 1343 | |
| 1344 | } |
| 1345 | |
| 1346 | #if 0 |
| 1347 | |
| 1348 | int |
| 1349 | sys_xsetsockaddr(tcp) |
| 1350 | struct tcb *tcp; |
| 1351 | { |
| 1352 | return netlib_call (tcp, sys_setsockaddr); |
| 1353 | } |
| 1354 | |
| 1355 | #endif |
| 1356 | |
| 1357 | int |
| 1358 | sys_xgetsockopt(tcp) |
| 1359 | struct tcb *tcp; |
| 1360 | { |
| 1361 | return netlib_call (tcp, sys_getsockopt); |
| 1362 | } |
| 1363 | |
| 1364 | int |
| 1365 | sys_xsetsockopt(tcp) |
| 1366 | struct tcb *tcp; |
| 1367 | { |
| 1368 | return netlib_call (tcp, sys_setsockopt); |
| 1369 | } |
| 1370 | |
| 1371 | int |
| 1372 | sys_xshutdown(tcp) |
| 1373 | struct tcb *tcp; |
| 1374 | { |
| 1375 | return netlib_call (tcp, sys_shutdown); |
| 1376 | } |
| 1377 | |
| 1378 | #endif |