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