blob: e0b225e2319981b2a3dd431e3effe40f95772b27 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00005 * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000029 */
30
31#include "defs.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000032#include <sys/stat.h>
33#include <sys/socket.h>
34#include <sys/un.h>
Wichert Akkermanf1850652001-02-16 20:29:03 +000035#if defined(HAVE_SIN6_SCOPE_ID_LINUX)
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010036# define in6_addr in6_addr_libc
37# define ipv6_mreq ipv6_mreq_libc
38# define sockaddr_in6 sockaddr_in6_libc
Wichert Akkermanf1850652001-02-16 20:29:03 +000039#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000040#include <netinet/in.h>
Wichert Akkerman8c7122c2001-02-16 19:59:55 +000041#ifdef HAVE_NETINET_TCP_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010042# include <netinet/tcp.h>
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000043#endif
Wichert Akkerman8c7122c2001-02-16 19:59:55 +000044#ifdef HAVE_NETINET_UDP_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010045# include <netinet/udp.h>
Wichert Akkerman8c7122c2001-02-16 19:59:55 +000046#endif
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +010047#ifdef HAVE_NETINET_SCTP_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010048# include <netinet/sctp.h>
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +010049#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050#include <arpa/inet.h>
Wichert Akkermanf1850652001-02-16 20:29:03 +000051#include <net/if.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052#include <asm/types.h>
Denys Vlasenko99aa1812013-02-08 18:49:06 +010053#if defined(__GLIBC__)
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010054# include <netipx/ipx.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000055#else
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010056# include <linux/ipx.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058
Denys Vlasenko99aa1812013-02-08 18:49:06 +010059#if defined(__GLIBC__) && defined(HAVE_SIN6_SCOPE_ID_LINUX)
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010060# if defined(HAVE_LINUX_IN6_H)
61# if defined(HAVE_SIN6_SCOPE_ID_LINUX)
62# undef in6_addr
63# undef ipv6_mreq
64# undef sockaddr_in6
65# define in6_addr in6_addr_kernel
66# define ipv6_mreq ipv6_mreq_kernel
67# define sockaddr_in6 sockaddr_in6_kernel
68# endif
69# include <linux/in6.h>
70# if defined(HAVE_SIN6_SCOPE_ID_LINUX)
71# undef in6_addr
72# undef ipv6_mreq
73# undef sockaddr_in6
74# define in6_addr in6_addr_libc
75# define ipv6_mreq ipv6_mreq_libc
76# define sockaddr_in6 sockaddr_in6_kernel
77# endif
78# endif
Wichert Akkerman2f473da1999-11-01 19:53:31 +000079#endif
Wichert Akkerman505e1761999-11-01 19:39:08 +000080
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000081#if defined(HAVE_SYS_UIO_H)
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010082# include <sys/uio.h>
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000083#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000084#if defined(HAVE_LINUX_NETLINK_H)
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010085# include <linux/netlink.h>
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000086#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000087#if defined(HAVE_LINUX_IF_PACKET_H)
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010088# include <linux/if_packet.h>
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000089#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +000090#if defined(HAVE_LINUX_ICMP_H)
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010091# include <linux/icmp.h>
Wichert Akkerman7987cdf2000-07-05 16:05:39 +000092#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000093#ifndef PF_UNSPEC
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010094# define PF_UNSPEC AF_UNSPEC
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000095#endif
96
Roland McGrathd9f816f2004-09-04 03:39:20 +000097static const struct xlat domains[] = {
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +000098#ifdef PF_UNSPEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000099 XLAT(PF_UNSPEC),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000100#endif
101#ifdef PF_LOCAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000102 XLAT(PF_LOCAL),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000103#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000104#ifdef PF_UNIX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000105 XLAT(PF_UNIX),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000106#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000107#ifdef PF_INET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000108 XLAT(PF_INET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000109#endif
110#ifdef PF_AX25
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000111 XLAT(PF_AX25),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000112#endif
113#ifdef PF_IPX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000114 XLAT(PF_IPX),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000115#endif
116#ifdef PF_APPLETALK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000117 XLAT(PF_APPLETALK),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000118#endif
119#ifdef PF_NETROM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000120 XLAT(PF_NETROM),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000121#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000122#ifdef PF_BRIDGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000123 XLAT(PF_BRIDGE),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000124#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000125#ifdef PF_ATMPVC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000126 XLAT(PF_ATMPVC),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000127#endif
128#ifdef PF_X25
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000129 XLAT(PF_X25),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000130#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000131#ifdef PF_INET6
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000132 XLAT(PF_INET6),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000133#endif
134#ifdef PF_ROSE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000135 XLAT(PF_ROSE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000136#endif
137#ifdef PF_DECnet
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000138 XLAT(PF_DECnet),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000139#endif
140#ifdef PF_NETBEUI
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000141 XLAT(PF_NETBEUI),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000142#endif
143#ifdef PF_SECURITY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000144 XLAT(PF_SECURITY),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000145#endif
146#ifdef PF_KEY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000147 XLAT(PF_KEY),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000148#endif
149#ifdef PF_NETLINK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000150 XLAT(PF_NETLINK),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000151#endif
152#ifdef PF_ROUTE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000153 XLAT(PF_ROUTE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000154#endif
155#ifdef PF_PACKET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000156 XLAT(PF_PACKET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000157#endif
158#ifdef PF_ASH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000159 XLAT(PF_ASH),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000160#endif
161#ifdef PF_ECONET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000162 XLAT(PF_ECONET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000163#endif
164#ifdef PF_ATMSVC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000165 XLAT(PF_ATMSVC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000166#endif
167#ifdef PF_RDS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000168 XLAT(PF_RDS),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000169#endif
170#ifdef PF_SNA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000171 XLAT(PF_SNA),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000172#endif
173#ifdef PF_IRDA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000174 XLAT(PF_IRDA),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000175#endif
176#ifdef PF_PPPOX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000177 XLAT(PF_PPPOX),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000178#endif
179#ifdef PF_WANPIPE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000180 XLAT(PF_WANPIPE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000181#endif
182#ifdef PF_LLC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000183 XLAT(PF_LLC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000184#endif
185#ifdef PF_CAN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000186 XLAT(PF_CAN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000187#endif
188#ifdef PF_TIPC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000189 XLAT(PF_TIPC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000190#endif
191#ifdef PF_BLUETOOTH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000192 XLAT(PF_BLUETOOTH),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000193#endif
194#ifdef PF_IUCV
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000195 XLAT(PF_IUCV),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000196#endif
197#ifdef PF_RXRPC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000198 XLAT(PF_RXRPC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000199#endif
200#ifdef PF_ISDN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000201 XLAT(PF_ISDN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000202#endif
203#ifdef PF_PHONET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000204 XLAT(PF_PHONET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000205#endif
206#ifdef PF_IEEE802154
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000207 XLAT(PF_IEEE802154),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000208#endif
209#ifdef PF_CAIF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000210 XLAT(PF_CAIF),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000211#endif
212#ifdef PF_ALG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000213 XLAT(PF_ALG),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000214#endif
215#ifdef PF_NFC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000216 XLAT(PF_NFC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000217#endif
218#ifdef PF_VSOCK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000219 XLAT(PF_VSOCK),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000220#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000221 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000222};
Roland McGrathd9f816f2004-09-04 03:39:20 +0000223const struct xlat addrfams[] = {
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000224#ifdef AF_UNSPEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000225 XLAT(AF_UNSPEC),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000226#endif
227#ifdef AF_LOCAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000228 XLAT(AF_LOCAL),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000229#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000230#ifdef AF_UNIX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000231 XLAT(AF_UNIX),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000232#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000233#ifdef AF_INET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000234 XLAT(AF_INET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000235#endif
236#ifdef AF_AX25
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000237 XLAT(AF_AX25),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000238#endif
239#ifdef AF_IPX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000240 XLAT(AF_IPX),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000241#endif
242#ifdef AF_APPLETALK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000243 XLAT(AF_APPLETALK),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000244#endif
245#ifdef AF_NETROM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000246 XLAT(AF_NETROM),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000247#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000248#ifdef AF_BRIDGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000249 XLAT(AF_BRIDGE),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000250#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000251#ifdef AF_ATMPVC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000252 XLAT(AF_ATMPVC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000253#endif
254#ifdef AF_X25
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000255 XLAT(AF_X25),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000256#endif
257#ifdef AF_INET6
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000258 XLAT(AF_INET6),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000259#endif
260#ifdef AF_ROSE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000261 XLAT(AF_ROSE),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000262#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000263#ifdef AF_DECnet
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000264 XLAT(AF_DECnet),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000265#endif
266#ifdef AF_NETBEUI
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000267 XLAT(AF_NETBEUI),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000268#endif
269#ifdef AF_SECURITY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000270 XLAT(AF_SECURITY),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000271#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000272#ifdef AF_KEY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000273 XLAT(AF_KEY),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000274#endif
275#ifdef AF_NETLINK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000276 XLAT(AF_NETLINK),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000277#endif
278#ifdef AF_ROUTE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000279 XLAT(AF_ROUTE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000280#endif
281#ifdef AF_PACKET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000282 XLAT(AF_PACKET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000283#endif
284#ifdef AF_ASH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000285 XLAT(AF_ASH),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000286#endif
287#ifdef AF_ECONET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000288 XLAT(AF_ECONET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000289#endif
290#ifdef AF_ATMSVC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000291 XLAT(AF_ATMSVC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000292#endif
293#ifdef AF_RDS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000294 XLAT(AF_RDS),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000295#endif
Roland McGrath5a8146a2004-06-04 02:24:14 +0000296#ifdef AF_SNA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000297 XLAT(AF_SNA),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000298#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000299#ifdef AF_IRDA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000300 XLAT(AF_IRDA),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000301#endif
302#ifdef AF_PPPOX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000303 XLAT(AF_PPPOX),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000304#endif
305#ifdef AF_WANPIPE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000306 XLAT(AF_WANPIPE),
Roland McGrath5a8146a2004-06-04 02:24:14 +0000307#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000308#ifdef AF_LLC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000309 XLAT(AF_LLC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000310#endif
311#ifdef AF_CAN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000312 XLAT(AF_CAN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000313#endif
314#ifdef AF_TIPC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000315 XLAT(AF_TIPC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000316#endif
317#ifdef AF_BLUETOOTH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000318 XLAT(AF_BLUETOOTH),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000319#endif
320#ifdef AF_IUCV
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000321 XLAT(AF_IUCV),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000322#endif
323#ifdef AF_RXRPC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000324 XLAT(AF_RXRPC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000325#endif
326#ifdef AF_ISDN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000327 XLAT(AF_ISDN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000328#endif
329#ifdef AF_PHONET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000330 XLAT(AF_PHONET),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000331#endif
332#ifdef AF_IEEE802154
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000333 XLAT(AF_IEEE802154),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000334#endif
335#ifdef AF_CAIF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000336 XLAT(AF_CAIF),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000337#endif
338#ifdef AF_ALG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000339 XLAT(AF_ALG),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000340#endif
341#ifdef AF_NFC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000342 XLAT(AF_NFC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000343#endif
344#ifdef AF_VSOCK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000345 XLAT(AF_VSOCK),
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000346#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000347 XLAT_END
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000348};
Roland McGrathd9f816f2004-09-04 03:39:20 +0000349static const struct xlat socktypes[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000350 XLAT(SOCK_STREAM),
351 XLAT(SOCK_DGRAM),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000352#ifdef SOCK_RAW
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000353 XLAT(SOCK_RAW),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000354#endif
Dmitry V. Levin8a550d72008-11-10 17:21:23 +0000355#ifdef SOCK_RDM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000356 XLAT(SOCK_RDM),
Dmitry V. Levin8a550d72008-11-10 17:21:23 +0000357#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000358#ifdef SOCK_SEQPACKET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000359 XLAT(SOCK_SEQPACKET),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000360#endif
Dmitry V. Levin8a550d72008-11-10 17:21:23 +0000361#ifdef SOCK_DCCP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000362 XLAT(SOCK_DCCP),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000363#endif
364#ifdef SOCK_PACKET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000365 XLAT(SOCK_PACKET),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000367 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000368};
Dmitry V. Levind475c062011-03-03 01:02:41 +0000369static const struct xlat sock_type_flags[] = {
Dmitry V. Levin8a550d72008-11-10 17:21:23 +0000370#ifdef SOCK_CLOEXEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000371 XLAT(SOCK_CLOEXEC),
Dmitry V. Levin8a550d72008-11-10 17:21:23 +0000372#endif
373#ifdef SOCK_NONBLOCK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000374 XLAT(SOCK_NONBLOCK),
Dmitry V. Levin8a550d72008-11-10 17:21:23 +0000375#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000376 XLAT_END
Dmitry V. Levin8a550d72008-11-10 17:21:23 +0000377};
378#ifndef SOCK_TYPE_MASK
379# define SOCK_TYPE_MASK 0xf
380#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +0000381static const struct xlat socketlayers[] = {
John Hughes1e4cb342001-03-06 09:25:46 +0000382#if defined(SOL_IP)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000383 XLAT(SOL_IP),
John Hughes1e4cb342001-03-06 09:25:46 +0000384#endif
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000385#if defined(SOL_ICMP)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000386 XLAT(SOL_ICMP),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000387#endif
John Hughes1e4cb342001-03-06 09:25:46 +0000388#if defined(SOL_TCP)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000389 XLAT(SOL_TCP),
John Hughes1e4cb342001-03-06 09:25:46 +0000390#endif
391#if defined(SOL_UDP)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000392 XLAT(SOL_UDP),
John Hughes1e4cb342001-03-06 09:25:46 +0000393#endif
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000394#if defined(SOL_IPV6)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000395 XLAT(SOL_IPV6),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000396#endif
397#if defined(SOL_ICMPV6)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000398 XLAT(SOL_ICMPV6),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000399#endif
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100400#if defined(SOL_SCTP)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000401 XLAT(SOL_SCTP),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100402#endif
403#if defined(SOL_UDPLITE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000404 XLAT(SOL_UDPLITE),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100405#endif
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000406#if defined(SOL_RAW)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000407 XLAT(SOL_RAW),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000408#endif
409#if defined(SOL_IPX)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000410 XLAT(SOL_IPX),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000411#endif
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000412#if defined(SOL_AX25)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000413 XLAT(SOL_AX25),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000414#endif
415#if defined(SOL_ATALK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000416 XLAT(SOL_ATALK),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000417#endif
418#if defined(SOL_NETROM)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000419 XLAT(SOL_NETROM),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000420#endif
421#if defined(SOL_ROSE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000422 XLAT(SOL_ROSE),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000423#endif
424#if defined(SOL_DECNET)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000425 XLAT(SOL_DECNET),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000426#endif
427#if defined(SOL_X25)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000428 XLAT(SOL_X25),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000429#endif
430#if defined(SOL_PACKET)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000431 XLAT(SOL_PACKET),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000432#endif
433#if defined(SOL_ATM)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000434 XLAT(SOL_ATM),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000435#endif
436#if defined(SOL_AAL)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000437 XLAT(SOL_AAL),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000438#endif
439#if defined(SOL_IRDA)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000440 XLAT(SOL_IRDA),
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000441#endif
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100442#if defined(SOL_NETBEUI)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000443 XLAT(SOL_NETBEUI),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100444#endif
445#if defined(SOL_LLC)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000446 XLAT(SOL_LLC),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100447#endif
448#if defined(SOL_DCCP)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000449 XLAT(SOL_DCCP),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100450#endif
451#if defined(SOL_NETLINK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000452 XLAT(SOL_NETLINK),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100453#endif
454#if defined(SOL_TIPC)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000455 XLAT(SOL_TIPC),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100456#endif
457#if defined(SOL_RXRPC)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000458 XLAT(SOL_RXRPC),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100459#endif
460#if defined(SOL_PPPOL2TP)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000461 XLAT(SOL_PPPOL2TP),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100462#endif
463#if defined(SOL_BLUETOOTH)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000464 XLAT(SOL_BLUETOOTH),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100465#endif
466#if defined(SOL_PNPIPE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000467 XLAT(SOL_PNPIPE),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100468#endif
469#if defined(SOL_RDS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000470 XLAT(SOL_RDS),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100471#endif
472#if defined(SOL_IUVC)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000473 XLAT(SOL_IUCV),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100474#endif
475#if defined(SOL_CAIF)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000476 XLAT(SOL_CAIF),
Holger Hans Peter Freytherce9e0f42011-01-14 11:08:11 +0100477#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000478 XLAT(SOL_SOCKET), /* Never used! */
Dmitry V. Levind475c062011-03-03 01:02:41 +0000479 /* The SOL_* array should remain not NULL-terminated. */
Wichert Akkermanefdecac2000-11-26 03:59:21 +0000480};
John Hughes93f7fcc2002-05-22 15:46:49 +0000481/*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
Masatake YAMATO2394a3d2014-03-11 23:37:37 +0900482 falls into "inet_protocols" array below!!!! This is intended!!! ***/
483static const struct xlat inet_protocols[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000484 XLAT(IPPROTO_IP),
485 XLAT(IPPROTO_ICMP),
486 XLAT(IPPROTO_TCP),
487 XLAT(IPPROTO_UDP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000488#ifdef IPPROTO_IGMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000489 XLAT(IPPROTO_IGMP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000490#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000491#ifdef IPPROTO_GGP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000492 XLAT(IPPROTO_GGP),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000493#endif
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000494#ifdef IPPROTO_IPIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000495 XLAT(IPPROTO_IPIP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000496#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000497#ifdef IPPROTO_EGP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000498 XLAT(IPPROTO_EGP),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000499#endif
500#ifdef IPPROTO_PUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000501 XLAT(IPPROTO_PUP),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000502#endif
503#ifdef IPPROTO_IDP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000504 XLAT(IPPROTO_IDP),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000505#endif
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000506#ifdef IPPROTO_TP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000507 XLAT(IPPROTO_TP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000508#endif
509#ifdef IPPROTO_DCCP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000510 XLAT(IPPROTO_DCCP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000511#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000512#ifdef IPPROTO_IPV6
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000513 XLAT(IPPROTO_IPV6),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000514#endif
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000515#ifdef IPPROTO_ROUTING
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000516 XLAT(IPPROTO_ROUTING),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000517#endif
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000518#ifdef IPPROTO_FRAGMENT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000519 XLAT(IPPROTO_FRAGMENT),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000520#endif
521#ifdef IPPROTO_RSVP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000522 XLAT(IPPROTO_RSVP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000523#endif
524#ifdef IPPROTO_GRE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000525 XLAT(IPPROTO_GRE),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000526#endif
527#ifdef IPPROTO_ESP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000528 XLAT(IPPROTO_ESP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000529#endif
530#ifdef IPPROTO_AH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000531 XLAT(IPPROTO_AH),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000532#endif
533#ifdef IPPROTO_ICMPV6
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000534 XLAT(IPPROTO_ICMPV6),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000535#endif
536#ifdef IPPROTO_NONE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000537 XLAT(IPPROTO_NONE),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000538#endif
539#ifdef IPPROTO_DSTOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000540 XLAT(IPPROTO_DSTOPTS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000541#endif
542#ifdef IPPROTO_HELLO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000543 XLAT(IPPROTO_HELLO),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000544#endif
545#ifdef IPPROTO_ND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000546 XLAT(IPPROTO_ND),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000547#endif
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000548#ifdef IPPROTO_MTP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000549 XLAT(IPPROTO_MTP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000550#endif
551#ifdef IPPROTO_ENCAP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000552 XLAT(IPPROTO_ENCAP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000553#endif
554#ifdef IPPROTO_PIM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000555 XLAT(IPPROTO_PIM),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000556#endif
557#ifdef IPPROTO_COMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000558 XLAT(IPPROTO_COMP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000559#endif
560#ifdef IPPROTO_SCTP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000561 XLAT(IPPROTO_SCTP),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000562#endif
563#ifdef IPPROTO_UDPLITE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000564 XLAT(IPPROTO_UDPLITE),
Dmitry V. Levind48c6b92011-01-10 01:14:38 +0000565#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000566#ifdef IPPROTO_RAW
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000567 XLAT(IPPROTO_RAW),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000568#endif
569#ifdef IPPROTO_MAX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000570 XLAT(IPPROTO_MAX),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000571#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000572 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000573};
Masatake YAMATO2394a3d2014-03-11 23:37:37 +0900574
575#ifdef PF_NETLINK
576static const struct xlat netlink_protocols[] = {
577#ifdef NETLINK_ROUTE
578 XLAT(NETLINK_ROUTE),
579#endif
580#ifdef NETLINK_UNUSED
581 XLAT(NETLINK_UNUSED),
582#endif
583#ifdef NETLINK_USERSOCK
584 XLAT(NETLINK_USERSOCK),
585#endif
586#ifdef NETLINK_FIREWALL
587 XLAT(NETLINK_FIREWALL),
588#endif
589#ifdef NETLINK_SOCK_DIAG
590 XLAT(NETLINK_SOCK_DIAG),
591#endif
592#ifdef NETLINK_NFLOG
593 XLAT(NETLINK_NFLOG),
594#endif
595#ifdef NETLINK_XFRM
596 XLAT(NETLINK_XFRM),
597#endif
598#ifdef NETLINK_SELINUX
599 XLAT(NETLINK_SELINUX),
600#endif
601#ifdef NETLINK_ISCSI
602 XLAT(NETLINK_ISCSI),
603#endif
604#ifdef NETLINK_AUDIT
605 XLAT(NETLINK_AUDIT),
606#endif
607#ifdef NETLINK_FIB_LOOKUP
608 XLAT(NETLINK_FIB_LOOKUP),
609#endif
610#ifdef NETLINK_CONNECTOR
611 XLAT(NETLINK_CONNECTOR),
612#endif
613#ifdef NETLINK_NETFILTER
614 XLAT(NETLINK_NETFILTER),
615#endif
616#ifdef NETLINK_IP6_FW
617 XLAT(NETLINK_IP6_FW),
618#endif
619#ifdef NETLINK_DNRTMSG
620 XLAT(NETLINK_DNRTMSG),
621#endif
622#ifdef NETLINK_KOBJECT_UEVENT
623 XLAT(NETLINK_KOBJECT_UEVENT),
624#endif
625#ifdef NETLINK_GENERIC
626 XLAT(NETLINK_GENERIC),
627#endif
628#ifdef NETLINK_SCSITRANSPORT
629 XLAT(NETLINK_SCSITRANSPORT),
630#endif
631#ifdef NETLINK_ECRYPTFS
632 XLAT(NETLINK_ECRYPTFS),
633#endif
634#ifdef NETLINK_RDMA
635 XLAT(NETLINK_RDMA),
636#endif
637#ifdef NETLINK_CRYPTO
638 XLAT(NETLINK_CRYPTO),
639#endif
640 XLAT_END
641};
642#endif
643
Roland McGrathd9f816f2004-09-04 03:39:20 +0000644static const struct xlat msg_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000645 XLAT(MSG_OOB),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000646#ifdef MSG_PEEK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000647 XLAT(MSG_PEEK),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000648#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000649#ifdef MSG_DONTROUTE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000650 XLAT(MSG_DONTROUTE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000651#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000652#ifdef MSG_CTRUNC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000653 XLAT(MSG_CTRUNC),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000654#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000655#ifdef MSG_PROBE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000656 XLAT(MSG_PROBE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000657#endif
658#ifdef MSG_TRUNC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000659 XLAT(MSG_TRUNC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000660#endif
661#ifdef MSG_DONTWAIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000662 XLAT(MSG_DONTWAIT),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000663#endif
664#ifdef MSG_EOR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000665 XLAT(MSG_EOR),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000666#endif
667#ifdef MSG_WAITALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000668 XLAT(MSG_WAITALL),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000669#endif
Roland McGrath05e5e792004-04-14 02:53:54 +0000670#ifdef MSG_FIN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000671 XLAT(MSG_FIN),
Roland McGrath05e5e792004-04-14 02:53:54 +0000672#endif
673#ifdef MSG_SYN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000674 XLAT(MSG_SYN),
Roland McGrath05e5e792004-04-14 02:53:54 +0000675#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000676#ifdef MSG_CONFIRM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000677 XLAT(MSG_CONFIRM),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000678#endif
Roland McGrath05e5e792004-04-14 02:53:54 +0000679#ifdef MSG_RST
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000680 XLAT(MSG_RST),
Roland McGrath05e5e792004-04-14 02:53:54 +0000681#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000682#ifdef MSG_ERRQUEUE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000683 XLAT(MSG_ERRQUEUE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000684#endif
Roland McGrath05e5e792004-04-14 02:53:54 +0000685#ifdef MSG_NOSIGNAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000686 XLAT(MSG_NOSIGNAL),
Roland McGrath05e5e792004-04-14 02:53:54 +0000687#endif
688#ifdef MSG_MORE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000689 XLAT(MSG_MORE),
Roland McGrath05e5e792004-04-14 02:53:54 +0000690#endif
Dmitry V. Levin3df080a2012-03-13 01:26:26 +0000691#ifdef MSG_WAITFORONE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000692 XLAT(MSG_WAITFORONE),
Dmitry V. Levin3df080a2012-03-13 01:26:26 +0000693#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000694#ifdef MSG_EOF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000695 XLAT(MSG_EOF),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000696#endif
697#ifdef MSG_FASTOPEN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000698 XLAT(MSG_FASTOPEN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000699#endif
Roland McGrath71d3d662007-08-07 01:00:26 +0000700#ifdef MSG_CMSG_CLOEXEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000701 XLAT(MSG_CMSG_CLOEXEC),
Roland McGrath71d3d662007-08-07 01:00:26 +0000702#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000703 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000704};
705
Roland McGrathd9f816f2004-09-04 03:39:20 +0000706static const struct xlat sockoptions[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000707#ifdef SO_ACCEPTCONN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000708 XLAT(SO_ACCEPTCONN),
John Hughes38ae88d2002-05-23 11:48:58 +0000709#endif
710#ifdef SO_ALLRAW
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000711 XLAT(SO_ALLRAW),
John Hughes38ae88d2002-05-23 11:48:58 +0000712#endif
Roland McGrath1bf43732004-08-31 07:16:14 +0000713#ifdef SO_ATTACH_FILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000714 XLAT(SO_ATTACH_FILTER),
Roland McGrath1bf43732004-08-31 07:16:14 +0000715#endif
716#ifdef SO_BINDTODEVICE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000717 XLAT(SO_BINDTODEVICE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000718#endif
719#ifdef SO_BROADCAST
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000720 XLAT(SO_BROADCAST),
Roland McGrath1bf43732004-08-31 07:16:14 +0000721#endif
722#ifdef SO_BSDCOMPAT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000723 XLAT(SO_BSDCOMPAT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000724#endif
725#ifdef SO_DEBUG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000726 XLAT(SO_DEBUG),
Roland McGrath1bf43732004-08-31 07:16:14 +0000727#endif
728#ifdef SO_DETACH_FILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000729 XLAT(SO_DETACH_FILTER),
Roland McGrath1bf43732004-08-31 07:16:14 +0000730#endif
731#ifdef SO_DONTROUTE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000732 XLAT(SO_DONTROUTE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000733#endif
734#ifdef SO_ERROR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000735 XLAT(SO_ERROR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000736#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000737#ifdef SO_ICS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000738 XLAT(SO_ICS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000739#endif
Roland McGrath1bf43732004-08-31 07:16:14 +0000740#ifdef SO_IMASOCKET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000741 XLAT(SO_IMASOCKET),
Roland McGrath1bf43732004-08-31 07:16:14 +0000742#endif
743#ifdef SO_KEEPALIVE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000744 XLAT(SO_KEEPALIVE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000745#endif
746#ifdef SO_LINGER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000747 XLAT(SO_LINGER),
Roland McGrath1bf43732004-08-31 07:16:14 +0000748#endif
749#ifdef SO_LISTENING
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000750 XLAT(SO_LISTENING),
Roland McGrath1bf43732004-08-31 07:16:14 +0000751#endif
752#ifdef SO_MGMT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000753 XLAT(SO_MGMT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000754#endif
755#ifdef SO_NO_CHECK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000756 XLAT(SO_NO_CHECK),
Roland McGrath1bf43732004-08-31 07:16:14 +0000757#endif
758#ifdef SO_OOBINLINE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000759 XLAT(SO_OOBINLINE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000760#endif
761#ifdef SO_ORDREL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000762 XLAT(SO_ORDREL),
Roland McGrath1bf43732004-08-31 07:16:14 +0000763#endif
764#ifdef SO_PARALLELSVR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000765 XLAT(SO_PARALLELSVR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000766#endif
767#ifdef SO_PASSCRED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000768 XLAT(SO_PASSCRED),
Roland McGrath1bf43732004-08-31 07:16:14 +0000769#endif
770#ifdef SO_PEERCRED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000771 XLAT(SO_PEERCRED),
Roland McGrath1bf43732004-08-31 07:16:14 +0000772#endif
773#ifdef SO_PEERNAME
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000774 XLAT(SO_PEERNAME),
Roland McGrath1bf43732004-08-31 07:16:14 +0000775#endif
776#ifdef SO_PEERSEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000777 XLAT(SO_PEERSEC),
Roland McGrath1bf43732004-08-31 07:16:14 +0000778#endif
779#ifdef SO_PRIORITY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000780 XLAT(SO_PRIORITY),
Roland McGrath1bf43732004-08-31 07:16:14 +0000781#endif
782#ifdef SO_PROTOTYPE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000783 XLAT(SO_PROTOTYPE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000784#endif
785#ifdef SO_RCVBUF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000786 XLAT(SO_RCVBUF),
Roland McGrath1bf43732004-08-31 07:16:14 +0000787#endif
788#ifdef SO_RCVLOWAT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000789 XLAT(SO_RCVLOWAT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000790#endif
791#ifdef SO_RCVTIMEO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000792 XLAT(SO_RCVTIMEO),
Roland McGrath1bf43732004-08-31 07:16:14 +0000793#endif
794#ifdef SO_RDWR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000795 XLAT(SO_RDWR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000796#endif
797#ifdef SO_REUSEADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000798 XLAT(SO_REUSEADDR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000799#endif
800#ifdef SO_REUSEPORT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000801 XLAT(SO_REUSEPORT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000802#endif
803#ifdef SO_SECURITY_AUTHENTICATION
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000804 XLAT(SO_SECURITY_AUTHENTICATION),
Roland McGrath1bf43732004-08-31 07:16:14 +0000805#endif
806#ifdef SO_SECURITY_ENCRYPTION_NETWORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000807 XLAT(SO_SECURITY_ENCRYPTION_NETWORK),
Roland McGrath1bf43732004-08-31 07:16:14 +0000808#endif
809#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000810 XLAT(SO_SECURITY_ENCRYPTION_TRANSPORT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000811#endif
812#ifdef SO_SEMA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000813 XLAT(SO_SEMA),
Roland McGrath1bf43732004-08-31 07:16:14 +0000814#endif
815#ifdef SO_SNDBUF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000816 XLAT(SO_SNDBUF),
Roland McGrath1bf43732004-08-31 07:16:14 +0000817#endif
818#ifdef SO_SNDLOWAT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000819 XLAT(SO_SNDLOWAT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000820#endif
821#ifdef SO_SNDTIMEO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000822 XLAT(SO_SNDTIMEO),
Roland McGrath1bf43732004-08-31 07:16:14 +0000823#endif
824#ifdef SO_TIMESTAMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000825 XLAT(SO_TIMESTAMP),
Roland McGrath1bf43732004-08-31 07:16:14 +0000826#endif
827#ifdef SO_TYPE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000828 XLAT(SO_TYPE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000829#endif
830#ifdef SO_USELOOPBACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000831 XLAT(SO_USELOOPBACK),
Roland McGrath1bf43732004-08-31 07:16:14 +0000832#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000833 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000834};
835
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100836#if !defined(SOL_IP) && defined(IPPROTO_IP)
John Hughes93f7fcc2002-05-22 15:46:49 +0000837#define SOL_IP IPPROTO_IP
838#endif
839
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000840#ifdef SOL_IP
Roland McGrathd9f816f2004-09-04 03:39:20 +0000841static const struct xlat sockipoptions[] = {
John Hughes93f7fcc2002-05-22 15:46:49 +0000842#ifdef IP_TOS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000843 XLAT(IP_TOS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000844#endif
845#ifdef IP_TTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000846 XLAT(IP_TTL),
John Hughes93f7fcc2002-05-22 15:46:49 +0000847#endif
848#ifdef IP_HDRINCL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000849 XLAT(IP_HDRINCL),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000850#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000851#ifdef IP_OPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000852 XLAT(IP_OPTIONS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000853#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000854#ifdef IP_ROUTER_ALERT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000855 XLAT(IP_ROUTER_ALERT),
John Hughes93f7fcc2002-05-22 15:46:49 +0000856#endif
857#ifdef IP_RECVOPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000858 XLAT(IP_RECVOPTIONS),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000859#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000860#ifdef IP_RECVOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000861 XLAT(IP_RECVOPTS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000862#endif
863#ifdef IP_RECVRETOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000864 XLAT(IP_RECVRETOPTS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000865#endif
866#ifdef IP_RECVDSTADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000867 XLAT(IP_RECVDSTADDR),
John Hughes93f7fcc2002-05-22 15:46:49 +0000868#endif
869#ifdef IP_RETOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000870 XLAT(IP_RETOPTS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000871#endif
872#ifdef IP_PKTINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000873 XLAT(IP_PKTINFO),
John Hughes93f7fcc2002-05-22 15:46:49 +0000874#endif
875#ifdef IP_PKTOPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000876 XLAT(IP_PKTOPTIONS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000877#endif
878#ifdef IP_MTU_DISCOVER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000879 XLAT(IP_MTU_DISCOVER),
John Hughes93f7fcc2002-05-22 15:46:49 +0000880#endif
881#ifdef IP_RECVERR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000882 XLAT(IP_RECVERR),
John Hughes93f7fcc2002-05-22 15:46:49 +0000883#endif
884#ifdef IP_RECVTTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000885 XLAT(IP_RECVTTL),
John Hughes93f7fcc2002-05-22 15:46:49 +0000886#endif
887#ifdef IP_RECVTOS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000888 XLAT(IP_RECVTOS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000889#endif
890#ifdef IP_MTU
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000891 XLAT(IP_MTU),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000892#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000893#ifdef IP_MULTICAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000894 XLAT(IP_MULTICAST_IF),
John Hughes93f7fcc2002-05-22 15:46:49 +0000895#endif
896#ifdef IP_MULTICAST_TTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000897 XLAT(IP_MULTICAST_TTL),
John Hughes93f7fcc2002-05-22 15:46:49 +0000898#endif
899#ifdef IP_MULTICAST_LOOP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000900 XLAT(IP_MULTICAST_LOOP),
John Hughes93f7fcc2002-05-22 15:46:49 +0000901#endif
902#ifdef IP_ADD_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000903 XLAT(IP_ADD_MEMBERSHIP),
John Hughes93f7fcc2002-05-22 15:46:49 +0000904#endif
905#ifdef IP_DROP_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000906 XLAT(IP_DROP_MEMBERSHIP),
John Hughes93f7fcc2002-05-22 15:46:49 +0000907#endif
908#ifdef IP_BROADCAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000909 XLAT(IP_BROADCAST_IF),
John Hughes93f7fcc2002-05-22 15:46:49 +0000910#endif
911#ifdef IP_RECVIFINDEX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000912 XLAT(IP_RECVIFINDEX),
John Hughes93f7fcc2002-05-22 15:46:49 +0000913#endif
Roland McGrath4f6ba692004-08-31 07:01:26 +0000914#ifdef IP_MSFILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000915 XLAT(IP_MSFILTER),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000916#endif
917#ifdef MCAST_MSFILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000918 XLAT(MCAST_MSFILTER),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000919#endif
920#ifdef IP_FREEBIND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000921 XLAT(IP_FREEBIND),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000922#endif
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500923#ifdef IP_IPSEC_POLICY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000924 XLAT(IP_IPSEC_POLICY),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500925#endif
926#ifdef IP_XFRM_POLICY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000927 XLAT(IP_XFRM_POLICY),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500928#endif
929#ifdef IP_PASSSEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000930 XLAT(IP_PASSSEC),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500931#endif
932#ifdef IP_TRANSPARENT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000933 XLAT(IP_TRANSPARENT),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500934#endif
935#ifdef IP_ORIGDSTADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000936 XLAT(IP_ORIGDSTADDR),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500937#endif
938#ifdef IP_RECVORIGDSTADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000939 XLAT(IP_RECVORIGDSTADDR),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500940#endif
941#ifdef IP_MINTTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000942 XLAT(IP_MINTTL),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500943#endif
944#ifdef IP_NODEFRAG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000945 XLAT(IP_NODEFRAG),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500946#endif
947#ifdef IP_UNBLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000948 XLAT(IP_UNBLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500949#endif
950#ifdef IP_BLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000951 XLAT(IP_BLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500952#endif
953#ifdef IP_ADD_SOURCE_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000954 XLAT(IP_ADD_SOURCE_MEMBERSHIP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500955#endif
956#ifdef IP_DROP_SOURCE_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000957 XLAT(IP_DROP_SOURCE_MEMBERSHIP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500958#endif
959#ifdef MCAST_JOIN_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000960 XLAT(MCAST_JOIN_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500961#endif
962#ifdef MCAST_BLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000963 XLAT(MCAST_BLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500964#endif
965#ifdef MCAST_UNBLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000966 XLAT(MCAST_UNBLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500967#endif
968#ifdef MCAST_LEAVE_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000969 XLAT(MCAST_LEAVE_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500970#endif
971#ifdef MCAST_JOIN_SOURCE_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000972 XLAT(MCAST_JOIN_SOURCE_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500973#endif
974#ifdef MCAST_LEAVE_SOURCE_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000975 XLAT(MCAST_LEAVE_SOURCE_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500976#endif
977#ifdef IP_MULTICAST_ALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000978 XLAT(IP_MULTICAST_ALL),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500979#endif
980#ifdef IP_UNICAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000981 XLAT(IP_UNICAST_IF),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500982#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000983 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000984};
985#endif /* SOL_IP */
986
Roland McGrath4f6ba692004-08-31 07:01:26 +0000987#ifdef SOL_IPV6
Roland McGrathd9f816f2004-09-04 03:39:20 +0000988static const struct xlat sockipv6options[] = {
Roland McGrath4f6ba692004-08-31 07:01:26 +0000989#ifdef IPV6_ADDRFORM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000990 XLAT(IPV6_ADDRFORM),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000991#endif
992#ifdef MCAST_FILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000993 XLAT(MCAST_FILTER),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000994#endif
995#ifdef IPV6_PKTOPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000996 XLAT(IPV6_PKTOPTIONS),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000997#endif
998#ifdef IPV6_MTU
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000999 XLAT(IPV6_MTU),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001000#endif
1001#ifdef IPV6_V6ONLY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001002 XLAT(IPV6_V6ONLY),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001003#endif
1004#ifdef IPV6_PKTINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001005 XLAT(IPV6_PKTINFO),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001006#endif
1007#ifdef IPV6_HOPLIMIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001008 XLAT(IPV6_HOPLIMIT),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001009#endif
1010#ifdef IPV6_RTHDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001011 XLAT(IPV6_RTHDR),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001012#endif
1013#ifdef IPV6_HOPOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001014 XLAT(IPV6_HOPOPTS),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001015#endif
1016#ifdef IPV6_DSTOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001017 XLAT(IPV6_DSTOPTS),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001018#endif
1019#ifdef IPV6_FLOWINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001020 XLAT(IPV6_FLOWINFO),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001021#endif
1022#ifdef IPV6_UNICAST_HOPS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001023 XLAT(IPV6_UNICAST_HOPS),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001024#endif
1025#ifdef IPV6_MULTICAST_HOPS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001026 XLAT(IPV6_MULTICAST_HOPS),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001027#endif
1028#ifdef IPV6_MULTICAST_LOOP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001029 XLAT(IPV6_MULTICAST_LOOP),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001030#endif
1031#ifdef IPV6_MULTICAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001032 XLAT(IPV6_MULTICAST_IF),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001033#endif
1034#ifdef IPV6_MTU_DISCOVER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001035 XLAT(IPV6_MTU_DISCOVER),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001036#endif
1037#ifdef IPV6_RECVERR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001038 XLAT(IPV6_RECVERR),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001039#endif
1040#ifdef IPV6_FLOWINFO_SEND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001041 XLAT(IPV6_FLOWINFO_SEND),
Roland McGrath4f6ba692004-08-31 07:01:26 +00001042#endif
Roland McGrathc0b9e372005-07-04 23:33:38 +00001043#ifdef IPV6_ADD_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001044 XLAT(IPV6_ADD_MEMBERSHIP),
Roland McGrathc0b9e372005-07-04 23:33:38 +00001045#endif
1046#ifdef IPV6_DROP_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001047 XLAT(IPV6_DROP_MEMBERSHIP),
Roland McGrathc0b9e372005-07-04 23:33:38 +00001048#endif
1049#ifdef IPV6_ROUTER_ALERT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001050 XLAT(IPV6_ROUTER_ALERT),
Roland McGrathc0b9e372005-07-04 23:33:38 +00001051#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001052 XLAT_END
Roland McGrath4f6ba692004-08-31 07:01:26 +00001053};
1054#endif /* SOL_IPV6 */
1055
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001056#ifdef SOL_IPX
Roland McGrathd9f816f2004-09-04 03:39:20 +00001057static const struct xlat sockipxoptions[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001058 XLAT(IPX_TYPE),
Dmitry V. Levin59452732014-02-05 02:20:51 +00001059 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001060};
1061#endif /* SOL_IPX */
1062
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001063#ifdef SOL_RAW
Roland McGrathd9f816f2004-09-04 03:39:20 +00001064static const struct xlat sockrawoptions[] = {
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001065#if defined(ICMP_FILTER)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001066 XLAT(ICMP_FILTER),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001067#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001068 XLAT_END
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001069};
1070#endif /* SOL_RAW */
1071
1072#ifdef SOL_PACKET
Roland McGrathd9f816f2004-09-04 03:39:20 +00001073static const struct xlat sockpacketoptions[] = {
Roland McGrathc294b8f2007-11-01 21:37:33 +00001074#ifdef PACKET_ADD_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001075 XLAT(PACKET_ADD_MEMBERSHIP),
Roland McGrathc294b8f2007-11-01 21:37:33 +00001076#endif
1077#ifdef PACKET_DROP_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001078 XLAT(PACKET_DROP_MEMBERSHIP),
Roland McGrathc294b8f2007-11-01 21:37:33 +00001079#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001080#if defined(PACKET_RECV_OUTPUT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001081 XLAT(PACKET_RECV_OUTPUT),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001082#endif
1083#if defined(PACKET_RX_RING)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001084 XLAT(PACKET_RX_RING),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001085#endif
1086#if defined(PACKET_STATISTICS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001087 XLAT(PACKET_STATISTICS),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001088#endif
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001089#if defined(PACKET_COPY_THRESH)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001090 XLAT(PACKET_COPY_THRESH),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001091#endif
1092#if defined(PACKET_AUXDATA)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001093 XLAT(PACKET_AUXDATA),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001094#endif
1095#if defined(PACKET_ORIGDEV)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001096 XLAT(PACKET_ORIGDEV),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001097#endif
1098#if defined(PACKET_VERSION)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001099 XLAT(PACKET_VERSION),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001100#endif
1101#if defined(PACKET_HDRLEN)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001102 XLAT(PACKET_HDRLEN),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001103#endif
1104#if defined(PACKET_RESERVE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001105 XLAT(PACKET_RESERVE),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001106#endif
1107#if defined(PACKET_TX_RING)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001108 XLAT(PACKET_TX_RING),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001109#endif
1110#if defined(PACKET_LOSS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001111 XLAT(PACKET_LOSS),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001112#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001113 XLAT_END
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001114};
1115#endif /* SOL_PACKET */
1116
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001117#ifdef SOL_SCTP
1118static const struct xlat socksctpoptions[] = {
1119#if defined(SCTP_RTOINFO)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001120 XLAT(SCTP_RTOINFO),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001121#endif
1122#if defined(SCTP_ASSOCINFO)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001123 XLAT(SCTP_ASSOCINFO),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001124#endif
1125#if defined(SCTP_INITMSG)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001126 XLAT(SCTP_INITMSG),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001127#endif
1128#if defined(SCTP_NODELAY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001129 XLAT(SCTP_NODELAY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001130#endif
1131#if defined(SCTP_AUTOCLOSE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001132 XLAT(SCTP_AUTOCLOSE),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001133#endif
1134#if defined(SCTP_SET_PEER_PRIMARY_ADDR)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001135 XLAT(SCTP_SET_PEER_PRIMARY_ADDR),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001136#endif
1137#if defined(SCTP_PRIMARY_ADDR)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001138 XLAT(SCTP_PRIMARY_ADDR),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001139#endif
1140#if defined(SCTP_ADAPTATION_LAYER)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001141 XLAT(SCTP_ADAPTATION_LAYER),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001142#endif
1143#if defined(SCTP_DISABLE_FRAGMENTS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001144 XLAT(SCTP_DISABLE_FRAGMENTS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001145#endif
1146#if defined(SCTP_PEER_ADDR_PARAMS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001147 XLAT(SCTP_PEER_ADDR_PARAMS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001148#endif
1149#if defined(SCTP_DEFAULT_SEND_PARAM)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001150 XLAT(SCTP_DEFAULT_SEND_PARAM),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001151#endif
1152#if defined(SCTP_EVENTS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001153 XLAT(SCTP_EVENTS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001154#endif
1155#if defined(SCTP_I_WANT_MAPPED_V4_ADDR)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001156 XLAT(SCTP_I_WANT_MAPPED_V4_ADDR),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001157#endif
1158#if defined(SCTP_MAXSEG)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001159 XLAT(SCTP_MAXSEG),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001160#endif
1161#if defined(SCTP_STATUS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001162 XLAT(SCTP_STATUS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001163#endif
1164#if defined(SCTP_GET_PEER_ADDR_INFO)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001165 XLAT(SCTP_GET_PEER_ADDR_INFO),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001166#endif
1167#if defined(SCTP_DELAYED_ACK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001168 XLAT(SCTP_DELAYED_ACK),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001169#endif
1170#if defined(SCTP_CONTEXT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001171 XLAT(SCTP_CONTEXT),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001172#endif
1173#if defined(SCTP_FRAGMENT_INTERLEAVE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001174 XLAT(SCTP_FRAGMENT_INTERLEAVE),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001175#endif
1176#if defined(SCTP_PARTIAL_DELIVERY_POINT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001177 XLAT(SCTP_PARTIAL_DELIVERY_POINT),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001178#endif
1179#if defined(SCTP_MAX_BURST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001180 XLAT(SCTP_MAX_BURST),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001181#endif
1182#if defined(SCTP_AUTH_CHUNK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001183 XLAT(SCTP_AUTH_CHUNK),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001184#endif
1185#if defined(SCTP_HMAC_IDENT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001186 XLAT(SCTP_HMAC_IDENT),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001187#endif
1188#if defined(SCTP_AUTH_KEY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001189 XLAT(SCTP_AUTH_KEY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001190#endif
1191#if defined(SCTP_AUTH_ACTIVE_KEY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001192 XLAT(SCTP_AUTH_ACTIVE_KEY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001193#endif
1194#if defined(SCTP_AUTH_DELETE_KEY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001195 XLAT(SCTP_AUTH_DELETE_KEY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001196#endif
1197#if defined(SCTP_PEER_AUTH_CHUNKS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001198 XLAT(SCTP_PEER_AUTH_CHUNKS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001199#endif
1200#if defined(SCTP_LOCAL_AUTH_CHUNKS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001201 XLAT(SCTP_LOCAL_AUTH_CHUNKS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001202#endif
1203#if defined(SCTP_GET_ASSOC_NUMBER)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001204 XLAT(SCTP_GET_ASSOC_NUMBER),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001205#endif
1206
1207 /* linux specific things */
1208#if defined(SCTP_SOCKOPT_BINDX_ADD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001209 XLAT(SCTP_SOCKOPT_BINDX_ADD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001210#endif
1211#if defined(SCTP_SOCKOPT_BINDX_REM)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001212 XLAT(SCTP_SOCKOPT_BINDX_REM),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001213#endif
1214#if defined(SCTP_SOCKOPT_PEELOFF)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001215 XLAT(SCTP_SOCKOPT_PEELOFF),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001216#endif
1217#if defined(SCTP_GET_PEER_ADDRS_NUM_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001218 XLAT(SCTP_GET_PEER_ADDRS_NUM_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001219#endif
1220#if defined(SCTP_GET_PEER_ADDRS_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001221 XLAT(SCTP_GET_PEER_ADDRS_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001222#endif
1223#if defined(SCTP_GET_LOCAL_ADDRS_NUM_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001224 XLAT(SCTP_GET_LOCAL_ADDRS_NUM_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001225#endif
1226#if defined(SCTP_GET_LOCAL_ADDRS_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001227 XLAT(SCTP_GET_LOCAL_ADDRS_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001228#endif
1229#if defined(SCTP_SOCKOPT_CONNECTX_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001230 XLAT(SCTP_SOCKOPT_CONNECTX_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001231#endif
1232#if defined(SCTP_GET_PEER_ADDRS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001233 XLAT(SCTP_GET_PEER_ADDRS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001234#endif
1235#if defined(SCTP_GET_LOCAL_ADDRS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001236 XLAT(SCTP_GET_LOCAL_ADDRS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001237#endif
1238
Dmitry V. Levin59452732014-02-05 02:20:51 +00001239 XLAT_END
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001240};
1241#endif
1242
Denys Vlasenkoc36c3522012-02-25 02:47:15 +01001243#if !defined(SOL_TCP) && defined(IPPROTO_TCP)
John Hughes93f7fcc2002-05-22 15:46:49 +00001244#define SOL_TCP IPPROTO_TCP
1245#endif
1246
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001247#ifdef SOL_TCP
Roland McGrathd9f816f2004-09-04 03:39:20 +00001248static const struct xlat socktcpoptions[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001249 XLAT(TCP_NODELAY),
1250 XLAT(TCP_MAXSEG),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001251#ifdef TCP_CORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001252 XLAT(TCP_CORK),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001253#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001254#ifdef TCP_KEEPIDLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001255 XLAT(TCP_KEEPIDLE),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001256#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001257#ifdef TCP_KEEPINTVL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001258 XLAT(TCP_KEEPINTVL),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001259#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001260#ifdef TCP_KEEPCNT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001261 XLAT(TCP_KEEPCNT),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001262#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001263#ifdef TCP_SYNCNT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001264 XLAT(TCP_SYNCNT),
John Hughes38ae88d2002-05-23 11:48:58 +00001265#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001266#ifdef TCP_LINGER2
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001267 XLAT(TCP_LINGER2),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001268#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001269#ifdef TCP_DEFER_ACCEPT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001270 XLAT(TCP_DEFER_ACCEPT),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001271#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001272#ifdef TCP_WINDOW_CLAMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001273 XLAT(TCP_WINDOW_CLAMP),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001274#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001275#ifdef TCP_INFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001276 XLAT(TCP_INFO),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001277#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001278#ifdef TCP_QUICKACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001279 XLAT(TCP_QUICKACK),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001280#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001281#ifdef TCP_CONGESTION
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001282 XLAT(TCP_CONGESTION),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001283#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001284#ifdef TCP_MD5SIG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001285 XLAT(TCP_MD5SIG),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001286#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001287#ifdef TCP_COOKIE_TRANSACTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001288 XLAT(TCP_COOKIE_TRANSACTIONS),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001289#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001290#ifdef TCP_THIN_LINEAR_TIMEOUTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001291 XLAT(TCP_THIN_LINEAR_TIMEOUTS),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001292#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001293#ifdef TCP_THIN_DUPACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001294 XLAT(TCP_THIN_DUPACK),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001295#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001296#ifdef TCP_USER_TIMEOUT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001297 XLAT(TCP_USER_TIMEOUT),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001298#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001299#ifdef TCP_REPAIR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001300 XLAT(TCP_REPAIR),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001301#endif
1302#ifdef TCP_REPAIR_QUEUE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001303 XLAT(TCP_REPAIR_QUEUE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001304#endif
1305#ifdef TCP_QUEUE_SEQ
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001306 XLAT(TCP_QUEUE_SEQ),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001307#endif
1308#ifdef TCP_REPAIR_OPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001309 XLAT(TCP_REPAIR_OPTIONS),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001310#endif
1311#ifdef TCP_FASTOPEN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001312 XLAT(TCP_FASTOPEN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001313#endif
1314#ifdef TCP_TIMESTAMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001315 XLAT(TCP_TIMESTAMP),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001316#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001317 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001318};
1319#endif /* SOL_TCP */
1320
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001321#ifdef SOL_RAW
Roland McGrathd9f816f2004-09-04 03:39:20 +00001322static const struct xlat icmpfilterflags[] = {
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001323#if defined(ICMP_ECHOREPLY)
1324 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
1325#endif
1326#if defined(ICMP_DEST_UNREACH)
1327 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
1328#endif
1329#if defined(ICMP_SOURCE_QUENCH)
1330 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
1331#endif
1332#if defined(ICMP_REDIRECT)
1333 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
1334#endif
1335#if defined(ICMP_ECHO)
1336 { (1<<ICMP_ECHO), "ICMP_ECHO" },
1337#endif
1338#if defined(ICMP_TIME_EXCEEDED)
1339 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
1340#endif
1341#if defined(ICMP_PARAMETERPROB)
1342 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
1343#endif
1344#if defined(ICMP_TIMESTAMP)
1345 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
1346#endif
1347#if defined(ICMP_TIMESTAMPREPLY)
1348 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
1349#endif
1350#if defined(ICMP_INFO_REQUEST)
1351 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
1352#endif
1353#if defined(ICMP_INFO_REPLY)
1354 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
1355#endif
1356#if defined(ICMP_ADDRESS)
1357 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
1358#endif
1359#if defined(ICMP_ADDRESSREPLY)
1360 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
1361#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001362 XLAT_END
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001363};
1364#endif /* SOL_RAW */
1365
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001366#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
Roland McGrathd9f816f2004-09-04 03:39:20 +00001367static const struct xlat af_packet_types[] = {
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001368#if defined(PACKET_HOST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001369 XLAT(PACKET_HOST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001370#endif
1371#if defined(PACKET_BROADCAST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001372 XLAT(PACKET_BROADCAST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001373#endif
1374#if defined(PACKET_MULTICAST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001375 XLAT(PACKET_MULTICAST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001376#endif
1377#if defined(PACKET_OTHERHOST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001378 XLAT(PACKET_OTHERHOST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001379#endif
1380#if defined(PACKET_OUTGOING)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001381 XLAT(PACKET_OUTGOING),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001382#endif
1383#if defined(PACKET_LOOPBACK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001384 XLAT(PACKET_LOOPBACK),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001385#endif
1386#if defined(PACKET_FASTROUTE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001387 XLAT(PACKET_FASTROUTE),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001388#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001389 XLAT_END
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001390};
1391#endif /* defined(AF_PACKET) */
1392
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001393void
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001394printsock(struct tcb *tcp, long addr, int addrlen)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001395{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001396 union {
1397 char pad[128];
1398 struct sockaddr sa;
1399 struct sockaddr_in sin;
1400 struct sockaddr_un sau;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001401#ifdef HAVE_INET_NTOP
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001402 struct sockaddr_in6 sa6;
1403#endif
Denys Vlasenko84703742012-02-25 02:38:52 +01001404#if defined(AF_IPX)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001405 struct sockaddr_ipx sipx;
1406#endif
1407#ifdef AF_PACKET
1408 struct sockaddr_ll ll;
1409#endif
1410#ifdef AF_NETLINK
1411 struct sockaddr_nl nl;
1412#endif
1413 } addrbuf;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001414 char string_addr[100];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001415
1416 if (addr == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001417 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001418 return;
1419 }
1420 if (!verbose(tcp)) {
1421 tprintf("%#lx", addr);
1422 return;
1423 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001424
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001425 if (addrlen < 2 || addrlen > sizeof(addrbuf))
1426 addrlen = sizeof(addrbuf);
1427
1428 memset(&addrbuf, 0, sizeof(addrbuf));
1429 if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001430 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001431 return;
1432 }
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001433 addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001434
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001435 tprints("{sa_family=");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001436 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001437 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001438
1439 switch (addrbuf.sa.sa_family) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001440 case AF_UNIX:
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001441 if (addrlen == 2) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001442 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001443 } else if (addrbuf.sau.sun_path[0]) {
Dmitry V. Levinc86340e2012-02-22 00:23:52 +00001444 tprints("sun_path=");
Dmitry V. Levin16fbe972007-10-13 21:03:17 +00001445 printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001446 } else {
Dmitry V. Levinc86340e2012-02-22 00:23:52 +00001447 tprints("sun_path=@");
Dmitry V. Levin16fbe972007-10-13 21:03:17 +00001448 printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001449 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001450 break;
1451 case AF_INET:
John Hughes1fcb1d62001-09-18 15:56:53 +00001452 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001453 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001454 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001455#ifdef HAVE_INET_NTOP
1456 case AF_INET6:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001457 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
Wichert Akkermanf1850652001-02-16 20:29:03 +00001458 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
1459 ntohs(addrbuf.sa6.sin6_port), string_addr,
1460 addrbuf.sa6.sin6_flowinfo);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001461#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
Wichert Akkermanf1850652001-02-16 20:29:03 +00001462 {
1463#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001464 int numericscope = 0;
1465 if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr)
1466 || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) {
1467 char scopebuf[IFNAMSIZ + 1];
Roland McGrath6d2b3492002-12-30 00:51:30 +00001468
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001469 if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
1470 numericscope++;
1471 else
1472 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
1473 } else
1474 numericscope++;
Roland McGrath6d2b3492002-12-30 00:51:30 +00001475
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001476 if (numericscope)
Wichert Akkermanf1850652001-02-16 20:29:03 +00001477#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001478 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
Wichert Akkermanf1850652001-02-16 20:29:03 +00001479 }
1480#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001481 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001482#endif
Denys Vlasenko84703742012-02-25 02:38:52 +01001483#if defined(AF_IPX)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001484 case AF_IPX:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001485 {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001486 int i;
John Hughes1fcb1d62001-09-18 15:56:53 +00001487 tprintf("sipx_port=htons(%u), ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001488 ntohs(addrbuf.sipx.sipx_port));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001489 /* Yes, I know, this does not look too
1490 * strace-ish, but otherwise the IPX
1491 * addresses just look monstrous...
1492 * Anyways, feel free if you don't like
Roland McGrath6d2b3492002-12-30 00:51:30 +00001493 * this way.. :)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001494 */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001495 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001496 for (i = 0; i < IPX_NODE_LEN; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001497 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
1498 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001499 }
1500 break;
Denys Vlasenko84703742012-02-25 02:38:52 +01001501#endif /* AF_IPX */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001502#ifdef AF_PACKET
1503 case AF_PACKET:
1504 {
1505 int i;
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001506 tprintf("proto=%#04x, if%d, pkttype=",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001507 ntohs(addrbuf.ll.sll_protocol),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001508 addrbuf.ll.sll_ifindex);
1509 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
1510 tprintf(", addr(%d)={%d, ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001511 addrbuf.ll.sll_halen,
1512 addrbuf.ll.sll_hatype);
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001513 for (i = 0; i < addrbuf.ll.sll_halen; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001514 tprintf("%02x", addrbuf.ll.sll_addr[i]);
1515 }
1516 break;
1517
Denys Vlasenko84703742012-02-25 02:38:52 +01001518#endif /* AF_PACKET */
Roland McGrath36ef1bc2003-11-06 23:41:23 +00001519#ifdef AF_NETLINK
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001520 case AF_NETLINK:
1521 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
1522 break;
1523#endif /* AF_NETLINK */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001524 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001525 AF_X25 AF_ROSE etc. still need to be done */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001526
1527 default:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001528 tprints("sa_data=");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001529 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001530 sizeof addrbuf.sa.sa_data);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001531 break;
1532 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001533 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001534}
1535
1536#if HAVE_SENDMSG
Roland McGrath50770822004-10-06 22:11:51 +00001537static const struct xlat scmvals[] = {
1538#ifdef SCM_RIGHTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001539 XLAT(SCM_RIGHTS),
Roland McGrath50770822004-10-06 22:11:51 +00001540#endif
1541#ifdef SCM_CREDENTIALS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001542 XLAT(SCM_CREDENTIALS),
Roland McGrath50770822004-10-06 22:11:51 +00001543#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001544 XLAT_END
Roland McGrath50770822004-10-06 22:11:51 +00001545};
1546
1547static void
Denys Vlasenko132c52a2009-03-23 13:12:46 +00001548printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len)
Roland McGrath50770822004-10-06 22:11:51 +00001549{
Roland McGrathaa524c82005-06-01 19:22:06 +00001550 struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ?
1551 NULL : malloc(len);
1552 if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) {
Roland McGrath50770822004-10-06 22:11:51 +00001553 tprintf(", msg_control=%#lx", addr);
Roland McGrathaa524c82005-06-01 19:22:06 +00001554 free(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001555 return;
1556 }
1557
Denys Vlasenko132c52a2009-03-23 13:12:46 +00001558 tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len);
Roland McGrathaa524c82005-06-01 19:22:06 +00001559 printxval(socketlayers, cmsg->cmsg_level, "SOL_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001560 tprints(", cmsg_type=");
Roland McGrath50770822004-10-06 22:11:51 +00001561
Roland McGrathaa524c82005-06-01 19:22:06 +00001562 if (cmsg->cmsg_level == SOL_SOCKET) {
1563 unsigned long cmsg_len;
Roland McGrath96ad7b82005-02-02 03:11:32 +00001564
Roland McGrathaa524c82005-06-01 19:22:06 +00001565 printxval(scmvals, cmsg->cmsg_type, "SCM_???");
1566 cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len;
1567
1568 if (cmsg->cmsg_type == SCM_RIGHTS
1569 && CMSG_LEN(sizeof(int)) <= cmsg_len) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001570 int *fds = (int *) CMSG_DATA(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001571 int first = 1;
Roland McGrathaa524c82005-06-01 19:22:06 +00001572
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001573 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +00001574 while ((char *) fds < ((char *) cmsg + cmsg_len)) {
Roland McGrath50770822004-10-06 22:11:51 +00001575 if (!first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001576 tprints(", ");
Dmitry V. Levinf23b0972014-05-29 21:35:34 +00001577 printfd(tcp, *fds++);
Roland McGrath50770822004-10-06 22:11:51 +00001578 first = 0;
1579 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001580 tprints("}}");
Roland McGrathaa524c82005-06-01 19:22:06 +00001581 free(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001582 return;
1583 }
Roland McGrathaa524c82005-06-01 19:22:06 +00001584 if (cmsg->cmsg_type == SCM_CREDENTIALS
1585 && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001586 struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg);
Roland McGrathaa524c82005-06-01 19:22:06 +00001587
Roland McGrath50770822004-10-06 22:11:51 +00001588 tprintf("{pid=%ld, uid=%ld, gid=%ld}}",
1589 (long)uc->pid, (long)uc->uid, (long)uc->gid);
Roland McGrathaa524c82005-06-01 19:22:06 +00001590 free(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001591 return;
1592 }
1593 }
Roland McGrathaa524c82005-06-01 19:22:06 +00001594 free(cmsg);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001595 tprints(", ...}");
Roland McGrath50770822004-10-06 22:11:51 +00001596}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001597
1598static void
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001599do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
Andreas Schwab0873f292010-02-12 21:39:12 +01001600{
1601 tprintf("{msg_name(%d)=", msg->msg_namelen);
1602 printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
1603
1604 tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001605 tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
1606 (unsigned long)msg->msg_iov, 1, data_size);
Andreas Schwab0873f292010-02-12 21:39:12 +01001607
1608#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
1609 tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
1610 if (msg->msg_controllen)
1611 printcmsghdr(tcp, (unsigned long) msg->msg_control,
1612 msg->msg_controllen);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001613 tprints(", msg_flags=");
Andreas Schwab0873f292010-02-12 21:39:12 +01001614 printflags(msg_flags, msg->msg_flags, "MSG_???");
1615#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
1616 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
1617 (unsigned long) msg->msg_accrights, msg->msg_accrightslen);
1618#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001619 tprints("}");
Andreas Schwab0873f292010-02-12 21:39:12 +01001620}
1621
Denys Vlasenko3e759d42013-02-12 11:57:48 +01001622struct msghdr32 {
1623 uint32_t /* void* */ msg_name;
1624 uint32_t /* socklen_t */msg_namelen;
1625 uint32_t /* iovec* */ msg_iov;
1626 uint32_t /* size_t */ msg_iovlen;
1627 uint32_t /* void* */ msg_control;
1628 uint32_t /* size_t */ msg_controllen;
1629 uint32_t /* int */ msg_flags;
1630};
1631struct mmsghdr32 {
1632 struct msghdr32 msg_hdr;
1633 uint32_t /* unsigned */ msg_len;
1634};
1635
Andreas Schwab0873f292010-02-12 21:39:12 +01001636static void
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001637printmsghdr(struct tcb *tcp, long addr, unsigned long data_size)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001638{
1639 struct msghdr msg;
1640
Denys Vlasenko3e759d42013-02-12 11:57:48 +01001641#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
1642 if (current_wordsize == 4) {
1643 struct msghdr32 msg32;
1644
1645 if (umove(tcp, addr, &msg32) < 0) {
1646 tprintf("%#lx", addr);
1647 return;
1648 }
1649 msg.msg_name = (void*)(long)msg32.msg_name;
1650 msg.msg_namelen = msg32.msg_namelen;
1651 msg.msg_iov = (void*)(long)msg32.msg_iov;
1652 msg.msg_iovlen = msg32.msg_iovlen;
1653 msg.msg_control = (void*)(long)msg32.msg_control;
1654 msg.msg_controllen = msg32.msg_controllen;
1655 msg.msg_flags = msg32.msg_flags;
1656 } else
1657#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001658 if (umove(tcp, addr, &msg) < 0) {
1659 tprintf("%#lx", addr);
1660 return;
1661 }
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001662 do_msghdr(tcp, &msg, data_size);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001663}
1664
Andreas Schwab0873f292010-02-12 21:39:12 +01001665static void
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001666printmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
Andreas Schwab0873f292010-02-12 21:39:12 +01001667{
1668 struct mmsghdr {
1669 struct msghdr msg_hdr;
1670 unsigned msg_len;
1671 } mmsg;
1672
Denys Vlasenko3e759d42013-02-12 11:57:48 +01001673#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
1674 if (current_wordsize == 4) {
1675 struct mmsghdr32 mmsg32;
1676
1677 addr += sizeof(mmsg32) * idx;
1678 if (umove(tcp, addr, &mmsg32) < 0) {
1679 tprintf("%#lx", addr);
1680 return;
1681 }
1682 mmsg.msg_hdr.msg_name = (void*)(long)mmsg32.msg_hdr.msg_name;
1683 mmsg.msg_hdr.msg_namelen = mmsg32.msg_hdr.msg_namelen;
1684 mmsg.msg_hdr.msg_iov = (void*)(long)mmsg32.msg_hdr.msg_iov;
1685 mmsg.msg_hdr.msg_iovlen = mmsg32.msg_hdr.msg_iovlen;
1686 mmsg.msg_hdr.msg_control = (void*)(long)mmsg32.msg_hdr.msg_control;
1687 mmsg.msg_hdr.msg_controllen = mmsg32.msg_hdr.msg_controllen;
1688 mmsg.msg_hdr.msg_flags = mmsg32.msg_hdr.msg_flags;
1689 mmsg.msg_len = mmsg32.msg_len;
1690 } else
1691#endif
1692 {
1693 addr += sizeof(mmsg) * idx;
1694 if (umove(tcp, addr, &mmsg) < 0) {
1695 tprintf("%#lx", addr);
1696 return;
1697 }
Andreas Schwab0873f292010-02-12 21:39:12 +01001698 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001699 tprints("{");
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001700 do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
Andreas Schwab0873f292010-02-12 21:39:12 +01001701 tprintf(", %u}", mmsg.msg_len);
1702}
Andreas Schwab0873f292010-02-12 21:39:12 +01001703
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001704static void
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001705decode_mmsg(struct tcb *tcp, unsigned long msg_len)
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001706{
1707 /* mmsgvec */
1708 if (syserror(tcp)) {
1709 tprintf("%#lx", tcp->u_arg[1]);
1710 } else {
1711 unsigned int len = tcp->u_rval;
1712 unsigned int i;
1713
1714 tprints("{");
1715 for (i = 0; i < len; ++i) {
1716 if (i)
1717 tprints(", ");
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001718 printmmsghdr(tcp, tcp->u_arg[1], i, msg_len);
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001719 }
1720 tprints("}");
1721 }
1722 /* vlen */
1723 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
1724 /* flags */
1725 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1726}
1727
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001728#endif /* HAVE_SENDMSG */
1729
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001730/*
1731 * low bits of the socket type define real socket type,
1732 * other bits are socket type flags.
1733 */
1734static void
1735tprint_sock_type(struct tcb *tcp, int flags)
1736{
1737 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
1738
Denys Vlasenko7b609d52011-06-22 14:32:43 +02001739 if (str) {
Denys Vlasenko5940e652011-09-01 09:55:05 +02001740 tprints(str);
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001741 flags &= ~SOCK_TYPE_MASK;
1742 if (!flags)
1743 return;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001744 tprints("|");
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001745 }
1746 printflags(sock_type_flags, flags, "SOCK_???");
1747}
1748
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001749int
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001750sys_socket(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001751{
1752 if (entering(tcp)) {
1753 printxval(domains, tcp->u_arg[0], "PF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001754 tprints(", ");
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001755 tprint_sock_type(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001756 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001757 switch (tcp->u_arg[0]) {
1758 case PF_INET:
Roland McGrath8758e542003-06-23 23:39:59 +00001759#ifdef PF_INET6
1760 case PF_INET6:
1761#endif
Masatake YAMATO2394a3d2014-03-11 23:37:37 +09001762 printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001763 break;
1764#ifdef PF_IPX
1765 case PF_IPX:
1766 /* BTW: I don't believe this.. */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001767 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001768 printxval(domains, tcp->u_arg[2], "PF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001769 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001770 break;
1771#endif /* PF_IPX */
Masatake YAMATO2394a3d2014-03-11 23:37:37 +09001772#ifdef PF_NETLINK
1773 case PF_NETLINK:
1774 printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
1775 break;
1776#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001777 default:
1778 tprintf("%lu", tcp->u_arg[2]);
1779 break;
1780 }
1781 }
1782 return 0;
1783}
1784
John Hughesbdf48f52001-03-06 15:08:09 +00001785int
Denys Vlasenko12014262011-05-30 14:00:14 +02001786sys_bind(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001787{
1788 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001789 printfd(tcp, tcp->u_arg[0]);
1790 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001791 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001792 tprintf(", %lu", tcp->u_arg[2]);
1793 }
1794 return 0;
1795}
1796
1797int
Denys Vlasenko12014262011-05-30 14:00:14 +02001798sys_connect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001799{
1800 return sys_bind(tcp);
1801}
1802
1803int
Denys Vlasenko12014262011-05-30 14:00:14 +02001804sys_listen(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001805{
1806 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001807 printfd(tcp, tcp->u_arg[0]);
1808 tprints(", ");
1809 tprintf("%lu", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001810 }
1811 return 0;
1812}
1813
Paolo Bonzini705ff102009-08-14 12:34:05 +02001814static int
1815do_accept(struct tcb *tcp, int flags_arg)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001816{
1817 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001818 printfd(tcp, tcp->u_arg[0]);
1819 tprints(", ");
Paolo Bonzini705ff102009-08-14 12:34:05 +02001820 return 0;
1821 }
1822 if (!tcp->u_arg[2])
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001823 tprintf("%#lx, NULL", tcp->u_arg[1]);
1824 else {
Dmitry V. Levin2fc66152009-01-01 22:47:51 +00001825 int len;
1826 if (tcp->u_arg[1] == 0 || syserror(tcp)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001827 || umove(tcp, tcp->u_arg[2], &len) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001828 tprintf("%#lx", tcp->u_arg[1]);
1829 } else {
Dmitry V. Levin2fc66152009-01-01 22:47:51 +00001830 printsock(tcp, tcp->u_arg[1], len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001831 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001832 tprints(", ");
Dmitry V. Levin2fc66152009-01-01 22:47:51 +00001833 printnum_int(tcp, tcp->u_arg[2], "%u");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001834 }
Paolo Bonzini705ff102009-08-14 12:34:05 +02001835 if (flags_arg >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001836 tprints(", ");
Paolo Bonzini705ff102009-08-14 12:34:05 +02001837 printflags(sock_type_flags, tcp->u_arg[flags_arg],
1838 "SOCK_???");
1839 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001840 return 0;
1841}
1842
1843int
Paolo Bonzini705ff102009-08-14 12:34:05 +02001844sys_accept(struct tcb *tcp)
1845{
1846 return do_accept(tcp, -1);
1847}
1848
Paolo Bonzini705ff102009-08-14 12:34:05 +02001849int
1850sys_accept4(struct tcb *tcp)
1851{
1852 return do_accept(tcp, 3);
1853}
Paolo Bonzini705ff102009-08-14 12:34:05 +02001854
1855int
Denys Vlasenko12014262011-05-30 14:00:14 +02001856sys_send(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001857{
1858 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001859 printfd(tcp, tcp->u_arg[0]);
1860 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001861 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1862 tprintf(", %lu, ", tcp->u_arg[2]);
1863 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +00001864 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001865 }
1866 return 0;
1867}
1868
1869int
Denys Vlasenko12014262011-05-30 14:00:14 +02001870sys_sendto(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001871{
1872 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001873 printfd(tcp, tcp->u_arg[0]);
1874 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001875 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1876 tprintf(", %lu, ", tcp->u_arg[2]);
1877 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +00001878 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001879 /* to address */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001880 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001881 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001882 /* to length */
1883 tprintf(", %lu", tcp->u_arg[5]);
1884 }
1885 return 0;
1886}
1887
1888#ifdef HAVE_SENDMSG
1889
1890int
Denys Vlasenko12014262011-05-30 14:00:14 +02001891sys_sendmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001892{
1893 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001894 printfd(tcp, tcp->u_arg[0]);
1895 tprints(", ");
Dmitry V. Levin043b5f82012-05-01 20:30:02 +00001896 printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001897 /* flags */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001898 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001899 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001900 }
1901 return 0;
1902}
1903
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001904int
1905sys_sendmmsg(struct tcb *tcp)
1906{
1907 if (entering(tcp)) {
1908 /* sockfd */
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001909 printfd(tcp, tcp->u_arg[0]);
1910 tprints(", ");
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001911 if (!verbose(tcp)) {
1912 tprintf("%#lx, %u, ",
1913 tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
1914 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1915 }
1916 } else {
1917 if (verbose(tcp))
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001918 decode_mmsg(tcp, (unsigned long) -1L);
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001919 }
1920 return 0;
1921}
1922
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001923#endif /* HAVE_SENDMSG */
1924
1925int
Denys Vlasenko12014262011-05-30 14:00:14 +02001926sys_recv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001927{
1928 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001929 printfd(tcp, tcp->u_arg[0]);
1930 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001931 } else {
1932 if (syserror(tcp))
1933 tprintf("%#lx", tcp->u_arg[1]);
1934 else
1935 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1936
1937 tprintf(", %lu, ", tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +00001938 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001939 }
1940 return 0;
1941}
1942
1943int
Denys Vlasenko12014262011-05-30 14:00:14 +02001944sys_recvfrom(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001945{
1946 int fromlen;
1947
1948 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001949 printfd(tcp, tcp->u_arg[0]);
1950 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001951 } else {
1952 if (syserror(tcp)) {
1953 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
1954 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
1955 tcp->u_arg[4], tcp->u_arg[5]);
1956 return 0;
1957 }
1958 /* buf */
1959 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1960 /* len */
1961 tprintf(", %lu, ", tcp->u_arg[2]);
1962 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +00001963 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001964 /* from address, len */
1965 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
1966 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001967 tprints(", NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001968 else
1969 tprintf(", %#lx", tcp->u_arg[4]);
1970 if (tcp->u_arg[5] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001971 tprints(", NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001972 else
1973 tprintf(", %#lx", tcp->u_arg[5]);
1974 return 0;
1975 }
1976 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001977 tprints(", {...}, [?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001978 return 0;
1979 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001980 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001981 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001982 /* from length */
1983 tprintf(", [%u]", fromlen);
1984 }
1985 return 0;
1986}
1987
1988#ifdef HAVE_SENDMSG
1989
1990int
Denys Vlasenko12014262011-05-30 14:00:14 +02001991sys_recvmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001992{
1993 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001994 printfd(tcp, tcp->u_arg[0]);
1995 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001996 } else {
1997 if (syserror(tcp) || !verbose(tcp))
1998 tprintf("%#lx", tcp->u_arg[1]);
1999 else
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02002000 printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002001 /* flags */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002002 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00002003 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002004 }
2005 return 0;
2006}
2007
Andreas Schwab0873f292010-02-12 21:39:12 +01002008int
2009sys_recvmmsg(struct tcb *tcp)
2010{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01002011 /* +5 chars are for "left " prefix */
2012 static char str[5 + TIMESPEC_TEXT_BUFSIZE];
Dmitry V. Levine6591032010-03-29 20:45:48 +04002013
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01002014 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08002015 printfd(tcp, tcp->u_arg[0]);
2016 tprints(", ");
Dmitry V. Levine6591032010-03-29 20:45:48 +04002017 if (verbose(tcp)) {
2018 sprint_timespec(str, tcp, tcp->u_arg[4]);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01002019 /* Abusing tcp->auxstr as temp storage.
2020 * Will be used and freed on syscall exit.
2021 */
Dmitry V. Levine6591032010-03-29 20:45:48 +04002022 tcp->auxstr = strdup(str);
2023 } else {
2024 tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
2025 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002026 tprints(", ");
Dmitry V. Levine6591032010-03-29 20:45:48 +04002027 print_timespec(tcp, tcp->u_arg[4]);
2028 }
2029 return 0;
2030 } else {
2031 if (verbose(tcp)) {
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00002032 decode_mmsg(tcp, 0);
Dmitry V. Levine6591032010-03-29 20:45:48 +04002033 /* timeout on entrance */
2034 tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
2035 free((void *) tcp->auxstr);
2036 tcp->auxstr = NULL;
2037 }
2038 if (syserror(tcp))
2039 return 0;
2040 if (tcp->u_rval == 0) {
2041 tcp->auxstr = "Timeout";
2042 return RVAL_STR;
2043 }
2044 if (!verbose(tcp))
2045 return 0;
2046 /* timeout on exit */
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01002047 sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
Dmitry V. Levine6591032010-03-29 20:45:48 +04002048 tcp->auxstr = str;
2049 return RVAL_STR;
Andreas Schwab0873f292010-02-12 21:39:12 +01002050 }
Andreas Schwab0873f292010-02-12 21:39:12 +01002051}
Andreas Schwab0873f292010-02-12 21:39:12 +01002052
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002053#endif /* HAVE_SENDMSG */
2054
Sebastian Pipping9cd38502011-03-03 01:12:25 +01002055static const struct xlat shutdown_modes[] = {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002056 { 0, "SHUT_RD" },
2057 { 1, "SHUT_WR" },
2058 { 2, "SHUT_RDWR" },
Dmitry V. Levin59452732014-02-05 02:20:51 +00002059 XLAT_END
Sebastian Pipping9cd38502011-03-03 01:12:25 +01002060};
2061
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002062int
Denys Vlasenko12014262011-05-30 14:00:14 +02002063sys_shutdown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002064{
2065 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08002066 printfd(tcp, tcp->u_arg[0]);
2067 tprints(", ");
Sebastian Pipping9cd38502011-03-03 01:12:25 +01002068 printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002069 }
2070 return 0;
2071}
2072
2073int
Denys Vlasenko12014262011-05-30 14:00:14 +02002074sys_getsockname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002075{
2076 return sys_accept(tcp);
2077}
2078
2079int
Denys Vlasenko12014262011-05-30 14:00:14 +02002080sys_getpeername(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002081{
2082 return sys_accept(tcp);
2083}
2084
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002085static int
2086do_pipe(struct tcb *tcp, int flags_arg)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002087{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002088 if (exiting(tcp)) {
2089 if (syserror(tcp)) {
2090 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002091 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01002092#if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002093 int fds[2];
2094
2095 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002096 tprints("[...]");
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002097 else
2098 tprintf("[%u, %u]", fds[0], fds[1]);
Denys Vlasenko84703742012-02-25 02:38:52 +01002099#elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64)
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002100 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
2101#else
2102 tprintf("%#lx", tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002103#endif
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002104 }
2105 if (flags_arg >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002106 tprints(", ");
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002107 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
2108 }
2109 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002110 return 0;
2111}
2112
2113int
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002114sys_pipe(struct tcb *tcp)
2115{
2116 return do_pipe(tcp, -1);
2117}
2118
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002119int
2120sys_pipe2(struct tcb *tcp)
2121{
2122 return do_pipe(tcp, 1);
2123}
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002124
2125int
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00002126sys_socketpair(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002127{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002128 int fds[2];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002129
2130 if (entering(tcp)) {
2131 printxval(domains, tcp->u_arg[0], "PF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002132 tprints(", ");
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00002133 tprint_sock_type(tcp, tcp->u_arg[1]);
Dmitry V. Levin033fb912014-03-11 22:50:39 +00002134 tprintf(", %lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002135 } else {
2136 if (syserror(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00002137 tprintf(", %#lx", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002138 return 0;
2139 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002140 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002141 tprints(", [...]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002142 else
2143 tprintf(", [%u, %u]", fds[0], fds[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002144 }
2145 return 0;
2146}
2147
2148int
Dmitry V. Levin31289192009-11-06 18:05:40 +00002149sys_getsockopt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002150{
2151 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08002152 printfd(tcp, tcp->u_arg[0]);
2153 tprints(", ");
John Hughes93f7fcc2002-05-22 15:46:49 +00002154 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002155 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002156 switch (tcp->u_arg[1]) {
2157 case SOL_SOCKET:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002158 printxval(sockoptions, tcp->u_arg[2], "SO_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002159 break;
2160#ifdef SOL_IP
2161 case SOL_IP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002162 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002163 break;
2164#endif
Roland McGrath4f6ba692004-08-31 07:01:26 +00002165#ifdef SOL_IPV6
2166 case SOL_IPV6:
2167 printxval(sockipv6options, tcp->u_arg[2], "IPV6_???");
2168 break;
2169#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002170#ifdef SOL_IPX
2171 case SOL_IPX:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002172 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002173 break;
2174#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002175#ifdef SOL_PACKET
2176 case SOL_PACKET:
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002177 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002178 break;
2179#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002180#ifdef SOL_TCP
2181 case SOL_TCP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002182 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002183 break;
2184#endif
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01002185#ifdef SOL_SCTP
2186 case SOL_SCTP:
2187 printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???");
2188 break;
2189#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002190
2191 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
2192 * etc. still need work */
Roland McGrath6d2b3492002-12-30 00:51:30 +00002193 default:
John Hughes93f7fcc2002-05-22 15:46:49 +00002194 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002195 break;
2196 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002197 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002198 } else {
Roland McGrathfc544db2005-02-02 02:48:57 +00002199 int len;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002200 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
Dmitry V. Levin31289192009-11-06 18:05:40 +00002201 tprintf("%#lx, %#lx",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002202 tcp->u_arg[3], tcp->u_arg[4]);
2203 return 0;
2204 }
John Hughes93f7fcc2002-05-22 15:46:49 +00002205
2206 switch (tcp->u_arg[1]) {
2207 case SOL_SOCKET:
2208 switch (tcp->u_arg[2]) {
2209#ifdef SO_LINGER
2210 case SO_LINGER:
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002211 if (len == sizeof(struct linger)) {
John Hughes93f7fcc2002-05-22 15:46:49 +00002212 struct linger linger;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002213 if (umove(tcp,
John Hughes93f7fcc2002-05-22 15:46:49 +00002214 tcp->u_arg[3],
2215 &linger) < 0)
2216 break;
Dmitry V. Levin31289192009-11-06 18:05:40 +00002217 tprintf("{onoff=%d, linger=%d}, "
Roland McGrath96ad7b82005-02-02 03:11:32 +00002218 "[%d]",
John Hughes93f7fcc2002-05-22 15:46:49 +00002219 linger.l_onoff,
2220 linger.l_linger,
2221 len);
2222 return 0;
2223 }
2224 break;
2225#endif
Dmitry V. Levin0ddd8ad2010-12-03 16:54:53 +00002226#ifdef SO_PEERCRED
2227 case SO_PEERCRED:
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002228 if (len == sizeof(struct ucred)) {
Dmitry V. Levin0ddd8ad2010-12-03 16:54:53 +00002229 struct ucred uc;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002230 if (umove(tcp,
Dmitry V. Levin0ddd8ad2010-12-03 16:54:53 +00002231 tcp->u_arg[3],
2232 &uc) < 0)
2233 break;
2234 tprintf("{pid=%ld, uid=%ld, gid=%ld}, "
2235 "[%d]",
2236 (long)uc.pid,
2237 (long)uc.uid,
2238 (long)uc.gid,
2239 len);
2240 return 0;
2241 }
2242 break;
2243#endif
John Hughes93f7fcc2002-05-22 15:46:49 +00002244 }
2245 break;
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002246 case SOL_PACKET:
2247 switch (tcp->u_arg[2]) {
2248#ifdef PACKET_STATISTICS
2249 case PACKET_STATISTICS:
2250 if (len == sizeof(struct tpacket_stats)) {
2251 struct tpacket_stats stats;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002252 if (umove(tcp,
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002253 tcp->u_arg[3],
2254 &stats) < 0)
2255 break;
2256 tprintf("{packets=%u, drops=%u}, "
2257 "[%d]",
2258 stats.tp_packets,
2259 stats.tp_drops,
2260 len);
2261 return 0;
2262 }
2263 break;
2264#endif
2265 }
2266 break;
John Hughes93f7fcc2002-05-22 15:46:49 +00002267 }
2268
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002269 if (len == sizeof(int)) {
Dmitry V. Levin31289192009-11-06 18:05:40 +00002270 printnum_int(tcp, tcp->u_arg[3], "%d");
John Hughes93f7fcc2002-05-22 15:46:49 +00002271 }
2272 else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002273 printstr(tcp, tcp->u_arg[3], len);
John Hughes93f7fcc2002-05-22 15:46:49 +00002274 }
Roland McGrathfc544db2005-02-02 02:48:57 +00002275 tprintf(", [%d]", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002276 }
2277 return 0;
2278}
2279
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002280#if defined(ICMP_FILTER)
Denys Vlasenko12014262011-05-30 14:00:14 +02002281static void printicmpfilter(struct tcb *tcp, long addr)
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002282{
2283 struct icmp_filter filter;
2284
2285 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002286 tprints("NULL");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002287 return;
2288 }
2289 if (syserror(tcp) || !verbose(tcp)) {
2290 tprintf("%#lx", addr);
2291 return;
2292 }
2293 if (umove(tcp, addr, &filter) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002294 tprints("{...}");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002295 return;
2296 }
2297
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002298 tprints("~(");
Roland McGrathb2dee132005-06-01 19:02:36 +00002299 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002300 tprints(")");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002301}
2302#endif /* ICMP_FILTER */
2303
John Hughes38ae88d2002-05-23 11:48:58 +00002304static int
Denys Vlasenko12014262011-05-30 14:00:14 +02002305printsockopt(struct tcb *tcp, int level, int name, long addr, int len)
John Hughes38ae88d2002-05-23 11:48:58 +00002306{
2307 printxval(socketlayers, level, "SOL_??");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002308 tprints(", ");
John Hughes38ae88d2002-05-23 11:48:58 +00002309 switch (level) {
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002310 case SOL_SOCKET:
John Hughes38ae88d2002-05-23 11:48:58 +00002311 printxval(sockoptions, name, "SO_???");
2312 switch (name) {
2313#if defined(SO_LINGER)
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002314 case SO_LINGER:
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002315 if (len == sizeof(struct linger)) {
John Hughes38ae88d2002-05-23 11:48:58 +00002316 struct linger linger;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002317 if (umove(tcp, addr, &linger) < 0)
John Hughes38ae88d2002-05-23 11:48:58 +00002318 break;
2319 tprintf(", {onoff=%d, linger=%d}",
2320 linger.l_onoff,
2321 linger.l_linger);
2322 return 0;
2323 }
2324 break;
2325#endif
2326 }
2327 break;
2328#ifdef SOL_IP
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002329 case SOL_IP:
John Hughes38ae88d2002-05-23 11:48:58 +00002330 printxval(sockipoptions, name, "IP_???");
2331 break;
2332#endif
Roland McGrath4f6ba692004-08-31 07:01:26 +00002333#ifdef SOL_IPV6
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002334 case SOL_IPV6:
Roland McGrath4f6ba692004-08-31 07:01:26 +00002335 printxval(sockipv6options, name, "IPV6_???");
2336 break;
2337#endif
John Hughes38ae88d2002-05-23 11:48:58 +00002338#ifdef SOL_IPX
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002339 case SOL_IPX:
John Hughes38ae88d2002-05-23 11:48:58 +00002340 printxval(sockipxoptions, name, "IPX_???");
2341 break;
2342#endif
2343#ifdef SOL_PACKET
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002344 case SOL_PACKET:
John Hughes38ae88d2002-05-23 11:48:58 +00002345 printxval(sockpacketoptions, name, "PACKET_???");
2346 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002347 switch (name) {
2348#ifdef PACKET_RX_RING
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002349 case PACKET_RX_RING:
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002350#endif
2351#ifdef PACKET_TX_RING
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002352 case PACKET_TX_RING:
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002353#endif
2354#if defined(PACKET_RX_RING) || defined(PACKET_TX_RING)
2355 if (len == sizeof(struct tpacket_req)) {
2356 struct tpacket_req req;
2357 if (umove(tcp, addr, &req) < 0)
2358 break;
2359 tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}",
2360 req.tp_block_size,
2361 req.tp_block_nr,
2362 req.tp_frame_size,
2363 req.tp_frame_nr);
2364 return 0;
2365 }
2366 break;
2367#endif /* PACKET_RX_RING || PACKET_TX_RING */
2368 }
John Hughes38ae88d2002-05-23 11:48:58 +00002369 break;
2370#endif
2371#ifdef SOL_TCP
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002372 case SOL_TCP:
John Hughes38ae88d2002-05-23 11:48:58 +00002373 printxval(socktcpoptions, name, "TCP_???");
2374 break;
2375#endif
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01002376#ifdef SOL_SCTP
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002377 case SOL_SCTP:
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01002378 printxval(socksctpoptions, name, "SCTP_???");
2379 break;
2380#endif
John Hughes38ae88d2002-05-23 11:48:58 +00002381#ifdef SOL_RAW
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002382 case SOL_RAW:
John Hughes38ae88d2002-05-23 11:48:58 +00002383 printxval(sockrawoptions, name, "RAW_???");
2384 switch (name) {
2385#if defined(ICMP_FILTER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002386 case ICMP_FILTER:
2387 tprints(", ");
2388 printicmpfilter(tcp, addr);
2389 return 0;
John Hughes38ae88d2002-05-23 11:48:58 +00002390#endif
2391 }
2392 break;
2393#endif
2394
Roland McGrath6d2b3492002-12-30 00:51:30 +00002395 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
John Hughes38ae88d2002-05-23 11:48:58 +00002396 * etc. still need work */
2397
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002398 default:
John Hughes38ae88d2002-05-23 11:48:58 +00002399 tprintf("%u", name);
2400 }
2401
2402 /* default arg printing */
2403
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002404 tprints(", ");
Roland McGrath6d2b3492002-12-30 00:51:30 +00002405
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002406 if (len == sizeof(int)) {
2407 printnum_int(tcp, addr, "%d");
John Hughes38ae88d2002-05-23 11:48:58 +00002408 }
2409 else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002410 printstr(tcp, addr, len);
John Hughes38ae88d2002-05-23 11:48:58 +00002411 }
2412 return 0;
2413}
2414
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002415int
Denys Vlasenko12014262011-05-30 14:00:14 +02002416sys_setsockopt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002417{
2418 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08002419 printfd(tcp, tcp->u_arg[0]);
2420 tprints(", ");
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002421 printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
John Hughes38ae88d2002-05-23 11:48:58 +00002422 tcp->u_arg[3], tcp->u_arg[4]);
John Hughes93f7fcc2002-05-22 15:46:49 +00002423 tprintf(", %lu", tcp->u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002424 }
2425 return 0;
2426}