net.c revision 2e2553a534f532a1546ea2b2f3dc3cd2276d020d
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>
576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * All rights reserved.
676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * Redistribution and use in source and binary forms, with or without
876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * modification, are permitted provided that the following conditions
976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * are met:
1076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 1. Redistributions of source code must retain the above copyright
1176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    notice, this list of conditions and the following disclaimer.
1276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 2. Redistributions in binary form must reproduce the above copyright
1376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    notice, this list of conditions and the following disclaimer in the
1476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    documentation and/or other materials provided with the distribution.
1576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * 3. The name of the author may not be used to endorse or promote products
1676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *    derived from this software without specific prior written permission.
1776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
1876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *
2976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman *	$Id$
3076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman */
3176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include "defs.h"
3376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/stat.h>
3576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/socket.h>
3676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/un.h>
3776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <netinet/in.h>
3876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <arpa/inet.h>
3976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(LINUX)
4076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <asm/types.h>
4176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3)
4276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#  include <netipx/ipx.h>
4376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#else
4476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#  include <linux/ipx.h>
4576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
4676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* LINUX */
4776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
4876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef PF_UNSPEC
4976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define PF_UNSPEC AF_UNSPEC
5076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
5176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
5276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef LINUX
5376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman/* Under Linux these are enums so we can't test for them with ifdef. */
5476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_EGP IPPROTO_EGP
5576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_PUP IPPROTO_PUP
5676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_IDP IPPROTO_IDP
5776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_IGMP IPPROTO_IGMP
5876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_RAW IPPROTO_RAW
5976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_MAX IPPROTO_MAX
6076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
6276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat domains[] = {
6376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_UNSPEC,	"PF_UNSPEC"	},
6476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_UNIX,	"PF_UNIX"	},
6576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_INET,	"PF_INET"	},
6676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_LOCAL
6776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_LOCAL,	"PS_LOCAL"	},
6876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_ISO
7076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_ISO,	"PF_ISO"	},
7176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
7276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_AX25
7376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_AX25,	"PF_AX25"	},
7476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
7576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
7676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_IPX,	"PF_IPX"	},
7776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
7876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_APPLETALK
7976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_APPLETALK,	"PF_APPLETALK"	},
8076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
8176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_NETROM
8276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_NETROM,	"PF_NETROM"	},
8376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
8476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_BRIDGE
8576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_BRIDGE,	"PF_BRIDGE"	},
8676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
8776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_AAL5
8876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_AAL5,	"PF_AAL5"	},
8976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
9076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_X25
9176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_X25,	"PF_X25"	},
9276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
9376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_INET6
9476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_INET6,	"PF_INET6"	},
9576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
9676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_ROSE
9776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_ROSE,	"PF_ROSE"	},
9876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
9976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_DECNET
10076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_DECNET,	"PF_DECNET"	},
10176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
10276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_NETBEUI
10376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_NETBEUI,	"PF_NETBEUI"	},
10476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
10576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IMPLINK
10676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_IMPLINK,	"PF_IMPLINK"	},
10776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
10876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
10976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
11076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat socktypes[] = {
11176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_STREAM,	"SOCK_STREAM"	},
11276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_DGRAM,	"SOCK_DGRAM"	},
11376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_RAW
11476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_RAW,	"SOCK_RAW"	},
11576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
11676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_SEQPACKET
11776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_SEQPACKET,"SOCK_SEQPACKET"},
11876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
11976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_RDM
12076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_RDM,	"SOCK_RDM"	},
12176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
12276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_PACKET
12376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_PACKET,	"SOCK_PACKET"	},
12476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
12576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
12676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
12776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat protocols[] = {
12876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IP,	"IPPROTO_IP"	},
12976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ICMP,	"IPPROTO_ICMP"	},
13076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_TCP,	"IPPROTO_TCP"	},
13176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_UDP,	"IPPROTO_UDP"	},
13276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_GGP
13376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_GGP,	"IPPROTO_GGP"	},
13476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
13576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_EGP
13676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_EGP,	"IPPROTO_EGP"	},
13776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
13876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_PUP
13976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_PUP,	"IPPROTO_PUP"	},
14076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
14176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IDP
14276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IDP,	"IPPROTO_IDP"	},
14376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
14476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IPV6
14576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IPV6,	"IPPROTO_IPV6"	},
14676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
14776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_ICMPV6
14876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ICMPV6,"IPPROTO_ICMPV6"},
14976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
15076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IGMP
15176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IGMP,	"IPPROTO_IGMP"	},
15276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
15376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_HELLO
15476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_HELLO,"IPPROTO_HELLO"	},
15576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
15676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_ND
15776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ND,	"IPPROTO_ND"	},
15876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
15976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_RAW
16076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_RAW,	"IPPROTO_RAW"	},
16176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
16276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_MAX
16376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_MAX,	"IPPROTO_MAX"	},
16476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
16576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IPIP
16676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IPIP,	"IPPROTO_IPIP"	},
16776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
16876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
16976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
17076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat msg_flags[] = {
17176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_OOB,	"MSG_OOB"	},
17276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_DONTROUTE
17376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_DONTROUTE,"MSG_DONTROUTE"	},
17476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
17576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_PEEK
17676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_PEEK,	"MSG_PEEK"	},
17776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
17876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_CTRUNC
17976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_CTRUNC,	"MSG_CTRUNC"	},
18076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_PROXY
18276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_PROXY,	"MSG_PROXY"	},
18376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_EOR
18576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_EOR,	"MSG_EOR"	},
18676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_WAITALL
18876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ MSG_WAITALL,	"MSG_WAITALL"	},
18976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
19076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
19176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
19276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
19376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat sockoptions[] = {
19476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_DEBUG
19576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_DEBUG,	"SO_DEBUG"	},
19676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
19776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_REUSEADDR
19876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_REUSEADDR,	"SO_REUSEADDR"	},
19976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
20076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_KEEPALIVE
20176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_KEEPALIVE,	"SO_KEEPALIVE"	},
20276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
20376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_DONTROUTE
20476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_DONTROUTE,	"SO_DONTROUTE"	},
20576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
20676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_BROADCAST
20776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_BROADCAST,	"SO_BROADCAST"	},
20876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
20976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_LINGER
21076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_LINGER,	"SO_LINGER"	},
21176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
21276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_OOBINLINE
21376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_OOBINLINE,	"SO_OOBINLINE"	},
21476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
21576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_TYPE
21676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_TYPE,	"SO_TYPE"	},
21776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
21876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_ERROR
21976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_ERROR,	"SO_ERROR"	},
22076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
22176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDBUF
22276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDBUF,	"SO_SNDBUF"	},
22376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
22476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVBUF
22576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVBUF,	"SO_RCVBUF"	},
22676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
22776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_NO_CHECK
22876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_NO_CHECK,	"SO_NO_CHECK"	},
22976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
23076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_PRIORITY
23176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_PRIORITY,	"SO_PRIORITY"	},
23276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
23376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_ACCEPTCONN
23476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_ACCEPTCONN,"SO_ACCEPTCONN"	},
23576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
23676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_USELOOPBACK
23776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_USELOOPBACK,"SO_USELOOPBACK"},
23876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
23976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDLOWAT
24076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDLOWAT,	"SO_SNDLOWAT"	},
24176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
24276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVLOWAT
24376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVLOWAT,	"SO_RCVLOWAT"	},
24476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
24576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDTIMEO
24676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDTIMEO,	"SO_SNDTIMEO"	},
24776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
24876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVTIMEO
24976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVTIMEO,	"SO_RCVTIMEO"	},
25076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
25176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_BSDCOMPAT
25276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_BSDCOMPAT,	"SO_BSDCOMPAT"	},
25376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
25476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_REUSEPORT
25576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_REUSEPORT,	"SO_REUSEPORT"	},
25676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
25776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVLOWAT
25876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVLOWAT, "SO_RCVLOWAT"	},
25976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
26076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDLOWAT
26176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDLOWAT, "SO_SNDLOWAT"	},
26276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
26376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVTIMEO
26476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVTIMEO, "SO_RCVTIMEO"	},
26576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
26676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_SNDTIMEO
26776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_SNDTIMEO, "SO_SNDTIMEO"	},
26876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
26976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
27076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
27176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
27276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
27376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat sockipoptions[] = {
27476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_TOS,       "IP_TOS"        },
27576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_TTL,       "IP_TTL"        },
27676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(IP_HDRINCL)
27776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_HDRINCL,   "IP_HDRINCL"    },
27876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
27976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(IP_OPTIONS)
28076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_OPTIONS,   "IP_OPTIONS"    },
28176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
28276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_MULTICAST_IF,      "IP_MULTICAST_IF"       },
28376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_MULTICAST_TTL,     "IP_MULTICAST_TTL"      },
28476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_MULTICAST_LOOP,    "IP_MULTICAST_LOOP"     },
28576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_ADD_MEMBERSHIP,    "IP_ADD_MEMBERSHIP"     },
28676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IP_DROP_MEMBERSHIP,   "IP_DROP_MEMBERSHIP"    },
28776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,            NULL            },
28876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
28976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_IP */
29076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
29176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
29276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat sockipxoptions[] = {
29376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPX_TYPE,     "IPX_TYPE"      },
29476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,            NULL            },
29576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
29676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_IPX */
29776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
29876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
29976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic struct xlat socktcpoptions[] = {
30076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ TCP_NODELAY,  "TCP_NODELAY"   },
30176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ TCP_MAXSEG,   "TCP_MAXSEG"    },
30276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,            NULL            },
30376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
30476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_TCP */
30576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
30676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanvoid
30776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanprintsock(tcp, addr)
30876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
30976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanlong addr;
31076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
31176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	struct sockaddr sa;
31276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	struct sockaddr_in *sin = (struct sockaddr_in *) &sa;
31376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	struct sockaddr_un sau;
31476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef LINUX
31576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	struct sockaddr_ipx sipx;
31676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
31776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
31876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (addr == 0) {
31976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("NULL");
32076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
32176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
32276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (!verbose(tcp)) {
32376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%#lx", addr);
32476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
32576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
32676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (umove(tcp, addr, &sa) < 0) {
32776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("{...}");
32876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
32976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
33076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	switch (sa.sa_family) {
33176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_UNIX:
33276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umove(tcp, addr, &sau) < 0)
33376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("{sun_family=AF_UNIX, ...}");
33476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
33576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("{sun_family=AF_UNIX, sun_path=\"%s\"}",
33676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				sau.sun_path);
33776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
33876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_INET:
33976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("{sin_family=AF_INET, ");
34076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")}",
34176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			ntohs(sin->sin_port), inet_ntoa(sin->sin_addr));
34276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
34376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef AF_IPX
34476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_IPX:
34576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umove(tcp, addr, &sipx)<0)
34676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("{sipx_family=AF_IPX, ...}");
34776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else {
34876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			int i;
34976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("{sipx_family=AF_IPX, ");
35076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("{sipx_port=htons(%u), ",
35176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				ntohs(sipx.sipx_port));
35276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* Yes, I know, this does not look too
35376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * strace-ish, but otherwise the IPX
35476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * addresses just look monstrous...
35576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * Anyways, feel free if you don't like
35676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * this way.. :)
35776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 */
3586bfcd3287759af376cfcc7670da3f048261fab90Nate Sammons			tprintf("%08lx:", (unsigned long)ntohl(sipx.sipx_network));
35976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			for (i = 0; i<IPX_NODE_LEN; i++)
36076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf("%02x", sipx.sipx_node[i]);
36176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("/[%02x]", sipx.sipx_type);
36276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("}");
36376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
36476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
36576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* AF_IPX */
36676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	/* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
36776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	AF_X25 AF_INET6 AF_ROSE still need to be done */
36876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
36976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	default:
37076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("{sa_family=%u, sa_data=", sa.sa_family);
37176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
37276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			sizeof sa.sa_data);
37376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("}");
37476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
37576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
37676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
37776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
37876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if HAVE_SENDMSG
37976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
38076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic void
38176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanprintmsghdr(tcp, addr)
38276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
38376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanlong addr;
38476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
38576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	struct msghdr msg;
38676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3872e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	if (umove(tcp, addr, &msg) < 0) {
3882e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman		tprintf("%#lx", addr);
3892e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman		return;
3902e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	}
3912e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	tprintf("{msg_name=");
3922e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	printstr(tcp, (long) msg.msg_name, msg.msg_namelen);
3932e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	tprintf(", msg_namelen=%u, msg_iov=%#lx, msg_iovlen=%u, ",
3942e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman		msg.msg_namelen,
39576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		(unsigned long) msg.msg_iov, msg.msg_iovlen);
39676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_MSG_CONTROL
39776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	tprintf("msg_control=%#lx, msg_controllen=%u, msg_flags=%#x}",
39876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		(unsigned long) msg.msg_control, msg.msg_controllen,
39976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		msg.msg_flags);
40076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#else /* !HAVE_MSG_CONTROL */
40176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	tprintf("msg_accrights=%#lx, msg_accrightslen=%u}",
40276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		(unsigned long) msg.msg_accrights, msg.msg_accrightslen);
40376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* !HAVE_MSG_CONTROL */
40476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
40576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
40676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
40776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
40876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
40976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_socket(tcp)
41076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
41176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
41276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
41376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(domains, tcp->u_arg[0], "PF_???");
41476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
41576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(socktypes, tcp->u_arg[1], "SOCK_???");
41676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
41776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[0]) {
41876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_INET:
41976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
42076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
42176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
42276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_IPX:
42376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* BTW: I don't believe this.. */
42476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[");
42576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(domains, tcp->u_arg[2], "PF_???");
42676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("]");
42776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
42876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* PF_IPX */
42976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
43076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%lu", tcp->u_arg[2]);
43176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
43276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
43376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
43476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
43576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
43676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
43776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
43876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_bind(tcp)
43976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
44076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
44176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
44276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
44376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printsock(tcp, tcp->u_arg[1]);
44476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu", tcp->u_arg[2]);
44576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
44676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
44776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
44876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
44976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
45076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_connect(tcp)
45176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
45276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
45376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_bind(tcp);
45476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
45576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
45676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
45776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_listen(tcp)
45876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
45976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
46076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
46176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
46276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
46376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
46476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
46576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
46676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
46776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_accept(tcp)
46876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
46976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
47076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
47176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
47276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else if (!tcp->u_arg[2])
47376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%#lx, NULL", tcp->u_arg[1]);
47476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	else {
47576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (tcp->u_arg[1] == 0 || syserror(tcp)) {
47676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
47776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		} else {
47876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printsock(tcp, tcp->u_arg[1]);
47976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
48076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
48176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printnum(tcp, tcp->u_arg[2], "%lu");
48276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
48376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
48476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
48576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
48676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
48776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_send(tcp)
48876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
48976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
49076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
49176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
49276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
49376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
49476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
49576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
49676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
49776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
49876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
49976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
50076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
50176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
50276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_sendto(tcp)
50376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
50476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
50576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
50676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
50776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
50876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
50976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
51076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
51176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
51276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* to address */
51376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
51476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printsock(tcp, tcp->u_arg[4]);
51576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* to length */
51676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu", tcp->u_arg[5]);
51776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
51876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
51976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
52076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
52176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_SENDMSG
52276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
52376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
52476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_sendmsg(tcp)
52576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
52676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
52776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
52876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
52976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printmsghdr(tcp, tcp->u_arg[1]);
53076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
53176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
53276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[2]) == 0)
53376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
53476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
53576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
53676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
53776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
53876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
53976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
54076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
54176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_recv(tcp)
54276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
54376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
54476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
54576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
54676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
54776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp))
54876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
54976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
55076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printstr(tcp, tcp->u_arg[1], tcp->u_rval);
55176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
55276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
55376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
55476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
55576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
55676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
55776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
55876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
55976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
56076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_recvfrom(tcp)
56176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
56276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
56376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fromlen;
56476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
56576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
56676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
56776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
56876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
56976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx, %lu, %lu, %#lx, %#lx",
57076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
57176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[4], tcp->u_arg[5]);
57276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
57376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
57476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* buf */
57576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_rval);
57676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* len */
57776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
57876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
57976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[3]) == 0)
58076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
58176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* from address, len */
58276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
58376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			if (tcp->u_arg[4] == 0)
58476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", NULL");
58576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			else
58676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", %#lx", tcp->u_arg[4]);
58776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			if (tcp->u_arg[5] == 0)
58876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", NULL");
58976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			else
59076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", %#lx", tcp->u_arg[5]);
59176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
59276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
59376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
59476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", {...}, [?]");
59576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
59676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
59776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
59876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printsock(tcp, tcp->u_arg[4]);
59976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* from length */
60076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", [%u]", fromlen);
60176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
60276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
60376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
60476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
60576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_SENDMSG
60676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
60776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
60876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_recvmsg(tcp)
60976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
61076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
61176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
61276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
61376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
61476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp) || !verbose(tcp))
61576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
61676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
61776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printmsghdr(tcp, tcp->u_arg[1]);
61876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
61976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
62076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (printflags(msg_flags, tcp->u_arg[2]) == 0)
62176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("0");
62276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
62376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
62476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
62576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
62676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
62776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
62876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
62976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_shutdown(tcp)
63076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
63176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
63276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
63376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
63476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[1]) {
63576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case 0:
63676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%s", " /* receive */");
63776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
63876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case 1:
63976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%s", " /* send */");
64076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
64176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case 2:
64276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%s", " /* send and receive */");
64376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
64476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
64576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
64676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
64776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
64876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
64976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
65076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_getsockname(tcp)
65176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
65276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
65376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_accept(tcp);
65476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
65576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
65676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
65776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_getpeername(tcp)
65876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
65976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
66076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_accept(tcp);
66176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
66276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
66376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
66476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_pipe(tcp)
66576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
66676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
66776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
66876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if defined(LINUX) && !defined(SPARC)
66976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fds[2];
67076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
67176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (exiting(tcp)) {
67276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
67376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[0]);
67476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
67576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
67676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
67776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[...]");
67876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
67976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[%u, %u]", fds[0], fds[1]);
68076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
6815daa028ca314e4c36c1f38e0149834d9a0520128Wichert Akkerman#elif defined(SPARC) || defined(SVR4)
68276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (exiting(tcp))
68376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
68476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
68576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
68676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
68776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
68876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
68976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_socketpair(tcp)
69076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
69176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
69276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef LINUX
69376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fds[2];
69476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
69576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
69676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
69776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(domains, tcp->u_arg[0], "PF_???");
69876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
69976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(socktypes, tcp->u_arg[1], "SOCK_???");
70076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
70176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[0]) {
70276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_INET:
70376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
70476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
70576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
70676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_IPX:
70776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* BTW: I don't believe this.. */
70876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("[");
70976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(domains, tcp->u_arg[2], "PF_???");
71076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("]");
71176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
71276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* PF_IPX */
71376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
7142e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf("%lu", tcp->u_arg[2]);
71576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
71676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
71776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
71876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
7192e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf(", %#lx", tcp->u_arg[3]);
72076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
72176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
72276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef LINUX
72376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
7242e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf(", [...]");
72576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
72676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", [%u, %u]", fds[0], fds[1]);
72776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* LINUX */
72876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SUNOS4
72976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
73076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SUNOS4 */
73176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SVR4
73276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", [%lu, %lu]", tcp->u_rval, getrval2(tcp));
73376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SVR4 */
73476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
73576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
73676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
73776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
73876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
73976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_getsockopt(tcp)
74076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
74176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
74276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
74376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
74476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[1]) {
74576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_SOCKET:
74676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_SOCKET, ");
74776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockoptions, tcp->u_arg[2], "SO_???");
74876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
74976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
75076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
75176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IP:
75276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IP, ");
75376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipoptions, tcp->u_arg[2], "IP_???");
75476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
75576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
75676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
75776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
75876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IPX:
75976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IPX, ");
76076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
76176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
76276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
76376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
76476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
76576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_TCP:
76676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_TCP, ");
76776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
76876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
76976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
77076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
77176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
77276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
77376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		 * etc. still need work */
77476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
77576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* XXX - should know socket family here */
77676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[1], "IPPROTO_???");
77776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%lu, ", tcp->u_arg[2]);
77876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
77976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
78076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
78176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
78276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx, %#lx",
78376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[3], tcp->u_arg[4]);
78476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
78576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
78676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printnum(tcp, tcp->u_arg[3], "%ld");
78776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", ");
78876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printnum(tcp, tcp->u_arg[4], "%ld");
78976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
79076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
79176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
79276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
79376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
79476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermansys_setsockopt(tcp)
79576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstruct tcb *tcp;
79676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
79776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
79876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
79976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[1]) {
80076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_SOCKET:
80176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_SOCKET, ");
80276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockoptions, tcp->u_arg[2], "SO_???");
80376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
80476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
80576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
80676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IP:
80776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IP, ");
80876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipoptions, tcp->u_arg[2], "IP_???");
80976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
81076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
81176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
81276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
81376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IPX:
81476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_IPX, ");
81576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
81676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
81776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
81876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
81976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
82076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_TCP:
82176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("SOL_TCP, ");
82276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
82376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", ");
82476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
82576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
82676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
82776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
82876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		 * etc. still need work  */
82976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
83076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* XXX - should know socket family here */
83176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[1], "IPPROTO_???");
83276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%lu, ", tcp->u_arg[2]);
83376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
83476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
83576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printnum(tcp, tcp->u_arg[3], "%ld");
83676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu", tcp->u_arg[4]);
83776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
83876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
83976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
840