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