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