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