summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/brand/lx/sys/lx_socket.h
blob: 9fa574439ced3b3ca1d683fba6be54552e84bfb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright 2015 Joyent, Inc.
 */

#ifndef _SYS_LX_SOCKET_H
#define	_SYS_LX_SOCKET_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Linux address family definitions
 * Some of these are not supported
 */
#define	LX_AF_UNSPEC		0  /* Unspecified */
#define	LX_AF_UNIX		1  /* local file/pipe name */
#define	LX_AF_INET		2  /* IP protocol family */
#define	LX_AF_AX25		3  /* Amateur Radio AX.25 */
#define	LX_AF_IPX		4  /* Novell Internet Protocol */
#define	LX_AF_APPLETALK		5  /* Appletalk */
#define	LX_AF_NETROM		6  /* Amateur radio */
#define	LX_AF_BRIDGE		7  /* Multiprotocol bridge */
#define	LX_AF_ATMPVC		8  /* ATM PVCs */
#define	LX_AF_X25		9  /* X.25 */
#define	LX_AF_INET6		10 /* IPV 6 */
#define	LX_AF_ROSE		11 /* Amateur Radio X.25 */
#define	LX_AF_DECNET		12 /* DECnet */
#define	LX_AF_NETBEUI		13 /* 802.2LLC */
#define	LX_AF_SECURITY		14 /* Security callback */
#define	LX_AF_KEY		15 /* key management */
#define	LX_AF_ROUTE		16 /* Alias to emulate 4.4BSD */
#define	LX_AF_NETLINK		LX_AF_ROUTE
#define	LX_AF_PACKET		17 /* Packet family */
#define	LX_AF_ASH		18 /* Ash ? */
#define	LX_AF_ECONET		19 /* Acorn Econet */
#define	LX_AF_ATMSVC		20 /* ATM SVCs */
#define	LX_AF_SNA		22 /* Linux SNA */
#define	LX_AF_IRDA		23 /* IRDA sockets */
#define	LX_AF_PPPOX		24 /* PPPoX sockets */
#define	LX_AF_WANPIPE		25 /* Wanpipe API sockets */
#define	LX_AF_LLC		26
/* gap in Linux defines for 27 and 28 */
#define	LX_AF_CAN		29
#define	LX_AF_TIPC		30
#define	LX_AF_BLUETOOTH		31 /* Bluetooth sockets */
#define	LX_AF_IUCV		32
#define	LX_AF_RXRPC		33

/* limit of AF mappings */
#define	LX_AF_MAX		LX_AF_RXRPC

#define	AF_NOTSUPPORTED		-1
#define	AF_INVAL		-2

/*
 * Options for use with [gs]etsockopt at the SOL_SOCKET level.
 */
#define	LX_SOL_SOCKET				1

#define	LX_SCM_RIGHTS				1
#define	LX_SCM_CRED				2

#define	LX_SO_DEBUG				1
#define	LX_SO_REUSEADDR				2
#define	LX_SO_TYPE				3
#define	LX_SO_ERROR				4
#define	LX_SO_DONTROUTE				5
#define	LX_SO_BROADCAST				6
#define	LX_SO_SNDBUF				7
#define	LX_SO_RCVBUF				8
#define	LX_SO_KEEPALIVE				9
#define	LX_SO_OOBINLINE				10
#define	LX_SO_NO_CHECK				11
#define	LX_SO_PRIORITY				12
#define	LX_SO_LINGER				13
#define	LX_SO_BSDCOMPAT				14
#define	LX_SO_REUSEPORT				15
/*
 * For Linux see unix(7) man page SO_PASSCRED description. For Illumos see
 * socket.h(3HEAD) man page SO_RECVUCRED description.
 */
#define	LX_SO_PASSCRED				16
#define	LX_SO_PEERCRED				17
#define	LX_SO_RCVLOWAT				18
#define	LX_SO_SNDLOWAT				19
#define	LX_SO_RCVTIMEO				20
#define	LX_SO_SNDTIMEO				21
/* Security levels - as per NRL IPv6 - don't actually do anything */
#define	LX_SO_SECURITY_AUTHENTICATION		22
#define	LX_SO_SECURITY_ENCRYPTION_TRANSPORT	23
#define	LX_SO_SECURITY_ENCRYPTION_NETWORK	24
#define	LX_SO_BINDTODEVICE			25
/* Socket filtering */
#define	LX_SO_ATTACH_FILTER			26
#define	LX_SO_DETACH_FILTER			27
#define	LX_SO_PEERNAME				28
#define	LX_SO_TIMESTAMP				29
#define	LX_SCM_TIMESTAMP			LX_SO_TIMESTAMP
#define	LX_SO_ACCEPTCONN			30

