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