1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifndef _SYS_LX_SOCKET_H
27 #define _SYS_LX_SOCKET_H
28
29 #pragma ident "%Z%%M% %I% %E% SMI"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <sys/lx_types.h>
36
37 /*
38 * Linux address family definitions
39 * Some of these are not supported
40 */
41 #define LX_AF_UNSPEC 0 /* Unspecified */
42 #define LX_AF_UNIX 1 /* local file/pipe name */
43 #define LX_AF_INET 2 /* IP protocol family */
44 #define LX_AF_AX25 3 /* Amateur Radio AX.25 */
45 #define LX_AF_IPX 4 /* Novell Internet Protocol */
46 #define LX_AF_APPLETALK 5 /* Appletalk */
47 #define LX_AF_NETROM 6 /* Amateur radio */
48 #define LX_AF_BRIDGE 7 /* Multiprotocol bridge */
49 #define LX_AF_ATMPVC 8 /* ATM PVCs */
50 #define LX_AF_X25 9 /* X.25 */
51 #define LX_AF_INET6 10 /* IPV 6 */
52 #define LX_AF_ROSE 11 /* Amateur Radio X.25 */
53 #define LX_AF_DECnet 12 /* DECnet */
54 #define LX_AF_NETBEUI 13 /* 802.2LLC */
55 #define LX_AF_SECURITY 14 /* Security callback */
56 #define LX_AF_KEY 15 /* key management */
57 #define LX_AF_ROUTE 16 /* Alias to emulate 4.4BSD */
58 #define LX_AF_PACKET 17 /* Packet family */
59 #define LX_AF_ASH 18 /* Ash ? */
60 #define LX_AF_ECONET 19 /* Acorn Econet */
61 #define LX_AF_ATMSVC 20 /* ATM SVCs */
62 #define LX_AF_SNA 22 /* Linux SNA */
63 #define LX_AF_IRDA 23 /* IRDA sockets */
64 #define LX_AF_PPPOX 24 /* PPPoX sockets */
65 #define LX_AF_WANPIPE 25 /* Wanpipe API sockets */
66 #define LX_AF_BLUETOOTH 31 /* Bluetooth sockets */
67 #define LX_AF_MAX 32 /* MAX socket type */
68
69 #define AF_NOTSUPPORTED -1
70 #define AF_INVAL -2
71
72 /*
73 * Linux ARP protocol hardware identifiers
74 */
75 #define LX_ARPHRD_ETHER 1 /* Ethernet */
76 #define LX_ARPHRD_LOOPBACK 772 /* Loopback */
77 #define LX_ARPHRD_VOID 0xffff /* Unknown */
78
79 /*
80 * Linux socket type definitions
81 */
82 #define LX_SOCK_STREAM 1 /* Connection-based byte streams */
83 #define LX_SOCK_DGRAM 2 /* Connectionless, datagram */
84 #define LX_SOCK_RAW 3 /* Raw protocol interface */
85 #define LX_SOCK_RDM 4 /* Reliably-delivered message */
86 #define LX_SOCK_SEQPACKET 5 /* Sequenced packet stream */
87 #define LX_SOCK_PACKET 10 /* Linux specific */
88 #define LX_SOCK_MAX 11
89
90 #define SOCK_NOTSUPPORTED -1
91 #define SOCK_INVAL -2
92
93 /*
94 * Options for use with [gs]etsockopt at the IP level.
95 * IPPROTO_IP
96 */
97 #define LX_IP_TOS 1
98 #define LX_IP_TTL 2
99 #define LX_IP_HDRINCL 3
100 #define LX_IP_OPTIONS 4
101 #define LX_IP_ROUTER_ALERT 5
102 #define LX_IP_RECVOPTS 6
103 #define LX_IP_RETOPTS 7
104 #define LX_IP_PKTINFO 8
105 #define LX_IP_PKTOPTIONS 9
106 #define LX_IP_MTU_DISCOVER 10
107 #define LX_IP_RECVERR 11
108 #define LX_IP_RECVTTL 12
109 #define LX_IP_RECVTOS 13
110 #define LX_IP_MTU 14
111 #define LX_IP_FREEBIND 15
112 #define LX_IP_MULTICAST_IF 32
113 #define LX_IP_MULTICAST_TTL 33
114 #define LX_IP_MULTICAST_LOOP 34
115 #define LX_IP_ADD_MEMBERSHIP 35
116 #define LX_IP_DROP_MEMBERSHIP 36
117
118 /*
119 * Options for use with [gs]etsockopt at the TCP level.
120 * IPPROTO_TCP
121 */
122 #define LX_TCP_NODELAY 1 /* Don't delay send to coalesce packets */
123 #define LX_TCP_MAXSEG 2 /* Set maximum segment size */
124 #define LX_TCP_CORK 3 /* Control sending of partial frames */
125 #define LX_TCP_KEEPIDLE 4 /* Start keeplives after this period */
126 #define LX_TCP_KEEPINTVL 5 /* Interval between keepalives */
127 #define LX_TCP_KEEPCNT 6 /* Number of keepalives before death */
128 #define LX_TCP_SYNCNT 7 /* Number of SYN retransmits */
129 #define LX_TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
130 #define LX_TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
131 #define LX_TCP_WINDOW_CLAMP 10 /* Bound advertised window */
132 #define LX_TCP_INFO 11 /* Information about this connection. */
133 #define LX_TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */
134
135 /*
136 * Options for use with [gs]etsockopt at the IGMP level.
137 * IPPROTO_IGMP
138 */
139 #define LX_IGMP_MINLEN 8
140 #define LX_IGMP_MAX_HOST_REPORT_DELAY 10
141 #define LX_IGMP_HOST_MEMBERSHIP_QUERY 0x11
142 #define LX_IGMP_HOST_MEMBERSHIP_REPORT 0x12
143 #define LX_IGMP_DVMRP 0x13
144 #define LX_IGMP_PIM 0x14
145 #define LX_IGMP_TRACE 0x15
146 #define LX_IGMP_HOST_NEW_MEMBERSHIP_REPORT 0x16
147 #define LX_IGMP_HOST_LEAVE_MESSAGE 0x17
148 #define LX_IGMP_MTRACE_RESP 0x1e
149 #define LX_IGMP_MTRACE 0x1f
150
151 /*
152 * Options for use with [gs]etsockopt at the SOL_SOCKET level.
153 */
154 #define LX_SOL_SOCKET 1
155
156 #define LX_SCM_RIGHTS 1
157 #define LX_SCM_CRED 2
158
159 #define LX_SO_DEBUG 1
160 #define LX_SO_REUSEADDR 2
161 #define LX_SO_TYPE 3
162 #define LX_SO_ERROR 4
163 #define LX_SO_DONTROUTE 5
164 #define LX_SO_BROADCAST 6
165 #define LX_SO_SNDBUF 7
166 #define LX_SO_RCVBUF 8
167 #define LX_SO_KEEPALIVE 9
168 #define LX_SO_OOBINLINE 10
169 #define LX_SO_NO_CHECK 11
170 #define LX_SO_PRIORITY 12
171 #define LX_SO_LINGER 13
172 #define LX_SO_BSDCOMPAT 14
173 /* To add :#define LX_SO_REUSEPORT 15 */
174 #define LX_SO_PASSCRED 16
175 #define LX_SO_PEERCRED 17
176 #define LX_SO_RCVLOWAT 18
177 #define LX_SO_SNDLOWAT 19
178 #define LX_SO_RCVTIMEO 20
179 #define LX_SO_SNDTIMEO 21
180 /* Security levels - as per NRL IPv6 - don't actually do anything */
181 #define LX_SO_SECURITY_AUTHENTICATION 22
182 #define LX_SO_SECURITY_ENCRYPTION_TRANSPORT 23
183 #define LX_SO_SECURITY_ENCRYPTION_NETWORK 24
184 #define LX_SO_BINDTODEVICE 25
185 /* Socket filtering */
186 #define LX_SO_ATTACH_FILTER 26
187 #define LX_SO_DETACH_FILTER 27
188 #define LX_SO_PEERNAME 28
189 #define LX_SO_TIMESTAMP 29
190 #define LX_SCM_TIMESTAMP LX_SO_TIMESTAMP
191 #define LX_SO_ACCEPTCONN 30
192
193 /*
194 * Linux socketcall indices.
195 * These constitute all 17 socket related system calls
196 *
197 * These system calls are called via a single system call socketcall().
198 * The first arg being the endex of the system call type
199 */
200 #define LX_SOCKET 1
201 #define LX_BIND 2
202 #define LX_CONNECT 3
203 #define LX_LISTEN 4
204 #define LX_ACCEPT 5
205 #define LX_GETSOCKNAME 6
206 #define LX_GETPEERNAME 7
207 #define LX_SOCKETPAIR 8
208 #define LX_SEND 9
209 #define LX_RECV 10
210 #define LX_SENDTO 11
211 #define LX_RECVFROM 12
212 #define LX_SHUTDOWN 13
213 #define LX_SETSOCKOPT 14
214 #define LX_GETSOCKOPT 15
215 #define LX_SENDMSG 16
216 #define LX_RECVMSG 17
217
218 /*
219 * Linux socket flags for use with recv(2)/send(2)/recvmsg(2)/sendmsg(2)
220 */
221 #define LX_MSG_OOB 1
222 #define LX_MSG_PEEK 2
223 #define LX_MSG_DONTROUTE 4
224 #define LX_MSG_CTRUNC 8
225 #define LX_MSG_PROXY 0x10
226 #define LX_MSG_TRUNC 0x20
227 #define LX_MSG_DONTWAIT 0x40
228 #define LX_MSG_EOR 0x80
229 #define LX_MSG_WAITALL 0x100
230 #define LX_MSG_FIN 0x200
231 #define LX_MSG_SYN 0x400
232 #define LX_MSG_CONFIRM 0x800
233 #define LX_MSG_RST 0x1000
234 #define LX_MSG_ERRQUEUE 0x2000
235 #define LX_MSG_NOSIGNAL 0x4000
236 #define LX_MSG_MORE 0x8000
237
238 struct lx_msghdr {
239 void *msg_name; /* optional address */
240 socklen_t msg_namelen; /* size of address */
241 struct iovec *msg_iov; /* scatter/gather array */
242 int msg_iovlen; /* # elements in msg_iov */
243 void *msg_control; /* ancillary data */
244 socklen_t msg_controllen; /* ancillary data buffer len */
245 int msg_flags; /* flags on received message */
246 };
247
248 struct lx_ucred {
249 pid_t lxu_pid;
250 lx_uid_t lxu_uid;
251 lx_gid_t lxu_gid;
252 };
253
254 #ifdef __cplusplus
255 }
256 #endif
257
258 #endif /* _SYS_LX_SOCKET_H */