net.c revision 99aa181ebcee3f6ae4f8eb83c719cc64cc5a09ec
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
3176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include "defs.h"
3276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/stat.h>
3376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/socket.h>
3476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/un.h>
35f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
36a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# define in6_addr in6_addr_libc
37a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# define ipv6_mreq ipv6_mreq_libc
38a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# define sockaddr_in6 sockaddr_in6_libc
39f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#endif
4076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <netinet/in.h>
418c7122c9519dfd46ea7c8c026eab6f7aed74cf21Wichert Akkerman#ifdef HAVE_NETINET_TCP_H
42a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <netinet/tcp.h>
43bf79f2e16b090ffe59cd1e1820935680a2da7b78Wichert Akkerman#endif
448c7122c9519dfd46ea7c8c026eab6f7aed74cf21Wichert Akkerman#ifdef HAVE_NETINET_UDP_H
45a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <netinet/udp.h>
468c7122c9519dfd46ea7c8c026eab6f7aed74cf21Wichert Akkerman#endif
477fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#ifdef HAVE_NETINET_SCTP_H
48a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <netinet/sctp.h>
497fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
5076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <arpa/inet.h>
51f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#include <net/if.h>
5276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <asm/types.h>
5399aa181ebcee3f6ae4f8eb83c719cc64cc5a09ecDenys Vlasenko#if defined(__GLIBC__)
54a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <netipx/ipx.h>
5576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#else
56a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <linux/ipx.h>
5776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
5876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
5999aa181ebcee3f6ae4f8eb83c719cc64cc5a09ecDenys Vlasenko#if defined(__GLIBC__) && defined(HAVE_SIN6_SCOPE_ID_LINUX)
60a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# if defined(HAVE_LINUX_IN6_H)
61a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#  if defined(HAVE_SIN6_SCOPE_ID_LINUX)
62a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   undef in6_addr
63a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   undef ipv6_mreq
64a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   undef sockaddr_in6
65a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   define in6_addr in6_addr_kernel
66a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   define ipv6_mreq ipv6_mreq_kernel
67a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   define sockaddr_in6 sockaddr_in6_kernel
68a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#  endif
69a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#  include <linux/in6.h>
70a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#  if defined(HAVE_SIN6_SCOPE_ID_LINUX)
71a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   undef in6_addr
72a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   undef ipv6_mreq
73a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   undef sockaddr_in6
74a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   define in6_addr in6_addr_libc
75a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   define ipv6_mreq ipv6_mreq_libc
76a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#   define sockaddr_in6 sockaddr_in6_kernel
77a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko#  endif
78a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# endif
792f473da12babff710bbe37c7f95be01fd00118f9Wichert Akkerman#endif
80505e176ded6376a1283093b334c2c6deb47916e7Wichert Akkerman
81f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(HAVE_SYS_UIO_H)
82a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <sys/uio.h>
83f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
84f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(HAVE_LINUX_NETLINK_H)
85a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <linux/netlink.h>
86f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
87f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#if defined(HAVE_LINUX_IF_PACKET_H)
88a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <linux/if_packet.h>
89f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
907987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(HAVE_LINUX_ICMP_H)
91a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# include <linux/icmp.h>
927987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
9376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifndef PF_UNSPEC
94a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8Denys Vlasenko# define PF_UNSPEC AF_UNSPEC
9576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
9676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
9776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman/* Under Linux these are enums so we can't test for them with ifdef. */
9876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_EGP IPPROTO_EGP
9976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_PUP IPPROTO_PUP
10076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_IDP IPPROTO_IDP
10176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_IGMP IPPROTO_IGMP
10276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_RAW IPPROTO_RAW
10376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#define IPPROTO_MAX IPPROTO_MAX
10476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
105d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat domains[] = {
1065a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_AAL5
1075a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_AAL5,	"PF_AAL5"	},
108f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
1095a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_APPLETALK
1105a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_APPLETALK,	"PF_APPLETALK"	},
111f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
1125a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_ASH
1135a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_ASH,	"PF_ASH"	},
1145a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1155a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_ATMPVC
1165a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_ATMPVC,	"PF_ATMPVC"	},
117f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
118f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_ATMSVC
1195a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_ATMSVC,	"PF_ATMSVC"	},
1205a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1215a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_AX25
1225a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_AX25,	"PF_AX25"	},
1235a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1245a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_BLUETOOTH
1255a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_BLUETOOTH,	"PF_BLUETOOTH"	},
1265a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1275a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_BRIDGE
1285a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_BRIDGE,	"PF_BRIDGE"	},
1295a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1305a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_DECnet
1315a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_DECnet,	"PF_DECnet"	},
1325a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1335a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_DECNET
1345a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_DECNET,	"PF_DECNET"	},
1355a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1365a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_ECONET
1375a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_ECONET,	"PF_ECONET"	},
1385a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1395a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_FILE
1405a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_FILE,	"PF_FILE"	},
1415a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1425a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_IMPLINK
1435a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_IMPLINK,	"PF_IMPLINK"	},
1445a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1455a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_INET
1465a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_INET,	"PF_INET"	},
147f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
148f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef PF_INET6
149f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ PF_INET6,	"PF_INET6"	},
150f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
1515a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_IPX
1525a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_IPX,	"PF_IPX"	},
1535a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1545a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_IRDA
1555a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_IRDA,	"PF_IRDA"	},
15676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
15776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_ISO
15876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_ISO,	"PF_ISO"	},
15976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1605a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_KEY
1615a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_KEY,	"PF_KEY"	},
16276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1635a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_UNIX
1645a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_UNIX,	"PF_UNIX"	},
16576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1665a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_LOCAL
1675a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_LOCAL,	"PF_LOCAL"	},
1685a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1695a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_NETBEUI
1705a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_NETBEUI,	"PF_NETBEUI"	},
1715a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1725a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_NETLINK
1735a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_NETLINK,	"PF_NETLINK"	},
17476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
17576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_NETROM
17676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_NETROM,	"PF_NETROM"	},
17776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1785a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_PACKET
1795a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_PACKET,	"PF_PACKET"	},
18076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1815a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_PPPOX
1825a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_PPPOX,	"PF_PPPOX"	},
18376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_ROSE
18576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ PF_ROSE,	"PF_ROSE"	},
18676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1875a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_ROUTE
1885a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_ROUTE,	"PF_ROUTE"	},
18976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1905a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_SECURITY
1915a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_SECURITY,	"PF_SECURITY"	},
19276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1935a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_SNA
1945a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_SNA,	"PF_SNA"	},
1955a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1965a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_UNSPEC
1975a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_UNSPEC,	"PF_UNSPEC"	},
1985a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
1995a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_WANPIPE
2005a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_WANPIPE,	"PF_WANPIPE"	},
2015a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2025a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef PF_X25
2035a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ PF_X25,	"PF_X25"	},
20476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
20576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
20676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
207d9f816f60457930af27349fac3d23b3b78338036Roland McGrathconst struct xlat addrfams[] = {
2085a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_APPLETALK
2095a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_APPLETALK,	"AF_APPLETALK"	},
2105a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2115a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_ASH
2125a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_ASH,	"AF_ASH"	},
2135a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2145a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_ATMPVC
2155a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_ATMPVC,	"AF_ATMPVC"	},
2165a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2175a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_ATMSVC
2185a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_ATMSVC,	"AF_ATMSVC"	},
2195a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2205a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_AX25
2215a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_AX25,	"AF_AX25"	},
2225a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2235a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_BLUETOOTH
2245a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_BLUETOOTH,	"AF_BLUETOOTH"	},
2255a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2265a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_BRIDGE
2275a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_BRIDGE,	"AF_BRIDGE"	},
2285a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2295a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_DECnet
2305a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_DECnet,	"AF_DECnet"	},
2315a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2325a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_ECONET
2335a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_ECONET,	"AF_ECONET"	},
2345a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2355a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_FILE
2365a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_FILE,	"AF_FILE"	},
2375a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2385a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_IMPLINK
2395a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_IMPLINK,	"AF_IMPLINK"	},
2405a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2415a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_INET
242f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_INET,	"AF_INET"	},
2435a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
244e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#ifdef AF_INET6
245f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_INET6,	"AF_INET6"	},
246e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#endif
2475a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_IPX
2485a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_IPX,	"AF_IPX"	},
249f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
2505a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_IRDA
2515a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_IRDA,	"AF_IRDA"	},
2525a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2535a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_ISO
2545a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_ISO,	"AF_ISO"	},
2555a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2565a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_KEY
2575a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_KEY,	"AF_KEY"	},
2585a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2595a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_UNIX
2605a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_UNIX,	"AF_UNIX"	},
2615a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2625a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_LOCAL
2635a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_LOCAL,	"AF_LOCAL"	},
2645a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2655a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_NETBEUI
2665a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_NETBEUI,	"AF_NETBEUI"	},
267e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#endif
268e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#ifdef AF_NETLINK
269f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ AF_NETLINK,	"AF_NETLINK"	},
270e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman#endif
2715a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_NETROM
2725a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_NETROM,	"AF_NETROM"	},
273f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
2745a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_PACKET
2755a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_PACKET,	"AF_PACKET"	},
2765a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2775a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_PPPOX
2785a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_PPPOX,	"AF_PPPOX"	},
2795a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2805a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_ROSE
2815a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_ROSE,	"AF_ROSE"	},
2825a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2835a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_ROUTE
2845a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_ROUTE,	"AF_ROUTE"	},
2855a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2865a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_SECURITY
2875a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_SECURITY,	"AF_SECURITY"	},
2885a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2895a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_SNA
2905a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_SNA,	"AF_SNA"	},
2915a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2925a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_UNSPEC
2935a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_UNSPEC,	"AF_UNSPEC"	},
2945a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2955a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_WANPIPE
2965a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_WANPIPE,	"AF_WANPIPE"	},
2975a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#endif
2985a8146a20860eca692d182553ebe28b258c11af5Roland McGrath#ifdef AF_X25
2995a8146a20860eca692d182553ebe28b258c11af5Roland McGrath	{ AF_X25,	"AF_X25"	},
300f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
301f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	{ 0,		NULL		},
302f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman};
303d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat socktypes[] = {
30476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_STREAM,	"SOCK_STREAM"	},
30576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_DGRAM,	"SOCK_DGRAM"	},
30676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_RAW
30776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_RAW,	"SOCK_RAW"	},
30876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
3098a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#ifdef SOCK_RDM
3108a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	{ SOCK_RDM,	"SOCK_RDM"	},
3118a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#endif
31276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_SEQPACKET
31376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_SEQPACKET,"SOCK_SEQPACKET"},
31476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
3158a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#ifdef SOCK_DCCP
3168a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	{ SOCK_DCCP,	"SOCK_DCCP"	},
31776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
31876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOCK_PACKET
31976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SOCK_PACKET,	"SOCK_PACKET"	},
32076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
32176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
32276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
323d475c06134717745987e4c1859e4cdb8d16e2001Dmitry V. Levinstatic const struct xlat sock_type_flags[] = {
3248a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#ifdef SOCK_CLOEXEC
3258a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	{ SOCK_CLOEXEC,	"SOCK_CLOEXEC"	},
3268a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#endif
3278a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#ifdef SOCK_NONBLOCK
3288a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	{ SOCK_NONBLOCK,"SOCK_NONBLOCK"	},
3298a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#endif
3308a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	{ 0,		NULL		},
3318a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin};
3328a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#ifndef SOCK_TYPE_MASK
3338a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin# define SOCK_TYPE_MASK 0xf
3348a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin#endif
335d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat socketlayers[] = {
3361e4cb3466230aa8b4f2e8e8936b240c7b98db486John Hughes#if defined(SOL_IP)
337efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IP,	"SOL_IP"	},
3381e4cb3466230aa8b4f2e8e8936b240c7b98db486John Hughes#endif
339efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ICMP)
340efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ICMP,	"SOL_ICMP"	},
341efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
3421e4cb3466230aa8b4f2e8e8936b240c7b98db486John Hughes#if defined(SOL_TCP)
343efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_TCP,	"SOL_TCP"	},
3441e4cb3466230aa8b4f2e8e8936b240c7b98db486John Hughes#endif
3451e4cb3466230aa8b4f2e8e8936b240c7b98db486John Hughes#if defined(SOL_UDP)
346efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_UDP,	"SOL_UDP"	},
3471e4cb3466230aa8b4f2e8e8936b240c7b98db486John Hughes#endif
348efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_IPV6)
349efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IPV6,	"SOL_IPV6"	},
350efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
351efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ICMPV6)
352efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ICMPV6,	"SOL_ICMPV6"	},
353efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
354ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_SCTP)
355ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_SCTP,	"SOL_SCTP"	},
356ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
357ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_UDPLITE)
358ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_UDPLITE,	"SOL_UDPLITE"	},
359ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
360efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_RAW)
361efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_RAW,	"SOL_RAW"	},
362efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
363efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_IPX)
364efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IPX,	"SOL_IPX"	},
365efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
366efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_AX25)
367efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_AX25,	"SOL_AX25"	},
368efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
369efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ATALK)
370efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ATALK,	"SOL_ATALK"	},
371efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
372efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_NETROM)
373efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_NETROM,	"SOL_NETROM"	},
374efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
375efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ROSE)
376efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ROSE,	"SOL_ROSE"	},
377efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
378efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_DECNET)
379efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_DECNET,	"SOL_DECNET"	},
380efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
381efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_X25)
382efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_X25,	"SOL_X25"	},
383efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
384efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_PACKET)
385efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_PACKET,	"SOL_PACKET"	},
386efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
387efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_ATM)
388efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_ATM,	"SOL_ATM"	},
389efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
390efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_AAL)
391efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_AAL,	"SOL_AAL"	},
392efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
393efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#if defined(SOL_IRDA)
394efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman	{ SOL_IRDA,	"SOL_IRDA"	},
395efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman#endif
396ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_NETBEUI)
397ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_NETBEUI,	"SOL_NETBEUI"	},
398ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
399ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_LLC)
400ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_LLC,	"SOL_LLC"	},
401ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
402ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_DCCP)
403ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_DCCP,	"SOL_DCCP"	},
404ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
405ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_NETLINK)
406ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_NETLINK,	"SOL_NETLINK"	},
407ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
408ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_TIPC)
409ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_TIPC,	"SOL_TIPC"	},
410ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
411ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_RXRPC)
412ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_RXRPC,	"SOL_RXRPC"	},
413ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
414ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_PPPOL2TP)
415ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_PPPOL2TP,	"SOL_PPPOL2TP"	},
416ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
417ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_BLUETOOTH)
418ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_BLUETOOTH,"SOL_BLUETOOTH" },
419ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
420ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_PNPIPE)
421ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_PNPIPE,	"SOL_PNPIPE"	},
422ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
423ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_RDS)
424ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_RDS,	"SOL_RDS"	},
425ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
426ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_IUVC)
427ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_IUCV,	"SOL_IUCV"	},
428ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
429ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#if defined(SOL_CAIF)
430ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther	{ SOL_CAIF,	"SOL_CAIF"	},
431ce9e0f4c7fa3159376b7d05b8527bddfef0d2305Holger Hans Peter Freyther#endif
4326156357814ce751cb0e82a88a4824c931b2e3d62John Hughes	{ SOL_SOCKET,	"SOL_SOCKET"	},	/* Never used! */
433d475c06134717745987e4c1859e4cdb8d16e2001Dmitry V. Levin	/* The SOL_* array should remain not NULL-terminated. */
434efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman};
43593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes/*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
43693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes     falls into "protocols" array below!!!!   This is intended!!! ***/
437d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat protocols[] = {
43876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IP,	"IPPROTO_IP"	},
43976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ICMP,	"IPPROTO_ICMP"	},
44076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_TCP,	"IPPROTO_TCP"	},
44176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_UDP,	"IPPROTO_UDP"	},
442d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_IGMP
443d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_IGMP,	"IPPROTO_IGMP"	},
444d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
44576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_GGP
44676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_GGP,	"IPPROTO_GGP"	},
44776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
448d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_IPIP
449d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_IPIP,	"IPPROTO_IPIP"	},
450d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
45176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_EGP
45276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_EGP,	"IPPROTO_EGP"	},
45376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
45476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_PUP
45576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_PUP,	"IPPROTO_PUP"	},
45676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
45776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IDP
45876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IDP,	"IPPROTO_IDP"	},
45976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
460d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_TP
461d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_TP,	"IPPROTO_TP"	},
462d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
463d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_DCCP
464d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_DCCP,	"IPPROTO_DCCP"	},
465d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
46676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_IPV6
46776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_IPV6,	"IPPROTO_IPV6"	},
46876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
469d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_ROUTING
470d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_ROUTING, "IPPROTO_ROUTING" },
471d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
472d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_FRAGMENT
473d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_FRAGMENT, "IPPROTO_FRAGMENT" },
474d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
475d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_RSVP
476d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_RSVP,	"IPPROTO_RSVP"	},
477d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
478d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_GRE
479d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_GRE,	"IPPROTO_GRE"	},
480d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
481d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_ESP
482d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_ESP,	"IPPROTO_ESP"	},
483d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
484d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_AH
485d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_AH,	"IPPROTO_AH"	},
486d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
48776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_ICMPV6
488d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_ICMPV6, "IPPROTO_ICMPV6" },
48976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
490d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_NONE
491d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_NONE,	"IPPROTO_NONE"	},
492d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
493d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_DSTOPTS
494d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_DSTOPTS, "IPPROTO_DSTOPTS" },
49576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
49676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_HELLO
497d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_HELLO, "IPPROTO_HELLO" },
49876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
49976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef IPPROTO_ND
50076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ IPPROTO_ND,	"IPPROTO_ND"	},
50176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
502d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_MTP
503d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_MTP,	"IPPROTO_MTP"	},
50476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
505d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_ENCAP
506d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_ENCAP, "IPPROTO_ENCAP" },
50776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
508d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_PIM
509d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_PIM,	"IPPROTO_PIM"	},
510d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
511d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_COMP
512d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_COMP,	"IPPROTO_COMP"	},
513d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#endif
514d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_SCTP
515d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_SCTP,	"IPPROTO_SCTP"	},
51676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
517efa8bda2e7c06831de5262873d4da5749ea33302Holger Hans Peter Freyther#ifdef IPPROTO_UDPLITE
518efa8bda2e7c06831de5262873d4da5749ea33302Holger Hans Peter Freyther	{ IPPROTO_UDPLITE, "IPPROTO_UDPLITE" },
519efa8bda2e7c06831de5262873d4da5749ea33302Holger Hans Peter Freyther#endif
520d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_RAW
521d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_RAW,	"IPPROTO_RAW"	},
522efa8bda2e7c06831de5262873d4da5749ea33302Holger Hans Peter Freyther#endif
523d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin#ifdef IPPROTO_MAX
524d48c6b91e235d485308881f41bdfb21cd1426c15Dmitry V. Levin	{ IPPROTO_MAX,	"IPPROTO_MAX"	},
525efa8bda2e7c06831de5262873d4da5749ea33302Holger Hans Peter Freyther#endif
52676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
52776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
528d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat msg_flags[] = {
52971d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_OOB,		"MSG_OOB"		},
53076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_DONTROUTE
53171d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_DONTROUTE,	"MSG_DONTROUTE"		},
53276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
53376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_PEEK
53471d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_PEEK,		"MSG_PEEK"		},
53576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
53676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_CTRUNC
53771d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_CTRUNC,		"MSG_CTRUNC"		},
53876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
53976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_PROXY
54071d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_PROXY,		"MSG_PROXY"		},
54176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
54276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_EOR
54371d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_EOR,		"MSG_EOR"		},
54476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
54576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef MSG_WAITALL
54671d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_WAITALL,		"MSG_WAITALL"		},
54776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
548f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_TRUNC
54971d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_TRUNC,		"MSG_TRUNC"		},
550f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
551f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_CTRUNC
55271d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_CTRUNC,		"MSG_CTRUNC"		},
553f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
554f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_ERRQUEUE
55571d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_ERRQUEUE,		"MSG_ERRQUEUE"		},
556f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
557f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_DONTWAIT
55871d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_DONTWAIT,		"MSG_DONTWAIT"		},
559f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
560f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_CONFIRM
56171d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_CONFIRM,		"MSG_CONFIRM"		},
562f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
563f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef MSG_PROBE
56471d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_PROBE,		"MSG_PROBE"		},
565f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
56605e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#ifdef MSG_FIN
56771d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_FIN,		"MSG_FIN"		},
56805e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#endif
56905e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#ifdef MSG_SYN
57071d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_SYN,		"MSG_SYN"		},
57105e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#endif
57205e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#ifdef MSG_RST
57371d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_RST,		"MSG_RST"		},
57405e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#endif
57505e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#ifdef MSG_NOSIGNAL
57671d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_NOSIGNAL,		"MSG_NOSIGNAL"		},
57705e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#endif
57805e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#ifdef MSG_MORE
57971d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_MORE,		"MSG_MORE"		},
58005e5e79a706a560188c28aba8d765e1a8534e87bRoland McGrath#endif
5813df080af316bd7dad363d464114bc20ce36c1f53Dmitry V. Levin#ifdef MSG_WAITFORONE
5823df080af316bd7dad363d464114bc20ce36c1f53Dmitry V. Levin	{ MSG_WAITFORONE,	"MSG_WAITFORONE"	},
5833df080af316bd7dad363d464114bc20ce36c1f53Dmitry V. Levin#endif
58471d3d663caa197b26dcdade024612eee76bf837aRoland McGrath#ifdef MSG_CMSG_CLOEXEC
58571d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ MSG_CMSG_CLOEXEC,	"MSG_CMSG_CLOEXEC"	},
58671d3d663caa197b26dcdade024612eee76bf837aRoland McGrath#endif
58771d3d663caa197b26dcdade024612eee76bf837aRoland McGrath	{ 0,			NULL			},
58876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
58976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
590d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat sockoptions[] = {
5911bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_ACCEPTCONN
5921bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_ACCEPTCONN,	"SO_ACCEPTCONN"	},
593f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
5941bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_ALLRAW
5951bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_ALLRAW,	"SO_ALLRAW"	},
5961bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
5971bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_ATTACH_FILTER
5981bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_ATTACH_FILTER,	"SO_ATTACH_FILTER"	},
5991bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6001bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_BINDTODEVICE
6011bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_BINDTODEVICE,	"SO_BINDTODEVICE"	},
6021bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6031bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_BROADCAST
6041bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_BROADCAST,	"SO_BROADCAST"	},
6051bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6061bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_BSDCOMPAT
6071bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_BSDCOMPAT,	"SO_BSDCOMPAT"	},
608f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
60976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_DEBUG
61076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_DEBUG,	"SO_DEBUG"	},
61176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6121bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_DETACH_FILTER
6131bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_DETACH_FILTER,	"SO_DETACH_FILTER"	},
61476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
61576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_DONTROUTE
61676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_DONTROUTE,	"SO_DONTROUTE"	},
61776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6181bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_ERROR
6191bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_ERROR,	"SO_ERROR"	},
6201bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6211bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_ICS
6221bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_ICS,	"SO_ICS"	},
6231bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6241bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_IMASOCKET
6251bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_IMASOCKET,	"SO_IMASOCKET"	},
6261bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6271bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_KEEPALIVE
6281bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_KEEPALIVE,	"SO_KEEPALIVE"	},
62976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
63076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_LINGER
63176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_LINGER,	"SO_LINGER"	},
63276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6331bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_LISTENING
6341bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_LISTENING,	"SO_LISTENING"	},
6351bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6361bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_MGMT
6371bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_MGMT,	"SO_MGMT"	},
6381bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6391bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_NO_CHECK
6401bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_NO_CHECK,	"SO_NO_CHECK"	},
6411bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
64276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_OOBINLINE
64376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_OOBINLINE,	"SO_OOBINLINE"	},
64476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6451bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_ORDREL
6461bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_ORDREL,	"SO_ORDREL"	},
64776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6481bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_PARALLELSVR
6491bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_PARALLELSVR,	"SO_PARALLELSVR"	},
65076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6511bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_PASSCRED
6521bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_PASSCRED,	"SO_PASSCRED"	},
65376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6541bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_PEERCRED
6551bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_PEERCRED,	"SO_PEERCRED"	},
65676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6571bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_PEERNAME
6581bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_PEERNAME,	"SO_PEERNAME"	},
6591bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6601bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_PEERSEC
6611bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_PEERSEC,	"SO_PEERSEC"	},
66276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
66376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_PRIORITY
66476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_PRIORITY,	"SO_PRIORITY"	},
66576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6661bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_PROTOTYPE
6671bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_PROTOTYPE,	"SO_PROTOTYPE"	},
66876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6691bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_RCVBUF
6701bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_RCVBUF,	"SO_RCVBUF"	},
67176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
67276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVLOWAT
67376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVLOWAT,	"SO_RCVLOWAT"	},
67476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
67576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_RCVTIMEO
67676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_RCVTIMEO,	"SO_RCVTIMEO"	},
67776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6781bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_RDWR
6791bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_RDWR,	"SO_RDWR"	},
6801bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
6811bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_REUSEADDR
6821bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_REUSEADDR,	"SO_REUSEADDR"	},
68376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
68476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SO_REUSEPORT
68576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ SO_REUSEPORT,	"SO_REUSEPORT"	},
68676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6871bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_SECURITY_AUTHENTICATION
6881bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_SECURITY_AUTHENTICATION,"SO_SECURITY_AUTHENTICATION"},
68976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
6901bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_SECURITY_ENCRYPTION_NETWORK
6911bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_SECURITY_ENCRYPTION_NETWORK,"SO_SECURITY_ENCRYPTION_NETWORK"},
69238ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
6931bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
6941bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_SECURITY_ENCRYPTION_TRANSPORT,"SO_SECURITY_ENCRYPTION_TRANSPORT"},
69538ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
69638ae88d332acd9f86a30d58158e306d795d98977John Hughes#ifdef SO_SEMA
69738ae88d332acd9f86a30d58158e306d795d98977John Hughes	{ SO_SEMA,	"SO_SEMA"	},
69838ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
6991bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_SNDBUF
7001bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_SNDBUF,	"SO_SNDBUF"	},
70138ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
7021bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_SNDLOWAT
7031bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_SNDLOWAT,	"SO_SNDLOWAT"	},
70438ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
7051bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_SNDTIMEO
7061bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_SNDTIMEO,	"SO_SNDTIMEO"	},
70738ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
7081bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_TIMESTAMP
7091bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_TIMESTAMP,	"SO_TIMESTAMP"	},
7101bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
7111bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_TYPE
7121bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_TYPE,	"SO_TYPE"	},
7131bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#endif
7141bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath#ifdef SO_USELOOPBACK
7151bf4373ab6b6105d3174e024279e66292cee4b83Roland McGrath	{ SO_USELOOPBACK,	"SO_USELOOPBACK"	},
71676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
71776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	{ 0,		NULL		},
71876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
71976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
720c36c352329755387f0a503cc9a47047e6de6e711Denys Vlasenko#if !defined(SOL_IP) && defined(IPPROTO_IP)
72193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#define SOL_IP IPPROTO_IP
72293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
72393f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes
72476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
725d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat sockipoptions[] = {
72693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_TOS
7277987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_TOS,		"IP_TOS"		},
72893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
72993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_TTL
7307987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_TTL,		"IP_TTL"		},
73193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
73293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_HDRINCL
7337987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_HDRINCL,		"IP_HDRINCL"		},
73476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
73593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_OPTIONS
7367987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_OPTIONS,		"IP_OPTIONS"		},
7377987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
73893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_ROUTER_ALERT
7397987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_ROUTER_ALERT,	"IP_ROUTER_ALERT"	},
74093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
74193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVOPTIONS
7427987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RECVOPTIONS,	"IP_RECVOPTIONS"	},
7437987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
74493f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVOPTS
74593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes	{ IP_RECVOPTS,		"IP_RECVOPTS"		},
74693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
74793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVRETOPTS
74893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes	{ IP_RECVRETOPTS,	"IP_RECVRETOPTS"	},
74993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
75093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVDSTADDR
75193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes	{ IP_RECVDSTADDR,	"IP_RECVDSTADDR"	},
75293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
75393f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RETOPTS
7547987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RETOPTS,		"IP_RETOPTS"		},
75593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
75693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_PKTINFO
7577987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_PKTINFO,		"IP_PKTINFO"		},
75893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
75993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_PKTOPTIONS
76093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes	{ IP_PKTOPTIONS,	"IP_PKTOPTIONS"		},
76193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
76293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_MTU_DISCOVER
7637987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MTU_DISCOVER,	"IP_MTU_DISCOVER"	},
76493f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
76593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVERR
7667987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_RECVERR,		"IP_RECVERR"		},
76793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
76893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVTTL
76904ac03a554548ad69f2699b98ae31e15a7fc7915Roland McGrath	{ IP_RECVTTL,		"IP_RECVTTL"		},
77093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
77193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVTOS
77204ac03a554548ad69f2699b98ae31e15a7fc7915Roland McGrath	{ IP_RECVTOS,		"IP_RECVTOS"		},
77393f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
77493f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_MTU
7757987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MTU,		"IP_MTU"		},
7767987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
77793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_MULTICAST_IF
7787987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MULTICAST_IF,	"IP_MULTICAST_IF"	},
77993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
78093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_MULTICAST_TTL
7817987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MULTICAST_TTL,	"IP_MULTICAST_TTL"	},
78293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
78393f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_MULTICAST_LOOP
7847987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_MULTICAST_LOOP,	"IP_MULTICAST_LOOP"	},
78593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
78693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_ADD_MEMBERSHIP
7877987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_ADD_MEMBERSHIP,	"IP_ADD_MEMBERSHIP"	},
78893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
78993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_DROP_MEMBERSHIP
7907987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ IP_DROP_MEMBERSHIP,	"IP_DROP_MEMBERSHIP"	},
79193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
79293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_BROADCAST_IF
79393f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes	{ IP_BROADCAST_IF,	"IP_BROADCAST_IF"	},
79493f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
79593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef IP_RECVIFINDEX
79693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes	{ IP_RECVIFINDEX,	"IP_RECVIFINDEX"	},
79793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
7984f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IP_MSFILTER
7994f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IP_MSFILTER,		"IP_MSFILTER"		},
8004f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8014f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef MCAST_MSFILTER
8024f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ MCAST_MSFILTER,	"MCAST_MSFILTER"	},
8034f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8044f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IP_FREEBIND
8054f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IP_FREEBIND,		"IP_FREEBIND"		},
8064f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8077987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,			NULL			},
80876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
80976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_IP */
81076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
8114f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef SOL_IPV6
812d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat sockipv6options[] = {
8134f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_ADDRFORM
8144f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_ADDRFORM,	"IPV6_ADDRFORM"		},
8154f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8164f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef MCAST_FILTER
8174f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ MCAST_FILTER,		"MCAST_FILTER"		},
8184f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8194f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_PKTOPTIONS
8204f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_PKTOPTIONS,	"IPV6_PKTOPTIONS"	},
8214f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8224f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_MTU
8234f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_MTU,		"IPV6_MTU"		},
8244f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8254f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_V6ONLY
8264f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_V6ONLY,		"IPV6_V6ONLY"		},
8274f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8284f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_PKTINFO
8294f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_PKTINFO,		"IPV6_PKTINFO"		},
8304f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8314f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_HOPLIMIT
8324f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_HOPLIMIT,	"IPV6_HOPLIMIT"		},
8334f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8344f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_RTHDR
8354f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_RTHDR,		"IPV6_RTHDR"		},
8364f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8374f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_HOPOPTS
8384f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_HOPOPTS,		"IPV6_HOPOPTS"		},
8394f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8404f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_DSTOPTS
8414f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_DSTOPTS,		"IPV6_DSTOPTS"		},
8424f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8434f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_FLOWINFO
8444f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_FLOWINFO,	"IPV6_FLOWINFO"		},
8454f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8464f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_UNICAST_HOPS
8474f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_UNICAST_HOPS,	"IPV6_UNICAST_HOPS"	},
8484f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8494f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_MULTICAST_HOPS
8504f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_MULTICAST_HOPS,	"IPV6_MULTICAST_HOPS"	},
8514f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8524f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_MULTICAST_LOOP
8534f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_MULTICAST_LOOP,	"IPV6_MULTICAST_LOOP"	},
8544f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8554f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_MULTICAST_IF
8564f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_MULTICAST_IF,	"IPV6_MULTICAST_IF"	},
8574f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8584f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_MTU_DISCOVER
8594f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_MTU_DISCOVER,	"IPV6_MTU_DISCOVER"	},
8604f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8614f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_RECVERR
8624f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_RECVERR,		"IPV6_RECVERR"		},
8634f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
8644f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef IPV6_FLOWINFO_SEND
8654f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ IPV6_FLOWINFO_SEND,	"IPV6_FLOWINFO_SEND"	},
8664f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
867c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath#ifdef IPV6_ADD_MEMBERSHIP
868c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath	{ IPV6_ADD_MEMBERSHIP,	"IPV6_ADD_MEMBERSHIP"	},
869c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath#endif
870c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath#ifdef IPV6_DROP_MEMBERSHIP
871c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath	{ IPV6_DROP_MEMBERSHIP,	"IPV6_DROP_MEMBERSHIP"	},
872c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath#endif
873c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath#ifdef IPV6_ROUTER_ALERT
874c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath	{ IPV6_ROUTER_ALERT,	"IPV6_ROUTER_ALERT"	},
875c0b9e37b3fefaf5d7e6a3c132c72df84eee411a9Roland McGrath#endif
8764f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath	{ 0,			NULL			},
8774f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath};
8784f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif /* SOL_IPV6 */
8794f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath
88076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
881d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat sockipxoptions[] = {
882b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	{ IPX_TYPE,	"IPX_TYPE"	},
883b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	{ 0,		NULL		},
88476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
88576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_IPX */
88676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
8877987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_RAW
888d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat sockrawoptions[] = {
8897987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_FILTER)
8907987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ ICMP_FILTER,		"ICMP_FILTER"	},
8917987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
8927987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,			NULL		},
8937987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman};
8947987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* SOL_RAW */
8957987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
8967987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_PACKET
897d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat sockpacketoptions[] = {
898c294b8f411e25097f80280fbb924bc031becc181Roland McGrath#ifdef PACKET_ADD_MEMBERSHIP
8997987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_ADD_MEMBERSHIP,	"PACKET_ADD_MEMBERSHIP"	},
900c294b8f411e25097f80280fbb924bc031becc181Roland McGrath#endif
901c294b8f411e25097f80280fbb924bc031becc181Roland McGrath#ifdef PACKET_DROP_MEMBERSHIP
9027987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_DROP_MEMBERSHIP,	"PACKET_DROP_MEMBERSHIP"},
903c294b8f411e25097f80280fbb924bc031becc181Roland McGrath#endif
9047987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(PACKET_RECV_OUTPUT)
9057987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_RECV_OUTPUT,		"PACKET_RECV_OUTPUT"	},
9067987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
9077987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(PACKET_RX_RING)
9087987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_RX_RING,		"PACKET_RX_RING"	},
9097987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
9107987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(PACKET_STATISTICS)
9117987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ PACKET_STATISTICS,		"PACKET_STATISTICS"	},
9127987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
913ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_COPY_THRESH)
914ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_COPY_THRESH,		"PACKET_COPY_THRESH"	},
915ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
916ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_AUXDATA)
917ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_AUXDATA,		"PACKET_AUXDATA"	},
918ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
919ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_ORIGDEV)
920ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_ORIGDEV,		"PACKET_ORIGDEV"	},
921ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
922ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_VERSION)
923ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_VERSION,		"PACKET_VERSION"	},
924ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
925ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_HDRLEN)
926ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_HDRLEN,		"PACKET_HDRLEN"	},
927ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
928ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_RESERVE)
929ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_RESERVE,		"PACKET_RESERVE"	},
930ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
931ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_TX_RING)
932ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_TX_RING,		"PACKET_TX_RING"	},
933ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
934ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_LOSS)
935ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin	{ PACKET_LOSS,			"PACKET_LOSS"	},
936ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
9377987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,				NULL			},
9387987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman};
9397987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* SOL_PACKET */
9407987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
9417fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#ifdef SOL_SCTP
9427fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freytherstatic const struct xlat socksctpoptions[] = {
9437fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_RTOINFO)
9447fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_RTOINFO,			"SCTP_RTOINFO"	},
9457fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9467fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_ASSOCINFO)
9477fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_ASSOCINFO,		"SCTP_ASSOCINFO"},
9487fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9497fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_INITMSG)
9507fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_INITMSG,			"SCTP_INITMSG"	},
9517fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9527fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_NODELAY)
9537fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_NODELAY,			"SCTP_NODELAY"	},
9547fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9557fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_AUTOCLOSE)
9567fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_AUTOCLOSE,		"SCTP_AUTOCLOSE"},
9577fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9587fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_SET_PEER_PRIMARY_ADDR)
9597fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_SET_PEER_PRIMARY_ADDR,	"SCTP_SET_PEER_PRIMARY_ADDR"},
9607fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9617fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_PRIMARY_ADDR)
9627fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_PRIMARY_ADDR,		"SCTP_PRIMARY_ADDR"	},
9637fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9647fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_ADAPTATION_LAYER)
9657fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_ADAPTATION_LAYER,	"SCTP_ADAPTATION_LAYER"	},
9667fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9677fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_DISABLE_FRAGMENTS)
9687fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_DISABLE_FRAGMENTS,	"SCTP_DISABLE_FRAGMENTS"},
9697fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9707fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_PEER_ADDR_PARAMS)
9717fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_PEER_ADDR_PARAMS,	"SCTP_PEER_ADDR_PARAMS"	},
9727fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9737fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_DEFAULT_SEND_PARAM)
9747fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_DEFAULT_SEND_PARAM,	"SCTP_DEFAULT_SEND_PARAM"},
9757fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9767fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_EVENTS)
9777fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_EVENTS,			"SCTP_EVENTS"		},
9787fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9797fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_I_WANT_MAPPED_V4_ADDR)
9807fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_I_WANT_MAPPED_V4_ADDR,	"SCTP_I_WANT_MAPPED_V4_ADDR"},
9817fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9827fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_MAXSEG)
9837fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_MAXSEG,			"SCTP_MAXSEG"		},
9847fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9857fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_STATUS)
9867fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_STATUS,			"SCTP_STATUS"		},
9877fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9887fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_PEER_ADDR_INFO)
9897fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_PEER_ADDR_INFO,	"SCTP_GET_PEER_ADDR_INFO"},
9907fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9917fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_DELAYED_ACK)
9927fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_DELAYED_ACK,		"SCTP_DELAYED_ACK"	},
9937fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9947fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_CONTEXT)
9957fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_CONTEXT,			"SCTP_CONTEXT"		},
9967fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
9977fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_FRAGMENT_INTERLEAVE)
9987fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_FRAGMENT_INTERLEAVE,	"SCTP_FRAGMENT_INTERLEAVE"},
9997fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10007fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_PARTIAL_DELIVERY_POINT)
10017fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_PARTIAL_DELIVERY_POINT,	"SCTP_PARTIAL_DELIVERY_POINT"},
10027fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10037fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_MAX_BURST)
10047fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_MAX_BURST,		"SCTP_MAX_BURST"	},
10057fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10067fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_AUTH_CHUNK)
10077fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_AUTH_CHUNK,		"SCTP_AUTH_CHUNK"	},
10087fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10097fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_HMAC_IDENT)
10107fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_HMAC_IDENT,		"SCTP_HMAC_IDENT"	},
10117fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10127fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_AUTH_KEY)
10137fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_AUTH_KEY,		"SCTP_AUTH_KEY"		},
10147fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10157fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_AUTH_ACTIVE_KEY)
10167fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_AUTH_ACTIVE_KEY,		"SCTP_AUTH_ACTIVE_KEY"	},
10177fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10187fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_AUTH_DELETE_KEY)
10197fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_AUTH_DELETE_KEY,		"SCTP_AUTH_DELETE_KEY"	},
10207fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10217fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_PEER_AUTH_CHUNKS)
10227fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_PEER_AUTH_CHUNKS,	"SCTP_PEER_AUTH_CHUNKS"	},
10237fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10247fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_LOCAL_AUTH_CHUNKS)
10257fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_LOCAL_AUTH_CHUNKS,	"SCTP_LOCAL_AUTH_CHUNKS"},
10267fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10277fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_ASSOC_NUMBER)
10287fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_ASSOC_NUMBER,	"SCTP_GET_ASSOC_NUMBER"	},
10297fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10307fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther
10317fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	/* linux specific things */
10327fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_SOCKOPT_BINDX_ADD)
10337fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_SOCKOPT_BINDX_ADD,	"SCTP_SOCKOPT_BINDX_ADD"	},
10347fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10357fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_SOCKOPT_BINDX_REM)
10367fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_SOCKOPT_BINDX_REM,	"SCTP_SOCKOPT_BINDX_REM"	},
10377fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10387fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_SOCKOPT_PEELOFF)
10397fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_SOCKOPT_PEELOFF,		"SCTP_SOCKOPT_PEELOFF"		},
10407fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10417fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_PEER_ADDRS_NUM_OLD)
10427fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_PEER_ADDRS_NUM_OLD,	"SCTP_GET_PEER_ADDRS_NUM_OLD"	},
10437fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10447fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_PEER_ADDRS_OLD)
10457fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_PEER_ADDRS_OLD,	"SCTP_GET_PEER_ADDRS_OLD"	},
10467fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10477fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_LOCAL_ADDRS_NUM_OLD)
10487fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_LOCAL_ADDRS_NUM_OLD,	"SCTP_GET_LOCAL_ADDRS_NUM_OLD"	},
10497fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10507fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_LOCAL_ADDRS_OLD)
10517fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_LOCAL_ADDRS_OLD,	"SCTP_GET_LOCAL_ADDRS_OLD"	},
10527fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10537fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_SOCKOPT_CONNECTX_OLD)
10547fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_SOCKOPT_CONNECTX_OLD,	"SCTP_SOCKOPT_CONNECTX_OLD"	},
10557fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10567fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_PEER_ADDRS)
10577fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_PEER_ADDRS,		"SCTP_GET_PEER_ADDRS"		},
10587fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10597fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#if defined(SCTP_GET_LOCAL_ADDRS)
10607fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ SCTP_GET_LOCAL_ADDRS,		"SCTP_GET_LOCAL_ADDRS"		},
10617fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10627fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther
10637fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther	{ 0,	NULL	},
10647fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther};
10657fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
10667fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther
1067c36c352329755387f0a503cc9a47047e6de6e711Denys Vlasenko#if !defined(SOL_TCP) && defined(IPPROTO_TCP)
106893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#define SOL_TCP IPPROTO_TCP
106993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
107093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes
107176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
1072d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat socktcpoptions[] = {
10738b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_NODELAY,		"TCP_NODELAY"	},
10748b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_MAXSEG,		"TCP_MAXSEG"	},
10757987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(TCP_CORK)
10768b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_CORK,		"TCP_CORK"	},
10777987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
10788b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_KEEPIDLE)
10798b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_KEEPIDLE,		"TCP_KEEPIDLE" },
10808b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
10818b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_KEEPINTVL)
10828b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_KEEPINTVL,	"TCP_KEEPINTVL" },
10838b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
10848b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_KEEPCNT)
10858b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_KEEPCNT,		"TCP_KEEPCNT" },
10868b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
108738ae88d332acd9f86a30d58158e306d795d98977John Hughes#if defined(TCP_NKEEP)
108838ae88d332acd9f86a30d58158e306d795d98977John Hughes	{ TCP_NKEEP,		"TCP_NKEEP"	},
108938ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
10908b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_SYNCNT)
10918b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_SYNCNT,		"TCP_SYNCNT" },
10928b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
10938b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_LINGER2)
10948b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_LINGER2,		"TCP_LINGER2" },
10958b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
10968b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_DEFER_ACCEPT)
10978b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_DEFER_ACCEPT,	"TCP_DEFER_ACCEPT" },
10988b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
10998b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_WINDOW_CLAMP)
11008b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_WINDOW_CLAMP,	"TCP_WINDOW_CLAMP" },
11018b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
11028b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_INFO)
11038b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_INFO,		"TCP_INFO" },
11048b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
11058b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#if defined(TCP_QUICKACK)
11068b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ TCP_QUICKACK,		"TCP_QUICKACK" },
11078b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman#endif
1108b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#if defined(TCP_CONGESTION)
1109b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin	{ TCP_CONGESTION,	"TCP_CONGESTION" },
1110b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#endif
1111b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#if defined(TCP_MD5SIG)
1112b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin	{ TCP_MD5SIG,		"TCP_MD5SIG" },
1113b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#endif
1114b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#if defined(TCP_COOKIE_TRANSACTIONS)
1115b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin	{ TCP_COOKIE_TRANSACTIONS,	"TCP_COOKIE_TRANSACTIONS" },
1116b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#endif
1117b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#if defined(TCP_THIN_LINEAR_TIMEOUTS)
1118b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin	{ TCP_THIN_LINEAR_TIMEOUTS,	"TCP_THIN_LINEAR_TIMEOUTS" },
1119b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#endif
1120b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#if defined(TCP_THIN_DUPACK)
1121b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin	{ TCP_THIN_DUPACK,	"TCP_THIN_DUPACK" },
1122b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#endif
1123b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#if defined(TCP_USER_TIMEOUT)
1124b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin	{ TCP_USER_TIMEOUT,	"TCP_USER_TIMEOUT" },
1125b05fc5463be8df587b4acc8f522f51e21bc22be8Dmitry V. Levin#endif
11268b8ff7c7800c70393c03b1a806be6daec6a0e068Wichert Akkerman	{ 0,			NULL		},
112776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
112876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* SOL_TCP */
112976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
11307987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_RAW
1131d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat icmpfilterflags[] = {
11327987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ECHOREPLY)
11337987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ECHOREPLY),		"ICMP_ECHOREPLY"	},
11347987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11357987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_DEST_UNREACH)
11367987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_DEST_UNREACH),	"ICMP_DEST_UNREACH"	},
11377987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11387987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_SOURCE_QUENCH)
11397987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_SOURCE_QUENCH),	"ICMP_SOURCE_QUENCH"	},
11407987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11417987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_REDIRECT)
11427987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_REDIRECT),		"ICMP_REDIRECT"		},
11437987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11447987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ECHO)
11457987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ECHO),		"ICMP_ECHO"		},
11467987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11477987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_TIME_EXCEEDED)
11487987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_TIME_EXCEEDED),	"ICMP_TIME_EXCEEDED"	},
11497987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11507987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_PARAMETERPROB)
11517987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_PARAMETERPROB),	"ICMP_PARAMETERPROB"	},
11527987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11537987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_TIMESTAMP)
11547987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_TIMESTAMP),		"ICMP_TIMESTAMP"	},
11557987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11567987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_TIMESTAMPREPLY)
11577987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_TIMESTAMPREPLY),	"ICMP_TIMESTAMPREPLY"	},
11587987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11597987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_INFO_REQUEST)
11607987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_INFO_REQUEST),	"ICMP_INFO_REQUEST"	},
11617987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11627987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_INFO_REPLY)
11637987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_INFO_REPLY),		"ICMP_INFO_REPLY"	},
11647987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11657987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ADDRESS)
11667987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ADDRESS),		"ICMP_ADDRESS"		},
11677987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11687987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_ADDRESSREPLY)
11697987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ (1<<ICMP_ADDRESSREPLY),	"ICMP_ADDRESSREPLY"	},
11707987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
11717987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	{ 0,				NULL			},
11727987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman};
11737987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* SOL_RAW */
11747987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
1175b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
1176d9f816f60457930af27349fac3d23b3b78338036Roland McGrathstatic const struct xlat af_packet_types[] = {
1177b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(PACKET_HOST)
1178b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ PACKET_HOST,			"PACKET_HOST"		},
1179b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif
1180b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(PACKET_BROADCAST)
1181b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ PACKET_BROADCAST,		"PACKET_BROADCAST"	},
1182b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif
1183b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(PACKET_MULTICAST)
1184b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ PACKET_MULTICAST,		"PACKET_MULTICAST"	},
1185b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif
1186b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(PACKET_OTHERHOST)
1187b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ PACKET_OTHERHOST,		"PACKET_OTHERHOST"	},
1188b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif
1189b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(PACKET_OUTGOING)
1190b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ PACKET_OUTGOING,		"PACKET_OUTGOING"	},
1191b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif
1192b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(PACKET_LOOPBACK)
1193b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ PACKET_LOOPBACK,		"PACKET_LOOPBACK"	},
1194b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif
1195b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#if defined(PACKET_FASTROUTE)
1196b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ PACKET_FASTROUTE,		"PACKET_FASTROUTE"	},
1197b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif
1198b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman	{ 0,				NULL			},
1199b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman};
1200b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman#endif /* defined(AF_PACKET) */
1201b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman
120276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanvoid
1203b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levinprintsock(struct tcb *tcp, long addr, int addrlen)
120476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
1205f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	union {
1206f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		char pad[128];
1207f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr sa;
1208f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_in sin;
1209f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_un sau;
12109ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#ifdef HAVE_INET_NTOP
1211f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_in6 sa6;
12129ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#endif
12138470374cba7df0e70653d95c4f336a4082c68d82Denys Vlasenko#if defined(AF_IPX)
1214f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_ipx sipx;
1215f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
1216f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef AF_PACKET
1217f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_ll ll;
121876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
1219f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef AF_NETLINK
1220f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		struct sockaddr_nl nl;
1221f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif
1222f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	} addrbuf;
1223f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	char string_addr[100];
122476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
122576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (addr == 0) {
122660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("NULL");
122776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
122876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
122976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (!verbose(tcp)) {
123076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%#lx", addr);
123176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
123276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
1233f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
1234b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levin	if (addrlen < 2 || addrlen > sizeof(addrbuf))
1235b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levin		addrlen = sizeof(addrbuf);
1236b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levin
1237b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levin	memset(&addrbuf, 0, sizeof(addrbuf));
1238b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levin	if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
123960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("{...}");
124076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		return;
124176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
1242b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levin	addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
1243f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
124460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints("{sa_family=");
1245f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
124660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints(", ");
1247f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
1248f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	switch (addrbuf.sa.sa_family) {
124976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_UNIX:
1250b6c32f4598b84364472bc3febcb80ff3e475def8Dmitry V. Levin		if (addrlen == 2) {
125160fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("NULL");
1252f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		} else if (addrbuf.sau.sun_path[0]) {
1253c86340e171ebbb4b11e986d172e9b27535ae1807Dmitry V. Levin			tprints("sun_path=");
125416fbe97a10d7aa9af820b1c98243d9c2bfb120deDmitry V. Levin			printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
1255f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		} else {
1256c86340e171ebbb4b11e986d172e9b27535ae1807Dmitry V. Levin			tprints("sun_path=@");
125716fbe97a10d7aa9af820b1c98243d9c2bfb120deDmitry V. Levin			printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
1258f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		}
125976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
126076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_INET:
12611fcb1d64ed13836334d100af9412f220efa1bbfaJohn Hughes		tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
1262f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
126376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
12649ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#ifdef HAVE_INET_NTOP
12659ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman	case AF_INET6:
1266f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
1267f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman		tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
1268f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman				ntohs(addrbuf.sa6.sin6_port), string_addr,
1269f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman				addrbuf.sa6.sin6_flowinfo);
12706d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
1271f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman		{
1272f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
1273b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			int numericscope = 0;
1274b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr)
1275b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			    || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) {
1276b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				char scopebuf[IFNAMSIZ + 1];
12776d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath
1278b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
1279b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko					numericscope++;
1280b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				else
1281b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko					tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
1282b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			} else
1283b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				numericscope++;
12846d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath
1285b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			if (numericscope)
1286f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#endif
1287b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
1288f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman		}
1289f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#endif
1290b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		break;
12919ce1a63eb20b069607c06f9645ac5a17b418a5f3Wichert Akkerman#endif
12928470374cba7df0e70653d95c4f336a4082c68d82Denys Vlasenko#if defined(AF_IPX)
129376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	case AF_IPX:
1294f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		{
129576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			int i;
12961fcb1d64ed13836334d100af9412f220efa1bbfaJohn Hughes			tprintf("sipx_port=htons(%u), ",
1297f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					ntohs(addrbuf.sipx.sipx_port));
129876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* Yes, I know, this does not look too
129976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * strace-ish, but otherwise the IPX
130076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * addresses just look monstrous...
130176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 * Anyways, feel free if you don't like
13026d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath			 * this way.. :)
130376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			 */
1304f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
1305b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			for (i = 0; i < IPX_NODE_LEN; i++)
1306f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman				tprintf("%02x", addrbuf.sipx.sipx_node[i]);
1307f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			tprintf("/[%02x]", addrbuf.sipx.sipx_type);
1308f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		}
1309f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		break;
13108470374cba7df0e70653d95c4f336a4082c68d82Denys Vlasenko#endif /* AF_IPX */
1311f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#ifdef AF_PACKET
1312f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	case AF_PACKET:
1313f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		{
1314f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			int i;
1315b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman			tprintf("proto=%#04x, if%d, pkttype=",
1316f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					ntohs(addrbuf.ll.sll_protocol),
1317b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman					addrbuf.ll.sll_ifindex);
1318b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman			printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
1319b0c598ff8d03a57627a5335448a8a60f0950f4f7Wichert Akkerman			tprintf(", addr(%d)={%d, ",
1320f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					addrbuf.ll.sll_halen,
1321f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman					addrbuf.ll.sll_hatype);
1322b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			for (i = 0; i < addrbuf.ll.sll_halen; i++)
1323f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman				tprintf("%02x", addrbuf.ll.sll_addr[i]);
132476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
132576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
1326f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
13278470374cba7df0e70653d95c4f336a4082c68d82Denys Vlasenko#endif /* AF_PACKET */
132836ef1bc03e291f98eb5f44ba722a49b87c3cb5e5Roland McGrath#ifdef AF_NETLINK
1329f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	case AF_NETLINK:
1330f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
1331f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		break;
1332f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman#endif /* AF_NETLINK */
133376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	/* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
1334f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman	AF_X25 AF_ROSE etc. still need to be done */
133576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
133676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	default:
133760fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("sa_data=");
133876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
1339f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman			sizeof addrbuf.sa.sa_data);
134076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		break;
134176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
134260fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints("}");
134376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
134476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
134576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#if HAVE_SENDMSG
13465077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrathstatic const struct xlat scmvals[] = {
13475077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath#ifdef SCM_RIGHTS
13485077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath	{ SCM_RIGHTS,		"SCM_RIGHTS"		},
13495077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath#endif
13505077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath#ifdef SCM_CREDENTIALS
13515077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath	{ SCM_CREDENTIALS,	"SCM_CREDENTIALS"	},
13525077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath#endif
13535077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath	{ 0,			NULL			}
13545077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath};
13555077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath
13565077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrathstatic void
1357132c52a5ccf7b12a44a617f06c97d3f4344a4421Denys Vlasenkoprintcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len)
13585077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath{
1359aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath	struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ?
1360aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath			       NULL : malloc(len);
1361aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath	if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) {
13625077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath		tprintf(", msg_control=%#lx", addr);
1363aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		free(cmsg);
13645077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath		return;
13655077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath	}
13665077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath
1367132c52a5ccf7b12a44a617f06c97d3f4344a4421Denys Vlasenko	tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len);
1368aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath	printxval(socketlayers, cmsg->cmsg_level, "SOL_???");
136960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints(", cmsg_type=");
13705077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath
1371aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath	if (cmsg->cmsg_level == SOL_SOCKET) {
1372aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		unsigned long cmsg_len;
1373aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath
1374aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		printxval(scmvals, cmsg->cmsg_type, "SCM_???");
1375aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len;
137696ad7b8f529221bd1db1c3cdca871ee9e1dc713aRoland McGrath
1377aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		if (cmsg->cmsg_type == SCM_RIGHTS
1378aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		    && CMSG_LEN(sizeof(int)) <= cmsg_len) {
1379b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			int *fds = (int *) CMSG_DATA(cmsg);
13805077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath			int first = 1;
1381aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath
138260fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", {");
1383aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath			while ((char *) fds < ((char *) cmsg + cmsg_len)) {
13845077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath				if (!first)
138560fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko					tprints(", ");
13865077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath				tprintf("%d", *fds++);
13875077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath				first = 0;
13885077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath			}
138960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("}}");
1390aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath			free(cmsg);
13915077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath			return;
13925077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath		}
1393aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		if (cmsg->cmsg_type == SCM_CREDENTIALS
1394aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath		    && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) {
1395b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg);
1396aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath
13975077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath			tprintf("{pid=%ld, uid=%ld, gid=%ld}}",
13985077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath				(long)uc->pid, (long)uc->uid, (long)uc->gid);
1399aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath			free(cmsg);
14005077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath			return;
14015077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath		}
14025077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath	}
1403aa524c88c49814863cb7f19e5c8a8eeca6ce22feRoland McGrath	free(cmsg);
140460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints(", ...}");
14055077082649babf6dac0cabf5e2dd53dff4d393d0Roland McGrath}
140676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
140776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic void
1408e0bc222263cf47a43e1b26d55edb2ffadc8ccbffDenys Vlasenkodo_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
14090873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab{
14100873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	tprintf("{msg_name(%d)=", msg->msg_namelen);
14110873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
14120873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab
14130873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
1414e0bc222263cf47a43e1b26d55edb2ffadc8ccbffDenys Vlasenko	tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
1415e0bc222263cf47a43e1b26d55edb2ffadc8ccbffDenys Vlasenko		   (unsigned long)msg->msg_iov, 1, data_size);
14160873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab
14170873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
14180873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
14190873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	if (msg->msg_controllen)
14200873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab		printcmsghdr(tcp, (unsigned long) msg->msg_control,
14210873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab			     msg->msg_controllen);
142260fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints(", msg_flags=");
14230873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	printflags(msg_flags, msg->msg_flags, "MSG_???");
14240873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
14250873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
14260873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab		(unsigned long) msg->msg_accrights, msg->msg_accrightslen);
14270873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
142860fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints("}");
14290873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab}
14300873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab
14310873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwabstatic void
1432e0bc222263cf47a43e1b26d55edb2ffadc8ccbffDenys Vlasenkoprintmsghdr(struct tcb *tcp, long addr, unsigned long data_size)
143376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
143476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	struct msghdr msg;
143576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
14362e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	if (umove(tcp, addr, &msg) < 0) {
14372e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman		tprintf("%#lx", addr);
14382e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman		return;
14392e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman	}
1440e0bc222263cf47a43e1b26d55edb2ffadc8ccbffDenys Vlasenko	do_msghdr(tcp, &msg, data_size);
14410873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab}
1442f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
14430873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwabstatic void
14445ea97658e78b6ce9fb768ffdd6a4b682c5df8e90Dmitry V. Levinprintmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
14450873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab{
14460873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	struct mmsghdr {
14470873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab		struct msghdr msg_hdr;
14480873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab		unsigned msg_len;
14490873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	} mmsg;
1450f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
14517af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	addr += sizeof(mmsg) * idx;
14520873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	if (umove(tcp, addr, &mmsg) < 0) {
14530873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab		tprintf("%#lx", addr);
14540873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab		return;
14550873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	}
145660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints("{");
14575ea97658e78b6ce9fb768ffdd6a4b682c5df8e90Dmitry V. Levin	do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
14580873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	tprintf(", %u}", mmsg.msg_len);
145976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
146076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
14617af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levinstatic void
14625ea97658e78b6ce9fb768ffdd6a4b682c5df8e90Dmitry V. Levindecode_mmsg(struct tcb *tcp, unsigned long msg_len)
14637af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin{
14647af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	/* mmsgvec */
14657af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	if (syserror(tcp)) {
14667af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		tprintf("%#lx", tcp->u_arg[1]);
14677af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	} else {
14687af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		unsigned int len = tcp->u_rval;
14697af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		unsigned int i;
14707af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin
14717af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		tprints("{");
14727af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		for (i = 0; i < len; ++i) {
14737af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin			if (i)
14747af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin				tprints(", ");
14755ea97658e78b6ce9fb768ffdd6a4b682c5df8e90Dmitry V. Levin			printmmsghdr(tcp, tcp->u_arg[1], i, msg_len);
14767af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		}
14777af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		tprints("}");
14787af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	}
14797af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	/* vlen */
14807af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
14817af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	/* flags */
14827af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	printflags(msg_flags, tcp->u_arg[3], "MSG_???");
14837af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin}
14847af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin
148576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
148676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
14878a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin/*
14888a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin * low bits of the socket type define real socket type,
14898a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin * other bits are socket type flags.
14908a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin */
14918a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levinstatic void
14928a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levintprint_sock_type(struct tcb *tcp, int flags)
14938a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin{
14948a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
14958a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin
14967b609d5ba0852e6c56ba311350ebd4412361777bDenys Vlasenko	if (str) {
14975940e6593911dcace424c668a1c0934c71fccb9eDenys Vlasenko		tprints(str);
14988a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin		flags &= ~SOCK_TYPE_MASK;
14998a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin		if (!flags)
15008a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin			return;
150160fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("|");
15028a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	}
15038a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin	printflags(sock_type_flags, flags, "SOCK_???");
15048a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin}
15058a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin
150676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
15078a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levinsys_socket(struct tcb *tcp)
150876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
150976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
151076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(domains, tcp->u_arg[0], "PF_???");
151160fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
15128a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin		tprint_sock_type(tcp, tcp->u_arg[1]);
151360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
151476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[0]) {
151576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_INET:
15168758e544d502e54202079b0521ae0a234d644a4aRoland McGrath#ifdef PF_INET6
15178758e544d502e54202079b0521ae0a234d644a4aRoland McGrath		case PF_INET6:
15188758e544d502e54202079b0521ae0a234d644a4aRoland McGrath#endif
151976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
152076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
152176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
152276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_IPX:
152376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* BTW: I don't believe this.. */
152460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("[");
152576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(domains, tcp->u_arg[2], "PF_???");
152660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("]");
152776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
152876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* PF_IPX */
152976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		default:
153076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%lu", tcp->u_arg[2]);
153176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
153276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
153376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
153476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
153576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
153676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
1537bdf48f55f264a9cd2eb1b3cac8f1f87c1acad008John Hughesint
15381201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_bind(struct tcb *tcp)
153976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
154076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
154176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
1542f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
154376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu", tcp->u_arg[2]);
154476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
154576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
154676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
154776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
154876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
15491201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_connect(struct tcb *tcp)
155076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
155176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_bind(tcp);
155276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
155376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
155476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
15551201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_listen(struct tcb *tcp)
155676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
155776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
155876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
155976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
156076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
156176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
156276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
1563705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzinistatic int
1564705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzinido_accept(struct tcb *tcp, int flags_arg)
156576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
156676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
156776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
1568705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini		return 0;
1569705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini	}
1570705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini	if (!tcp->u_arg[2])
157176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%#lx, NULL", tcp->u_arg[1]);
157276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	else {
15732fc6615b9137234af661ed15796e021e98e43bf9Dmitry V. Levin		int len;
15742fc6615b9137234af661ed15796e021e98e43bf9Dmitry V. Levin		if (tcp->u_arg[1] == 0 || syserror(tcp)
1575b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		    || umove(tcp, tcp->u_arg[2], &len) < 0) {
157676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
157776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		} else {
15782fc6615b9137234af661ed15796e021e98e43bf9Dmitry V. Levin			printsock(tcp, tcp->u_arg[1], len);
157976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
158060fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
15812fc6615b9137234af661ed15796e021e98e43bf9Dmitry V. Levin		printnum_int(tcp, tcp->u_arg[2], "%u");
158276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
1583705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini	if (flags_arg >= 0) {
158460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
1585705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini		printflags(sock_type_flags, tcp->u_arg[flags_arg],
1586705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini			   "SOCK_???");
1587705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini	}
158876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
158976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
159076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
159176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
1592705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzinisys_accept(struct tcb *tcp)
1593705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini{
1594705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini	return do_accept(tcp, -1);
1595705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini}
1596705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini
1597705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonziniint
1598705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzinisys_accept4(struct tcb *tcp)
1599705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini{
1600705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini	return do_accept(tcp, 3);
1601705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini}
1602705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonzini
1603705ff10c0b9c07b9b51fc2f2bc6f3e6412f6ed9cPaolo Bonziniint
16041201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_send(struct tcb *tcp)
160576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
160676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
160776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
160876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
160976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
161076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
1611b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		printflags(msg_flags, tcp->u_arg[3], "MSG_???");
161276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
161376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
161476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
161576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
161676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
16171201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_sendto(struct tcb *tcp)
161876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
161976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
162076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
162176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
162276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
162376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
1624b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		printflags(msg_flags, tcp->u_arg[3], "MSG_???");
162576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* to address */
162660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
1627f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
162876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* to length */
162976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu", tcp->u_arg[5]);
163076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
163176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
163276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
163376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
163476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_SENDMSG
163576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
163676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
16371201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_sendmsg(struct tcb *tcp)
163876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
163976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
164076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
1641043b5f81429412cf23d578d1dc2b45107a8352e5Dmitry V. Levin		printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
164276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
164360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
1644b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		printflags(msg_flags, tcp->u_arg[2], "MSG_???");
164576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
164676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
164776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
164876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
16497af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levinint
16507af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levinsys_sendmmsg(struct tcb *tcp)
16517af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin{
16527af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	if (entering(tcp)) {
16537af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		/* sockfd */
16547af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		tprintf("%d, ", (int) tcp->u_arg[0]);
16557af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		if (!verbose(tcp)) {
16567af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin			tprintf("%#lx, %u, ",
16577af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin				tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
16587af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin			printflags(msg_flags, tcp->u_arg[3], "MSG_???");
16597af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		}
16607af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	} else {
16617af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin		if (verbose(tcp))
16625ea97658e78b6ce9fb768ffdd6a4b682c5df8e90Dmitry V. Levin			decode_mmsg(tcp, (unsigned long) -1L);
16637af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	}
16647af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin	return 0;
16657af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin}
16667af9f35001af19e2844b3e9fb3c672ee696be17bDmitry V. Levin
166776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
166876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
166976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
16701201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_recv(struct tcb *tcp)
167176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
167276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
167376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
167476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
167576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp))
167676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
167776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
167876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printstr(tcp, tcp->u_arg[1], tcp->u_rval);
167976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
168076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
1681b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		printflags(msg_flags, tcp->u_arg[3], "MSG_???");
168276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
168376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
168476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
168576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
168676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
16871201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_recvfrom(struct tcb *tcp)
168876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
168976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fromlen;
169076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
169176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
169276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
169376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
169476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
169576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx, %lu, %lu, %#lx, %#lx",
169676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
169776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[4], tcp->u_arg[5]);
169876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
169976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
170076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* buf */
170176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printstr(tcp, tcp->u_arg[1], tcp->u_rval);
170276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* len */
170376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", %lu, ", tcp->u_arg[2]);
170476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
1705b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		printflags(msg_flags, tcp->u_arg[3], "MSG_???");
170676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* from address, len */
170776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
170876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			if (tcp->u_arg[4] == 0)
170960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko				tprints(", NULL");
171076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			else
171176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", %#lx", tcp->u_arg[4]);
171276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			if (tcp->u_arg[5] == 0)
171360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko				tprints(", NULL");
171476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			else
171576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tprintf(", %#lx", tcp->u_arg[5]);
171676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
171776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
171876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
171960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", {...}, [?]");
172076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
172176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
172260fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
1723f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman		printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
172476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* from length */
172576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf(", [%u]", fromlen);
172676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
172776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
172876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
172976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
173076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef HAVE_SENDMSG
173176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
173276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
17331201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_recvmsg(struct tcb *tcp)
173476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
173576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
173676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
173776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
173876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp) || !verbose(tcp))
173976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[1]);
174076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
1741e0bc222263cf47a43e1b26d55edb2ffadc8ccbffDenys Vlasenko			printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval);
174276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* flags */
174360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
1744b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath		printflags(msg_flags, tcp->u_arg[2], "MSG_???");
174576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
174676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
174776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
174876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
17490873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwabint
17500873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwabsys_recvmmsg(struct tcb *tcp)
17510873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab{
1752a1d541ec56e2fb4716f083fcc814b1dedde63d87Denys Vlasenko	/* +5 chars are for "left " prefix */
1753a1d541ec56e2fb4716f083fcc814b1dedde63d87Denys Vlasenko	static char str[5 + TIMESPEC_TEXT_BUFSIZE];
1754e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin
1755a1d541ec56e2fb4716f083fcc814b1dedde63d87Denys Vlasenko	if (entering(tcp)) {
17560873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab		tprintf("%ld, ", tcp->u_arg[0]);
1757e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		if (verbose(tcp)) {
1758e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			sprint_timespec(str, tcp, tcp->u_arg[4]);
1759a1d541ec56e2fb4716f083fcc814b1dedde63d87Denys Vlasenko			/* Abusing tcp->auxstr as temp storage.
1760a1d541ec56e2fb4716f083fcc814b1dedde63d87Denys Vlasenko			 * Will be used and freed on syscall exit.
1761a1d541ec56e2fb4716f083fcc814b1dedde63d87Denys Vlasenko			 */
1762e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			tcp->auxstr = strdup(str);
1763e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		} else {
1764e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
1765e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			printflags(msg_flags, tcp->u_arg[3], "MSG_???");
176660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", ");
1767e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			print_timespec(tcp, tcp->u_arg[4]);
1768e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		}
1769e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		return 0;
1770e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin	} else {
1771e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		if (verbose(tcp)) {
17725ea97658e78b6ce9fb768ffdd6a4b682c5df8e90Dmitry V. Levin			decode_mmsg(tcp, 0);
1773e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			/* timeout on entrance */
1774e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
1775e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			free((void *) tcp->auxstr);
1776e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			tcp->auxstr = NULL;
1777e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		}
1778e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		if (syserror(tcp))
1779e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			return 0;
1780e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		if (tcp->u_rval == 0) {
1781e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			tcp->auxstr = "Timeout";
1782e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			return RVAL_STR;
1783e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		}
1784e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		if (!verbose(tcp))
1785e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin			return 0;
1786e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		/* timeout on exit */
1787a1d541ec56e2fb4716f083fcc814b1dedde63d87Denys Vlasenko		sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
1788e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		tcp->auxstr = str;
1789e6591031475ace4ac54bb9995f21dd86fa857b1bDmitry V. Levin		return RVAL_STR;
17900873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab	}
17910873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab}
17920873f29af4c1b2357e4f13338731665dd1ee2893Andreas Schwab
179376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* HAVE_SENDMSG */
179476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
17959cd385010ec1e0d22be70ff5163db194f1f22735Sebastian Pippingstatic const struct xlat shutdown_modes[] = {
1796b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	{ 0,	"SHUT_RD"	},
1797b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	{ 1,	"SHUT_WR"	},
1798b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	{ 2,	"SHUT_RDWR"	},
1799b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	{ 0,	NULL		}
18009cd385010ec1e0d22be70ff5163db194f1f22735Sebastian Pipping};
18019cd385010ec1e0d22be70ff5163db194f1f22735Sebastian Pipping
180276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
18031201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_shutdown(struct tcb *tcp)
180476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
180576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
18069cd385010ec1e0d22be70ff5163db194f1f22735Sebastian Pipping		tprintf("%ld, ", tcp->u_arg[0]);
18079cd385010ec1e0d22be70ff5163db194f1f22735Sebastian Pipping		printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
180876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
180976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
181076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
181176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
181276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
18131201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_getsockname(struct tcb *tcp)
181476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
181576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_accept(tcp);
181676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
181776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
181876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
18191201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_getpeername(struct tcb *tcp)
182076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
182176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return sys_accept(tcp);
182276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
182376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
18244371b10b30ceb369942e93105c038519524ba18eDmitry V. Levinstatic int
18254371b10b30ceb369942e93105c038519524ba18eDmitry V. Levindo_pipe(struct tcb *tcp, int flags_arg)
18264371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin{
182776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (exiting(tcp)) {
182876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
182976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf("%#lx", tcp->u_arg[0]);
18304371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin		} else {
18318470374cba7df0e70653d95c4f336a4082c68d82Denys Vlasenko#if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
18324371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin			int fds[2];
18334371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin
18344371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin			if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
183560fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko				tprints("[...]");
18364371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin			else
18374371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin				tprintf("[%u, %u]", fds[0], fds[1]);
18388470374cba7df0e70653d95c4f336a4082c68d82Denys Vlasenko#elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64)
18394371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin			tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
18404371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin#else
18414371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin			tprintf("%#lx", tcp->u_arg[0]);
184276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
18434371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin		}
18444371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin		if (flags_arg >= 0) {
184560fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", ");
18464371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin			printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
18474371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin		}
18484371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin	}
184976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
185076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
185176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
185276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
18534371b10b30ceb369942e93105c038519524ba18eDmitry V. Levinsys_pipe(struct tcb *tcp)
18544371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin{
18554371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin	return do_pipe(tcp, -1);
18564371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin}
18574371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin
18584371b10b30ceb369942e93105c038519524ba18eDmitry V. Levinint
18594371b10b30ceb369942e93105c038519524ba18eDmitry V. Levinsys_pipe2(struct tcb *tcp)
18604371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin{
18614371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin	return do_pipe(tcp, 1);
18624371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin}
18634371b10b30ceb369942e93105c038519524ba18eDmitry V. Levin
18644371b10b30ceb369942e93105c038519524ba18eDmitry V. Levinint
18658a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levinsys_socketpair(struct tcb *tcp)
186676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
186776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	int fds[2];
186876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
186976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
187076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		printxval(domains, tcp->u_arg[0], "PF_???");
187160fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
18728a550d729d53f963452d10990cd56d1132cb1602Dmitry V. Levin		tprint_sock_type(tcp, tcp->u_arg[1]);
187360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
187476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[0]) {
187576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_INET:
187676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
187776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
187876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef PF_IPX
187976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case PF_IPX:
188076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			/* BTW: I don't believe this.. */
188160fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("[");
188276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(domains, tcp->u_arg[2], "PF_???");
188360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("]");
188476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
188576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif /* PF_IPX */
18866d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath		default:
18872e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf("%lu", tcp->u_arg[2]);
188876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
188976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
189076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
189176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (syserror(tcp)) {
18922e2553a534f532a1546ea2b2f3dc3cd2276d020dWichert Akkerman			tprintf(", %#lx", tcp->u_arg[3]);
189376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
189476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
189576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
189660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", [...]");
189776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		else
189876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			tprintf(", [%u, %u]", fds[0], fds[1]);
189976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
190076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
190176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
190276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
190376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanint
1904312891930180ba10bd9d65c3e47f92cf15a6dacdDmitry V. Levinsys_getsockopt(struct tcb *tcp)
190576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
190676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	if (entering(tcp)) {
190776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		tprintf("%ld, ", tcp->u_arg[0]);
190893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		printxval(socketlayers, tcp->u_arg[1], "SOL_???");
190960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
191076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		switch (tcp->u_arg[1]) {
191176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_SOCKET:
191276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockoptions, tcp->u_arg[2], "SO_???");
191376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
191476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
191576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IP:
191676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipoptions, tcp->u_arg[2], "IP_???");
191776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
191876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
19194f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef SOL_IPV6
19204f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath		case SOL_IPV6:
19214f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath			printxval(sockipv6options, tcp->u_arg[2], "IPV6_???");
19224f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath			break;
19234f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
192476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
192576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_IPX:
192676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
192776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
192876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
19297987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_PACKET
19307987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		case SOL_PACKET:
19317987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
19327987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman			break;
19337987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
193476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
193576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		case SOL_TCP:
193676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
193776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
193876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
19397fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#ifdef SOL_SCTP
19407fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther		case SOL_SCTP:
19417fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther			printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???");
19427fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther			break;
19437fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
194476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
194576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		/* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
194676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		 * etc. still need work */
19476d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath		default:
194893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes			tprintf("%lu", tcp->u_arg[2]);
194976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
195076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
195160fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints(", ");
195276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	} else {
1953fc544dbb6ce7da41263aa91df62fd0f17ab716ddRoland McGrath		int len;
1954b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
1955312891930180ba10bd9d65c3e47f92cf15a6dacdDmitry V. Levin			tprintf("%#lx, %#lx",
195676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman				tcp->u_arg[3], tcp->u_arg[4]);
195776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			return 0;
195876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
195993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes
196093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		switch (tcp->u_arg[1]) {
196193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		case SOL_SOCKET:
196293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes			switch (tcp->u_arg[2]) {
196393f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#ifdef SO_LINGER
196493f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes			case SO_LINGER:
1965b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				if (len == sizeof(struct linger)) {
196693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes					struct linger linger;
1967b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko					if (umove(tcp,
196893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes						   tcp->u_arg[3],
196993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes						   &linger) < 0)
197093f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes						break;
1971312891930180ba10bd9d65c3e47f92cf15a6dacdDmitry V. Levin					tprintf("{onoff=%d, linger=%d}, "
197296ad7b8f529221bd1db1c3cdca871ee9e1dc713aRoland McGrath						"[%d]",
197393f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes						linger.l_onoff,
197493f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes						linger.l_linger,
197593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes						len);
197693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes					return 0;
197793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes				}
197893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes				break;
197993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#endif
19800ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin#ifdef SO_PEERCRED
19810ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin			case SO_PEERCRED:
1982b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				if (len == sizeof(struct ucred)) {
19830ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin					struct ucred uc;
1984b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko					if (umove(tcp,
19850ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						   tcp->u_arg[3],
19860ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						   &uc) < 0)
19870ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						break;
19880ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin					tprintf("{pid=%ld, uid=%ld, gid=%ld}, "
19890ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						"[%d]",
19900ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						(long)uc.pid,
19910ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						(long)uc.uid,
19920ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						(long)uc.gid,
19930ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin						len);
19940ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin					return 0;
19950ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin				}
19960ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin				break;
19970ddd8addef9e9b0c7af00f70b97b3e464205ad1dDmitry V. Levin#endif
199893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes			}
199993f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes			break;
2000ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin		case SOL_PACKET:
2001ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin			switch (tcp->u_arg[2]) {
2002ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#ifdef PACKET_STATISTICS
2003ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin			case PACKET_STATISTICS:
2004ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin				if (len == sizeof(struct tpacket_stats)) {
2005ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					struct tpacket_stats stats;
2006b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko					if (umove(tcp,
2007ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin						   tcp->u_arg[3],
2008ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin						   &stats) < 0)
2009ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin						break;
2010ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					tprintf("{packets=%u, drops=%u}, "
2011ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin						"[%d]",
2012ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin						stats.tp_packets,
2013ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin						stats.tp_drops,
2014ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin						len);
2015ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					return 0;
2016ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin				}
2017ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin				break;
2018ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
2019ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin			}
2020ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin			break;
202193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		}
202293f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes
2023b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		if (len == sizeof(int)) {
2024312891930180ba10bd9d65c3e47f92cf15a6dacdDmitry V. Levin			printnum_int(tcp, tcp->u_arg[3], "%d");
202593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		}
202693f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		else {
2027b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			printstr(tcp, tcp->u_arg[3], len);
202893f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		}
2029fc544dbb6ce7da41263aa91df62fd0f17ab716ddRoland McGrath		tprintf(", [%d]", len);
203076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
203176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
203276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
203376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
20347987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_FILTER)
20351201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkostatic void printicmpfilter(struct tcb *tcp, long addr)
20367987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman{
20377987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	struct icmp_filter	filter;
20387987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
20397987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	if (!addr) {
204060fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("NULL");
20417987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		return;
20427987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	}
20437987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	if (syserror(tcp) || !verbose(tcp)) {
20447987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		tprintf("%#lx", addr);
20457987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		return;
20467987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	}
20477987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	if (umove(tcp, addr, &filter) < 0) {
204860fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("{...}");
20497987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman		return;
20507987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman	}
20517987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
205260fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints("~(");
2053b2dee13345a62c80a677f3342cd525d611fbc632Roland McGrath	printflags(icmpfilterflags, ~filter.data, "ICMP_???");
205460fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints(")");
20557987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman}
20567987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif /* ICMP_FILTER */
20577987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
205838ae88d332acd9f86a30d58158e306d795d98977John Hughesstatic int
20591201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoprintsockopt(struct tcb *tcp, int level, int name, long addr, int len)
206076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
206138ae88d332acd9f86a30d58158e306d795d98977John Hughes	printxval(socketlayers, level, "SOL_??");
206260fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints(", ");
206338ae88d332acd9f86a30d58158e306d795d98977John Hughes	switch (level) {
2064989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_SOCKET:
206538ae88d332acd9f86a30d58158e306d795d98977John Hughes		printxval(sockoptions, name, "SO_???");
206638ae88d332acd9f86a30d58158e306d795d98977John Hughes		switch (name) {
206793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes#if defined(SO_LINGER)
2068989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko		case SO_LINGER:
2069b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko			if (len == sizeof(struct linger)) {
207038ae88d332acd9f86a30d58158e306d795d98977John Hughes				struct linger linger;
2071b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko				if (umove(tcp, addr, &linger) < 0)
207238ae88d332acd9f86a30d58158e306d795d98977John Hughes					break;
207338ae88d332acd9f86a30d58158e306d795d98977John Hughes				tprintf(", {onoff=%d, linger=%d}",
207438ae88d332acd9f86a30d58158e306d795d98977John Hughes					linger.l_onoff,
207538ae88d332acd9f86a30d58158e306d795d98977John Hughes					linger.l_linger);
207638ae88d332acd9f86a30d58158e306d795d98977John Hughes				return 0;
207793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes			}
207876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman			break;
207938ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
208038ae88d332acd9f86a30d58158e306d795d98977John Hughes		}
208138ae88d332acd9f86a30d58158e306d795d98977John Hughes		break;
208276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IP
2083989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_IP:
208438ae88d332acd9f86a30d58158e306d795d98977John Hughes		printxval(sockipoptions, name, "IP_???");
208538ae88d332acd9f86a30d58158e306d795d98977John Hughes		break;
208676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
20874f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#ifdef SOL_IPV6
2088989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_IPV6:
20894f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath		printxval(sockipv6options, name, "IPV6_???");
20904f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath		break;
20914f6ba69d99a8b6933707abdeb0151f98c28172c9Roland McGrath#endif
209276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_IPX
2093989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_IPX:
209438ae88d332acd9f86a30d58158e306d795d98977John Hughes		printxval(sockipxoptions, name, "IPX_???");
209538ae88d332acd9f86a30d58158e306d795d98977John Hughes		break;
20967987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
20977987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_PACKET
2098989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_PACKET:
209938ae88d332acd9f86a30d58158e306d795d98977John Hughes		printxval(sockpacketoptions, name, "PACKET_???");
210038ae88d332acd9f86a30d58158e306d795d98977John Hughes		/* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
2101ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin		switch (name) {
2102ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#ifdef PACKET_RX_RING
2103989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko		case PACKET_RX_RING:
2104ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
2105ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#ifdef PACKET_TX_RING
2106989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko		case PACKET_TX_RING:
2107ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif
2108ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#if defined(PACKET_RX_RING) || defined(PACKET_TX_RING)
2109ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin			if (len == sizeof(struct tpacket_req)) {
2110ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin				struct tpacket_req req;
2111ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin				if (umove(tcp, addr, &req) < 0)
2112ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					break;
2113ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin				tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}",
2114ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					req.tp_block_size,
2115ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					req.tp_block_nr,
2116ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					req.tp_frame_size,
2117ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin					req.tp_frame_nr);
2118ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin				return 0;
2119ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin			}
2120ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin			break;
2121ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin#endif /* PACKET_RX_RING || PACKET_TX_RING */
2122ca75bd6dffc01e4d95e85d3af82d446cd80afbb5Dmitry V. Levin		}
212338ae88d332acd9f86a30d58158e306d795d98977John Hughes		break;
212476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
212576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#ifdef SOL_TCP
2126989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_TCP:
212738ae88d332acd9f86a30d58158e306d795d98977John Hughes		printxval(socktcpoptions, name, "TCP_???");
212838ae88d332acd9f86a30d58158e306d795d98977John Hughes		break;
21297987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
21307fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#ifdef SOL_SCTP
2131989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_SCTP:
21327fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther		printxval(socksctpoptions, name, "SCTP_???");
21337fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther		break;
21347fea79b7606644ec4e7c2e0a9fbb070c15cbc589Holger Hans Peter Freyther#endif
21357987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#ifdef SOL_RAW
2136989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	case SOL_RAW:
213738ae88d332acd9f86a30d58158e306d795d98977John Hughes		printxval(sockrawoptions, name, "RAW_???");
213838ae88d332acd9f86a30d58158e306d795d98977John Hughes		switch (name) {
21397987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#if defined(ICMP_FILTER)
2140b237b1b20da4ff40efb919f9d4a6458a05f375caDenys Vlasenko			case ICMP_FILTER:
2141b237b1b20da4ff40efb919f9d4a6458a05f375caDenys Vlasenko				tprints(", ");
2142b237b1b20da4ff40efb919f9d4a6458a05f375caDenys Vlasenko				printicmpfilter(tcp, addr);
2143b237b1b20da4ff40efb919f9d4a6458a05f375caDenys Vlasenko				return 0;
21447987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman#endif
214538ae88d332acd9f86a30d58158e306d795d98977John Hughes		}
214638ae88d332acd9f86a30d58158e306d795d98977John Hughes		break;
214776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#endif
214876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
21496d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath		/* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
215076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		 * etc. still need work  */
215193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes
2152989ebc91395600c21b4242aee27df9190b2166b3Denys Vlasenko	default:
215338ae88d332acd9f86a30d58158e306d795d98977John Hughes		tprintf("%u", name);
215438ae88d332acd9f86a30d58158e306d795d98977John Hughes	}
215593f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes
215638ae88d332acd9f86a30d58158e306d795d98977John Hughes	/* default arg printing */
215793f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes
215860fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	tprints(", ");
21596d2b34971b33d379c89c36c5ad1b0c6d5d12c453Roland McGrath
2160b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko	if (len == sizeof(int)) {
2161b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		printnum_int(tcp, addr, "%d");
216238ae88d332acd9f86a30d58158e306d795d98977John Hughes	}
216338ae88d332acd9f86a30d58158e306d795d98977John Hughes	else {
2164b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		printstr(tcp, addr, len);
216538ae88d332acd9f86a30d58158e306d795d98977John Hughes	}
216638ae88d332acd9f86a30d58158e306d795d98977John Hughes	return 0;
216738ae88d332acd9f86a30d58158e306d795d98977John Hughes}
216838ae88d332acd9f86a30d58158e306d795d98977John Hughes
2169c3ca0d80a59586c39803a75384e64e13424e8506Roland McGrath#ifdef HAVE_STRUCT_OPTHDR
217038ae88d332acd9f86a30d58158e306d795d98977John Hughes
217138ae88d332acd9f86a30d58158e306d795d98977John Hughesvoid
21721201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkoprint_sock_optmgmt(struct tcb *tcp, long addr, int len)
217338ae88d332acd9f86a30d58158e306d795d98977John Hughes{
217438ae88d332acd9f86a30d58158e306d795d98977John Hughes	int c = 0;
217538ae88d332acd9f86a30d58158e306d795d98977John Hughes	struct opthdr hdr;
217638ae88d332acd9f86a30d58158e306d795d98977John Hughes
21772c4e3a8061130493bd196564f096b677c5528fc1John Hughes	while (len >= (int) sizeof hdr) {
217838ae88d332acd9f86a30d58158e306d795d98977John Hughes		if (umove(tcp, addr, &hdr) < 0) break;
217938ae88d332acd9f86a30d58158e306d795d98977John Hughes		if (c++) {
218060fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints(", ");
218176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman		}
218238ae88d332acd9f86a30d58158e306d795d98977John Hughes		else if (len > hdr.len + sizeof hdr) {
218360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko			tprints("[");
218493f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		}
218560fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("{");
218638ae88d332acd9f86a30d58158e306d795d98977John Hughes		addr += sizeof hdr;
218738ae88d332acd9f86a30d58158e306d795d98977John Hughes		len -= sizeof hdr;
2188b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		printsockopt(tcp, hdr.level, hdr.name, addr, hdr.len);
21892c4e3a8061130493bd196564f096b677c5528fc1John Hughes		if (hdr.len > 0) {
21902c4e3a8061130493bd196564f096b677c5528fc1John Hughes			addr += hdr.len;
21912c4e3a8061130493bd196564f096b677c5528fc1John Hughes			len -= hdr.len;
21922c4e3a8061130493bd196564f096b677c5528fc1John Hughes		}
219360fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		tprints("}");
219438ae88d332acd9f86a30d58158e306d795d98977John Hughes	}
219538ae88d332acd9f86a30d58158e306d795d98977John Hughes	if (len > 0) {
219660fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko		if (c++) tprints(", ");
2197b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		printstr(tcp, addr, len);
219838ae88d332acd9f86a30d58158e306d795d98977John Hughes	}
219960fe8c139c6f2febefe595781812ddf0864a6ab8Denys Vlasenko	if (c > 1) tprints("]");
220038ae88d332acd9f86a30d58158e306d795d98977John Hughes}
220138ae88d332acd9f86a30d58158e306d795d98977John Hughes
220238ae88d332acd9f86a30d58158e306d795d98977John Hughes#endif
220338ae88d332acd9f86a30d58158e306d795d98977John Hughes
220438ae88d332acd9f86a30d58158e306d795d98977John Hughesint
22051201426dd43f5b4e12dfe520e2a9c5027d33dc11Denys Vlasenkosys_setsockopt(struct tcb *tcp)
220638ae88d332acd9f86a30d58158e306d795d98977John Hughes{
220738ae88d332acd9f86a30d58158e306d795d98977John Hughes	if (entering(tcp)) {
220838ae88d332acd9f86a30d58158e306d795d98977John Hughes		tprintf("%ld, ", tcp->u_arg[0]);
2209b63256e69bf3f1a74aadb0e14556490bc8f4ef95Denys Vlasenko		printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
221038ae88d332acd9f86a30d58158e306d795d98977John Hughes			      tcp->u_arg[3], tcp->u_arg[4]);
221193f7fccaa60735509fd75ad22c8a97a8cd52f6bbJohn Hughes		tprintf(", %lu", tcp->u_arg[4]);
221276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	}
221376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman	return 0;
221476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
2215