blob: f09d1dd66a92edee24f66e2925aaf251e595523e [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
482 falls into "protocols" array below!!!! This is intended!!! ***/
Roland McGrathd9f816f2004-09-04 03:39:20 +0000483static const struct xlat 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};
Roland McGrathd9f816f2004-09-04 03:39:20 +0000574static const struct xlat msg_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000575 XLAT(MSG_OOB),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000576#ifdef MSG_PEEK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000577 XLAT(MSG_PEEK),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000578#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000579#ifdef MSG_DONTROUTE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000580 XLAT(MSG_DONTROUTE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000581#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000582#ifdef MSG_CTRUNC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000583 XLAT(MSG_CTRUNC),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000584#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000585#ifdef MSG_PROBE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000586 XLAT(MSG_PROBE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000587#endif
588#ifdef MSG_TRUNC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000589 XLAT(MSG_TRUNC),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000590#endif
591#ifdef MSG_DONTWAIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000592 XLAT(MSG_DONTWAIT),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000593#endif
594#ifdef MSG_EOR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000595 XLAT(MSG_EOR),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000596#endif
597#ifdef MSG_WAITALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000598 XLAT(MSG_WAITALL),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000599#endif
Roland McGrath05e5e792004-04-14 02:53:54 +0000600#ifdef MSG_FIN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000601 XLAT(MSG_FIN),
Roland McGrath05e5e792004-04-14 02:53:54 +0000602#endif
603#ifdef MSG_SYN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000604 XLAT(MSG_SYN),
Roland McGrath05e5e792004-04-14 02:53:54 +0000605#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000606#ifdef MSG_CONFIRM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000607 XLAT(MSG_CONFIRM),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000608#endif
Roland McGrath05e5e792004-04-14 02:53:54 +0000609#ifdef MSG_RST
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000610 XLAT(MSG_RST),
Roland McGrath05e5e792004-04-14 02:53:54 +0000611#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000612#ifdef MSG_ERRQUEUE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000613 XLAT(MSG_ERRQUEUE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000614#endif
Roland McGrath05e5e792004-04-14 02:53:54 +0000615#ifdef MSG_NOSIGNAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000616 XLAT(MSG_NOSIGNAL),
Roland McGrath05e5e792004-04-14 02:53:54 +0000617#endif
618#ifdef MSG_MORE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000619 XLAT(MSG_MORE),
Roland McGrath05e5e792004-04-14 02:53:54 +0000620#endif
Dmitry V. Levin3df080a2012-03-13 01:26:26 +0000621#ifdef MSG_WAITFORONE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000622 XLAT(MSG_WAITFORONE),
Dmitry V. Levin3df080a2012-03-13 01:26:26 +0000623#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000624#ifdef MSG_EOF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000625 XLAT(MSG_EOF),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000626#endif
627#ifdef MSG_FASTOPEN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000628 XLAT(MSG_FASTOPEN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +0000629#endif
Roland McGrath71d3d662007-08-07 01:00:26 +0000630#ifdef MSG_CMSG_CLOEXEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000631 XLAT(MSG_CMSG_CLOEXEC),
Roland McGrath71d3d662007-08-07 01:00:26 +0000632#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000633 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000634};
635
Roland McGrathd9f816f2004-09-04 03:39:20 +0000636static const struct xlat sockoptions[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000637#ifdef SO_ACCEPTCONN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000638 XLAT(SO_ACCEPTCONN),
John Hughes38ae88d2002-05-23 11:48:58 +0000639#endif
640#ifdef SO_ALLRAW
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000641 XLAT(SO_ALLRAW),
John Hughes38ae88d2002-05-23 11:48:58 +0000642#endif
Roland McGrath1bf43732004-08-31 07:16:14 +0000643#ifdef SO_ATTACH_FILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000644 XLAT(SO_ATTACH_FILTER),
Roland McGrath1bf43732004-08-31 07:16:14 +0000645#endif
646#ifdef SO_BINDTODEVICE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000647 XLAT(SO_BINDTODEVICE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000648#endif
649#ifdef SO_BROADCAST
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000650 XLAT(SO_BROADCAST),
Roland McGrath1bf43732004-08-31 07:16:14 +0000651#endif
652#ifdef SO_BSDCOMPAT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000653 XLAT(SO_BSDCOMPAT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000654#endif
655#ifdef SO_DEBUG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000656 XLAT(SO_DEBUG),
Roland McGrath1bf43732004-08-31 07:16:14 +0000657#endif
658#ifdef SO_DETACH_FILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000659 XLAT(SO_DETACH_FILTER),
Roland McGrath1bf43732004-08-31 07:16:14 +0000660#endif
661#ifdef SO_DONTROUTE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000662 XLAT(SO_DONTROUTE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000663#endif
664#ifdef SO_ERROR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000665 XLAT(SO_ERROR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000666#endif
John Hughes38ae88d2002-05-23 11:48:58 +0000667#ifdef SO_ICS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000668 XLAT(SO_ICS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000669#endif
Roland McGrath1bf43732004-08-31 07:16:14 +0000670#ifdef SO_IMASOCKET
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000671 XLAT(SO_IMASOCKET),
Roland McGrath1bf43732004-08-31 07:16:14 +0000672#endif
673#ifdef SO_KEEPALIVE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000674 XLAT(SO_KEEPALIVE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000675#endif
676#ifdef SO_LINGER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000677 XLAT(SO_LINGER),
Roland McGrath1bf43732004-08-31 07:16:14 +0000678#endif
679#ifdef SO_LISTENING
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000680 XLAT(SO_LISTENING),
Roland McGrath1bf43732004-08-31 07:16:14 +0000681#endif
682#ifdef SO_MGMT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000683 XLAT(SO_MGMT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000684#endif
685#ifdef SO_NO_CHECK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000686 XLAT(SO_NO_CHECK),
Roland McGrath1bf43732004-08-31 07:16:14 +0000687#endif
688#ifdef SO_OOBINLINE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000689 XLAT(SO_OOBINLINE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000690#endif
691#ifdef SO_ORDREL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000692 XLAT(SO_ORDREL),
Roland McGrath1bf43732004-08-31 07:16:14 +0000693#endif
694#ifdef SO_PARALLELSVR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000695 XLAT(SO_PARALLELSVR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000696#endif
697#ifdef SO_PASSCRED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000698 XLAT(SO_PASSCRED),
Roland McGrath1bf43732004-08-31 07:16:14 +0000699#endif
700#ifdef SO_PEERCRED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000701 XLAT(SO_PEERCRED),
Roland McGrath1bf43732004-08-31 07:16:14 +0000702#endif
703#ifdef SO_PEERNAME
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000704 XLAT(SO_PEERNAME),
Roland McGrath1bf43732004-08-31 07:16:14 +0000705#endif
706#ifdef SO_PEERSEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000707 XLAT(SO_PEERSEC),
Roland McGrath1bf43732004-08-31 07:16:14 +0000708#endif
709#ifdef SO_PRIORITY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000710 XLAT(SO_PRIORITY),
Roland McGrath1bf43732004-08-31 07:16:14 +0000711#endif
712#ifdef SO_PROTOTYPE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000713 XLAT(SO_PROTOTYPE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000714#endif
715#ifdef SO_RCVBUF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000716 XLAT(SO_RCVBUF),
Roland McGrath1bf43732004-08-31 07:16:14 +0000717#endif
718#ifdef SO_RCVLOWAT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000719 XLAT(SO_RCVLOWAT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000720#endif
721#ifdef SO_RCVTIMEO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000722 XLAT(SO_RCVTIMEO),
Roland McGrath1bf43732004-08-31 07:16:14 +0000723#endif
724#ifdef SO_RDWR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000725 XLAT(SO_RDWR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000726#endif
727#ifdef SO_REUSEADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000728 XLAT(SO_REUSEADDR),
Roland McGrath1bf43732004-08-31 07:16:14 +0000729#endif
730#ifdef SO_REUSEPORT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000731 XLAT(SO_REUSEPORT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000732#endif
733#ifdef SO_SECURITY_AUTHENTICATION
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000734 XLAT(SO_SECURITY_AUTHENTICATION),
Roland McGrath1bf43732004-08-31 07:16:14 +0000735#endif
736#ifdef SO_SECURITY_ENCRYPTION_NETWORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000737 XLAT(SO_SECURITY_ENCRYPTION_NETWORK),
Roland McGrath1bf43732004-08-31 07:16:14 +0000738#endif
739#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000740 XLAT(SO_SECURITY_ENCRYPTION_TRANSPORT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000741#endif
742#ifdef SO_SEMA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000743 XLAT(SO_SEMA),
Roland McGrath1bf43732004-08-31 07:16:14 +0000744#endif
745#ifdef SO_SNDBUF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000746 XLAT(SO_SNDBUF),
Roland McGrath1bf43732004-08-31 07:16:14 +0000747#endif
748#ifdef SO_SNDLOWAT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000749 XLAT(SO_SNDLOWAT),
Roland McGrath1bf43732004-08-31 07:16:14 +0000750#endif
751#ifdef SO_SNDTIMEO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000752 XLAT(SO_SNDTIMEO),
Roland McGrath1bf43732004-08-31 07:16:14 +0000753#endif
754#ifdef SO_TIMESTAMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000755 XLAT(SO_TIMESTAMP),
Roland McGrath1bf43732004-08-31 07:16:14 +0000756#endif
757#ifdef SO_TYPE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000758 XLAT(SO_TYPE),
Roland McGrath1bf43732004-08-31 07:16:14 +0000759#endif
760#ifdef SO_USELOOPBACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000761 XLAT(SO_USELOOPBACK),
Roland McGrath1bf43732004-08-31 07:16:14 +0000762#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000763 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000764};
765
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100766#if !defined(SOL_IP) && defined(IPPROTO_IP)
John Hughes93f7fcc2002-05-22 15:46:49 +0000767#define SOL_IP IPPROTO_IP
768#endif
769
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000770#ifdef SOL_IP
Roland McGrathd9f816f2004-09-04 03:39:20 +0000771static const struct xlat sockipoptions[] = {
John Hughes93f7fcc2002-05-22 15:46:49 +0000772#ifdef IP_TOS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000773 XLAT(IP_TOS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000774#endif
775#ifdef IP_TTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000776 XLAT(IP_TTL),
John Hughes93f7fcc2002-05-22 15:46:49 +0000777#endif
778#ifdef IP_HDRINCL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000779 XLAT(IP_HDRINCL),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000780#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000781#ifdef IP_OPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000782 XLAT(IP_OPTIONS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000783#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000784#ifdef IP_ROUTER_ALERT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000785 XLAT(IP_ROUTER_ALERT),
John Hughes93f7fcc2002-05-22 15:46:49 +0000786#endif
787#ifdef IP_RECVOPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000788 XLAT(IP_RECVOPTIONS),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000789#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000790#ifdef IP_RECVOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000791 XLAT(IP_RECVOPTS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000792#endif
793#ifdef IP_RECVRETOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000794 XLAT(IP_RECVRETOPTS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000795#endif
796#ifdef IP_RECVDSTADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000797 XLAT(IP_RECVDSTADDR),
John Hughes93f7fcc2002-05-22 15:46:49 +0000798#endif
799#ifdef IP_RETOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000800 XLAT(IP_RETOPTS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000801#endif
802#ifdef IP_PKTINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000803 XLAT(IP_PKTINFO),
John Hughes93f7fcc2002-05-22 15:46:49 +0000804#endif
805#ifdef IP_PKTOPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000806 XLAT(IP_PKTOPTIONS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000807#endif
808#ifdef IP_MTU_DISCOVER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000809 XLAT(IP_MTU_DISCOVER),
John Hughes93f7fcc2002-05-22 15:46:49 +0000810#endif
811#ifdef IP_RECVERR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000812 XLAT(IP_RECVERR),
John Hughes93f7fcc2002-05-22 15:46:49 +0000813#endif
814#ifdef IP_RECVTTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000815 XLAT(IP_RECVTTL),
John Hughes93f7fcc2002-05-22 15:46:49 +0000816#endif
817#ifdef IP_RECVTOS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000818 XLAT(IP_RECVTOS),
John Hughes93f7fcc2002-05-22 15:46:49 +0000819#endif
820#ifdef IP_MTU
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000821 XLAT(IP_MTU),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000822#endif
John Hughes93f7fcc2002-05-22 15:46:49 +0000823#ifdef IP_MULTICAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000824 XLAT(IP_MULTICAST_IF),
John Hughes93f7fcc2002-05-22 15:46:49 +0000825#endif
826#ifdef IP_MULTICAST_TTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000827 XLAT(IP_MULTICAST_TTL),
John Hughes93f7fcc2002-05-22 15:46:49 +0000828#endif
829#ifdef IP_MULTICAST_LOOP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000830 XLAT(IP_MULTICAST_LOOP),
John Hughes93f7fcc2002-05-22 15:46:49 +0000831#endif
832#ifdef IP_ADD_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000833 XLAT(IP_ADD_MEMBERSHIP),
John Hughes93f7fcc2002-05-22 15:46:49 +0000834#endif
835#ifdef IP_DROP_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000836 XLAT(IP_DROP_MEMBERSHIP),
John Hughes93f7fcc2002-05-22 15:46:49 +0000837#endif
838#ifdef IP_BROADCAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000839 XLAT(IP_BROADCAST_IF),
John Hughes93f7fcc2002-05-22 15:46:49 +0000840#endif
841#ifdef IP_RECVIFINDEX
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000842 XLAT(IP_RECVIFINDEX),
John Hughes93f7fcc2002-05-22 15:46:49 +0000843#endif
Roland McGrath4f6ba692004-08-31 07:01:26 +0000844#ifdef IP_MSFILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000845 XLAT(IP_MSFILTER),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000846#endif
847#ifdef MCAST_MSFILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000848 XLAT(MCAST_MSFILTER),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000849#endif
850#ifdef IP_FREEBIND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000851 XLAT(IP_FREEBIND),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000852#endif
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500853#ifdef IP_IPSEC_POLICY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000854 XLAT(IP_IPSEC_POLICY),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500855#endif
856#ifdef IP_XFRM_POLICY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000857 XLAT(IP_XFRM_POLICY),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500858#endif
859#ifdef IP_PASSSEC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000860 XLAT(IP_PASSSEC),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500861#endif
862#ifdef IP_TRANSPARENT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000863 XLAT(IP_TRANSPARENT),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500864#endif
865#ifdef IP_ORIGDSTADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000866 XLAT(IP_ORIGDSTADDR),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500867#endif
868#ifdef IP_RECVORIGDSTADDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000869 XLAT(IP_RECVORIGDSTADDR),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500870#endif
871#ifdef IP_MINTTL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000872 XLAT(IP_MINTTL),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500873#endif
874#ifdef IP_NODEFRAG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000875 XLAT(IP_NODEFRAG),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500876#endif
877#ifdef IP_UNBLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000878 XLAT(IP_UNBLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500879#endif
880#ifdef IP_BLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000881 XLAT(IP_BLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500882#endif
883#ifdef IP_ADD_SOURCE_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000884 XLAT(IP_ADD_SOURCE_MEMBERSHIP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500885#endif
886#ifdef IP_DROP_SOURCE_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000887 XLAT(IP_DROP_SOURCE_MEMBERSHIP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500888#endif
889#ifdef MCAST_JOIN_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000890 XLAT(MCAST_JOIN_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500891#endif
892#ifdef MCAST_BLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000893 XLAT(MCAST_BLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500894#endif
895#ifdef MCAST_UNBLOCK_SOURCE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000896 XLAT(MCAST_UNBLOCK_SOURCE),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500897#endif
898#ifdef MCAST_LEAVE_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000899 XLAT(MCAST_LEAVE_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500900#endif
901#ifdef MCAST_JOIN_SOURCE_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000902 XLAT(MCAST_JOIN_SOURCE_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500903#endif
904#ifdef MCAST_LEAVE_SOURCE_GROUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000905 XLAT(MCAST_LEAVE_SOURCE_GROUP),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500906#endif
907#ifdef IP_MULTICAST_ALL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000908 XLAT(IP_MULTICAST_ALL),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500909#endif
910#ifdef IP_UNICAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000911 XLAT(IP_UNICAST_IF),
Mike Frysingeraa4633c2014-01-30 18:53:43 -0500912#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000913 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000914};
915#endif /* SOL_IP */
916
Roland McGrath4f6ba692004-08-31 07:01:26 +0000917#ifdef SOL_IPV6
Roland McGrathd9f816f2004-09-04 03:39:20 +0000918static const struct xlat sockipv6options[] = {
Roland McGrath4f6ba692004-08-31 07:01:26 +0000919#ifdef IPV6_ADDRFORM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000920 XLAT(IPV6_ADDRFORM),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000921#endif
922#ifdef MCAST_FILTER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000923 XLAT(MCAST_FILTER),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000924#endif
925#ifdef IPV6_PKTOPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000926 XLAT(IPV6_PKTOPTIONS),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000927#endif
928#ifdef IPV6_MTU
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000929 XLAT(IPV6_MTU),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000930#endif
931#ifdef IPV6_V6ONLY
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000932 XLAT(IPV6_V6ONLY),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000933#endif
934#ifdef IPV6_PKTINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000935 XLAT(IPV6_PKTINFO),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000936#endif
937#ifdef IPV6_HOPLIMIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000938 XLAT(IPV6_HOPLIMIT),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000939#endif
940#ifdef IPV6_RTHDR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000941 XLAT(IPV6_RTHDR),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000942#endif
943#ifdef IPV6_HOPOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000944 XLAT(IPV6_HOPOPTS),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000945#endif
946#ifdef IPV6_DSTOPTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000947 XLAT(IPV6_DSTOPTS),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000948#endif
949#ifdef IPV6_FLOWINFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000950 XLAT(IPV6_FLOWINFO),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000951#endif
952#ifdef IPV6_UNICAST_HOPS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000953 XLAT(IPV6_UNICAST_HOPS),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000954#endif
955#ifdef IPV6_MULTICAST_HOPS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000956 XLAT(IPV6_MULTICAST_HOPS),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000957#endif
958#ifdef IPV6_MULTICAST_LOOP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000959 XLAT(IPV6_MULTICAST_LOOP),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000960#endif
961#ifdef IPV6_MULTICAST_IF
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000962 XLAT(IPV6_MULTICAST_IF),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000963#endif
964#ifdef IPV6_MTU_DISCOVER
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000965 XLAT(IPV6_MTU_DISCOVER),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000966#endif
967#ifdef IPV6_RECVERR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000968 XLAT(IPV6_RECVERR),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000969#endif
970#ifdef IPV6_FLOWINFO_SEND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000971 XLAT(IPV6_FLOWINFO_SEND),
Roland McGrath4f6ba692004-08-31 07:01:26 +0000972#endif
Roland McGrathc0b9e372005-07-04 23:33:38 +0000973#ifdef IPV6_ADD_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000974 XLAT(IPV6_ADD_MEMBERSHIP),
Roland McGrathc0b9e372005-07-04 23:33:38 +0000975#endif
976#ifdef IPV6_DROP_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000977 XLAT(IPV6_DROP_MEMBERSHIP),
Roland McGrathc0b9e372005-07-04 23:33:38 +0000978#endif
979#ifdef IPV6_ROUTER_ALERT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000980 XLAT(IPV6_ROUTER_ALERT),
Roland McGrathc0b9e372005-07-04 23:33:38 +0000981#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000982 XLAT_END
Roland McGrath4f6ba692004-08-31 07:01:26 +0000983};
984#endif /* SOL_IPV6 */
985
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000986#ifdef SOL_IPX
Roland McGrathd9f816f2004-09-04 03:39:20 +0000987static const struct xlat sockipxoptions[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000988 XLAT(IPX_TYPE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000989 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000990};
991#endif /* SOL_IPX */
992
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000993#ifdef SOL_RAW
Roland McGrathd9f816f2004-09-04 03:39:20 +0000994static const struct xlat sockrawoptions[] = {
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000995#if defined(ICMP_FILTER)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000996 XLAT(ICMP_FILTER),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000997#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000998 XLAT_END
Wichert Akkerman7987cdf2000-07-05 16:05:39 +0000999};
1000#endif /* SOL_RAW */
1001
1002#ifdef SOL_PACKET
Roland McGrathd9f816f2004-09-04 03:39:20 +00001003static const struct xlat sockpacketoptions[] = {
Roland McGrathc294b8f2007-11-01 21:37:33 +00001004#ifdef PACKET_ADD_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001005 XLAT(PACKET_ADD_MEMBERSHIP),
Roland McGrathc294b8f2007-11-01 21:37:33 +00001006#endif
1007#ifdef PACKET_DROP_MEMBERSHIP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001008 XLAT(PACKET_DROP_MEMBERSHIP),
Roland McGrathc294b8f2007-11-01 21:37:33 +00001009#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001010#if defined(PACKET_RECV_OUTPUT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001011 XLAT(PACKET_RECV_OUTPUT),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001012#endif
1013#if defined(PACKET_RX_RING)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001014 XLAT(PACKET_RX_RING),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001015#endif
1016#if defined(PACKET_STATISTICS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001017 XLAT(PACKET_STATISTICS),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001018#endif
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001019#if defined(PACKET_COPY_THRESH)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001020 XLAT(PACKET_COPY_THRESH),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001021#endif
1022#if defined(PACKET_AUXDATA)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001023 XLAT(PACKET_AUXDATA),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001024#endif
1025#if defined(PACKET_ORIGDEV)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001026 XLAT(PACKET_ORIGDEV),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001027#endif
1028#if defined(PACKET_VERSION)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001029 XLAT(PACKET_VERSION),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001030#endif
1031#if defined(PACKET_HDRLEN)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001032 XLAT(PACKET_HDRLEN),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001033#endif
1034#if defined(PACKET_RESERVE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001035 XLAT(PACKET_RESERVE),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001036#endif
1037#if defined(PACKET_TX_RING)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001038 XLAT(PACKET_TX_RING),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001039#endif
1040#if defined(PACKET_LOSS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001041 XLAT(PACKET_LOSS),
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00001042#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001043 XLAT_END
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001044};
1045#endif /* SOL_PACKET */
1046
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001047#ifdef SOL_SCTP
1048static const struct xlat socksctpoptions[] = {
1049#if defined(SCTP_RTOINFO)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001050 XLAT(SCTP_RTOINFO),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001051#endif
1052#if defined(SCTP_ASSOCINFO)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001053 XLAT(SCTP_ASSOCINFO),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001054#endif
1055#if defined(SCTP_INITMSG)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001056 XLAT(SCTP_INITMSG),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001057#endif
1058#if defined(SCTP_NODELAY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001059 XLAT(SCTP_NODELAY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001060#endif
1061#if defined(SCTP_AUTOCLOSE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001062 XLAT(SCTP_AUTOCLOSE),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001063#endif
1064#if defined(SCTP_SET_PEER_PRIMARY_ADDR)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001065 XLAT(SCTP_SET_PEER_PRIMARY_ADDR),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001066#endif
1067#if defined(SCTP_PRIMARY_ADDR)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001068 XLAT(SCTP_PRIMARY_ADDR),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001069#endif
1070#if defined(SCTP_ADAPTATION_LAYER)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001071 XLAT(SCTP_ADAPTATION_LAYER),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001072#endif
1073#if defined(SCTP_DISABLE_FRAGMENTS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001074 XLAT(SCTP_DISABLE_FRAGMENTS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001075#endif
1076#if defined(SCTP_PEER_ADDR_PARAMS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001077 XLAT(SCTP_PEER_ADDR_PARAMS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001078#endif
1079#if defined(SCTP_DEFAULT_SEND_PARAM)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001080 XLAT(SCTP_DEFAULT_SEND_PARAM),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001081#endif
1082#if defined(SCTP_EVENTS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001083 XLAT(SCTP_EVENTS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001084#endif
1085#if defined(SCTP_I_WANT_MAPPED_V4_ADDR)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001086 XLAT(SCTP_I_WANT_MAPPED_V4_ADDR),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001087#endif
1088#if defined(SCTP_MAXSEG)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001089 XLAT(SCTP_MAXSEG),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001090#endif
1091#if defined(SCTP_STATUS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001092 XLAT(SCTP_STATUS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001093#endif
1094#if defined(SCTP_GET_PEER_ADDR_INFO)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001095 XLAT(SCTP_GET_PEER_ADDR_INFO),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001096#endif
1097#if defined(SCTP_DELAYED_ACK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001098 XLAT(SCTP_DELAYED_ACK),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001099#endif
1100#if defined(SCTP_CONTEXT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001101 XLAT(SCTP_CONTEXT),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001102#endif
1103#if defined(SCTP_FRAGMENT_INTERLEAVE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001104 XLAT(SCTP_FRAGMENT_INTERLEAVE),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001105#endif
1106#if defined(SCTP_PARTIAL_DELIVERY_POINT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001107 XLAT(SCTP_PARTIAL_DELIVERY_POINT),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001108#endif
1109#if defined(SCTP_MAX_BURST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001110 XLAT(SCTP_MAX_BURST),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001111#endif
1112#if defined(SCTP_AUTH_CHUNK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001113 XLAT(SCTP_AUTH_CHUNK),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001114#endif
1115#if defined(SCTP_HMAC_IDENT)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001116 XLAT(SCTP_HMAC_IDENT),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001117#endif
1118#if defined(SCTP_AUTH_KEY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001119 XLAT(SCTP_AUTH_KEY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001120#endif
1121#if defined(SCTP_AUTH_ACTIVE_KEY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001122 XLAT(SCTP_AUTH_ACTIVE_KEY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001123#endif
1124#if defined(SCTP_AUTH_DELETE_KEY)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001125 XLAT(SCTP_AUTH_DELETE_KEY),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001126#endif
1127#if defined(SCTP_PEER_AUTH_CHUNKS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001128 XLAT(SCTP_PEER_AUTH_CHUNKS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001129#endif
1130#if defined(SCTP_LOCAL_AUTH_CHUNKS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001131 XLAT(SCTP_LOCAL_AUTH_CHUNKS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001132#endif
1133#if defined(SCTP_GET_ASSOC_NUMBER)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001134 XLAT(SCTP_GET_ASSOC_NUMBER),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001135#endif
1136
1137 /* linux specific things */
1138#if defined(SCTP_SOCKOPT_BINDX_ADD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001139 XLAT(SCTP_SOCKOPT_BINDX_ADD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001140#endif
1141#if defined(SCTP_SOCKOPT_BINDX_REM)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001142 XLAT(SCTP_SOCKOPT_BINDX_REM),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001143#endif
1144#if defined(SCTP_SOCKOPT_PEELOFF)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001145 XLAT(SCTP_SOCKOPT_PEELOFF),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001146#endif
1147#if defined(SCTP_GET_PEER_ADDRS_NUM_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001148 XLAT(SCTP_GET_PEER_ADDRS_NUM_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001149#endif
1150#if defined(SCTP_GET_PEER_ADDRS_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001151 XLAT(SCTP_GET_PEER_ADDRS_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001152#endif
1153#if defined(SCTP_GET_LOCAL_ADDRS_NUM_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001154 XLAT(SCTP_GET_LOCAL_ADDRS_NUM_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001155#endif
1156#if defined(SCTP_GET_LOCAL_ADDRS_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001157 XLAT(SCTP_GET_LOCAL_ADDRS_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001158#endif
1159#if defined(SCTP_SOCKOPT_CONNECTX_OLD)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001160 XLAT(SCTP_SOCKOPT_CONNECTX_OLD),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001161#endif
1162#if defined(SCTP_GET_PEER_ADDRS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001163 XLAT(SCTP_GET_PEER_ADDRS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001164#endif
1165#if defined(SCTP_GET_LOCAL_ADDRS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001166 XLAT(SCTP_GET_LOCAL_ADDRS),
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001167#endif
1168
Dmitry V. Levin59452732014-02-05 02:20:51 +00001169 XLAT_END
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01001170};
1171#endif
1172
Denys Vlasenkoc36c3522012-02-25 02:47:15 +01001173#if !defined(SOL_TCP) && defined(IPPROTO_TCP)
John Hughes93f7fcc2002-05-22 15:46:49 +00001174#define SOL_TCP IPPROTO_TCP
1175#endif
1176
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001177#ifdef SOL_TCP
Roland McGrathd9f816f2004-09-04 03:39:20 +00001178static const struct xlat socktcpoptions[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001179 XLAT(TCP_NODELAY),
1180 XLAT(TCP_MAXSEG),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001181#ifdef TCP_CORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001182 XLAT(TCP_CORK),
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001183#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001184#ifdef TCP_KEEPIDLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001185 XLAT(TCP_KEEPIDLE),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001186#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001187#ifdef TCP_KEEPINTVL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001188 XLAT(TCP_KEEPINTVL),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001189#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001190#ifdef TCP_KEEPCNT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001191 XLAT(TCP_KEEPCNT),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001192#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001193#ifdef TCP_SYNCNT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001194 XLAT(TCP_SYNCNT),
John Hughes38ae88d2002-05-23 11:48:58 +00001195#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001196#ifdef TCP_LINGER2
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001197 XLAT(TCP_LINGER2),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001198#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001199#ifdef TCP_DEFER_ACCEPT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001200 XLAT(TCP_DEFER_ACCEPT),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001201#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001202#ifdef TCP_WINDOW_CLAMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001203 XLAT(TCP_WINDOW_CLAMP),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001204#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001205#ifdef TCP_INFO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001206 XLAT(TCP_INFO),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001207#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001208#ifdef TCP_QUICKACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001209 XLAT(TCP_QUICKACK),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001210#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001211#ifdef TCP_CONGESTION
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001212 XLAT(TCP_CONGESTION),
Wichert Akkerman8b8ff7c2001-12-27 22:27:30 +00001213#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001214#ifdef TCP_MD5SIG
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001215 XLAT(TCP_MD5SIG),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001216#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001217#ifdef TCP_COOKIE_TRANSACTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001218 XLAT(TCP_COOKIE_TRANSACTIONS),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001219#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001220#ifdef TCP_THIN_LINEAR_TIMEOUTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001221 XLAT(TCP_THIN_LINEAR_TIMEOUTS),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001222#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001223#ifdef TCP_THIN_DUPACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001224 XLAT(TCP_THIN_DUPACK),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001225#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001226#ifdef TCP_USER_TIMEOUT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001227 XLAT(TCP_USER_TIMEOUT),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001228#endif
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001229#ifdef TCP_REPAIR
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001230 XLAT(TCP_REPAIR),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001231#endif
1232#ifdef TCP_REPAIR_QUEUE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001233 XLAT(TCP_REPAIR_QUEUE),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001234#endif
1235#ifdef TCP_QUEUE_SEQ
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001236 XLAT(TCP_QUEUE_SEQ),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001237#endif
1238#ifdef TCP_REPAIR_OPTIONS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001239 XLAT(TCP_REPAIR_OPTIONS),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001240#endif
1241#ifdef TCP_FASTOPEN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001242 XLAT(TCP_FASTOPEN),
Dmitry V. Levinea0d2a62013-05-16 22:19:30 +00001243#endif
1244#ifdef TCP_TIMESTAMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001245 XLAT(TCP_TIMESTAMP),
Dmitry V. Levinb05fc542011-12-01 21:06:00 +00001246#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001247 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001248};
1249#endif /* SOL_TCP */
1250
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001251#ifdef SOL_RAW
Roland McGrathd9f816f2004-09-04 03:39:20 +00001252static const struct xlat icmpfilterflags[] = {
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001253#if defined(ICMP_ECHOREPLY)
1254 { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" },
1255#endif
1256#if defined(ICMP_DEST_UNREACH)
1257 { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" },
1258#endif
1259#if defined(ICMP_SOURCE_QUENCH)
1260 { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" },
1261#endif
1262#if defined(ICMP_REDIRECT)
1263 { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" },
1264#endif
1265#if defined(ICMP_ECHO)
1266 { (1<<ICMP_ECHO), "ICMP_ECHO" },
1267#endif
1268#if defined(ICMP_TIME_EXCEEDED)
1269 { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" },
1270#endif
1271#if defined(ICMP_PARAMETERPROB)
1272 { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" },
1273#endif
1274#if defined(ICMP_TIMESTAMP)
1275 { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" },
1276#endif
1277#if defined(ICMP_TIMESTAMPREPLY)
1278 { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" },
1279#endif
1280#if defined(ICMP_INFO_REQUEST)
1281 { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" },
1282#endif
1283#if defined(ICMP_INFO_REPLY)
1284 { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" },
1285#endif
1286#if defined(ICMP_ADDRESS)
1287 { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" },
1288#endif
1289#if defined(ICMP_ADDRESSREPLY)
1290 { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" },
1291#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001292 XLAT_END
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00001293};
1294#endif /* SOL_RAW */
1295
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001296#if defined(AF_PACKET) /* from e.g. linux/if_packet.h */
Roland McGrathd9f816f2004-09-04 03:39:20 +00001297static const struct xlat af_packet_types[] = {
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001298#if defined(PACKET_HOST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001299 XLAT(PACKET_HOST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001300#endif
1301#if defined(PACKET_BROADCAST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001302 XLAT(PACKET_BROADCAST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001303#endif
1304#if defined(PACKET_MULTICAST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001305 XLAT(PACKET_MULTICAST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001306#endif
1307#if defined(PACKET_OTHERHOST)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001308 XLAT(PACKET_OTHERHOST),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001309#endif
1310#if defined(PACKET_OUTGOING)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001311 XLAT(PACKET_OUTGOING),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001312#endif
1313#if defined(PACKET_LOOPBACK)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001314 XLAT(PACKET_LOOPBACK),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001315#endif
1316#if defined(PACKET_FASTROUTE)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001317 XLAT(PACKET_FASTROUTE),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001318#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001319 XLAT_END
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001320};
1321#endif /* defined(AF_PACKET) */
1322
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001323void
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001324printsock(struct tcb *tcp, long addr, int addrlen)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001325{
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001326 union {
1327 char pad[128];
1328 struct sockaddr sa;
1329 struct sockaddr_in sin;
1330 struct sockaddr_un sau;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001331#ifdef HAVE_INET_NTOP
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001332 struct sockaddr_in6 sa6;
1333#endif
Denys Vlasenko84703742012-02-25 02:38:52 +01001334#if defined(AF_IPX)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001335 struct sockaddr_ipx sipx;
1336#endif
1337#ifdef AF_PACKET
1338 struct sockaddr_ll ll;
1339#endif
1340#ifdef AF_NETLINK
1341 struct sockaddr_nl nl;
1342#endif
1343 } addrbuf;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001344 char string_addr[100];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001345
1346 if (addr == 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001347 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001348 return;
1349 }
1350 if (!verbose(tcp)) {
1351 tprintf("%#lx", addr);
1352 return;
1353 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001354
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001355 if (addrlen < 2 || addrlen > sizeof(addrbuf))
1356 addrlen = sizeof(addrbuf);
1357
1358 memset(&addrbuf, 0, sizeof(addrbuf));
1359 if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001360 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001361 return;
1362 }
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001363 addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0';
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001364
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001365 tprints("{sa_family=");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001366 printxval(addrfams, addrbuf.sa.sa_family, "AF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001367 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001368
1369 switch (addrbuf.sa.sa_family) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001370 case AF_UNIX:
Dmitry V. Levinb6c32f42007-10-08 23:31:19 +00001371 if (addrlen == 2) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001372 tprints("NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001373 } else if (addrbuf.sau.sun_path[0]) {
Dmitry V. Levinc86340e2012-02-22 00:23:52 +00001374 tprints("sun_path=");
Dmitry V. Levin16fbe972007-10-13 21:03:17 +00001375 printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path));
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001376 } else {
Dmitry V. Levinc86340e2012-02-22 00:23:52 +00001377 tprints("sun_path=@");
Dmitry V. Levin16fbe972007-10-13 21:03:17 +00001378 printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1));
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001379 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001380 break;
1381 case AF_INET:
John Hughes1fcb1d62001-09-18 15:56:53 +00001382 tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001383 ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001384 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001385#ifdef HAVE_INET_NTOP
1386 case AF_INET6:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001387 inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr));
Wichert Akkermanf1850652001-02-16 20:29:03 +00001388 tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
1389 ntohs(addrbuf.sa6.sin6_port), string_addr,
1390 addrbuf.sa6.sin6_flowinfo);
Roland McGrath6d2b3492002-12-30 00:51:30 +00001391#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
Wichert Akkermanf1850652001-02-16 20:29:03 +00001392 {
1393#if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001394 int numericscope = 0;
1395 if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr)
1396 || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) {
1397 char scopebuf[IFNAMSIZ + 1];
Roland McGrath6d2b3492002-12-30 00:51:30 +00001398
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001399 if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
1400 numericscope++;
1401 else
1402 tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
1403 } else
1404 numericscope++;
Roland McGrath6d2b3492002-12-30 00:51:30 +00001405
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001406 if (numericscope)
Wichert Akkermanf1850652001-02-16 20:29:03 +00001407#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001408 tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
Wichert Akkermanf1850652001-02-16 20:29:03 +00001409 }
1410#endif
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001411 break;
Wichert Akkerman9ce1a631999-08-29 23:15:07 +00001412#endif
Denys Vlasenko84703742012-02-25 02:38:52 +01001413#if defined(AF_IPX)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001414 case AF_IPX:
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001415 {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001416 int i;
John Hughes1fcb1d62001-09-18 15:56:53 +00001417 tprintf("sipx_port=htons(%u), ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001418 ntohs(addrbuf.sipx.sipx_port));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001419 /* Yes, I know, this does not look too
1420 * strace-ish, but otherwise the IPX
1421 * addresses just look monstrous...
1422 * Anyways, feel free if you don't like
Roland McGrath6d2b3492002-12-30 00:51:30 +00001423 * this way.. :)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001424 */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001425 tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001426 for (i = 0; i < IPX_NODE_LEN; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001427 tprintf("%02x", addrbuf.sipx.sipx_node[i]);
1428 tprintf("/[%02x]", addrbuf.sipx.sipx_type);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001429 }
1430 break;
Denys Vlasenko84703742012-02-25 02:38:52 +01001431#endif /* AF_IPX */
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001432#ifdef AF_PACKET
1433 case AF_PACKET:
1434 {
1435 int i;
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001436 tprintf("proto=%#04x, if%d, pkttype=",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001437 ntohs(addrbuf.ll.sll_protocol),
Wichert Akkermanb0c598f2002-04-01 12:48:06 +00001438 addrbuf.ll.sll_ifindex);
1439 printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?");
1440 tprintf(", addr(%d)={%d, ",
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001441 addrbuf.ll.sll_halen,
1442 addrbuf.ll.sll_hatype);
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001443 for (i = 0; i < addrbuf.ll.sll_halen; i++)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001444 tprintf("%02x", addrbuf.ll.sll_addr[i]);
1445 }
1446 break;
1447
Denys Vlasenko84703742012-02-25 02:38:52 +01001448#endif /* AF_PACKET */
Roland McGrath36ef1bc2003-11-06 23:41:23 +00001449#ifdef AF_NETLINK
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001450 case AF_NETLINK:
1451 tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups);
1452 break;
1453#endif /* AF_NETLINK */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001454 /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001455 AF_X25 AF_ROSE etc. still need to be done */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001456
1457 default:
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001458 tprints("sa_data=");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001459 printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001460 sizeof addrbuf.sa.sa_data);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001461 break;
1462 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001463 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001464}
1465
1466#if HAVE_SENDMSG
Roland McGrath50770822004-10-06 22:11:51 +00001467static const struct xlat scmvals[] = {
1468#ifdef SCM_RIGHTS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001469 XLAT(SCM_RIGHTS),
Roland McGrath50770822004-10-06 22:11:51 +00001470#endif
1471#ifdef SCM_CREDENTIALS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +00001472 XLAT(SCM_CREDENTIALS),
Roland McGrath50770822004-10-06 22:11:51 +00001473#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +00001474 XLAT_END
Roland McGrath50770822004-10-06 22:11:51 +00001475};
1476
1477static void
Denys Vlasenko132c52a2009-03-23 13:12:46 +00001478printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len)
Roland McGrath50770822004-10-06 22:11:51 +00001479{
Roland McGrathaa524c82005-06-01 19:22:06 +00001480 struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ?
1481 NULL : malloc(len);
1482 if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) {
Roland McGrath50770822004-10-06 22:11:51 +00001483 tprintf(", msg_control=%#lx", addr);
Roland McGrathaa524c82005-06-01 19:22:06 +00001484 free(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001485 return;
1486 }
1487
Denys Vlasenko132c52a2009-03-23 13:12:46 +00001488 tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len);
Roland McGrathaa524c82005-06-01 19:22:06 +00001489 printxval(socketlayers, cmsg->cmsg_level, "SOL_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001490 tprints(", cmsg_type=");
Roland McGrath50770822004-10-06 22:11:51 +00001491
Roland McGrathaa524c82005-06-01 19:22:06 +00001492 if (cmsg->cmsg_level == SOL_SOCKET) {
1493 unsigned long cmsg_len;
Roland McGrath96ad7b82005-02-02 03:11:32 +00001494
Roland McGrathaa524c82005-06-01 19:22:06 +00001495 printxval(scmvals, cmsg->cmsg_type, "SCM_???");
1496 cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len;
1497
1498 if (cmsg->cmsg_type == SCM_RIGHTS
1499 && CMSG_LEN(sizeof(int)) <= cmsg_len) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001500 int *fds = (int *) CMSG_DATA(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001501 int first = 1;
Roland McGrathaa524c82005-06-01 19:22:06 +00001502
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001503 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +00001504 while ((char *) fds < ((char *) cmsg + cmsg_len)) {
Roland McGrath50770822004-10-06 22:11:51 +00001505 if (!first)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001506 tprints(", ");
Roland McGrath50770822004-10-06 22:11:51 +00001507 tprintf("%d", *fds++);
1508 first = 0;
1509 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001510 tprints("}}");
Roland McGrathaa524c82005-06-01 19:22:06 +00001511 free(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001512 return;
1513 }
Roland McGrathaa524c82005-06-01 19:22:06 +00001514 if (cmsg->cmsg_type == SCM_CREDENTIALS
1515 && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001516 struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg);
Roland McGrathaa524c82005-06-01 19:22:06 +00001517
Roland McGrath50770822004-10-06 22:11:51 +00001518 tprintf("{pid=%ld, uid=%ld, gid=%ld}}",
1519 (long)uc->pid, (long)uc->uid, (long)uc->gid);
Roland McGrathaa524c82005-06-01 19:22:06 +00001520 free(cmsg);
Roland McGrath50770822004-10-06 22:11:51 +00001521 return;
1522 }
1523 }
Roland McGrathaa524c82005-06-01 19:22:06 +00001524 free(cmsg);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001525 tprints(", ...}");
Roland McGrath50770822004-10-06 22:11:51 +00001526}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001527
1528static void
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001529do_msghdr(struct tcb *tcp, struct msghdr *msg, unsigned long data_size)
Andreas Schwab0873f292010-02-12 21:39:12 +01001530{
1531 tprintf("{msg_name(%d)=", msg->msg_namelen);
1532 printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
1533
1534 tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001535 tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
1536 (unsigned long)msg->msg_iov, 1, data_size);
Andreas Schwab0873f292010-02-12 21:39:12 +01001537
1538#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
1539 tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
1540 if (msg->msg_controllen)
1541 printcmsghdr(tcp, (unsigned long) msg->msg_control,
1542 msg->msg_controllen);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001543 tprints(", msg_flags=");
Andreas Schwab0873f292010-02-12 21:39:12 +01001544 printflags(msg_flags, msg->msg_flags, "MSG_???");
1545#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
1546 tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
1547 (unsigned long) msg->msg_accrights, msg->msg_accrightslen);
1548#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001549 tprints("}");
Andreas Schwab0873f292010-02-12 21:39:12 +01001550}
1551
Denys Vlasenko3e759d42013-02-12 11:57:48 +01001552struct msghdr32 {
1553 uint32_t /* void* */ msg_name;
1554 uint32_t /* socklen_t */msg_namelen;
1555 uint32_t /* iovec* */ msg_iov;
1556 uint32_t /* size_t */ msg_iovlen;
1557 uint32_t /* void* */ msg_control;
1558 uint32_t /* size_t */ msg_controllen;
1559 uint32_t /* int */ msg_flags;
1560};
1561struct mmsghdr32 {
1562 struct msghdr32 msg_hdr;
1563 uint32_t /* unsigned */ msg_len;
1564};
1565
Andreas Schwab0873f292010-02-12 21:39:12 +01001566static void
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001567printmsghdr(struct tcb *tcp, long addr, unsigned long data_size)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001568{
1569 struct msghdr msg;
1570
Denys Vlasenko3e759d42013-02-12 11:57:48 +01001571#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
1572 if (current_wordsize == 4) {
1573 struct msghdr32 msg32;
1574
1575 if (umove(tcp, addr, &msg32) < 0) {
1576 tprintf("%#lx", addr);
1577 return;
1578 }
1579 msg.msg_name = (void*)(long)msg32.msg_name;
1580 msg.msg_namelen = msg32.msg_namelen;
1581 msg.msg_iov = (void*)(long)msg32.msg_iov;
1582 msg.msg_iovlen = msg32.msg_iovlen;
1583 msg.msg_control = (void*)(long)msg32.msg_control;
1584 msg.msg_controllen = msg32.msg_controllen;
1585 msg.msg_flags = msg32.msg_flags;
1586 } else
1587#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00001588 if (umove(tcp, addr, &msg) < 0) {
1589 tprintf("%#lx", addr);
1590 return;
1591 }
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001592 do_msghdr(tcp, &msg, data_size);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001593}
1594
Andreas Schwab0873f292010-02-12 21:39:12 +01001595static void
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001596printmmsghdr(struct tcb *tcp, long addr, unsigned int idx, unsigned long msg_len)
Andreas Schwab0873f292010-02-12 21:39:12 +01001597{
1598 struct mmsghdr {
1599 struct msghdr msg_hdr;
1600 unsigned msg_len;
1601 } mmsg;
1602
Denys Vlasenko3e759d42013-02-12 11:57:48 +01001603#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
1604 if (current_wordsize == 4) {
1605 struct mmsghdr32 mmsg32;
1606
1607 addr += sizeof(mmsg32) * idx;
1608 if (umove(tcp, addr, &mmsg32) < 0) {
1609 tprintf("%#lx", addr);
1610 return;
1611 }
1612 mmsg.msg_hdr.msg_name = (void*)(long)mmsg32.msg_hdr.msg_name;
1613 mmsg.msg_hdr.msg_namelen = mmsg32.msg_hdr.msg_namelen;
1614 mmsg.msg_hdr.msg_iov = (void*)(long)mmsg32.msg_hdr.msg_iov;
1615 mmsg.msg_hdr.msg_iovlen = mmsg32.msg_hdr.msg_iovlen;
1616 mmsg.msg_hdr.msg_control = (void*)(long)mmsg32.msg_hdr.msg_control;
1617 mmsg.msg_hdr.msg_controllen = mmsg32.msg_hdr.msg_controllen;
1618 mmsg.msg_hdr.msg_flags = mmsg32.msg_hdr.msg_flags;
1619 mmsg.msg_len = mmsg32.msg_len;
1620 } else
1621#endif
1622 {
1623 addr += sizeof(mmsg) * idx;
1624 if (umove(tcp, addr, &mmsg) < 0) {
1625 tprintf("%#lx", addr);
1626 return;
1627 }
Andreas Schwab0873f292010-02-12 21:39:12 +01001628 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001629 tprints("{");
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001630 do_msghdr(tcp, &mmsg.msg_hdr, msg_len ? msg_len : mmsg.msg_len);
Andreas Schwab0873f292010-02-12 21:39:12 +01001631 tprintf(", %u}", mmsg.msg_len);
1632}
Andreas Schwab0873f292010-02-12 21:39:12 +01001633
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001634static void
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001635decode_mmsg(struct tcb *tcp, unsigned long msg_len)
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001636{
1637 /* mmsgvec */
1638 if (syserror(tcp)) {
1639 tprintf("%#lx", tcp->u_arg[1]);
1640 } else {
1641 unsigned int len = tcp->u_rval;
1642 unsigned int i;
1643
1644 tprints("{");
1645 for (i = 0; i < len; ++i) {
1646 if (i)
1647 tprints(", ");
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001648 printmmsghdr(tcp, tcp->u_arg[1], i, msg_len);
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001649 }
1650 tprints("}");
1651 }
1652 /* vlen */
1653 tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
1654 /* flags */
1655 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1656}
1657
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001658#endif /* HAVE_SENDMSG */
1659
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001660/*
1661 * low bits of the socket type define real socket type,
1662 * other bits are socket type flags.
1663 */
1664static void
1665tprint_sock_type(struct tcb *tcp, int flags)
1666{
1667 const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK);
1668
Denys Vlasenko7b609d52011-06-22 14:32:43 +02001669 if (str) {
Denys Vlasenko5940e652011-09-01 09:55:05 +02001670 tprints(str);
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001671 flags &= ~SOCK_TYPE_MASK;
1672 if (!flags)
1673 return;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001674 tprints("|");
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001675 }
1676 printflags(sock_type_flags, flags, "SOCK_???");
1677}
1678
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001679int
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001680sys_socket(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001681{
1682 if (entering(tcp)) {
1683 printxval(domains, tcp->u_arg[0], "PF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001684 tprints(", ");
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00001685 tprint_sock_type(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001686 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001687 switch (tcp->u_arg[0]) {
1688 case PF_INET:
Roland McGrath8758e542003-06-23 23:39:59 +00001689#ifdef PF_INET6
1690 case PF_INET6:
1691#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001692 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
1693 break;
1694#ifdef PF_IPX
1695 case PF_IPX:
1696 /* BTW: I don't believe this.. */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001697 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001698 printxval(domains, tcp->u_arg[2], "PF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001699 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001700 break;
1701#endif /* PF_IPX */
1702 default:
1703 tprintf("%lu", tcp->u_arg[2]);
1704 break;
1705 }
1706 }
1707 return 0;
1708}
1709
John Hughesbdf48f52001-03-06 15:08:09 +00001710int
Denys Vlasenko12014262011-05-30 14:00:14 +02001711sys_bind(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001712{
1713 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001714 printfd(tcp, tcp->u_arg[0]);
1715 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001716 printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001717 tprintf(", %lu", tcp->u_arg[2]);
1718 }
1719 return 0;
1720}
1721
1722int
Denys Vlasenko12014262011-05-30 14:00:14 +02001723sys_connect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001724{
1725 return sys_bind(tcp);
1726}
1727
1728int
Denys Vlasenko12014262011-05-30 14:00:14 +02001729sys_listen(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001730{
1731 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001732 printfd(tcp, tcp->u_arg[0]);
1733 tprints(", ");
1734 tprintf("%lu", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001735 }
1736 return 0;
1737}
1738
Paolo Bonzini705ff102009-08-14 12:34:05 +02001739static int
1740do_accept(struct tcb *tcp, int flags_arg)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001741{
1742 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001743 printfd(tcp, tcp->u_arg[0]);
1744 tprints(", ");
Paolo Bonzini705ff102009-08-14 12:34:05 +02001745 return 0;
1746 }
1747 if (!tcp->u_arg[2])
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001748 tprintf("%#lx, NULL", tcp->u_arg[1]);
1749 else {
Dmitry V. Levin2fc66152009-01-01 22:47:51 +00001750 int len;
1751 if (tcp->u_arg[1] == 0 || syserror(tcp)
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001752 || umove(tcp, tcp->u_arg[2], &len) < 0) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001753 tprintf("%#lx", tcp->u_arg[1]);
1754 } else {
Dmitry V. Levin2fc66152009-01-01 22:47:51 +00001755 printsock(tcp, tcp->u_arg[1], len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001756 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001757 tprints(", ");
Dmitry V. Levin2fc66152009-01-01 22:47:51 +00001758 printnum_int(tcp, tcp->u_arg[2], "%u");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001759 }
Paolo Bonzini705ff102009-08-14 12:34:05 +02001760 if (flags_arg >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001761 tprints(", ");
Paolo Bonzini705ff102009-08-14 12:34:05 +02001762 printflags(sock_type_flags, tcp->u_arg[flags_arg],
1763 "SOCK_???");
1764 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001765 return 0;
1766}
1767
1768int
Paolo Bonzini705ff102009-08-14 12:34:05 +02001769sys_accept(struct tcb *tcp)
1770{
1771 return do_accept(tcp, -1);
1772}
1773
Paolo Bonzini705ff102009-08-14 12:34:05 +02001774int
1775sys_accept4(struct tcb *tcp)
1776{
1777 return do_accept(tcp, 3);
1778}
Paolo Bonzini705ff102009-08-14 12:34:05 +02001779
1780int
Denys Vlasenko12014262011-05-30 14:00:14 +02001781sys_send(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001782{
1783 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001784 printfd(tcp, tcp->u_arg[0]);
1785 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001786 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1787 tprintf(", %lu, ", tcp->u_arg[2]);
1788 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +00001789 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001790 }
1791 return 0;
1792}
1793
1794int
Denys Vlasenko12014262011-05-30 14:00:14 +02001795sys_sendto(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001796{
1797 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001798 printfd(tcp, tcp->u_arg[0]);
1799 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001800 printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
1801 tprintf(", %lu, ", tcp->u_arg[2]);
1802 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +00001803 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001804 /* to address */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001805 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001806 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001807 /* to length */
1808 tprintf(", %lu", tcp->u_arg[5]);
1809 }
1810 return 0;
1811}
1812
1813#ifdef HAVE_SENDMSG
1814
1815int
Denys Vlasenko12014262011-05-30 14:00:14 +02001816sys_sendmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001817{
1818 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001819 printfd(tcp, tcp->u_arg[0]);
1820 tprints(", ");
Dmitry V. Levin043b5f82012-05-01 20:30:02 +00001821 printmsghdr(tcp, tcp->u_arg[1], (unsigned long) -1L);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001822 /* flags */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001823 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001824 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001825 }
1826 return 0;
1827}
1828
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001829int
1830sys_sendmmsg(struct tcb *tcp)
1831{
1832 if (entering(tcp)) {
1833 /* sockfd */
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001834 printfd(tcp, tcp->u_arg[0]);
1835 tprints(", ");
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001836 if (!verbose(tcp)) {
1837 tprintf("%#lx, %u, ",
1838 tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
1839 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
1840 }
1841 } else {
1842 if (verbose(tcp))
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001843 decode_mmsg(tcp, (unsigned long) -1L);
Dmitry V. Levin7af9f352012-03-11 23:59:29 +00001844 }
1845 return 0;
1846}
1847
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001848#endif /* HAVE_SENDMSG */
1849
1850int
Denys Vlasenko12014262011-05-30 14:00:14 +02001851sys_recv(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001852{
1853 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001854 printfd(tcp, tcp->u_arg[0]);
1855 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001856 } else {
1857 if (syserror(tcp))
1858 tprintf("%#lx", tcp->u_arg[1]);
1859 else
1860 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1861
1862 tprintf(", %lu, ", tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +00001863 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001864 }
1865 return 0;
1866}
1867
1868int
Denys Vlasenko12014262011-05-30 14:00:14 +02001869sys_recvfrom(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001870{
1871 int fromlen;
1872
1873 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001874 printfd(tcp, tcp->u_arg[0]);
1875 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001876 } else {
1877 if (syserror(tcp)) {
1878 tprintf("%#lx, %lu, %lu, %#lx, %#lx",
1879 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3],
1880 tcp->u_arg[4], tcp->u_arg[5]);
1881 return 0;
1882 }
1883 /* buf */
1884 printstr(tcp, tcp->u_arg[1], tcp->u_rval);
1885 /* len */
1886 tprintf(", %lu, ", tcp->u_arg[2]);
1887 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +00001888 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001889 /* from address, len */
1890 if (!tcp->u_arg[4] || !tcp->u_arg[5]) {
1891 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001892 tprints(", NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001893 else
1894 tprintf(", %#lx", tcp->u_arg[4]);
1895 if (tcp->u_arg[5] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001896 tprints(", NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001897 else
1898 tprintf(", %#lx", tcp->u_arg[5]);
1899 return 0;
1900 }
1901 if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001902 tprints(", {...}, [?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001903 return 0;
1904 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001905 tprints(", ");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +00001906 printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001907 /* from length */
1908 tprintf(", [%u]", fromlen);
1909 }
1910 return 0;
1911}
1912
1913#ifdef HAVE_SENDMSG
1914
1915int
Denys Vlasenko12014262011-05-30 14:00:14 +02001916sys_recvmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001917{
1918 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001919 printfd(tcp, tcp->u_arg[0]);
1920 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001921 } else {
1922 if (syserror(tcp) || !verbose(tcp))
1923 tprintf("%#lx", tcp->u_arg[1]);
1924 else
Denys Vlasenkoe0bc2222012-04-28 14:26:18 +02001925 printmsghdr(tcp, tcp->u_arg[1], tcp->u_rval);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001926 /* flags */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001927 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +00001928 printflags(msg_flags, tcp->u_arg[2], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001929 }
1930 return 0;
1931}
1932
Andreas Schwab0873f292010-02-12 21:39:12 +01001933int
1934sys_recvmmsg(struct tcb *tcp)
1935{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01001936 /* +5 chars are for "left " prefix */
1937 static char str[5 + TIMESPEC_TEXT_BUFSIZE];
Dmitry V. Levine6591032010-03-29 20:45:48 +04001938
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01001939 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001940 printfd(tcp, tcp->u_arg[0]);
1941 tprints(", ");
Dmitry V. Levine6591032010-03-29 20:45:48 +04001942 if (verbose(tcp)) {
1943 sprint_timespec(str, tcp, tcp->u_arg[4]);
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01001944 /* Abusing tcp->auxstr as temp storage.
1945 * Will be used and freed on syscall exit.
1946 */
Dmitry V. Levine6591032010-03-29 20:45:48 +04001947 tcp->auxstr = strdup(str);
1948 } else {
1949 tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
1950 printflags(msg_flags, tcp->u_arg[3], "MSG_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02001951 tprints(", ");
Dmitry V. Levine6591032010-03-29 20:45:48 +04001952 print_timespec(tcp, tcp->u_arg[4]);
1953 }
1954 return 0;
1955 } else {
1956 if (verbose(tcp)) {
Dmitry V. Levin5ea97652012-05-01 20:41:40 +00001957 decode_mmsg(tcp, 0);
Dmitry V. Levine6591032010-03-29 20:45:48 +04001958 /* timeout on entrance */
1959 tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
1960 free((void *) tcp->auxstr);
1961 tcp->auxstr = NULL;
1962 }
1963 if (syserror(tcp))
1964 return 0;
1965 if (tcp->u_rval == 0) {
1966 tcp->auxstr = "Timeout";
1967 return RVAL_STR;
1968 }
1969 if (!verbose(tcp))
1970 return 0;
1971 /* timeout on exit */
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +01001972 sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]);
Dmitry V. Levine6591032010-03-29 20:45:48 +04001973 tcp->auxstr = str;
1974 return RVAL_STR;
Andreas Schwab0873f292010-02-12 21:39:12 +01001975 }
Andreas Schwab0873f292010-02-12 21:39:12 +01001976}
Andreas Schwab0873f292010-02-12 21:39:12 +01001977
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001978#endif /* HAVE_SENDMSG */
1979
Sebastian Pipping9cd38502011-03-03 01:12:25 +01001980static const struct xlat shutdown_modes[] = {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02001981 { 0, "SHUT_RD" },
1982 { 1, "SHUT_WR" },
1983 { 2, "SHUT_RDWR" },
Dmitry V. Levin59452732014-02-05 02:20:51 +00001984 XLAT_END
Sebastian Pipping9cd38502011-03-03 01:12:25 +01001985};
1986
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001987int
Denys Vlasenko12014262011-05-30 14:00:14 +02001988sys_shutdown(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001989{
1990 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001991 printfd(tcp, tcp->u_arg[0]);
1992 tprints(", ");
Sebastian Pipping9cd38502011-03-03 01:12:25 +01001993 printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001994 }
1995 return 0;
1996}
1997
1998int
Denys Vlasenko12014262011-05-30 14:00:14 +02001999sys_getsockname(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002000{
2001 return sys_accept(tcp);
2002}
2003
2004int
Denys Vlasenko12014262011-05-30 14:00:14 +02002005sys_getpeername(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002006{
2007 return sys_accept(tcp);
2008}
2009
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002010static int
2011do_pipe(struct tcb *tcp, int flags_arg)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002012{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002013 if (exiting(tcp)) {
2014 if (syserror(tcp)) {
2015 tprintf("%#lx", tcp->u_arg[0]);
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002016 } else {
Denys Vlasenko84703742012-02-25 02:38:52 +01002017#if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64)
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002018 int fds[2];
2019
2020 if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002021 tprints("[...]");
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002022 else
2023 tprintf("[%u, %u]", fds[0], fds[1]);
Denys Vlasenko84703742012-02-25 02:38:52 +01002024#elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64)
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002025 tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
2026#else
2027 tprintf("%#lx", tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002028#endif
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002029 }
2030 if (flags_arg >= 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002031 tprints(", ");
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002032 printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
2033 }
2034 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002035 return 0;
2036}
2037
2038int
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002039sys_pipe(struct tcb *tcp)
2040{
2041 return do_pipe(tcp, -1);
2042}
2043
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002044int
2045sys_pipe2(struct tcb *tcp)
2046{
2047 return do_pipe(tcp, 1);
2048}
Dmitry V. Levin4371b102008-11-10 22:53:02 +00002049
2050int
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00002051sys_socketpair(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002052{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002053 int fds[2];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002054
2055 if (entering(tcp)) {
2056 printxval(domains, tcp->u_arg[0], "PF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002057 tprints(", ");
Dmitry V. Levin8a550d72008-11-10 17:21:23 +00002058 tprint_sock_type(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002059 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002060 switch (tcp->u_arg[0]) {
2061 case PF_INET:
2062 printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
2063 break;
2064#ifdef PF_IPX
2065 case PF_IPX:
2066 /* BTW: I don't believe this.. */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002067 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002068 printxval(domains, tcp->u_arg[2], "PF_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002069 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002070 break;
2071#endif /* PF_IPX */
Roland McGrath6d2b3492002-12-30 00:51:30 +00002072 default:
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00002073 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002074 break;
2075 }
2076 } else {
2077 if (syserror(tcp)) {
Wichert Akkerman2e2553a1999-05-09 00:29:58 +00002078 tprintf(", %#lx", tcp->u_arg[3]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002079 return 0;
2080 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002081 if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002082 tprints(", [...]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002083 else
2084 tprintf(", [%u, %u]", fds[0], fds[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002085 }
2086 return 0;
2087}
2088
2089int
Dmitry V. Levin31289192009-11-06 18:05:40 +00002090sys_getsockopt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002091{
2092 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08002093 printfd(tcp, tcp->u_arg[0]);
2094 tprints(", ");
John Hughes93f7fcc2002-05-22 15:46:49 +00002095 printxval(socketlayers, tcp->u_arg[1], "SOL_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002096 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002097 switch (tcp->u_arg[1]) {
2098 case SOL_SOCKET:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002099 printxval(sockoptions, tcp->u_arg[2], "SO_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002100 break;
2101#ifdef SOL_IP
2102 case SOL_IP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002103 printxval(sockipoptions, tcp->u_arg[2], "IP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002104 break;
2105#endif
Roland McGrath4f6ba692004-08-31 07:01:26 +00002106#ifdef SOL_IPV6
2107 case SOL_IPV6:
2108 printxval(sockipv6options, tcp->u_arg[2], "IPV6_???");
2109 break;
2110#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002111#ifdef SOL_IPX
2112 case SOL_IPX:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002113 printxval(sockipxoptions, tcp->u_arg[2], "IPX_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002114 break;
2115#endif
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002116#ifdef SOL_PACKET
2117 case SOL_PACKET:
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002118 printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002119 break;
2120#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002121#ifdef SOL_TCP
2122 case SOL_TCP:
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002123 printxval(socktcpoptions, tcp->u_arg[2], "TCP_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002124 break;
2125#endif
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01002126#ifdef SOL_SCTP
2127 case SOL_SCTP:
2128 printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???");
2129 break;
2130#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002131
2132 /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
2133 * etc. still need work */
Roland McGrath6d2b3492002-12-30 00:51:30 +00002134 default:
John Hughes93f7fcc2002-05-22 15:46:49 +00002135 tprintf("%lu", tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002136 break;
2137 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002138 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002139 } else {
Roland McGrathfc544db2005-02-02 02:48:57 +00002140 int len;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002141 if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
Dmitry V. Levin31289192009-11-06 18:05:40 +00002142 tprintf("%#lx, %#lx",
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002143 tcp->u_arg[3], tcp->u_arg[4]);
2144 return 0;
2145 }
John Hughes93f7fcc2002-05-22 15:46:49 +00002146
2147 switch (tcp->u_arg[1]) {
2148 case SOL_SOCKET:
2149 switch (tcp->u_arg[2]) {
2150#ifdef SO_LINGER
2151 case SO_LINGER:
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002152 if (len == sizeof(struct linger)) {
John Hughes93f7fcc2002-05-22 15:46:49 +00002153 struct linger linger;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002154 if (umove(tcp,
John Hughes93f7fcc2002-05-22 15:46:49 +00002155 tcp->u_arg[3],
2156 &linger) < 0)
2157 break;
Dmitry V. Levin31289192009-11-06 18:05:40 +00002158 tprintf("{onoff=%d, linger=%d}, "
Roland McGrath96ad7b82005-02-02 03:11:32 +00002159 "[%d]",
John Hughes93f7fcc2002-05-22 15:46:49 +00002160 linger.l_onoff,
2161 linger.l_linger,
2162 len);
2163 return 0;
2164 }
2165 break;
2166#endif
Dmitry V. Levin0ddd8ad2010-12-03 16:54:53 +00002167#ifdef SO_PEERCRED
2168 case SO_PEERCRED:
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002169 if (len == sizeof(struct ucred)) {
Dmitry V. Levin0ddd8ad2010-12-03 16:54:53 +00002170 struct ucred uc;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002171 if (umove(tcp,
Dmitry V. Levin0ddd8ad2010-12-03 16:54:53 +00002172 tcp->u_arg[3],
2173 &uc) < 0)
2174 break;
2175 tprintf("{pid=%ld, uid=%ld, gid=%ld}, "
2176 "[%d]",
2177 (long)uc.pid,
2178 (long)uc.uid,
2179 (long)uc.gid,
2180 len);
2181 return 0;
2182 }
2183 break;
2184#endif
John Hughes93f7fcc2002-05-22 15:46:49 +00002185 }
2186 break;
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002187 case SOL_PACKET:
2188 switch (tcp->u_arg[2]) {
2189#ifdef PACKET_STATISTICS
2190 case PACKET_STATISTICS:
2191 if (len == sizeof(struct tpacket_stats)) {
2192 struct tpacket_stats stats;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002193 if (umove(tcp,
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002194 tcp->u_arg[3],
2195 &stats) < 0)
2196 break;
2197 tprintf("{packets=%u, drops=%u}, "
2198 "[%d]",
2199 stats.tp_packets,
2200 stats.tp_drops,
2201 len);
2202 return 0;
2203 }
2204 break;
2205#endif
2206 }
2207 break;
John Hughes93f7fcc2002-05-22 15:46:49 +00002208 }
2209
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002210 if (len == sizeof(int)) {
Dmitry V. Levin31289192009-11-06 18:05:40 +00002211 printnum_int(tcp, tcp->u_arg[3], "%d");
John Hughes93f7fcc2002-05-22 15:46:49 +00002212 }
2213 else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002214 printstr(tcp, tcp->u_arg[3], len);
John Hughes93f7fcc2002-05-22 15:46:49 +00002215 }
Roland McGrathfc544db2005-02-02 02:48:57 +00002216 tprintf(", [%d]", len);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002217 }
2218 return 0;
2219}
2220
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002221#if defined(ICMP_FILTER)
Denys Vlasenko12014262011-05-30 14:00:14 +02002222static void printicmpfilter(struct tcb *tcp, long addr)
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002223{
2224 struct icmp_filter filter;
2225
2226 if (!addr) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002227 tprints("NULL");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002228 return;
2229 }
2230 if (syserror(tcp) || !verbose(tcp)) {
2231 tprintf("%#lx", addr);
2232 return;
2233 }
2234 if (umove(tcp, addr, &filter) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002235 tprints("{...}");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002236 return;
2237 }
2238
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002239 tprints("~(");
Roland McGrathb2dee132005-06-01 19:02:36 +00002240 printflags(icmpfilterflags, ~filter.data, "ICMP_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002241 tprints(")");
Wichert Akkerman7987cdf2000-07-05 16:05:39 +00002242}
2243#endif /* ICMP_FILTER */
2244
John Hughes38ae88d2002-05-23 11:48:58 +00002245static int
Denys Vlasenko12014262011-05-30 14:00:14 +02002246printsockopt(struct tcb *tcp, int level, int name, long addr, int len)
John Hughes38ae88d2002-05-23 11:48:58 +00002247{
2248 printxval(socketlayers, level, "SOL_??");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002249 tprints(", ");
John Hughes38ae88d2002-05-23 11:48:58 +00002250 switch (level) {
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002251 case SOL_SOCKET:
John Hughes38ae88d2002-05-23 11:48:58 +00002252 printxval(sockoptions, name, "SO_???");
2253 switch (name) {
2254#if defined(SO_LINGER)
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002255 case SO_LINGER:
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002256 if (len == sizeof(struct linger)) {
John Hughes38ae88d2002-05-23 11:48:58 +00002257 struct linger linger;
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002258 if (umove(tcp, addr, &linger) < 0)
John Hughes38ae88d2002-05-23 11:48:58 +00002259 break;
2260 tprintf(", {onoff=%d, linger=%d}",
2261 linger.l_onoff,
2262 linger.l_linger);
2263 return 0;
2264 }
2265 break;
2266#endif
2267 }
2268 break;
2269#ifdef SOL_IP
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002270 case SOL_IP:
John Hughes38ae88d2002-05-23 11:48:58 +00002271 printxval(sockipoptions, name, "IP_???");
2272 break;
2273#endif
Roland McGrath4f6ba692004-08-31 07:01:26 +00002274#ifdef SOL_IPV6
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002275 case SOL_IPV6:
Roland McGrath4f6ba692004-08-31 07:01:26 +00002276 printxval(sockipv6options, name, "IPV6_???");
2277 break;
2278#endif
John Hughes38ae88d2002-05-23 11:48:58 +00002279#ifdef SOL_IPX
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002280 case SOL_IPX:
John Hughes38ae88d2002-05-23 11:48:58 +00002281 printxval(sockipxoptions, name, "IPX_???");
2282 break;
2283#endif
2284#ifdef SOL_PACKET
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002285 case SOL_PACKET:
John Hughes38ae88d2002-05-23 11:48:58 +00002286 printxval(sockpacketoptions, name, "PACKET_???");
2287 /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002288 switch (name) {
2289#ifdef PACKET_RX_RING
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002290 case PACKET_RX_RING:
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002291#endif
2292#ifdef PACKET_TX_RING
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002293 case PACKET_TX_RING:
Dmitry V. Levinca75bd62009-11-13 12:51:04 +00002294#endif
2295#if defined(PACKET_RX_RING) || defined(PACKET_TX_RING)
2296 if (len == sizeof(struct tpacket_req)) {
2297 struct tpacket_req req;
2298 if (umove(tcp, addr, &req) < 0)
2299 break;
2300 tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}",
2301 req.tp_block_size,
2302 req.tp_block_nr,
2303 req.tp_frame_size,
2304 req.tp_frame_nr);
2305 return 0;
2306 }
2307 break;
2308#endif /* PACKET_RX_RING || PACKET_TX_RING */
2309 }
John Hughes38ae88d2002-05-23 11:48:58 +00002310 break;
2311#endif
2312#ifdef SOL_TCP
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002313 case SOL_TCP:
John Hughes38ae88d2002-05-23 11:48:58 +00002314 printxval(socktcpoptions, name, "TCP_???");
2315 break;
2316#endif
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01002317#ifdef SOL_SCTP
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002318 case SOL_SCTP:
Holger Hans Peter Freyther7fea79b2011-01-14 11:08:12 +01002319 printxval(socksctpoptions, name, "SCTP_???");
2320 break;
2321#endif
John Hughes38ae88d2002-05-23 11:48:58 +00002322#ifdef SOL_RAW
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002323 case SOL_RAW:
John Hughes38ae88d2002-05-23 11:48:58 +00002324 printxval(sockrawoptions, name, "RAW_???");
2325 switch (name) {
2326#if defined(ICMP_FILTER)
Denys Vlasenkob237b1b2012-02-27 13:56:59 +01002327 case ICMP_FILTER:
2328 tprints(", ");
2329 printicmpfilter(tcp, addr);
2330 return 0;
John Hughes38ae88d2002-05-23 11:48:58 +00002331#endif
2332 }
2333 break;
2334#endif
2335
Roland McGrath6d2b3492002-12-30 00:51:30 +00002336 /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
John Hughes38ae88d2002-05-23 11:48:58 +00002337 * etc. still need work */
2338
Denys Vlasenko989ebc92012-03-17 04:42:07 +01002339 default:
John Hughes38ae88d2002-05-23 11:48:58 +00002340 tprintf("%u", name);
2341 }
2342
2343 /* default arg printing */
2344
Denys Vlasenko60fe8c12011-09-01 10:00:28 +02002345 tprints(", ");
Roland McGrath6d2b3492002-12-30 00:51:30 +00002346
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002347 if (len == sizeof(int)) {
2348 printnum_int(tcp, addr, "%d");
John Hughes38ae88d2002-05-23 11:48:58 +00002349 }
2350 else {
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002351 printstr(tcp, addr, len);
John Hughes38ae88d2002-05-23 11:48:58 +00002352 }
2353 return 0;
2354}
2355
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002356int
Denys Vlasenko12014262011-05-30 14:00:14 +02002357sys_setsockopt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002358{
2359 if (entering(tcp)) {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08002360 printfd(tcp, tcp->u_arg[0]);
2361 tprints(", ");
Denys Vlasenkob63256e2011-06-07 12:13:24 +02002362 printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
John Hughes38ae88d2002-05-23 11:48:58 +00002363 tcp->u_arg[3], tcp->u_arg[4]);
John Hughes93f7fcc2002-05-22 15:46:49 +00002364 tprintf(", %lu", tcp->u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002365 }
2366 return 0;
2367}