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> |
| 39 | #include <arpa/inet.h> |
| 40 | #if defined(LINUX) |
| 41 | #include <asm/types.h> |
| 42 | #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3) |
| 43 | # include <netipx/ipx.h> |
| 44 | #else |
| 45 | # include <linux/ipx.h> |
| 46 | #endif |
| 47 | #endif /* LINUX */ |
| 48 | |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 49 | #if defined (__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 50 | #if defined(HAVE_LINUX_IN6_H) |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 51 | #include <linux/in6.h> |
| 52 | #endif |
Wichert Akkerman | 2f473da | 1999-11-01 19:53:31 +0000 | [diff] [blame] | 53 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 54 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 55 | #if defined(HAVE_SYS_UIO_H) |
| 56 | #include <sys/uio.h> |
| 57 | #endif |
| 58 | |
| 59 | #if defined(HAVE_LINUX_NETLINK_H) |
| 60 | #include <linux/netlink.h> |
| 61 | #endif |
| 62 | |
| 63 | #if defined(HAVE_LINUX_IF_PACKET_H) |
| 64 | #include <linux/if_packet.h> |
| 65 | #endif |
| 66 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 67 | #if defined(HAVE_LINUX_ICMP_H) |
| 68 | #include <linux/icmp.h> |
| 69 | #endif |
| 70 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 71 | #ifndef PF_UNSPEC |
| 72 | #define PF_UNSPEC AF_UNSPEC |
| 73 | #endif |
| 74 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame^] | 75 | #if UNIXWARE >= 7 |
| 76 | #define HAVE_SENDMSG 1 /* HACK - *FIXME* */ |
| 77 | #endif |
| 78 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 79 | #ifdef LINUX |
| 80 | /* Under Linux these are enums so we can't test for them with ifdef. */ |
| 81 | #define IPPROTO_EGP IPPROTO_EGP |
| 82 | #define IPPROTO_PUP IPPROTO_PUP |
| 83 | #define IPPROTO_IDP IPPROTO_IDP |
| 84 | #define IPPROTO_IGMP IPPROTO_IGMP |
| 85 | #define IPPROTO_RAW IPPROTO_RAW |
| 86 | #define IPPROTO_MAX IPPROTO_MAX |
| 87 | #endif |
| 88 | |
| 89 | static struct xlat domains[] = { |
| 90 | { PF_UNSPEC, "PF_UNSPEC" }, |
| 91 | { PF_UNIX, "PF_UNIX" }, |
| 92 | { PF_INET, "PF_INET" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 93 | #ifdef PF_NETLINK |
| 94 | { PF_NETLINK, "PF_NETLINK" }, |
| 95 | #endif |
| 96 | #ifdef PF_PACKET |
| 97 | { PF_PACKET, "PF_PACKET" }, |
| 98 | #endif |
| 99 | #ifdef PF_INET6 |
| 100 | { PF_INET6, "PF_INET6" }, |
| 101 | #endif |
| 102 | #ifdef PF_ATMSVC |
| 103 | { PF_ATMSVC, "PF_INET6" }, |
| 104 | #endif |
| 105 | #ifdef PF_INET6 |
| 106 | { PF_INET6, "PF_INET6" }, |
| 107 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 108 | #ifdef PF_LOCAL |
| 109 | { PF_LOCAL, "PS_LOCAL" }, |
| 110 | #endif |
| 111 | #ifdef PF_ISO |
| 112 | { PF_ISO, "PF_ISO" }, |
| 113 | #endif |
| 114 | #ifdef PF_AX25 |
| 115 | { PF_AX25, "PF_AX25" }, |
| 116 | #endif |
| 117 | #ifdef PF_IPX |
| 118 | { PF_IPX, "PF_IPX" }, |
| 119 | #endif |
| 120 | #ifdef PF_APPLETALK |
| 121 | { PF_APPLETALK, "PF_APPLETALK" }, |
| 122 | #endif |
| 123 | #ifdef PF_NETROM |
| 124 | { PF_NETROM, "PF_NETROM" }, |
| 125 | #endif |
| 126 | #ifdef PF_BRIDGE |
| 127 | { PF_BRIDGE, "PF_BRIDGE" }, |
| 128 | #endif |
| 129 | #ifdef PF_AAL5 |
| 130 | { PF_AAL5, "PF_AAL5" }, |
| 131 | #endif |
| 132 | #ifdef PF_X25 |
| 133 | { PF_X25, "PF_X25" }, |
| 134 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 135 | #ifdef PF_ROSE |
| 136 | { PF_ROSE, "PF_ROSE" }, |
| 137 | #endif |
| 138 | #ifdef PF_DECNET |
| 139 | { PF_DECNET, "PF_DECNET" }, |
| 140 | #endif |
| 141 | #ifdef PF_NETBEUI |
| 142 | { PF_NETBEUI, "PF_NETBEUI" }, |
| 143 | #endif |
| 144 | #ifdef PF_IMPLINK |
| 145 | { PF_IMPLINK, "PF_IMPLINK" }, |
| 146 | #endif |
| 147 | { 0, NULL }, |
| 148 | }; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 149 | static struct xlat addrfams[] = { |
| 150 | { AF_UNSPEC, "AF_UNSPEC" }, |
| 151 | { AF_UNIX, "AF_UNIX" }, |
| 152 | { AF_INET, "AF_INET" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 153 | #ifdef AF_INET6 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 154 | { AF_INET6, "AF_INET6" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 155 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 156 | { AF_DECnet, "AF_DECnet" }, |
| 157 | #ifdef PF_ATMSVC |
| 158 | { AF_ATMSVC, "AF_ATMSVC" }, |
| 159 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 160 | #ifdef AF_PACKET |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 161 | { AF_PACKET, "AF_PACKET" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 162 | #endif |
| 163 | #ifdef AF_NETLINK |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 164 | { AF_NETLINK, "AF_NETLINK" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 165 | #endif |
| 166 | #ifdef AF_ISO |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 167 | { AF_ISO, "AF_ISO" }, |
| 168 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 169 | #ifdef AF_IMPLINK |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 170 | { AF_IMPLINK, "AF_IMPLINK" }, |
| 171 | #endif |
| 172 | { 0, NULL }, |
| 173 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | static struct xlat socktypes[] = { |
| 175 | { SOCK_STREAM, "SOCK_STREAM" }, |
| 176 | { SOCK_DGRAM, "SOCK_DGRAM" }, |
| 177 | #ifdef SOCK_RAW |
| 178 | { SOCK_RAW, "SOCK_RAW" }, |
| 179 | #endif |
| 180 | #ifdef SOCK_SEQPACKET |
| 181 | { SOCK_SEQPACKET,"SOCK_SEQPACKET"}, |
| 182 | #endif |
| 183 | #ifdef SOCK_RDM |
| 184 | { SOCK_RDM, "SOCK_RDM" }, |
| 185 | #endif |
| 186 | #ifdef SOCK_PACKET |
| 187 | { SOCK_PACKET, "SOCK_PACKET" }, |
| 188 | #endif |
| 189 | { 0, NULL }, |
| 190 | }; |
| 191 | static struct xlat protocols[] = { |
| 192 | { IPPROTO_IP, "IPPROTO_IP" }, |
| 193 | { IPPROTO_ICMP, "IPPROTO_ICMP" }, |
| 194 | { IPPROTO_TCP, "IPPROTO_TCP" }, |
| 195 | { IPPROTO_UDP, "IPPROTO_UDP" }, |
| 196 | #ifdef IPPROTO_GGP |
| 197 | { IPPROTO_GGP, "IPPROTO_GGP" }, |
| 198 | #endif |
| 199 | #ifdef IPPROTO_EGP |
| 200 | { IPPROTO_EGP, "IPPROTO_EGP" }, |
| 201 | #endif |
| 202 | #ifdef IPPROTO_PUP |
| 203 | { IPPROTO_PUP, "IPPROTO_PUP" }, |
| 204 | #endif |
| 205 | #ifdef IPPROTO_IDP |
| 206 | { IPPROTO_IDP, "IPPROTO_IDP" }, |
| 207 | #endif |
| 208 | #ifdef IPPROTO_IPV6 |
| 209 | { IPPROTO_IPV6, "IPPROTO_IPV6" }, |
| 210 | #endif |
| 211 | #ifdef IPPROTO_ICMPV6 |
| 212 | { IPPROTO_ICMPV6,"IPPROTO_ICMPV6"}, |
| 213 | #endif |
| 214 | #ifdef IPPROTO_IGMP |
| 215 | { IPPROTO_IGMP, "IPPROTO_IGMP" }, |
| 216 | #endif |
| 217 | #ifdef IPPROTO_HELLO |
| 218 | { IPPROTO_HELLO,"IPPROTO_HELLO" }, |
| 219 | #endif |
| 220 | #ifdef IPPROTO_ND |
| 221 | { IPPROTO_ND, "IPPROTO_ND" }, |
| 222 | #endif |
| 223 | #ifdef IPPROTO_RAW |
| 224 | { IPPROTO_RAW, "IPPROTO_RAW" }, |
| 225 | #endif |
| 226 | #ifdef IPPROTO_MAX |
| 227 | { IPPROTO_MAX, "IPPROTO_MAX" }, |
| 228 | #endif |
| 229 | #ifdef IPPROTO_IPIP |
| 230 | { IPPROTO_IPIP, "IPPROTO_IPIP" }, |
| 231 | #endif |
| 232 | { 0, NULL }, |
| 233 | }; |
| 234 | static struct xlat msg_flags[] = { |
| 235 | { MSG_OOB, "MSG_OOB" }, |
| 236 | #ifdef MSG_DONTROUTE |
| 237 | { MSG_DONTROUTE,"MSG_DONTROUTE" }, |
| 238 | #endif |
| 239 | #ifdef MSG_PEEK |
| 240 | { MSG_PEEK, "MSG_PEEK" }, |
| 241 | #endif |
| 242 | #ifdef MSG_CTRUNC |
| 243 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
| 244 | #endif |
| 245 | #ifdef MSG_PROXY |
| 246 | { MSG_PROXY, "MSG_PROXY" }, |
| 247 | #endif |
| 248 | #ifdef MSG_EOR |
| 249 | { MSG_EOR, "MSG_EOR" }, |
| 250 | #endif |
| 251 | #ifdef MSG_WAITALL |
| 252 | { MSG_WAITALL, "MSG_WAITALL" }, |
| 253 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 254 | #ifdef MSG_TRUNC |
| 255 | { MSG_TRUNC, "MSG_TRUNC" }, |
| 256 | #endif |
| 257 | #ifdef MSG_CTRUNC |
| 258 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
| 259 | #endif |
| 260 | #ifdef MSG_ERRQUEUE |
| 261 | { MSG_ERRQUEUE, "MSG_ERRQUEUE" }, |
| 262 | #endif |
| 263 | #ifdef MSG_DONTWAIT |
| 264 | { MSG_DONTWAIT, "MSG_DONTWAIT" }, |
| 265 | #endif |
| 266 | #ifdef MSG_CONFIRM |
| 267 | { MSG_CONFIRM, "MSG_CONFIRM" }, |
| 268 | #endif |
| 269 | #ifdef MSG_PROBE |
| 270 | { MSG_PROBE, "MSG_PROBE" }, |
| 271 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 272 | { 0, NULL }, |
| 273 | }; |
| 274 | |
| 275 | static struct xlat sockoptions[] = { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 276 | #ifdef SO_PEERCRED |
| 277 | { SO_PEERCRED, "SO_PEERCRED" }, |
| 278 | #endif |
| 279 | #ifdef SO_PASSCRED |
| 280 | { SO_PASSCRED, "SO_PASSCRED" }, |
| 281 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 282 | #ifdef SO_DEBUG |
| 283 | { SO_DEBUG, "SO_DEBUG" }, |
| 284 | #endif |
| 285 | #ifdef SO_REUSEADDR |
| 286 | { SO_REUSEADDR, "SO_REUSEADDR" }, |
| 287 | #endif |
| 288 | #ifdef SO_KEEPALIVE |
| 289 | { SO_KEEPALIVE, "SO_KEEPALIVE" }, |
| 290 | #endif |
| 291 | #ifdef SO_DONTROUTE |
| 292 | { SO_DONTROUTE, "SO_DONTROUTE" }, |
| 293 | #endif |
| 294 | #ifdef SO_BROADCAST |
| 295 | { SO_BROADCAST, "SO_BROADCAST" }, |
| 296 | #endif |
| 297 | #ifdef SO_LINGER |
| 298 | { SO_LINGER, "SO_LINGER" }, |
| 299 | #endif |
| 300 | #ifdef SO_OOBINLINE |
| 301 | { SO_OOBINLINE, "SO_OOBINLINE" }, |
| 302 | #endif |
| 303 | #ifdef SO_TYPE |
| 304 | { SO_TYPE, "SO_TYPE" }, |
| 305 | #endif |
| 306 | #ifdef SO_ERROR |
| 307 | { SO_ERROR, "SO_ERROR" }, |
| 308 | #endif |
| 309 | #ifdef SO_SNDBUF |
| 310 | { SO_SNDBUF, "SO_SNDBUF" }, |
| 311 | #endif |
| 312 | #ifdef SO_RCVBUF |
| 313 | { SO_RCVBUF, "SO_RCVBUF" }, |
| 314 | #endif |
| 315 | #ifdef SO_NO_CHECK |
| 316 | { SO_NO_CHECK, "SO_NO_CHECK" }, |
| 317 | #endif |
| 318 | #ifdef SO_PRIORITY |
| 319 | { SO_PRIORITY, "SO_PRIORITY" }, |
| 320 | #endif |
| 321 | #ifdef SO_ACCEPTCONN |
| 322 | { SO_ACCEPTCONN,"SO_ACCEPTCONN" }, |
| 323 | #endif |
| 324 | #ifdef SO_USELOOPBACK |
| 325 | { SO_USELOOPBACK,"SO_USELOOPBACK"}, |
| 326 | #endif |
| 327 | #ifdef SO_SNDLOWAT |
| 328 | { SO_SNDLOWAT, "SO_SNDLOWAT" }, |
| 329 | #endif |
| 330 | #ifdef SO_RCVLOWAT |
| 331 | { SO_RCVLOWAT, "SO_RCVLOWAT" }, |
| 332 | #endif |
| 333 | #ifdef SO_SNDTIMEO |
| 334 | { SO_SNDTIMEO, "SO_SNDTIMEO" }, |
| 335 | #endif |
| 336 | #ifdef SO_RCVTIMEO |
| 337 | { SO_RCVTIMEO, "SO_RCVTIMEO" }, |
| 338 | #endif |
| 339 | #ifdef SO_BSDCOMPAT |
| 340 | { SO_BSDCOMPAT, "SO_BSDCOMPAT" }, |
| 341 | #endif |
| 342 | #ifdef SO_REUSEPORT |
| 343 | { SO_REUSEPORT, "SO_REUSEPORT" }, |
| 344 | #endif |
| 345 | #ifdef SO_RCVLOWAT |
| 346 | { SO_RCVLOWAT, "SO_RCVLOWAT" }, |
| 347 | #endif |
| 348 | #ifdef SO_SNDLOWAT |
| 349 | { SO_SNDLOWAT, "SO_SNDLOWAT" }, |
| 350 | #endif |
| 351 | #ifdef SO_RCVTIMEO |
| 352 | { SO_RCVTIMEO, "SO_RCVTIMEO" }, |
| 353 | #endif |
| 354 | #ifdef SO_SNDTIMEO |
| 355 | { SO_SNDTIMEO, "SO_SNDTIMEO" }, |
| 356 | #endif |
| 357 | { 0, NULL }, |
| 358 | }; |
| 359 | |
| 360 | #ifdef SOL_IP |
| 361 | static struct xlat sockipoptions[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 362 | { IP_TOS, "IP_TOS" }, |
| 363 | { IP_TTL, "IP_TTL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 364 | #if defined(IP_HDRINCL) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 365 | { IP_HDRINCL, "IP_HDRINCL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 366 | #endif |
| 367 | #if defined(IP_OPTIONS) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 368 | { IP_OPTIONS, "IP_OPTIONS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 369 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 370 | { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" }, |
| 371 | #if defined(IP_RECVOPTIONS) |
| 372 | { IP_RECVOPTIONS, "IP_RECVOPTIONS" }, |
| 373 | #endif |
| 374 | { IP_RETOPTS, "IP_RETOPTS" }, |
| 375 | { IP_PKTINFO, "IP_PKTINFO" }, |
| 376 | { IP_PKTOPTIONS, "IP_PKTOPTIONS" }, |
| 377 | { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, |
| 378 | { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, |
| 379 | { IP_RECVERR, "IP_RECVERR" }, |
| 380 | { IP_RECVTTL, "IP_RECRECVTTL" }, |
| 381 | { IP_RECVTOS, "IP_RECRECVTOS" }, |
| 382 | #if defined(IP_MTU) |
| 383 | { IP_MTU, "IP_MTU" }, |
| 384 | #endif |
| 385 | { IP_MULTICAST_IF, "IP_MULTICAST_IF" }, |
| 386 | { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" }, |
| 387 | { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" }, |
| 388 | { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" }, |
| 389 | { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" }, |
| 390 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 391 | }; |
| 392 | #endif /* SOL_IP */ |
| 393 | |
| 394 | #ifdef SOL_IPX |
| 395 | static struct xlat sockipxoptions[] = { |
| 396 | { IPX_TYPE, "IPX_TYPE" }, |
| 397 | { 0, NULL }, |
| 398 | }; |
| 399 | #endif /* SOL_IPX */ |
| 400 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 401 | #ifdef SOL_RAW |
| 402 | static struct xlat sockrawoptions[] = { |
| 403 | #if defined(ICMP_FILTER) |
| 404 | { ICMP_FILTER, "ICMP_FILTER" }, |
| 405 | #endif |
| 406 | { 0, NULL }, |
| 407 | }; |
| 408 | #endif /* SOL_RAW */ |
| 409 | |
| 410 | #ifdef SOL_PACKET |
| 411 | static struct xlat sockpacketoptions[] = { |
| 412 | { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" }, |
| 413 | { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"}, |
| 414 | #if defined(PACKET_RECV_OUTPUT) |
| 415 | { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" }, |
| 416 | #endif |
| 417 | #if defined(PACKET_RX_RING) |
| 418 | { PACKET_RX_RING, "PACKET_RX_RING" }, |
| 419 | #endif |
| 420 | #if defined(PACKET_STATISTICS) |
| 421 | { PACKET_STATISTICS, "PACKET_STATISTICS" }, |
| 422 | #endif |
| 423 | { 0, NULL }, |
| 424 | }; |
| 425 | #endif /* SOL_PACKET */ |
| 426 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 427 | #ifdef SOL_TCP |
| 428 | static struct xlat socktcpoptions[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 429 | { TCP_NODELAY, "TCP_NODELAY" }, |
| 430 | { TCP_MAXSEG, "TCP_MAXSEG" }, |
| 431 | #if defined(TCP_CORK) |
| 432 | { TCP_CORK, "TCP_CORK" }, |
| 433 | #endif |
| 434 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 435 | }; |
| 436 | #endif /* SOL_TCP */ |
| 437 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 438 | #ifdef SOL_RAW |
| 439 | static struct xlat icmpfilterflags[] = { |
| 440 | #if defined(ICMP_ECHOREPLY) |
| 441 | { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" }, |
| 442 | #endif |
| 443 | #if defined(ICMP_DEST_UNREACH) |
| 444 | { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" }, |
| 445 | #endif |
| 446 | #if defined(ICMP_SOURCE_QUENCH) |
| 447 | { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" }, |
| 448 | #endif |
| 449 | #if defined(ICMP_REDIRECT) |
| 450 | { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" }, |
| 451 | #endif |
| 452 | #if defined(ICMP_ECHO) |
| 453 | { (1<<ICMP_ECHO), "ICMP_ECHO" }, |
| 454 | #endif |
| 455 | #if defined(ICMP_TIME_EXCEEDED) |
| 456 | { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" }, |
| 457 | #endif |
| 458 | #if defined(ICMP_PARAMETERPROB) |
| 459 | { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" }, |
| 460 | #endif |
| 461 | #if defined(ICMP_TIMESTAMP) |
| 462 | { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" }, |
| 463 | #endif |
| 464 | #if defined(ICMP_TIMESTAMPREPLY) |
| 465 | { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" }, |
| 466 | #endif |
| 467 | #if defined(ICMP_INFO_REQUEST) |
| 468 | { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" }, |
| 469 | #endif |
| 470 | #if defined(ICMP_INFO_REPLY) |
| 471 | { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" }, |
| 472 | #endif |
| 473 | #if defined(ICMP_ADDRESS) |
| 474 | { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" }, |
| 475 | #endif |
| 476 | #if defined(ICMP_ADDRESSREPLY) |
| 477 | { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" }, |
| 478 | #endif |
| 479 | { 0, NULL }, |
| 480 | }; |
| 481 | #endif /* SOL_RAW */ |
| 482 | |
Wichert Akkerman | 16a03d2 | 2000-08-10 02:14:04 +0000 | [diff] [blame^] | 483 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 484 | void |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 485 | printsock(tcp, addr, addrlen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 486 | struct tcb *tcp; |
| 487 | long addr; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 488 | int addrlen; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 489 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 490 | union { |
| 491 | char pad[128]; |
| 492 | struct sockaddr sa; |
| 493 | struct sockaddr_in sin; |
| 494 | struct sockaddr_un sau; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 495 | #ifdef HAVE_INET_NTOP |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 496 | struct sockaddr_in6 sa6; |
| 497 | #endif |
| 498 | #if defined(LINUX) && defined(AF_IPX) |
| 499 | struct sockaddr_ipx sipx; |
| 500 | #endif |
| 501 | #ifdef AF_PACKET |
| 502 | struct sockaddr_ll ll; |
| 503 | #endif |
| 504 | #ifdef AF_NETLINK |
| 505 | struct sockaddr_nl nl; |
| 506 | #endif |
| 507 | } addrbuf; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 508 | char string_addr[100]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 509 | |
| 510 | if (addr == 0) { |
| 511 | tprintf("NULL"); |
| 512 | return; |
| 513 | } |
| 514 | if (!verbose(tcp)) { |
| 515 | tprintf("%#lx", addr); |
| 516 | return; |
| 517 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 518 | if ((addrlen<2) || (addrlen>sizeof(addrbuf))) |
| 519 | addrlen=sizeof(addrbuf); |
| 520 | |
| 521 | if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 522 | tprintf("{...}"); |
| 523 | return; |
| 524 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 525 | |
| 526 | tprintf("{sin_family="); |
| 527 | printxval(addrfams, addrbuf.sa.sa_family, "AF_???"); |
| 528 | tprintf(", "); |
| 529 | |
| 530 | switch (addrbuf.sa.sa_family) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 531 | case AF_UNIX: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 532 | if (addrlen==2) { |
| 533 | tprintf("<nil>"); |
| 534 | } else if (addrbuf.sau.sun_path[0]) { |
| 535 | tprintf("path=\"%*.*s\"", addrlen-2, addrlen-2, addrbuf.sau.sun_path); |
| 536 | } else { |
| 537 | tprintf("path=@%*.*s", addrlen-3, addrlen-3, addrbuf.sau.sun_path+1); |
| 538 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 539 | break; |
| 540 | case AF_INET: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 541 | tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 542 | ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 543 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 544 | #ifdef HAVE_INET_NTOP |
| 545 | case AF_INET6: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 546 | inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr)); |
| 547 | tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=htonl(%u)}", |
| 548 | ntohs(addrbuf.sa6.sin6_port), string_addr, ntohl(addrbuf.sa6.sin6_flowinfo)); |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 549 | break; |
| 550 | #endif |
Wichert Akkerman | dbb440e | 1999-05-11 15:06:44 +0000 | [diff] [blame] | 551 | #if defined(AF_IPX) && defined(linux) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 552 | case AF_IPX: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 553 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 554 | int i; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 555 | tprintf("{sipx_port=htons(%u), ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 556 | ntohs(addrbuf.sipx.sipx_port)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 557 | /* Yes, I know, this does not look too |
| 558 | * strace-ish, but otherwise the IPX |
| 559 | * addresses just look monstrous... |
| 560 | * Anyways, feel free if you don't like |
| 561 | * this way.. :) |
| 562 | */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 563 | tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 564 | for (i = 0; i<IPX_NODE_LEN; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 565 | tprintf("%02x", addrbuf.sipx.sipx_node[i]); |
| 566 | tprintf("/[%02x]", addrbuf.sipx.sipx_type); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 567 | } |
| 568 | break; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 569 | #endif /* AF_IPX && linux */ |
| 570 | #ifdef AF_PACKET |
| 571 | case AF_PACKET: |
| 572 | { |
| 573 | int i; |
| 574 | tprintf("proto=%#04x, if%d, pkttype=%d, addr(%d)={%d, ", |
| 575 | ntohs(addrbuf.ll.sll_protocol), |
| 576 | addrbuf.ll.sll_ifindex, |
| 577 | addrbuf.ll.sll_pkttype, |
| 578 | addrbuf.ll.sll_halen, |
| 579 | addrbuf.ll.sll_hatype); |
| 580 | for (i=0; i<addrbuf.ll.sll_addr[i]; i++) |
| 581 | tprintf("%02x", addrbuf.ll.sll_addr[i]); |
| 582 | } |
| 583 | break; |
| 584 | |
| 585 | #endif /* AF_APACKET */ |
| 586 | #ifdef AF_NETLINLK |
| 587 | case AF_NETLINK: |
| 588 | tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); |
| 589 | break; |
| 590 | #endif /* AF_NETLINK */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 591 | /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 592 | AF_X25 AF_ROSE etc. still need to be done */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 593 | |
| 594 | default: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 595 | tprintf("{sa_family=%u, sa_data=", addrbuf.sa.sa_family); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 596 | printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 597 | sizeof addrbuf.sa.sa_data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 598 | break; |
| 599 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 600 | tprintf("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | #if HAVE_SENDMSG |
| 604 | |
| 605 | static void |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 606 | printiovec(tcp, iovec, len) |
| 607 | struct tcb *tcp; |
| 608 | struct iovec *iovec; |
| 609 | long len; |
| 610 | { |
| 611 | struct iovec *iov; |
| 612 | int i; |
| 613 | |
| 614 | iov = (struct iovec *) malloc(len * sizeof *iov); |
| 615 | if (iov == NULL) { |
| 616 | fprintf(stderr, "No memory"); |
| 617 | return; |
| 618 | } |
| 619 | if (umoven(tcp, (long)iovec, |
| 620 | len * sizeof *iov, (char *) iov) < 0) { |
| 621 | tprintf("%#lx", (unsigned long)iovec); |
| 622 | } else { |
| 623 | tprintf("["); |
| 624 | for (i = 0; i < len; i++) { |
| 625 | if (i) |
| 626 | tprintf(", "); |
| 627 | tprintf("{"); |
| 628 | printstr(tcp, (long) iov[i].iov_base, |
| 629 | iov[i].iov_len); |
| 630 | tprintf(", %lu}", (unsigned long)iov[i].iov_len); |
| 631 | } |
| 632 | tprintf("]"); |
| 633 | } |
| 634 | free((char *) iov); |
| 635 | } |
| 636 | |
| 637 | static void |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 638 | printmsghdr(tcp, addr) |
| 639 | struct tcb *tcp; |
| 640 | long addr; |
| 641 | { |
| 642 | struct msghdr msg; |
| 643 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 644 | if (umove(tcp, addr, &msg) < 0) { |
| 645 | tprintf("%#lx", addr); |
| 646 | return; |
| 647 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 648 | tprintf("{msg_name(%d)=", msg.msg_namelen); |
| 649 | printsock(tcp, (long)msg.msg_name, msg.msg_namelen); |
| 650 | |
| 651 | tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen); |
| 652 | printiovec(tcp, msg.msg_iov, msg.msg_iovlen); |
| 653 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 654 | #ifdef HAVE_MSG_CONTROL |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 655 | tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen); |
| 656 | if (msg.msg_controllen) |
| 657 | tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control); |
| 658 | tprintf(", msg_flags="); |
| 659 | if (printflags(msg_flags, msg.msg_flags)==0) |
| 660 | tprintf("0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 661 | #else /* !HAVE_MSG_CONTROL */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 662 | tprintf("msg_accrights=%#lx, msg_accrightslen=%u", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 663 | (unsigned long) msg.msg_accrights, msg.msg_accrightslen); |
| 664 | #endif /* !HAVE_MSG_CONTROL */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 665 | tprintf("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | #endif /* HAVE_SENDMSG */ |
| 669 | |
| 670 | int |
| 671 | sys_socket(tcp) |
| 672 | struct tcb *tcp; |
| 673 | { |
| 674 | if (entering(tcp)) { |
| 675 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 676 | tprintf(", "); |
| 677 | printxval(socktypes, tcp->u_arg[1], "SOCK_???"); |
| 678 | tprintf(", "); |
| 679 | switch (tcp->u_arg[0]) { |
| 680 | case PF_INET: |
| 681 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 682 | break; |
| 683 | #ifdef PF_IPX |
| 684 | case PF_IPX: |
| 685 | /* BTW: I don't believe this.. */ |
| 686 | tprintf("["); |
| 687 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 688 | tprintf("]"); |
| 689 | break; |
| 690 | #endif /* PF_IPX */ |
| 691 | default: |
| 692 | tprintf("%lu", tcp->u_arg[2]); |
| 693 | break; |
| 694 | } |
| 695 | } |
| 696 | return 0; |
| 697 | } |
| 698 | |
| 699 | int |
| 700 | sys_bind(tcp) |
| 701 | struct tcb *tcp; |
| 702 | { |
| 703 | if (entering(tcp)) { |
| 704 | tprintf("%ld, ", tcp->u_arg[0]); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 705 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 706 | tprintf(", %lu", tcp->u_arg[2]); |
| 707 | } |
| 708 | return 0; |
| 709 | } |
| 710 | |
| 711 | int |
| 712 | sys_connect(tcp) |
| 713 | struct tcb *tcp; |
| 714 | { |
| 715 | return sys_bind(tcp); |
| 716 | } |
| 717 | |
| 718 | int |
| 719 | sys_listen(tcp) |
| 720 | struct tcb *tcp; |
| 721 | { |
| 722 | if (entering(tcp)) { |
| 723 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 724 | } |
| 725 | return 0; |
| 726 | } |
| 727 | |
| 728 | int |
| 729 | sys_accept(tcp) |
| 730 | struct tcb *tcp; |
| 731 | { |
| 732 | if (entering(tcp)) { |
| 733 | tprintf("%ld, ", tcp->u_arg[0]); |
| 734 | } else if (!tcp->u_arg[2]) |
| 735 | tprintf("%#lx, NULL", tcp->u_arg[1]); |
| 736 | else { |
| 737 | if (tcp->u_arg[1] == 0 || syserror(tcp)) { |
| 738 | tprintf("%#lx", tcp->u_arg[1]); |
| 739 | } else { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 740 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 741 | } |
| 742 | tprintf(", "); |
| 743 | printnum(tcp, tcp->u_arg[2], "%lu"); |
| 744 | } |
| 745 | return 0; |
| 746 | } |
| 747 | |
| 748 | int |
| 749 | sys_send(tcp) |
| 750 | struct tcb *tcp; |
| 751 | { |
| 752 | if (entering(tcp)) { |
| 753 | tprintf("%ld, ", tcp->u_arg[0]); |
| 754 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 755 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 756 | /* flags */ |
| 757 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 758 | tprintf("0"); |
| 759 | } |
| 760 | return 0; |
| 761 | } |
| 762 | |
| 763 | int |
| 764 | sys_sendto(tcp) |
| 765 | struct tcb *tcp; |
| 766 | { |
| 767 | if (entering(tcp)) { |
| 768 | tprintf("%ld, ", tcp->u_arg[0]); |
| 769 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 770 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 771 | /* flags */ |
| 772 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 773 | tprintf("0"); |
| 774 | /* to address */ |
| 775 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 776 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 777 | /* to length */ |
| 778 | tprintf(", %lu", tcp->u_arg[5]); |
| 779 | } |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | #ifdef HAVE_SENDMSG |
| 784 | |
| 785 | int |
| 786 | sys_sendmsg(tcp) |
| 787 | struct tcb *tcp; |
| 788 | { |
| 789 | if (entering(tcp)) { |
| 790 | tprintf("%ld, ", tcp->u_arg[0]); |
| 791 | printmsghdr(tcp, tcp->u_arg[1]); |
| 792 | /* flags */ |
| 793 | tprintf(", "); |
| 794 | if (printflags(msg_flags, tcp->u_arg[2]) == 0) |
| 795 | tprintf("0"); |
| 796 | } |
| 797 | return 0; |
| 798 | } |
| 799 | |
| 800 | #endif /* HAVE_SENDMSG */ |
| 801 | |
| 802 | int |
| 803 | sys_recv(tcp) |
| 804 | struct tcb *tcp; |
| 805 | { |
| 806 | if (entering(tcp)) { |
| 807 | tprintf("%ld, ", tcp->u_arg[0]); |
| 808 | } else { |
| 809 | if (syserror(tcp)) |
| 810 | tprintf("%#lx", tcp->u_arg[1]); |
| 811 | else |
| 812 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 813 | |
| 814 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 815 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 816 | tprintf("0"); |
| 817 | } |
| 818 | return 0; |
| 819 | } |
| 820 | |
| 821 | int |
| 822 | sys_recvfrom(tcp) |
| 823 | struct tcb *tcp; |
| 824 | { |
| 825 | int fromlen; |
| 826 | |
| 827 | if (entering(tcp)) { |
| 828 | tprintf("%ld, ", tcp->u_arg[0]); |
| 829 | } else { |
| 830 | if (syserror(tcp)) { |
| 831 | tprintf("%#lx, %lu, %lu, %#lx, %#lx", |
| 832 | tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], |
| 833 | tcp->u_arg[4], tcp->u_arg[5]); |
| 834 | return 0; |
| 835 | } |
| 836 | /* buf */ |
| 837 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 838 | /* len */ |
| 839 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 840 | /* flags */ |
| 841 | if (printflags(msg_flags, tcp->u_arg[3]) == 0) |
| 842 | tprintf("0"); |
| 843 | /* from address, len */ |
| 844 | if (!tcp->u_arg[4] || !tcp->u_arg[5]) { |
| 845 | if (tcp->u_arg[4] == 0) |
| 846 | tprintf(", NULL"); |
| 847 | else |
| 848 | tprintf(", %#lx", tcp->u_arg[4]); |
| 849 | if (tcp->u_arg[5] == 0) |
| 850 | tprintf(", NULL"); |
| 851 | else |
| 852 | tprintf(", %#lx", tcp->u_arg[5]); |
| 853 | return 0; |
| 854 | } |
| 855 | if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
| 856 | tprintf(", {...}, [?]"); |
| 857 | return 0; |
| 858 | } |
| 859 | tprintf(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 860 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 861 | /* from length */ |
| 862 | tprintf(", [%u]", fromlen); |
| 863 | } |
| 864 | return 0; |
| 865 | } |
| 866 | |
| 867 | #ifdef HAVE_SENDMSG |
| 868 | |
| 869 | int |
| 870 | sys_recvmsg(tcp) |
| 871 | struct tcb *tcp; |
| 872 | { |
| 873 | if (entering(tcp)) { |
| 874 | tprintf("%ld, ", tcp->u_arg[0]); |
| 875 | } else { |
| 876 | if (syserror(tcp) || !verbose(tcp)) |
| 877 | tprintf("%#lx", tcp->u_arg[1]); |
| 878 | else |
| 879 | printmsghdr(tcp, tcp->u_arg[1]); |
| 880 | /* flags */ |
| 881 | tprintf(", "); |
| 882 | if (printflags(msg_flags, tcp->u_arg[2]) == 0) |
| 883 | tprintf("0"); |
| 884 | } |
| 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | #endif /* HAVE_SENDMSG */ |
| 889 | |
| 890 | int |
| 891 | sys_shutdown(tcp) |
| 892 | struct tcb *tcp; |
| 893 | { |
| 894 | if (entering(tcp)) { |
| 895 | tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]); |
| 896 | switch (tcp->u_arg[1]) { |
| 897 | case 0: |
| 898 | tprintf("%s", " /* receive */"); |
| 899 | break; |
| 900 | case 1: |
| 901 | tprintf("%s", " /* send */"); |
| 902 | break; |
| 903 | case 2: |
| 904 | tprintf("%s", " /* send and receive */"); |
| 905 | break; |
| 906 | } |
| 907 | } |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | int |
| 912 | sys_getsockname(tcp) |
| 913 | struct tcb *tcp; |
| 914 | { |
| 915 | return sys_accept(tcp); |
| 916 | } |
| 917 | |
| 918 | int |
| 919 | sys_getpeername(tcp) |
| 920 | struct tcb *tcp; |
| 921 | { |
| 922 | return sys_accept(tcp); |
| 923 | } |
| 924 | |
| 925 | int |
| 926 | sys_pipe(tcp) |
| 927 | struct tcb *tcp; |
| 928 | { |
| 929 | |
| 930 | #if defined(LINUX) && !defined(SPARC) |
| 931 | int fds[2]; |
| 932 | |
| 933 | if (exiting(tcp)) { |
| 934 | if (syserror(tcp)) { |
| 935 | tprintf("%#lx", tcp->u_arg[0]); |
| 936 | return 0; |
| 937 | } |
| 938 | if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) |
| 939 | tprintf("[...]"); |
| 940 | else |
| 941 | tprintf("[%u, %u]", fds[0], fds[1]); |
| 942 | } |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 943 | #elif defined(SPARC) || defined(SVR4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 944 | if (exiting(tcp)) |
| 945 | tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 946 | #endif |
| 947 | return 0; |
| 948 | } |
| 949 | |
| 950 | int |
| 951 | sys_socketpair(tcp) |
| 952 | struct tcb *tcp; |
| 953 | { |
| 954 | #ifdef LINUX |
| 955 | int fds[2]; |
| 956 | #endif |
| 957 | |
| 958 | if (entering(tcp)) { |
| 959 | printxval(domains, tcp->u_arg[0], "PF_???"); |
| 960 | tprintf(", "); |
| 961 | printxval(socktypes, tcp->u_arg[1], "SOCK_???"); |
| 962 | tprintf(", "); |
| 963 | switch (tcp->u_arg[0]) { |
| 964 | case PF_INET: |
| 965 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 966 | break; |
| 967 | #ifdef PF_IPX |
| 968 | case PF_IPX: |
| 969 | /* BTW: I don't believe this.. */ |
| 970 | tprintf("["); |
| 971 | printxval(domains, tcp->u_arg[2], "PF_???"); |
| 972 | tprintf("]"); |
| 973 | break; |
| 974 | #endif /* PF_IPX */ |
| 975 | default: |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 976 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 977 | break; |
| 978 | } |
| 979 | } else { |
| 980 | if (syserror(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 981 | tprintf(", %#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 982 | return 0; |
| 983 | } |
| 984 | #ifdef LINUX |
| 985 | if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 986 | tprintf(", [...]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 987 | else |
| 988 | tprintf(", [%u, %u]", fds[0], fds[1]); |
| 989 | #endif /* LINUX */ |
| 990 | #ifdef SUNOS4 |
| 991 | tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
| 992 | #endif /* SUNOS4 */ |
| 993 | #ifdef SVR4 |
| 994 | tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
| 995 | #endif /* SVR4 */ |
| 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 |