net.c revision efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9f
176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman/*
276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
57987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * All rights reserved.
776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Redistribution and use in source and binary forms, with or without
976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * modification, are permitted provided that the following conditions
1076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * are met:
1176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 1. Redistributions of source code must retain the above copyright
1276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    notice, this list of conditions and the following disclaimer.
1376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 2. Redistributions in binary form must reproduce the above copyright
1476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    notice, this list of conditions and the following disclaimer in the
1576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    documentation and/or other materials provided with the distribution.
1676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 3. The name of the author may not be used to endorse or promote products
1776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    derived from this software without specific prior written permission.
1876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
1976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
3076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *	$Id$
3176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman */
3276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include "defs.h"
3476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/stat.h>
3676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/socket.h>
3776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/un.h>
3876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <netinet/in.h>
39bf79f2e16b090ffe59cd1e1820935680a2da7b78Wichert Akkerman#ifdef FREEBSD
40bf79f2e16b090ffe59cd1e1820935680a2da7b78Wichert Akkerman#include <netinet/tcp.h>
41bf79f2e16b090ffe59cd1e1820935680a2da7b78Wichert Akkerman#endif
4276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <arpa/inet.h>
4376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(LINUX)
4476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <asm/types.h>
4576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
4676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#  include <netipx/ipx.h>
4776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#else
4876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#  include <linux/ipx.h>
4976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
5076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* LINUX */
5176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
524dc8a2aec63e4fb5ee2688544c4de323ed5de3efWichert Akkerman#if defined (__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1))
53f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(HAVE_LINUX_IN6_H)
54505e176ded6376a1283093b334c2c6deb47916e7Wichert Akkerman#include <linux/in6.h>
55505e176ded6376a1283093b334c2c6deb47916e7Wichert Akkerman#endif
562f473da12babff710bbe37c7f95be01fd00118f9Wichert Akkerman#endif
57505e176ded6376a1283093b334c2c6deb47916e7Wichert Akkerman
58f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(HAVE_SYS_UIO_H)
59f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#include <sys/uio.h>
60f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
61f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
62f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(HAVE_LINUX_NETLINK_H)
63f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#include <linux/netlink.h>
64f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
65f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
66f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(HAVE_LINUX_IF_PACKET_H)
67f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#include <linux/if_packet.h>
68f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
69f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
707987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(HAVE_LINUX_ICMP_H)
717987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#include <linux/icmp.h>
727987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
737987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
7476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef PF_UNSPEC
7576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define PF_UNSPEC AF_UNSPEC
7676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
7776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
7816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman#if UNIXWARE >= 7
7916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman#define HAVE_SENDMSG		1		/* HACK - *FIXME* */
8016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman#endif
8116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
8276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef LINUX
8376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman/* Under Linux these are enums so we can't test for them with ifdef. */
8476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_EGP IPPROTO_EGP
8576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_PUP IPPROTO_PUP
8676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_IDP IPPROTO_IDP
8776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_IGMP IPPROTO_IGMP
8876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_RAW IPPROTO_RAW
8976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_MAX IPPROTO_MAX
9076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
9176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
9276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat domains[] = {
9376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_UNSPEC,	"PF_UNSPEC"	},
9476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_UNIX,	"PF_UNIX"	},
9576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_INET,	"PF_INET"	},
96f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_NETLINK
97f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ PF_NETLINK,	"PF_NETLINK"	},
98f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
99f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_PACKET
100f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ PF_PACKET,	"PF_PACKET"	},
101f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
102f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_INET6
103f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ PF_INET6,	"PF_INET6"	},
104f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
105f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_ATMSVC
106f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ PF_ATMSVC,	"PF_INET6"	},
107f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
108f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_INET6
109f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ PF_INET6,	"PF_INET6"	},
110f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
11176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_LOCAL
11276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_LOCAL,	"PS_LOCAL"	},
11376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
11476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_ISO
11576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_ISO,	"PF_ISO"	},
11676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
11776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_AX25
11876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_AX25,	"PF_AX25"	},
11976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
12076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
12176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_IPX,	"PF_IPX"	},
12276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
12376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_APPLETALK
12476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_APPLETALK,	"PF_APPLETALK"	},
12576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
12676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_NETROM
12776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_NETROM,	"PF_NETROM"	},
12876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
12976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_BRIDGE
13076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_BRIDGE,	"PF_BRIDGE"	},
13176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
13276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_AAL5
13376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_AAL5,	"PF_AAL5"	},
13476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
13576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_X25
13676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_X25,	"PF_X25"	},
13776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
13876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_ROSE
13976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_ROSE,	"PF_ROSE"	},
14076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
14176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_DECNET
14276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_DECNET,	"PF_DECNET"	},
14376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
14476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_NETBEUI
14576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_NETBEUI,	"PF_NETBEUI"	},
14676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
14776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IMPLINK
14876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_IMPLINK,	"PF_IMPLINK"	},
14976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
15076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
15176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
152f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanstatic struct xlat addrfams[] = {
153f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_UNSPEC,	"AF_UNSPEC"	},
154f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_UNIX,	"AF_UNIX"	},
155f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_INET,	"AF_INET"	},
156e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#ifdef AF_INET6
157f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_INET6,	"AF_INET6"	},
158e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#endif
159f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_DECnet,	"AF_DECnet"	},
160f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_ATMSVC
161f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_ATMSVC,	"AF_ATMSVC"	},
162f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
163e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#ifdef AF_PACKET
164f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_PACKET,	"AF_PACKET"	},
165e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#endif
166e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#ifdef AF_NETLINK
167f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_NETLINK,	"AF_NETLINK"	},
168e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#endif
169e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#ifdef AF_ISO
170f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_ISO,	"AF_ISO"	},
171f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
172e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#ifdef AF_IMPLINK
173f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_IMPLINK,	"AF_IMPLINK"	},
174f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
175f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ 0,		NULL		},
176f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman};
17776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat socktypes[] = {
17876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_STREAM,	"SOCK_STREAM"	},
17976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_DGRAM,	"SOCK_DGRAM"	},
18076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_RAW
18176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_RAW,	"SOCK_RAW"	},
18276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_SEQPACKET
18476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_SEQPACKET,"SOCK_SEQPACKET"},
18576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_RDM
18776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_RDM,	"SOCK_RDM"	},
18876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_PACKET
19076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_PACKET,	"SOCK_PACKET"	},
19176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
19276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
19376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
194efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkermanstatic struct xlat socketlayers[] = {
195efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IP,	"SOL_IP"	},
196efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ICMP)
197efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ICMP,	"SOL_ICMP"	},
198efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
199efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_TCP,	"SOL_TCP"	},
200efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_UDP,	"SOL_UDP"	},
201efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_IPV6)
202efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IPV6,	"SOL_IPV6"	},
203efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
204efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ICMPV6)
205efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ICMPV6,	"SOL_ICMPV6"	},
206efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
207efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_RAW)
208efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_RAW,	"SOL_RAW"	},
209efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
210efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_IPX)
211efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IPX,	"SOL_IPX"	},
212efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
213efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_IPX)
214efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IPX,	"SOL_IPX"	},
215efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
216efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_AX25)
217efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_AX25,	"SOL_AX25"	},
218efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
219efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ATALK)
220efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ATALK,	"SOL_ATALK"	},
221efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
222efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_NETROM)
223efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_NETROM,	"SOL_NETROM"	},
224efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
225efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ROSE)
226efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ROSE,	"SOL_ROSE"	},
227efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
228efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_DECNET)
229efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_DECNET,	"SOL_DECNET"	},
230efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
231efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_X25)
232efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_X25,	"SOL_X25"	},
233efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
234efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_PACKET)
235efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_PACKET,	"SOL_PACKET"	},
236efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
237efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ATM)
238efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ATM,	"SOL_ATM"	},
239efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
240efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_AAL)
241efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_AAL,	"SOL_AAL"	},
242efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
243efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_IRDA)
244efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IRDA,	"SOL_IRDA"	},
245efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
246efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman};
24776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat protocols[] = {
24876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IP,	"IPPROTO_IP"	},
24976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ICMP,	"IPPROTO_ICMP"	},
25076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_TCP,	"IPPROTO_TCP"	},
25176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_UDP,	"IPPROTO_UDP"	},
25276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_GGP
25376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_GGP,	"IPPROTO_GGP"	},
25476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
25576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_EGP
25676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_EGP,	"IPPROTO_EGP"	},
25776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
25876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_PUP
25976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_PUP,	"IPPROTO_PUP"	},
26076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
26176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IDP
26276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IDP,	"IPPROTO_IDP"	},
26376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
26476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IPV6
26576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IPV6,	"IPPROTO_IPV6"	},
26676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
26776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_ICMPV6
26876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
26976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
27076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IGMP
27176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IGMP,	"IPPROTO_IGMP"	},
27276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
27376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_HELLO
27476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_HELLO,"IPPROTO_HELLO"	},
27576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
27676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_ND
27776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ND,	"IPPROTO_ND"	},
27876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
27976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_RAW
28076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_RAW,	"IPPROTO_RAW"	},
28176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
28276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_MAX
28376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_MAX,	"IPPROTO_MAX"	},
28476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
28576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IPIP
28676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IPIP,	"IPPROTO_IPIP"	},
28776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
28876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
28976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
29076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat msg_flags[] = {
29176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_OOB,	"MSG_OOB"	},
29276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_DONTROUTE
29376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_DONTROUTE,"MSG_DONTROUTE"	},
29476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
29576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_PEEK
29676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_PEEK,	"MSG_PEEK"	},
29776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
29876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_CTRUNC
29976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_CTRUNC,	"MSG_CTRUNC"	},
30076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
30176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_PROXY
30276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_PROXY,	"MSG_PROXY"	},
30376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
30476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_EOR
30576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_EOR,	"MSG_EOR"	},
30676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
30776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_WAITALL
30876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_WAITALL,	"MSG_WAITALL"	},
30976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
310f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_TRUNC
311f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ MSG_TRUNC,	"MSG_TRUNC"	},
312f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
313f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_CTRUNC
314f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ MSG_CTRUNC,	"MSG_CTRUNC"	},
315f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
316f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_ERRQUEUE
317f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ MSG_ERRQUEUE,	"MSG_ERRQUEUE"	},
318f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
319f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_DONTWAIT
320f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ MSG_DONTWAIT,	"MSG_DONTWAIT"	},
321f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
322f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_CONFIRM
323f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ MSG_CONFIRM,	"MSG_CONFIRM"	},
324f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
325f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_PROBE
326f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ MSG_PROBE,	"MSG_PROBE"	},
327f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
32876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
32976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
33076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
33176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat sockoptions[] = {
332f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef SO_PEERCRED
333f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ SO_PEERCRED,	"SO_PEERCRED"	},
334f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
335f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef SO_PASSCRED
336f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ SO_PASSCRED,	"SO_PASSCRED"	},
337f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
33876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_DEBUG
33976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_DEBUG,	"SO_DEBUG"	},
34076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
34176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_REUSEADDR
34276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_REUSEADDR,	"SO_REUSEADDR"	},
34376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
34476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_KEEPALIVE
34576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_KEEPALIVE,	"SO_KEEPALIVE"	},
34676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
34776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_DONTROUTE
34876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_DONTROUTE,	"SO_DONTROUTE"	},
34976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
35076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_BROADCAST
35176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_BROADCAST,	"SO_BROADCAST"	},
35276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
35376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_LINGER
35476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_LINGER,	"SO_LINGER"	},
35576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
35676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_OOBINLINE
35776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_OOBINLINE,	"SO_OOBINLINE"	},
35876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
35976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_TYPE
36076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_TYPE,	"SO_TYPE"	},
36176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
36276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_ERROR
36376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_ERROR,	"SO_ERROR"	},
36476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
36576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDBUF
36676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDBUF,	"SO_SNDBUF"	},
36776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
36876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVBUF
36976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVBUF,	"SO_RCVBUF"	},
37076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
37176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_NO_CHECK
37276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_NO_CHECK,	"SO_NO_CHECK"	},
37376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
37476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_PRIORITY
37576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_PRIORITY,	"SO_PRIORITY"	},
37676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
37776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_ACCEPTCONN
37876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_ACCEPTCONN,"SO_ACCEPTCONN"	},
37976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
38076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_USELOOPBACK
38176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_USELOOPBACK,"SO_USELOOPBACK"},
38276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
38376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDLOWAT
38476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDLOWAT,	"SO_SNDLOWAT"	},
38576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
38676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVLOWAT
38776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVLOWAT,	"SO_RCVLOWAT"	},
38876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
38976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDTIMEO
39076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDTIMEO,	"SO_SNDTIMEO"	},
39176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
39276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVTIMEO
39376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVTIMEO,	"SO_RCVTIMEO"	},
39476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
39576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_BSDCOMPAT
39676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_BSDCOMPAT,	"SO_BSDCOMPAT"	},
39776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
39876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_REUSEPORT
39976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_REUSEPORT,	"SO_REUSEPORT"	},
40076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
40176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVLOWAT
40276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVLOWAT, "SO_RCVLOWAT"	},
40376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
40476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDLOWAT
40576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDLOWAT, "SO_SNDLOWAT"	},
40676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
40776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVTIMEO
40876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVTIMEO, "SO_RCVTIMEO"	},
40976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
41076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDTIMEO
41176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDTIMEO, "SO_SNDTIMEO"	},
41276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
41376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
41476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
41576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
41676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
41776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat sockipoptions[] = {
4187987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_TOS,		"IP_TOS"		},
4197987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_TTL,		"IP_TTL"		},
42076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(IP_HDRINCL)
4217987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_HDRINCL,		"IP_HDRINCL"		},
42276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
42376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(IP_OPTIONS)
4247987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_OPTIONS,		"IP_OPTIONS"		},
4257987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4267987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_ROUTER_ALERT,	"IP_ROUTER_ALERT"	},
4277987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(IP_RECVOPTIONS)
4287987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RECVOPTIONS,	"IP_RECVOPTIONS"	},
4297987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4307987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RETOPTS,		"IP_RETOPTS"		},
4317987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_PKTINFO,		"IP_PKTINFO"		},
4327987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_PKTOPTIONS,	"IP_PKTOPTIONS"	},
4337987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MTU_DISCOVER,	"IP_MTU_DISCOVER"	},
4347987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MTU_DISCOVER,	"IP_MTU_DISCOVER"	},
4357987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RECVERR,		"IP_RECVERR"		},
4367987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RECVTTL,		"IP_RECRECVTTL"		},
4377987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RECVTOS,		"IP_RECRECVTOS"		},
4387987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(IP_MTU)
4397987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MTU,		"IP_MTU"		},
4407987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4417987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MULTICAST_IF,	"IP_MULTICAST_IF"	},
4427987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MULTICAST_TTL,	"IP_MULTICAST_TTL"	},
4437987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MULTICAST_LOOP,	"IP_MULTICAST_LOOP"	},
4447987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_ADD_MEMBERSHIP,	"IP_ADD_MEMBERSHIP"	},
4457987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_DROP_MEMBERSHIP,	"IP_DROP_MEMBERSHIP"	},
4467987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,			NULL			},
44776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
44876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_IP */
44976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
45076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
45176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat sockipxoptions[] = {
45276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPX_TYPE,     "IPX_TYPE"      },
45376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,            NULL            },
45476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
45576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_IPX */
45676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
4577987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_RAW
4587987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkermanstatic struct xlat sockrawoptions[] = {
4597987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_FILTER)
4607987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ ICMP_FILTER,		"ICMP_FILTER"	},
4617987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4627987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,			NULL		},
4637987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman};
4647987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* SOL_RAW */
4657987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
4667987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_PACKET
4677987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkermanstatic struct xlat sockpacketoptions[] = {
4687987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_ADD_MEMBERSHIP,	"PACKET_ADD_MEMBERSHIP"	},
4697987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_DROP_MEMBERSHIP,	"PACKET_DROP_MEMBERSHIP"},
4707987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(PACKET_RECV_OUTPUT)
4717987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_RECV_OUTPUT,		"PACKET_RECV_OUTPUT"	},
4727987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4737987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(PACKET_RX_RING)
4747987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_RX_RING,		"PACKET_RX_RING"	},
4757987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4767987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(PACKET_STATISTICS)
4777987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_STATISTICS,		"PACKET_STATISTICS"	},
4787987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4797987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,				NULL			},
4807987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman};
4817987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* SOL_PACKET */
4827987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
48376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
48476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat socktcpoptions[] = {
4857987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ TCP_NODELAY,	"TCP_NODELAY"	},
4867987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ TCP_MAXSEG,	"TCP_MAXSEG"	},
4877987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(TCP_CORK)
4887987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ TCP_CORK,	"TCP_CORK"	},
4897987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4907987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,		NULL		},
49176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
49276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_TCP */
49376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
4947987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_RAW
4957987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkermanstatic struct xlat icmpfilterflags[] = {
4967987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ECHOREPLY)
4977987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ECHOREPLY),		"ICMP_ECHOREPLY"	},
4987987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
4997987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_DEST_UNREACH)
5007987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_DEST_UNREACH),	"ICMP_DEST_UNREACH"	},
5017987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5027987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_SOURCE_QUENCH)
5037987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_SOURCE_QUENCH),	"ICMP_SOURCE_QUENCH"	},
5047987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5057987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_REDIRECT)
5067987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_REDIRECT),		"ICMP_REDIRECT"		},
5077987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5087987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ECHO)
5097987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ECHO),		"ICMP_ECHO"		},
5107987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5117987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_TIME_EXCEEDED)
5127987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_TIME_EXCEEDED),	"ICMP_TIME_EXCEEDED"	},
5137987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5147987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_PARAMETERPROB)
5157987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_PARAMETERPROB),	"ICMP_PARAMETERPROB"	},
5167987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5177987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_TIMESTAMP)
5187987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_TIMESTAMP),		"ICMP_TIMESTAMP"	},
5197987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5207987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_TIMESTAMPREPLY)
5217987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_TIMESTAMPREPLY),	"ICMP_TIMESTAMPREPLY"	},
5227987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5237987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_INFO_REQUEST)
5247987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_INFO_REQUEST),	"ICMP_INFO_REQUEST"	},
5257987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5267987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_INFO_REPLY)
5277987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_INFO_REPLY),		"ICMP_INFO_REPLY"	},
5287987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5297987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ADDRESS)
5307987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ADDRESS),		"ICMP_ADDRESS"		},
5317987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5327987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ADDRESSREPLY)
5337987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ADDRESSREPLY),	"ICMP_ADDRESSREPLY"	},
5347987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
5357987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,				NULL			},
5367987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman};
5377987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* SOL_RAW */
5387987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
53916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
54076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanvoid
541f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanprintsock(tcp, addr, addrlen)
54276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
54376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanlong addr;
544f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanint addrlen;
54576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
546f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	union {
547f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		char pad[128];
548f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr sa;
549f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_in sin;
550f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_un sau;
5519ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#ifdef HAVE_INET_NTOP
552f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_in6 sa6;
5539ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#endif
554f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(LINUX) && defined(AF_IPX)
555f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_ipx sipx;
556f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
557f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef AF_PACKET
558f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_ll ll;
55976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
560f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef AF_NETLINK
561f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_nl nl;
562f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
563f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	} addrbuf;
564f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	char string_addr[100];
56576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
56676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (addr == 0) {
56776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("NULL");
56876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
56976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
57076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (!verbose(tcp)) {
57176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%#lx", addr);
57276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
57376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
574f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	if ((addrlen<2) || (addrlen>sizeof(addrbuf)))
575f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		addrlen=sizeof(addrbuf);
576f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
577f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	if (umoven(tcp, addr, addrlen, (char*)&addrbuf) < 0) {
57876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("{...}");
57976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
58076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
581f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
582f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf("{sin_family=");
583f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
584f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf(", ");
585f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
586f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	switch (addrbuf.sa.sa_family) {
58776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_UNIX:
588f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		if (addrlen==2) {
589f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("<nil>");
590f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		} else if (addrbuf.sau.sun_path[0]) {
591f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("path=\"%*.*s\"", addrlen-2, addrlen-2, addrbuf.sau.sun_path);
592f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		} else {
593f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("path=@%*.*s", addrlen-3, addrlen-3, addrbuf.sau.sun_path+1);
594f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		}
59576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
59676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_INET:
59776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}",
598f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
59976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
6009ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#ifdef HAVE_INET_NTOP
6019ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman	case AF_INET6:
602f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
603f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=htonl(%u)}",
604f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			ntohs(addrbuf.sa6.sin6_port), string_addr, ntohl(addrbuf.sa6.sin6_flowinfo));
6059ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman		break;
6069ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#endif
607dbb440e5ae5d1a6be4eeda28088e8dfc9b195bacWichert Akkerman#if defined(AF_IPX) && defined(linux)
60876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_IPX:
609f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		{
61076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			int i;
61176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("{sipx_port=htons(%u), ",
612f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					ntohs(addrbuf.sipx.sipx_port));
61376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* Yes, I know, this does not look too
61476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * strace-ish, but otherwise the IPX
61576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * addresses just look monstrous...
61676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * Anyways, feel free if you don't like
61776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * this way.. :)
61876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 */
619f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
62076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			for (i = 0; i<IPX_NODE_LEN; i++)
621f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman				tprintf("%02x", addrbuf.sipx.sipx_node[i]);
622f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("/[%02x]", addrbuf.sipx.sipx_type);
623f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		}
624f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		break;
625f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif /* AF_IPX && linux */
626f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef AF_PACKET
627f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	case AF_PACKET:
628f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		{
629f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			int i;
630f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("proto=%#04x, if%d, pkttype=%d, addr(%d)={%d, ",
631f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					ntohs(addrbuf.ll.sll_protocol),
632f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					addrbuf.ll.sll_ifindex,
633f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					addrbuf.ll.sll_pkttype,
634f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					addrbuf.ll.sll_halen,
635f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					addrbuf.ll.sll_hatype);
636f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			for (i=0; i<addrbuf.ll.sll_addr[i]; i++)
637f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman				tprintf("%02x", addrbuf.ll.sll_addr[i]);
63876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
63976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
640f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
641f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif /* AF_APACKET */
642f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef AF_NETLINLK
643f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	case AF_NETLINK:
644f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
645f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		break;
646f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif /* AF_NETLINK */
64776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	/* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
648f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	AF_X25 AF_ROSE etc. still need to be done */
64976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
65076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	default:
651f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("{sa_family=%u, sa_data=", addrbuf.sa.sa_family);
65276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
653f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			sizeof addrbuf.sa.sa_data);
65476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
65576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
656f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf("}");
65776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
65876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
65976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if HAVE_SENDMSG
66076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
66176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic void
662f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanprintiovec(tcp, iovec, len)
663f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanstruct tcb *tcp;
664f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanstruct iovec *iovec;
665f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanlong   len;
666f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman{
667f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	struct iovec *iov;
668f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	int i;
669f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
670f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	iov = (struct iovec *) malloc(len * sizeof *iov);
671f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	if (iov == NULL) {
672f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		fprintf(stderr, "No memory");
673f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		return;
674f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	}
675f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	if (umoven(tcp, (long)iovec,
676f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman				len * sizeof *iov, (char *) iov) < 0) {
677f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("%#lx", (unsigned long)iovec);
678f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	} else {
679f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("[");
680f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		for (i = 0; i < len; i++) {
681f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			if (i)
682f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman				tprintf(", ");
683f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("{");
684f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			printstr(tcp, (long) iov[i].iov_base,
685f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					iov[i].iov_len);
686f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf(", %lu}", (unsigned long)iov[i].iov_len);
687f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		}
688f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("]");
689f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	}
690f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	free((char *) iov);
691f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman}
692f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
693f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanstatic void
69476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanprintmsghdr(tcp, addr)
69576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
69676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanlong addr;
69776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
69876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	struct msghdr msg;
69976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
7002e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	if (umove(tcp, addr, &msg) < 0) {
7012e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman		tprintf("%#lx", addr);
7022e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman		return;
7032e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	}
704f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf("{msg_name(%d)=", msg.msg_namelen);
705f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	printsock(tcp, (long)msg.msg_name, msg.msg_namelen);
706f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
707f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
708f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	printiovec(tcp, msg.msg_iov, msg.msg_iovlen);
709f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
71076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_MSG_CONTROL
711f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen);
712f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	if (msg.msg_controllen)
713f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control);
714f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf(", msg_flags=");
715f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	if (printflags(msg_flags, msg.msg_flags)==0)
716f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("0");
71776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#else /* !HAVE_MSG_CONTROL */
718f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
71976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		(unsigned long) msg.msg_accrights, msg.msg_accrightslen);
72076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* !HAVE_MSG_CONTROL */
721f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	tprintf("}");
72276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
72376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
72476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
72576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
72676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
72776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_socket(tcp)
72876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
72976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
73076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
73176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(domains, tcp->u_arg[0], "PF_???");
73276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
73376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(socktypes, tcp->u_arg[1], "SOCK_???");
73476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
73576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[0]) {
73676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_INET:
73776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
73876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
73976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
74076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_IPX:
74176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* BTW: I don't believe this.. */
74276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[");
74376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(domains, tcp->u_arg[2], "PF_???");
74476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("]");
74576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
74676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* PF_IPX */
74776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
74876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%lu", tcp->u_arg[2]);
74976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
75076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
75176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
75276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
75376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
75476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
75576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
75676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_bind(tcp)
75776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
75876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
75976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
76076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
761f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
76276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu", tcp->u_arg[2]);
76376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
76476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
76576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
76676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
76776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
76876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_connect(tcp)
76976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
77076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
77176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_bind(tcp);
77276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
77376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
77476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
77576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_listen(tcp)
77676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
77776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
77876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
77976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
78076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
78176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
78276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
78376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
78476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
78576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_accept(tcp)
78676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
78776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
78876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
78976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
79076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else if (!tcp->u_arg[2])
79176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%#lx, NULL", tcp->u_arg[1]);
79276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	else {
79376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (tcp->u_arg[1] == 0 || syserror(tcp)) {
79476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
79576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		} else {
796f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
79776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
79876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
79976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printnum(tcp, tcp->u_arg[2], "%lu");
80076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
80176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
80276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
80376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
80476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
80576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_send(tcp)
80676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
80776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
80876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
80976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
81076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
81176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
81276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
81376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
81476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
81576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
81676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
81776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
81876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
81976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
82076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_sendto(tcp)
82176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
82276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
82376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
82476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
82576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
82676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
82776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
82876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
82976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
83076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* to address */
83176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
832f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
83376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* to length */
83476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu", tcp->u_arg[5]);
83576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
83676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
83776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
83876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
83976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_SENDMSG
84076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
84176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
84276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_sendmsg(tcp)
84376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
84476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
84576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
84676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
84776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printmsghdr(tcp, tcp->u_arg[1]);
84876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
84976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
85076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[2]) == 0)
85176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
85276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
85376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
85476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
85576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
85676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
85776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
85876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
85976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_recv(tcp)
86076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
86176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
86276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
86376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
86476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
86576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp))
86676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
86776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
86876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printstr(tcp, tcp->u_arg[1], tcp->u_rval);
86976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
87076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
87176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
87276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
87376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
87476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
87576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
87676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
87776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
87876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_recvfrom(tcp)
87976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
88076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
88176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fromlen;
88276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
88376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
88476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
88576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
88676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
88776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx, %lu, %lu, %#lx, %#lx",
88876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
88976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[4], tcp->u_arg[5]);
89076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
89176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
89276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* buf */
89376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_rval);
89476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* len */
89576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
89676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
89776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
89876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
89976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* from address, len */
90076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
90176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			if (tcp->u_arg[4] == 0)
90276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", NULL");
90376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			else
90476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", %#lx", tcp->u_arg[4]);
90576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			if (tcp->u_arg[5] == 0)
90676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", NULL");
90776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			else
90876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", %#lx", tcp->u_arg[5]);
90976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
91076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
91176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
91276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", {...}, [?]");
91376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
91476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
91576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
916f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
91776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* from length */
91876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", [%u]", fromlen);
91976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
92076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
92176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
92276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
92376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_SENDMSG
92476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
92576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
92676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_recvmsg(tcp)
92776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
92876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
92976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
93076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
93176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
93276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp) || !verbose(tcp))
93376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
93476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
93576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printmsghdr(tcp, tcp->u_arg[1]);
93676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
93776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
93876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[2]) == 0)
93976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
94076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
94176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
94276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
94376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
94476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
94576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
94676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
94776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_shutdown(tcp)
94876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
94976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
95076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
95176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
95276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[1]) {
95376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case 0:
95476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%s", " /* receive */");
95576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
95676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case 1:
95776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%s", " /* send */");
95876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
95976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case 2:
96076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%s", " /* send and receive */");
96176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
96276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
96376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
96476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
96576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
96676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
96776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
96876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_getsockname(tcp)
96976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
97076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
97176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_accept(tcp);
97276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
97376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
97476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
97576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_getpeername(tcp)
97676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
97776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
97876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_accept(tcp);
97976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
98076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
98176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
98276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_pipe(tcp)
98376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
98476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
98576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
98676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(LINUX) && !defined(SPARC)
98776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fds[2];
98876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
98976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (exiting(tcp)) {
99076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
99176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[0]);
99276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
99376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
99476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
99576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[...]");
99676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
99776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[%u, %u]", fds[0], fds[1]);
99876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
9992e4ffe59b588159eb80e236f068278ba47735932Wichert Akkerman#elif defined(SPARC) || defined(SVR4) || defined(FREEBSD)
100076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (exiting(tcp))
100176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
100276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
100376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
100476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
100576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
100676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
100776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_socketpair(tcp)
100876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
100976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
101076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef LINUX
101176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fds[2];
101276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
101376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
101476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
101576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(domains, tcp->u_arg[0], "PF_???");
101676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
101776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(socktypes, tcp->u_arg[1], "SOCK_???");
101876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
101976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[0]) {
102076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_INET:
102176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
102276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
102376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
102476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_IPX:
102576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* BTW: I don't believe this.. */
102676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[");
102776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(domains, tcp->u_arg[2], "PF_???");
102876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("]");
102976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
103076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* PF_IPX */
103176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
10322e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf("%lu", tcp->u_arg[2]);
103376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
103476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
103576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
103676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
10372e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf(", %#lx", tcp->u_arg[3]);
103876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
103976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
104076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef LINUX
104176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
10422e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf(", [...]");
104376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
104476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", [%u, %u]", fds[0], fds[1]);
104576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* LINUX */
10462e4ffe59b588159eb80e236f068278ba47735932Wichert Akkerman#if defined(SUNOS4) || defined(SVR4) || defined(FREEBSD)
104776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
10482e4ffe59b588159eb80e236f068278ba47735932Wichert Akkerman#endif /* SUNOS4 || SVR4 || FREEBSD */
104976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
105076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
105176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
105276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
105376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
105476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_getsockopt(tcp)
105576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
105676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
105776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
105876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
105976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[1]) {
106076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_SOCKET:
106176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_SOCKET, ");
106276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockoptions, tcp->u_arg[2], "SO_???");
106376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
106476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
106576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
106676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IP:
106776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IP, ");
106876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipoptions, tcp->u_arg[2], "IP_???");
106976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
107076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
107176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
107276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
107376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IPX:
107476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IPX, ");
107576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
107676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
107776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
107876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
10797987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_PACKET
10807987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		case SOL_PACKET:
10817987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf("SOL_PACKET, ");
10827987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
10837987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", ");
10847987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			break;
10857987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
108676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
108776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_TCP:
108876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_TCP, ");
108976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
109076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
109176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
109276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
109376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
109476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
109576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		 * etc. still need work */
109676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
109776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* XXX - should know socket family here */
1098efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman			printxval(socketlayers, tcp->u_arg[1], "SOL_???");
1099f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf(", %lu, ", tcp->u_arg[2]);
110076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
110176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
110276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
110376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
110476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx, %#lx",
110576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[3], tcp->u_arg[4]);
110676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
110776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
110876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printnum(tcp, tcp->u_arg[3], "%ld");
110976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
111076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printnum(tcp, tcp->u_arg[4], "%ld");
111176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
111276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
111376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
111476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
11157987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_FILTER)
11167987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkermanstatic void printicmpfilter(tcp, addr)
11177987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkermanstruct tcb *tcp;
11187987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkermanlong addr;
11197987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman{
11207987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	struct icmp_filter	filter;
11217987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
11227987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	if (!addr) {
11237987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		tprintf("NULL");
11247987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		return;
11257987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	}
11267987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	if (syserror(tcp) || !verbose(tcp)) {
11277987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		tprintf("%#lx", addr);
11287987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		return;
11297987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	}
11307987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	if (umove(tcp, addr, &filter) < 0) {
11317987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		tprintf("{...}");
11327987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		return;
11337987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	}
11347987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
11357987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	tprintf("~(");
11367987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	if (printflags(icmpfilterflags, ~filter.data) == 0)
11377987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		tprintf("0");
11387987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	tprintf(")");
11397987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman}
11407987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* ICMP_FILTER */
11417987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
114276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
114376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_setsockopt(tcp)
114476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
114576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
114676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
114776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
114876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[1]) {
114976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_SOCKET:
115076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_SOCKET, ");
115176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockoptions, tcp->u_arg[2], "SO_???");
115276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
11537987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printnum(tcp, tcp->u_arg[3], "%ld");
11547987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", %lu", tcp->u_arg[4]);
115576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
115676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
115776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IP:
115876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IP, ");
115976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipoptions, tcp->u_arg[2], "IP_???");
116076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
11617987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printnum(tcp, tcp->u_arg[3], "%ld");
11627987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", %lu", tcp->u_arg[4]);
116376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
116476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
116576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
116676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IPX:
116776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IPX, ");
116876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
116976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
11707987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printnum(tcp, tcp->u_arg[3], "%ld");
11717987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", %lu", tcp->u_arg[4]);
11727987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			break;
11737987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11747987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_PACKET
11757987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		case SOL_PACKET:
11767987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf("SOL_PACKET, ");
11777987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
11787987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", ");
11797987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			/* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
11807987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printnum(tcp, tcp->u_arg[3], "%ld");
11817987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", %lu", tcp->u_arg[4]);
118276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
118376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
118476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
118576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_TCP:
118676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_TCP, ");
118776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
118876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
11897987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printnum(tcp, tcp->u_arg[3], "%ld");
11907987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", %lu", tcp->u_arg[4]);
11917987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			break;
11927987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11937987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_RAW
11947987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		case SOL_RAW:
11957987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf("SOL_RAW, ");
11967987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printxval(sockrawoptions, tcp->u_arg[2], "RAW_???");
11977987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", ");
11987987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			switch (tcp->u_arg[2]) {
11997987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_FILTER)
12007987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman				case ICMP_FILTER:
12017987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman					printicmpfilter(tcp, tcp->u_arg[3]);
12027987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman					break;
12037987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
12047987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman				default:
12057987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman					printnum(tcp, tcp->u_arg[3], "%ld");
12067987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman					break;
12077987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			}
12087987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", %lu", tcp->u_arg[4]);
120976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
121076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
121176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
121276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
121376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		 * etc. still need work  */
121476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
121576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* XXX - should know socket family here */
1216efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman			printxval(socketlayers, tcp->u_arg[1], "IPPROTO_???");
1217efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman			tprintf(", %lu, ", tcp->u_arg[2]);
12187987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printnum(tcp, tcp->u_arg[3], "%ld");
12197987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			tprintf(", %lu", tcp->u_arg[4]);
122076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
122176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
122276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
122376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
122476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
122516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
122616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman#if UNIXWARE >= 7
122716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
122816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstatic struct xlat sock_version[] = {
122916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	{ __NETLIB_UW211_SVR4,	"UW211_SVR4" },
123016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	{ __NETLIB_UW211_XPG4,	"UW211_XPG4" },
123116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	{ __NETLIB_GEMINI_SVR4,	"GEMINI_SVR4" },
123216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	{ __NETLIB_GEMINI_XPG4,	"GEMINI_XPG4" },
123316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	{ __NETLIB_FP1_SVR4,	"FP1_SVR4" },
123416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	{ __NETLIB_FP1_XPG4,	"FP1_XPG4" },
123516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	{ 0,            NULL            },
123616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman};
123716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
123816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
123916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
124016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermannetlib_call(tcp, func)
124116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
124216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint (*func) ();
124316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
124416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	if (entering(tcp)) {
124516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		int i;
124616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
124716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		tprintf(", ");
124816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		--tcp->u_nargs;
124916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		for (i = 0; i < tcp->u_nargs; i++)
125016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman			tcp->u_arg[i] = tcp->u_arg[i + 1];
125116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		return func (tcp);
125216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
125316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	}
125416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
125516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return func (tcp);
125616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
125716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
125816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
125916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xsocket(tcp)
126016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
126116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
126216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_socket);
126316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
126416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
126516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
126616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xsocketpair(tcp)
126716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
126816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
126916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_socketpair);
127016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
127116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
127216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
127316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xbind(tcp)
127416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
127516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
127616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_bind);
127716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
127816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
127916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
128016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xconnect(tcp)
128116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
128216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
128316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_connect);
128416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
128516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
128616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
128716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xlisten(tcp)
128816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
128916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
129016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_listen);
129116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
129216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
129316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
129416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xaccept(tcp)
129516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
129616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
129716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_accept);
129816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
129916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
130016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
130116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xsendmsg(tcp)
130216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
130316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
130416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_sendmsg);
130516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
130616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
130716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
130816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xrecvmsg(tcp)
130916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
131016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
131116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_recvmsg);
131216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
131316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
131416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
131516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xgetsockaddr(tcp)
131616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
131716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
131816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	if (entering(tcp)) {
131916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
132016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		tprintf(", ");
132116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		if (tcp->u_arg[1] == 0) {
132216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman			tprintf ("LOCALNAME, ");
132316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		}
132416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		else if (tcp->u_arg[1] == 1) {
132516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman			tprintf ("REMOTENAME, ");
132616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		}
132716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		else {
132816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman			tprintf ("%ld, ", tcp->u_arg [1]);
132916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		}
133016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		tprintf ("%ld, ", tcp->u_arg [2]);
133116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	}
133216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	else {
133316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		if (tcp->u_arg[3] == 0 || syserror(tcp)) {
133416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman			tprintf("%#lx", tcp->u_arg[3]);
133516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		} else {
133616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman			printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
133716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		}
133816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		tprintf(", ");
133916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman		printnum(tcp, tcp->u_arg[4], "%lu");
134016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	}
134116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
134216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return 0;
134316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
134416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
134516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
134616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman#if 0
134716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
134816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
134916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xsetsockaddr(tcp)
135016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
135116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
135216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_setsockaddr);
135316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
135416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
135516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman#endif
135616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
135716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
135816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xgetsockopt(tcp)
135916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
136016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
136116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_getsockopt);
136216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
136316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
136416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
136516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xsetsockopt(tcp)
136616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
136716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
136816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_setsockopt);
136916a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
137016a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
137116a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanint
137216a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermansys_xshutdown(tcp)
137316a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkermanstruct tcb *tcp;
137416a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman{
137516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman	return netlib_call (tcp, sys_shutdown);
137616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman}
137716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
137816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman#endif
1379