#define	LX_SO_PEERSEC				31
#define	LX_SO_SNDBUFFORCE			32
#define	LX_SO_RCVBUFFORCE			33
#define	LX_SO_PASSSEC				34
#define	LX_SO_TIMESTAMPNS			35
#define	LX_SCM_TIMESTAMPNS			LX_SO_TIMESTAMPNS
#define	LX_SO_MARK				36
#define	LX_SO_TIMESTAMPING			37
#define	LX_SCM_TIMESTAMPING			LX_SO_TIMESTAMPING
#define	LX_SO_PROTOCOL				38
#define	LX_SO_DOMAIN				39
#define	LX_SO_RXQ_OVFL				40
#define	LX_SO_WIFI_STATUS			41
#define	LX_SCM_WIFI_STATUS			LX_SO_WIFI_STATUS
#define	LX_SO_PEEK_OFF				42
#define	LX_SO_NOFCS				43
#define	LX_SO_LOCK_FILTER			44
#define	LX_SO_SELECT_ERR_QUEUE			45
#define	LX_SO_BUSY_POLL				46
#define	LX_SO_MAX_PACING_RATE			47
#define	LX_SO_BPF_EXTENSIONS			48

/*
 * PF_PACKET protocol definitions.
 */
#define	LX_ETH_P_802_3	0x0001
#define	LX_ETH_P_ALL	0x0003
#define	LX_ETH_P_802_2	0x0004
#define	LX_ETH_P_IP	0x0800
#define	LX_ETH_P_ARP	0x0806
#define	LX_ETH_P_IPV6	0x86DD

/*
 * IP Protocol levels. Some of these match the Illumos IPPROTO_* values.
 */
#define	LX_IPPROTO_IP		0
#define	LX_IPPROTO_ICMP		1
#define	LX_IPPROTO_IGMP		2
#define	LX_IPPROTO_TCP		6
#define	LX_IPPROTO_UDP		17
#define	LX_IPPROTO_IPV6		41
#define	LX_IPPROTO_ICMPV6	58
#define	LX_IPPROTO_RAW		255

/*
 * Options for use with [gs]etsockopt at the IP level.
 * IPPROTO_IP
 */
#define	LX_IP_TOS		1
#define	LX_IP_TTL		2
#define	LX_IP_HDRINCL		3
#define	LX_IP_OPTIONS		4
#define	LX_IP_ROUTER_ALERT	5
#define	LX_IP_RECVOPTS		6
#define	LX_IP_RETOPTS		7
#define	LX_IP_PKTINFO		8
#define	LX_IP_PKTOPTIONS	9
#define	LX_IP_MTU_DISCOVER	10
#define	LX_IP_RECVERR		11
#define	LX_IP_RECVTTL		12
#define	LX_IP_RECVTOS		13
#define	LX_IP_MTU		14
#define	LX_IP_FREEBIND		15
#define	LX_IP_IPSEC_POLICY	16
#define	LX_IP_XFRM_POLICY	17
#define	LX_IP_PASSSEC		18
#define	LX_IP_TRANSPARENT	19
#define	LX_IP_ORIGDSTADDR	20
#define	LX_IP_MINTTL		21
#define	LX_IP_NODEFRAG		22
/* Linux apparently leaves a gap here */
#define	LX_IP_MULTICAST_IF	32
#define	LX_IP_MULTICAST_TTL	33
#define	LX_IP_MULTICAST_LOOP	34
#define	LX_IP_ADD_MEMBERSHIP	35
#define	LX_IP_DROP_MEMBERSHIP	36
#define	LX_IP_UNBLOCK_SOURC	37
#define	LX_IP_BLOCK_SOURCE	38
#define	LX_IP_ADD_SOURCE_MEMBERSHIP 39
#define	LX_IP_DROP_SOURCE_MEMBERSHIP 40
#define	LX_IP_MSFILTER		41
#define	LX_MCAST_JOIN_GROUP	42
#define	LX_MCAST_BLOCK_SOURCE	43
#define	LX_MCAST_UNBLOCK_SOURCE	44
#define	LX_MCAST_LEAVE_GROUP	45
#define	LX_MCAST_JOIN_SOURCE_GROUP 46
#define	LX_MCAST_LEAVE_SOURCE_GROUP 47
#define	LX_MCAST_MSFILTER	48
#define	LX_IP_MULTICAST_ALL	49
#define	LX_IP_UNICAST_IF	50

/*
 * Options for use with [gs]etsockopt at the IP level.
 * IPPROTO_IPV6
 */

#define	LX_IPV6_ADDRFORM	1
#define	LX_IPV6_2292PKTINFO	2
#define	LX_IPV6_2292HOPOPTS	3
#define	LX_IPV6_2292DSTOPTS	4
#define	LX_IPV6_2292RTHDR	5
#define	LX_IPV6_2292PKTOPTIONS	6
#define	LX_IPV6_CHECKSUM	7
#define	LX_IPV6_2292HOPLIMIT	8
#define	LX_IPV6_NEXTHOP		9
#define	LX_IPV6_AUTHHDR		10
#define	LX_IPV6_UNICAST_HOPS	16
#define	LX_IPV6_MULTICAST_IF	17
#define	LX_IPV6_MULTICAST_HOPS	18
#define	LX_IPV6_MULTICAST_LOOP	19
#define	LX_IPV6_JOIN_GROUP	20
#define	LX_IPV6_LEAVE_GROUP	21
#define	LX_IPV6_ROUTER_ALERT	22
#define	LX_IPV6_MTU_DISCOVER	23
#define	LX_IPV6_MTU		24
#define	LX_IPV6_RECVERR		25
#define	LX_IPV6_V6ONLY		26
#define	LX_IPV6_JOIN_ANYCAST	27
#define	LX_IPV6_LEAVE_ANYCAST	28
#define	LX_IPV6_IPSEC_POLICY	34
#define	LX_IPV6_XFRM_POLICY	35

#define	LX_IPV6_RECVPKTINFO	49
#define	LX_IPV6_PKTINFO		50
#define	LX_IPV6_RECVHOPLIMIT	51
#define	LX_IPV6_HOPLIMIT	52
#define	LX_IPV6_RECVHOPOPTS	53
#define	LX_IPV6_HOPOPTS		54
#define	LX_IPV6_RTHDRDSTOPTS	55
#define	LX_IPV6_RECVRTHDR	56
#define	LX_IPV6_RTHDR		57
#define	LX_IPV6_RECVDSTOPTS	58
#define	LX_IPV6_DSTOPTS		59
#define	LX_IPV6_RECVTCLASS	66
#define	LX_IPV6_TCLASS		67

/*
 * Linux socket flags for use with recv(2)/send(2)/recvmsg(2)/sendmsg(2)
 */
#define	LX_MSG_OOB		0x1
#define	LX_MSG_PEEK		0x2
#define	LX_MSG_DONTROUTE	0x4
#define	LX_MSG_CTRUNC		0x8
#define	LX_MSG_PROXY		0x10
#define	LX_MSG_TRUNC		0x20
#define	LX_MSG_DONTWAIT		0x40
#define	LX_MSG_EOR		0x80
#define	LX_MSG_WAITALL		0x100
#define	LX_MSG_FIN		0x200
#define	LX_MSG_SYN		0x400
#define	LX_MSG_CONFIRM		0x800
#define	LX_MSG_RST		0x1000
#define	LX_MSG_ERRQUEUE		0x2000
#define	LX_MSG_NOSIGNAL		0x4000
#define	LX_MSG_MORE		0x8000
#define	LX_MSG_WAITFORONE	0x10000
#define	LX_MSG_FASTOPEN		0x20000000
#define	LX_MSG_CMSG_CLOEXEC	0x40000000

typedef struct lx_msghdr {
	void		*msg_name;	/* optional address */
	socklen_t	msg_namelen;	/* size of address */
	struct iovec	*msg_iov;	/* scatter/gather array */
	int		msg_iovlen;	/* # elements in msg_iov */
	void		*msg_control;	/* ancillary data */
	socklen_t	msg_controllen;	/* ancillary data buffer len */
	int		msg_flags;	/* flags on received message */
} lx_msghdr_t;


#if defined(_LP64)

typedef struct lx_msghdr32 {
	caddr32_t	msg_name;	/* optional address */
	uint32_t	msg_namelen;	/* size of address */
	caddr32_t	msg_iov;	/* scatter/gather array */
	int32_t		msg_iovlen;	/* # elements in msg_iov */
	caddr32_t	msg_control;	/* ancillary data */
	uint32_t	msg_controllen;	/* ancillary data buffer len */
	int32_t		msg_flags;	/* flags on received message */
} lx_msghdr32_t;

#endif

typedef struct lx_sockaddr_in6 {
	sa_family_t	sin6_family;
	in_port_t	sin6_port;
	uint32_t	sin6_flowinfo;
	struct in6_addr	sin6_addr;
	uint32_t	sin6_scope_id;  /* Depends on scope of sin6_addr */
	/* one 32-bit field shorter than illumos */
} lx_sockaddr_in6_t;

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_LX_SOCKET_H */