williamr@2
|
1 |
// © Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
|
williamr@2
|
2 |
|
williamr@2
|
3 |
/*-
|
williamr@2
|
4 |
* Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
|
williamr@2
|
5 |
* The Regents of the University of California. All rights reserved.
|
williamr@2
|
6 |
* © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
|
williamr@2
|
7 |
* Redistribution and use in source and binary forms, with or without
|
williamr@2
|
8 |
* modification, are permitted provided that the following conditions
|
williamr@2
|
9 |
* are met:
|
williamr@2
|
10 |
* 1. Redistributions of source code must retain the above copyright
|
williamr@2
|
11 |
* notice, this list of conditions and the following disclaimer.
|
williamr@2
|
12 |
* 2. Redistributions in binary form must reproduce the above copyright
|
williamr@2
|
13 |
* notice, this list of conditions and the following disclaimer in the
|
williamr@2
|
14 |
* documentation and/or other materials provided with the distribution.
|
williamr@2
|
15 |
* 4. Neither the name of the University nor the names of its contributors
|
williamr@2
|
16 |
* may be used to endorse or promote products derived from this software
|
williamr@2
|
17 |
* without specific prior written permission.
|
williamr@2
|
18 |
*
|
williamr@2
|
19 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
williamr@2
|
20 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
williamr@2
|
21 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
williamr@2
|
22 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
williamr@2
|
23 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
williamr@2
|
24 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
williamr@2
|
25 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
williamr@2
|
26 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
williamr@2
|
27 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
williamr@2
|
28 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
williamr@2
|
29 |
* SUCH DAMAGE.
|
williamr@2
|
30 |
*
|
williamr@2
|
31 |
* @(#)socket.h 8.4 (Berkeley) 2/21/94
|
williamr@2
|
32 |
* $FreeBSD: src/sys/sys/socket.h,v 1.88.2.1 2005/09/27 21:14:10 rwatson Exp $
|
williamr@2
|
33 |
*/
|
williamr@2
|
34 |
|
williamr@2
|
35 |
#ifndef _SYS_SOCKET_H_
|
williamr@2
|
36 |
#define _SYS_SOCKET_H_
|
williamr@2
|
37 |
|
williamr@2
|
38 |
#include <sys/cdefs.h>
|
williamr@2
|
39 |
#include <sys/types.h>
|
williamr@2
|
40 |
#include <sys/_types.h>
|
williamr@2
|
41 |
#include <sys/_iovec.h>
|
williamr@2
|
42 |
#define _NO_NAMESPACE_POLLUTION
|
williamr@2
|
43 |
#include <machine/param.h>
|
williamr@2
|
44 |
#undef _NO_NAMESPACE_POLLUTION
|
williamr@2
|
45 |
|
williamr@2
|
46 |
/*
|
williamr@2
|
47 |
* Definitions related to sockets: types, address families, options.
|
williamr@2
|
48 |
*/
|
williamr@2
|
49 |
|
williamr@2
|
50 |
/*
|
williamr@2
|
51 |
* Data types.
|
williamr@2
|
52 |
*/
|
williamr@2
|
53 |
#if __BSD_VISIBLE
|
williamr@2
|
54 |
#ifndef _GID_T_DECLARED
|
williamr@2
|
55 |
typedef __gid_t gid_t;
|
williamr@2
|
56 |
#define _GID_T_DECLARED
|
williamr@2
|
57 |
#endif
|
williamr@2
|
58 |
|
williamr@2
|
59 |
#ifndef _OFF_T_DECLARED
|
williamr@2
|
60 |
typedef __off_t off_t;
|
williamr@2
|
61 |
#define _OFF_T_DECLARED
|
williamr@2
|
62 |
#endif
|
williamr@2
|
63 |
|
williamr@2
|
64 |
#ifndef _PID_T_DECLARED
|
williamr@2
|
65 |
typedef __pid_t pid_t;
|
williamr@2
|
66 |
#define _PID_T_DECLARED
|
williamr@2
|
67 |
#endif
|
williamr@2
|
68 |
#endif
|
williamr@2
|
69 |
|
williamr@2
|
70 |
#ifndef _SA_FAMILY_T_DECLARED
|
williamr@2
|
71 |
typedef __sa_family_t sa_family_t;
|
williamr@2
|
72 |
#define _SA_FAMILY_T_DECLARED
|
williamr@2
|
73 |
#endif
|
williamr@2
|
74 |
|
williamr@2
|
75 |
#ifndef _SOCKLEN_T_DECLARED
|
williamr@2
|
76 |
typedef __socklen_t socklen_t;
|
williamr@2
|
77 |
#define _SOCKLEN_T_DECLARED
|
williamr@2
|
78 |
#endif
|
williamr@2
|
79 |
|
williamr@2
|
80 |
#ifndef _SSIZE_T_DECLARED
|
williamr@2
|
81 |
typedef __ssize_t ssize_t;
|
williamr@2
|
82 |
#define _SSIZE_T_DECLARED
|
williamr@2
|
83 |
#endif
|
williamr@2
|
84 |
|
williamr@2
|
85 |
#if __BSD_VISIBLE
|
williamr@2
|
86 |
#ifndef _UID_T_DECLARED
|
williamr@2
|
87 |
typedef __uid_t uid_t;
|
williamr@2
|
88 |
#define _UID_T_DECLARED
|
williamr@2
|
89 |
#endif
|
williamr@2
|
90 |
#endif
|
williamr@2
|
91 |
|
williamr@2
|
92 |
/*
|
williamr@2
|
93 |
* Types
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
#define SOCK_STREAM 1 /* stream socket */
|
williamr@2
|
96 |
#define SOCK_DGRAM 2 /* datagram socket */
|
williamr@2
|
97 |
#ifdef __SYMBIAN32__
|
williamr@2
|
98 |
#define SOCK_RAW 4 /* raw-protocol interface */
|
williamr@2
|
99 |
#else
|
williamr@2
|
100 |
#define SOCK_RAW 3 /* raw-protocol interface */
|
williamr@2
|
101 |
#endif // __SYMBIAN32__
|
williamr@2
|
102 |
#if __BSD_VISIBLE
|
williamr@2
|
103 |
#define SOCK_RDM 4 /* reliably-delivered message */
|
williamr@2
|
104 |
#endif
|
williamr@2
|
105 |
#ifdef __SYMBIAN32__
|
williamr@2
|
106 |
#define SOCK_SEQPACKET 3 /* sequenced packet stream */
|
williamr@2
|
107 |
#else
|
williamr@2
|
108 |
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
williamr@2
|
109 |
#endif // __SYMBIAN32__
|
williamr@2
|
110 |
|
williamr@2
|
111 |
/*
|
williamr@2
|
112 |
* Option flags per-socket.
|
williamr@2
|
113 |
*/
|
williamr@2
|
114 |
#define SO_DEBUG 0x0001 /* turn on debugging info recording KSODebug */
|
williamr@2
|
115 |
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
williamr@2
|
116 |
#ifdef __SYMBIAN32__
|
williamr@2
|
117 |
#define SO_REUSEADDR 0x406 /* allow local address reuse */
|
williamr@2
|
118 |
#else
|
williamr@2
|
119 |
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
williamr@2
|
120 |
#endif // __SYMBIAN32__
|
williamr@2
|
121 |
#ifdef __SYMBIAN32__
|
williamr@2
|
122 |
#define SO_KEEPALIVE 0x305 /* keep connections alive KSoTcpKeepAlive */
|
williamr@2
|
123 |
#else
|
williamr@2
|
124 |
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
williamr@2
|
125 |
#endif // __SYMBIAN32__
|
williamr@2
|
126 |
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
|
williamr@2
|
127 |
#ifdef __SYMBIAN32__
|
williamr@2
|
128 |
#define SO_BROADCAST -1 /* permit sending of broadcast msgs */
|
williamr@2
|
129 |
#else
|
williamr@2
|
130 |
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
|
williamr@2
|
131 |
#endif // __SYMBIAN32__
|
williamr@2
|
132 |
#if __BSD_VISIBLE
|
williamr@2
|
133 |
#ifdef __SYMBIAN32__
|
williamr@2
|
134 |
#define SO_USELOOPBACK -2 /* bypass hardware when possible */
|
williamr@2
|
135 |
#else
|
williamr@2
|
136 |
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
|
williamr@2
|
137 |
#endif // __SYMBIAN32__
|
williamr@2
|
138 |
#endif
|
williamr@2
|
139 |
#ifdef __SYMBIAN32__
|
williamr@2
|
140 |
#define SO_LINGER -3 /* linger on close if data present */
|
williamr@2
|
141 |
#else
|
williamr@2
|
142 |
#define SO_LINGER 0x0080 /* linger on close if data present */
|
williamr@2
|
143 |
#endif // __SYMBIAN32__
|
williamr@2
|
144 |
#ifdef __SYMBIAN32__
|
williamr@2
|
145 |
#define SO_OOBINLINE 0x315 /* leave received OOB data in line KSoTcpOobInline */
|
williamr@2
|
146 |
#else
|
williamr@2
|
147 |
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
|
williamr@2
|
148 |
#endif // __SYMBIAN32__
|
williamr@2
|
149 |
#if __BSD_VISIBLE
|
williamr@2
|
150 |
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
|
williamr@2
|
151 |
#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */
|
williamr@2
|
152 |
#define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */
|
williamr@2
|
153 |
#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */
|
williamr@2
|
154 |
#define SO_BINTIME 0x2000 /* timestamp received dgram traffic */
|
williamr@2
|
155 |
#endif
|
williamr@2
|
156 |
|
williamr@2
|
157 |
/*
|
williamr@2
|
158 |
* Additional options, not kept in so_options.
|
williamr@2
|
159 |
*/
|
williamr@2
|
160 |
#ifdef __SYMBIAN32__
|
williamr@2
|
161 |
#define SO_SNDBUF 3 /* send buffer size KSOSendBuf */
|
williamr@2
|
162 |
#else
|
williamr@2
|
163 |
#define SO_SNDBUF 0x1001 /* send buffer size */
|
williamr@2
|
164 |
#endif // __SYMBIAN32__
|
williamr@2
|
165 |
#ifdef __SYMBIAN32__
|
williamr@2
|
166 |
#define SO_RCVBUF 2 /* receive buffer size KSORecvBuf */
|
williamr@2
|
167 |
#else
|
williamr@2
|
168 |
#define SO_RCVBUF 0x1002 /* receive buffer size */
|
williamr@2
|
169 |
#endif // __SYMBIAN32__
|
williamr@2
|
170 |
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
williamr@2
|
171 |
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
williamr@2
|
172 |
#define SO_SNDTIMEO 0x1005 /* send timeout */
|
williamr@2
|
173 |
#define SO_RCVTIMEO 0x1006 /* receive timeout */
|
williamr@2
|
174 |
#ifdef __SYMBIAN32__
|
williamr@2
|
175 |
#define SO_ERROR 9 /* get error status and clear */
|
williamr@2
|
176 |
#else
|
williamr@2
|
177 |
#define SO_ERROR 0x1007 /* get error status and clear */
|
williamr@2
|
178 |
#endif // __SYMBIAN32__
|
williamr@2
|
179 |
#define SO_TYPE 0x1008 /* get socket type */
|
williamr@2
|
180 |
#if __BSD_VISIBLE
|
williamr@2
|
181 |
#define SO_LABEL 0x1009 /* socket's MAC label */
|
williamr@2
|
182 |
#define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */
|
williamr@2
|
183 |
#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */
|
williamr@2
|
184 |
#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */
|
williamr@2
|
185 |
#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */
|
williamr@2
|
186 |
#endif
|
williamr@2
|
187 |
|
williamr@2
|
188 |
/*
|
williamr@2
|
189 |
* Structure used for manipulating linger option.
|
williamr@2
|
190 |
*/
|
williamr@2
|
191 |
struct linger {
|
williamr@2
|
192 |
int l_onoff; /* option on/off */
|
williamr@2
|
193 |
int l_linger; /* linger time */
|
williamr@2
|
194 |
};
|
williamr@2
|
195 |
|
williamr@2
|
196 |
#if __BSD_VISIBLE
|
williamr@2
|
197 |
struct accept_filter_arg {
|
williamr@2
|
198 |
char af_name[16];
|
williamr@2
|
199 |
char af_arg[256-16];
|
williamr@2
|
200 |
};
|
williamr@2
|
201 |
#endif
|
williamr@2
|
202 |
|
williamr@2
|
203 |
/*
|
williamr@2
|
204 |
* Level number for (get/set)sockopt() to apply to socket itself.
|
williamr@2
|
205 |
*/
|
williamr@2
|
206 |
#ifdef __SYMBIAN32__
|
williamr@2
|
207 |
#define SOL_SOCKET 1 /* options for socket level KSOLSocket */
|
williamr@2
|
208 |
#else
|
williamr@2
|
209 |
#define SOL_SOCKET 0xffff /* options for socket level */
|
williamr@2
|
210 |
#endif // __SYMBIAN32__
|
williamr@2
|
211 |
/*
|
williamr@2
|
212 |
* Address families.
|
williamr@2
|
213 |
*/
|
williamr@2
|
214 |
#define AF_UNSPEC 0 /* unspecified */
|
williamr@2
|
215 |
#if __BSD_VISIBLE
|
williamr@2
|
216 |
#ifdef __SYMBIAN32__
|
williamr@2
|
217 |
#define AF_LOCAL 0x666 /* local to host (pipes, portals) */
|
williamr@2
|
218 |
#else
|
williamr@2
|
219 |
#define AF_LOCAL AF_UNIX /* local to host (pipes, portals) */
|
williamr@2
|
220 |
#endif // __SYMBIAN32__
|
williamr@2
|
221 |
#endif
|
williamr@2
|
222 |
#define AF_UNIX 1 /* standardized name for AF_LOCAL */
|
williamr@2
|
223 |
#ifdef __SYMBIAN32__
|
williamr@2
|
224 |
#define AF_INET 0x0800 /* internetwork: UDP, TCP, etc. */
|
williamr@2
|
225 |
#else
|
williamr@2
|
226 |
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
|
williamr@2
|
227 |
#endif // __SYMBIAN32__
|
williamr@2
|
228 |
#if __BSD_VISIBLE
|
williamr@2
|
229 |
#define AF_IMPLINK 3 /* arpanet imp addresses */
|
williamr@2
|
230 |
#define AF_PUP 4 /* pup protocols: e.g. BSP */
|
williamr@2
|
231 |
#define AF_CHAOS 5 /* mit CHAOS protocols */
|
williamr@2
|
232 |
#define AF_NETBIOS 6 /* SMB protocols */
|
williamr@2
|
233 |
#define AF_ISO 7 /* ISO protocols */
|
williamr@2
|
234 |
#define AF_OSI AF_ISO
|
williamr@2
|
235 |
#define AF_ECMA 8 /* European computer manufacturers */
|
williamr@2
|
236 |
#define AF_DATAKIT 9 /* datakit protocols */
|
williamr@2
|
237 |
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
|
williamr@2
|
238 |
#define AF_SNA 11 /* IBM SNA */
|
williamr@2
|
239 |
#define AF_DECnet 12 /* DECnet */
|
williamr@2
|
240 |
#define AF_DLI 13 /* DEC Direct data link interface */
|
williamr@2
|
241 |
#define AF_LAT 14 /* LAT */
|
williamr@2
|
242 |
#define AF_HYLINK 15 /* NSC Hyperchannel */
|
williamr@2
|
243 |
#define AF_APPLETALK 16 /* Apple Talk */
|
williamr@2
|
244 |
#define AF_ROUTE 17 /* Internal Routing Protocol */
|
williamr@2
|
245 |
#define AF_LINK 18 /* Link layer interface */
|
williamr@2
|
246 |
#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
|
williamr@2
|
247 |
#define AF_COIP 20 /* connection-oriented IP, aka ST II */
|
williamr@2
|
248 |
#define AF_CNT 21 /* Computer Network Technology */
|
williamr@2
|
249 |
#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
|
williamr@2
|
250 |
#define AF_IPX 23 /* Novell Internet Protocol */
|
williamr@2
|
251 |
#define AF_SIP 24 /* Simple Internet Protocol */
|
williamr@2
|
252 |
#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
|
williamr@2
|
253 |
#define AF_ISDN 26 /* Integrated Services Digital Network*/
|
williamr@2
|
254 |
#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
|
williamr@2
|
255 |
#define pseudo_AF_KEY 27 /* Internal key-management function */
|
williamr@2
|
256 |
#endif
|
williamr@2
|
257 |
#ifdef __SYMBIAN32__
|
williamr@2
|
258 |
#define AF_INET6 0x0806 /* IPv6 */
|
williamr@2
|
259 |
#else
|
williamr@2
|
260 |
#define AF_INET6 28 /* IPv6 */
|
williamr@2
|
261 |
#endif
|
williamr@2
|
262 |
#if __BSD_VISIBLE
|
williamr@2
|
263 |
#define AF_NATM 29 /* native ATM access */
|
williamr@2
|
264 |
#define AF_ATM 30 /* ATM */
|
williamr@2
|
265 |
#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
|
williamr@2
|
266 |
* in interface output routine
|
williamr@2
|
267 |
*/
|
williamr@2
|
268 |
#define AF_NETGRAPH 32 /* Netgraph sockets */
|
williamr@2
|
269 |
#define AF_SLOW 33 /* 802.3ad slow protocol */
|
williamr@2
|
270 |
#define AF_SCLUSTER 34 /* Sitara cluster protocol */
|
williamr@2
|
271 |
#define AF_ARP 35
|
williamr@2
|
272 |
#define AF_BLUETOOTH 36 /* Bluetooth sockets */
|
williamr@2
|
273 |
#define AF_MAX 37
|
williamr@2
|
274 |
#endif
|
williamr@2
|
275 |
#ifdef __SYMBIAN32__
|
williamr@2
|
276 |
#define AF_IRDA 0x0100 /* IrDA */
|
williamr@2
|
277 |
#define AF_PLP 273 /* Symbian link protocol */
|
williamr@2
|
278 |
#endif // __SYMBIAN32__
|
williamr@2
|
279 |
|
williamr@2
|
280 |
#ifndef __SYMBIAN32__
|
williamr@2
|
281 |
/*
|
williamr@2
|
282 |
* Structure used by kernel to store most
|
williamr@2
|
283 |
* addresses.
|
williamr@2
|
284 |
*/
|
williamr@2
|
285 |
struct sockaddr {
|
williamr@2
|
286 |
unsigned char sa_len; /* total length */
|
williamr@2
|
287 |
sa_family_t sa_family; /* address family */
|
williamr@2
|
288 |
char sa_data[14]; /* actually longer; address value */
|
williamr@2
|
289 |
};
|
williamr@2
|
290 |
#else
|
williamr@2
|
291 |
/**
|
williamr@2
|
292 |
Structure used by EPOC32 to store most addresses.
|
williamr@2
|
293 |
NB. EPOC32 uses 32-bit family and port numbers internally, but they have been
|
williamr@2
|
294 |
left as shorts here for compatibility with code that uses htons()/ntohs() explicitly.
|
williamr@2
|
295 |
*/
|
williamr@2
|
296 |
struct sockaddr {
|
williamr@2
|
297 |
u_short sa_family; /* address family */
|
williamr@2
|
298 |
u_short sa_port; /* port number - a common feature of most protocols */
|
williamr@2
|
299 |
char sa_data[24]; /* up to 24 bytes of direct address */
|
williamr@2
|
300 |
unsigned char sa_len;
|
williamr@2
|
301 |
};
|
williamr@2
|
302 |
#endif //__SYMBIAN32__
|
williamr@2
|
303 |
|
williamr@2
|
304 |
#if __BSD_VISIBLE
|
williamr@2
|
305 |
#define SOCK_MAXADDRLEN 255 /* longest possible addresses */
|
williamr@2
|
306 |
|
williamr@2
|
307 |
/*
|
williamr@2
|
308 |
* Structure used by kernel to pass protocol
|
williamr@2
|
309 |
* information in raw sockets.
|
williamr@2
|
310 |
*/
|
williamr@2
|
311 |
struct sockproto {
|
williamr@2
|
312 |
unsigned short sp_family; /* address family */
|
williamr@2
|
313 |
unsigned short sp_protocol; /* protocol */
|
williamr@2
|
314 |
};
|
williamr@2
|
315 |
#endif
|
williamr@2
|
316 |
|
williamr@2
|
317 |
/*
|
williamr@2
|
318 |
* RFC 2553: protocol-independent placeholder for socket addresses
|
williamr@2
|
319 |
*/
|
williamr@2
|
320 |
#define _SS_MAXSIZE 128U
|
williamr@2
|
321 |
#define _SS_ALIGNSIZE (sizeof(__int64_t))
|
williamr@2
|
322 |
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \
|
williamr@2
|
323 |
sizeof(sa_family_t))
|
williamr@2
|
324 |
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \
|
williamr@2
|
325 |
sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
|
williamr@2
|
326 |
|
williamr@2
|
327 |
struct sockaddr_storage {
|
williamr@2
|
328 |
unsigned char ss_len; /* address length */
|
williamr@2
|
329 |
sa_family_t ss_family; /* address family */
|
williamr@2
|
330 |
char __ss_pad1[_SS_PAD1SIZE];
|
williamr@2
|
331 |
__int64_t __ss_align; /* force desired struct alignment */
|
williamr@2
|
332 |
char __ss_pad2[_SS_PAD2SIZE];
|
williamr@2
|
333 |
};
|
williamr@2
|
334 |
|
williamr@2
|
335 |
#if __BSD_VISIBLE
|
williamr@2
|
336 |
/*
|
williamr@2
|
337 |
* Protocol families, same as address families for now.
|
williamr@2
|
338 |
*/
|
williamr@2
|
339 |
#define PF_UNSPEC AF_UNSPEC
|
williamr@2
|
340 |
#define PF_LOCAL AF_LOCAL
|
williamr@2
|
341 |
#define PF_UNIX PF_LOCAL /* backward compatibility */
|
williamr@2
|
342 |
#define PF_INET AF_INET
|
williamr@2
|
343 |
#define PF_IMPLINK AF_IMPLINK
|
williamr@2
|
344 |
#define PF_PUP AF_PUP
|
williamr@2
|
345 |
#define PF_CHAOS AF_CHAOS
|
williamr@2
|
346 |
#define PF_NETBIOS AF_NETBIOS
|
williamr@2
|
347 |
#define PF_ISO AF_ISO
|
williamr@2
|
348 |
#define PF_OSI AF_ISO
|
williamr@2
|
349 |
#define PF_ECMA AF_ECMA
|
williamr@2
|
350 |
#define PF_DATAKIT AF_DATAKIT
|
williamr@2
|
351 |
#define PF_CCITT AF_CCITT
|
williamr@2
|
352 |
#define PF_SNA AF_SNA
|
williamr@2
|
353 |
#define PF_DECnet AF_DECnet
|
williamr@2
|
354 |
#define PF_DLI AF_DLI
|
williamr@2
|
355 |
#define PF_LAT AF_LAT
|
williamr@2
|
356 |
#define PF_HYLINK AF_HYLINK
|
williamr@2
|
357 |
#define PF_APPLETALK AF_APPLETALK
|
williamr@2
|
358 |
#define PF_ROUTE AF_ROUTE
|
williamr@2
|
359 |
#define PF_LINK AF_LINK
|
williamr@2
|
360 |
#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
|
williamr@2
|
361 |
#define PF_COIP AF_COIP
|
williamr@2
|
362 |
#define PF_CNT AF_CNT
|
williamr@2
|
363 |
#define PF_SIP AF_SIP
|
williamr@2
|
364 |
#define PF_IPX AF_IPX
|
williamr@2
|
365 |
#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
|
williamr@2
|
366 |
#define PF_PIP pseudo_AF_PIP
|
williamr@2
|
367 |
#define PF_ISDN AF_ISDN
|
williamr@2
|
368 |
#define PF_KEY pseudo_AF_KEY
|
williamr@2
|
369 |
#define PF_INET6 AF_INET6
|
williamr@2
|
370 |
#define PF_NATM AF_NATM
|
williamr@2
|
371 |
#define PF_ATM AF_ATM
|
williamr@2
|
372 |
#define PF_NETGRAPH AF_NETGRAPH
|
williamr@2
|
373 |
#define PF_SLOW AF_SLOW
|
williamr@2
|
374 |
#define PF_SCLUSTER AF_SCLUSTER
|
williamr@2
|
375 |
#define PF_ARP AF_ARP
|
williamr@2
|
376 |
#define PF_BLUETOOTH AF_BLUETOOTH
|
williamr@2
|
377 |
|
williamr@2
|
378 |
#define PF_MAX AF_MAX
|
williamr@2
|
379 |
|
williamr@2
|
380 |
#ifdef __SYMBIAN32__
|
williamr@2
|
381 |
#define PF_IRDA AF_IRDA
|
williamr@2
|
382 |
#define PF_PLP AF_PLP
|
williamr@2
|
383 |
#endif // __SYMBIAN32__
|
williamr@2
|
384 |
/*
|
williamr@2
|
385 |
* Definitions for network related sysctl, CTL_NET.
|
williamr@2
|
386 |
*
|
williamr@2
|
387 |
* Second level is protocol family.
|
williamr@2
|
388 |
* Third level is protocol number.
|
williamr@2
|
389 |
*
|
williamr@2
|
390 |
* Further levels are defined by the individual families below.
|
williamr@2
|
391 |
*/
|
williamr@2
|
392 |
#define NET_MAXID AF_MAX
|
williamr@2
|
393 |
|
williamr@2
|
394 |
#define CTL_NET_NAMES { \
|
williamr@2
|
395 |
{ 0, 0 }, \
|
williamr@2
|
396 |
{ "unix", CTLTYPE_NODE }, \
|
williamr@2
|
397 |
{ "inet", CTLTYPE_NODE }, \
|
williamr@2
|
398 |
{ "implink", CTLTYPE_NODE }, \
|
williamr@2
|
399 |
{ "pup", CTLTYPE_NODE }, \
|
williamr@2
|
400 |
{ "chaos", CTLTYPE_NODE }, \
|
williamr@2
|
401 |
{ "xerox_ns", CTLTYPE_NODE }, \
|
williamr@2
|
402 |
{ "iso", CTLTYPE_NODE }, \
|
williamr@2
|
403 |
{ "emca", CTLTYPE_NODE }, \
|
williamr@2
|
404 |
{ "datakit", CTLTYPE_NODE }, \
|
williamr@2
|
405 |
{ "ccitt", CTLTYPE_NODE }, \
|
williamr@2
|
406 |
{ "ibm_sna", CTLTYPE_NODE }, \
|
williamr@2
|
407 |
{ "decnet", CTLTYPE_NODE }, \
|
williamr@2
|
408 |
{ "dec_dli", CTLTYPE_NODE }, \
|
williamr@2
|
409 |
{ "lat", CTLTYPE_NODE }, \
|
williamr@2
|
410 |
{ "hylink", CTLTYPE_NODE }, \
|
williamr@2
|
411 |
{ "appletalk", CTLTYPE_NODE }, \
|
williamr@2
|
412 |
{ "route", CTLTYPE_NODE }, \
|
williamr@2
|
413 |
{ "link_layer", CTLTYPE_NODE }, \
|
williamr@2
|
414 |
{ "xtp", CTLTYPE_NODE }, \
|
williamr@2
|
415 |
{ "coip", CTLTYPE_NODE }, \
|
williamr@2
|
416 |
{ "cnt", CTLTYPE_NODE }, \
|
williamr@2
|
417 |
{ "rtip", CTLTYPE_NODE }, \
|
williamr@2
|
418 |
{ "ipx", CTLTYPE_NODE }, \
|
williamr@2
|
419 |
{ "sip", CTLTYPE_NODE }, \
|
williamr@2
|
420 |
{ "pip", CTLTYPE_NODE }, \
|
williamr@2
|
421 |
{ "isdn", CTLTYPE_NODE }, \
|
williamr@2
|
422 |
{ "key", CTLTYPE_NODE }, \
|
williamr@2
|
423 |
{ "inet6", CTLTYPE_NODE }, \
|
williamr@2
|
424 |
{ "natm", CTLTYPE_NODE }, \
|
williamr@2
|
425 |
{ "atm", CTLTYPE_NODE }, \
|
williamr@2
|
426 |
{ "hdrcomplete", CTLTYPE_NODE }, \
|
williamr@2
|
427 |
{ "netgraph", CTLTYPE_NODE }, \
|
williamr@2
|
428 |
{ "snp", CTLTYPE_NODE }, \
|
williamr@2
|
429 |
{ "scp", CTLTYPE_NODE }, \
|
williamr@2
|
430 |
}
|
williamr@2
|
431 |
|
williamr@2
|
432 |
/*
|
williamr@2
|
433 |
* PF_ROUTE - Routing table
|
williamr@2
|
434 |
*
|
williamr@2
|
435 |
* Three additional levels are defined:
|
williamr@2
|
436 |
* Fourth: address family, 0 is wildcard
|
williamr@2
|
437 |
* Fifth: type of info, defined below
|
williamr@2
|
438 |
* Sixth: flag(s) to mask with for NET_RT_FLAGS
|
williamr@2
|
439 |
*/
|
williamr@2
|
440 |
#define NET_RT_DUMP 1 /* dump; may limit to a.f. */
|
williamr@2
|
441 |
#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
|
williamr@2
|
442 |
#define NET_RT_IFLIST 3 /* survey interface list */
|
williamr@2
|
443 |
#define NET_RT_IFMALIST 4 /* return multicast address list */
|
williamr@2
|
444 |
#define NET_RT_MAXID 5
|
williamr@2
|
445 |
|
williamr@2
|
446 |
#define CTL_NET_RT_NAMES { \
|
williamr@2
|
447 |
{ 0, 0 }, \
|
williamr@2
|
448 |
{ "dump", CTLTYPE_STRUCT }, \
|
williamr@2
|
449 |
{ "flags", CTLTYPE_STRUCT }, \
|
williamr@2
|
450 |
{ "iflist", CTLTYPE_STRUCT }, \
|
williamr@2
|
451 |
{ "ifmalist", CTLTYPE_STRUCT }, \
|
williamr@2
|
452 |
}
|
williamr@2
|
453 |
#endif /* __BSD_VISIBLE */
|
williamr@2
|
454 |
|
williamr@2
|
455 |
/*
|
williamr@2
|
456 |
* Maximum queue length specifiable by listen.
|
williamr@2
|
457 |
*/
|
williamr@2
|
458 |
#ifdef __SYMBIAN32__
|
williamr@2
|
459 |
#define SOMAXCONN 5
|
williamr@2
|
460 |
#else
|
williamr@2
|
461 |
#define SOMAXCONN 128
|
williamr@2
|
462 |
#endif // __SYMBIAN32__
|
williamr@2
|
463 |
|
williamr@2
|
464 |
/*
|
williamr@2
|
465 |
* Message header for recvmsg and sendmsg calls.
|
williamr@2
|
466 |
* Used value-result for recvmsg, value only for sendmsg.
|
williamr@2
|
467 |
*/
|
williamr@2
|
468 |
struct msghdr {
|
williamr@2
|
469 |
void *msg_name; /* optional address */
|
williamr@2
|
470 |
socklen_t msg_namelen; /* size of address */
|
williamr@2
|
471 |
struct iovec *msg_iov; /* scatter/gather array */
|
williamr@2
|
472 |
int msg_iovlen; /* # elements in msg_iov */
|
williamr@2
|
473 |
void *msg_control; /* ancillary data, see below */
|
williamr@2
|
474 |
socklen_t msg_controllen; /* ancillary data buffer len */
|
williamr@2
|
475 |
int msg_flags; /* flags on received message */
|
williamr@2
|
476 |
};
|
williamr@2
|
477 |
|
williamr@2
|
478 |
#define MSG_OOB 0x1 /* process out-of-band data */
|
williamr@2
|
479 |
#define MSG_PEEK 0x2 /* peek at incoming message */
|
williamr@2
|
480 |
#define MSG_DONTROUTE 0x4 /* send without using routing tables */
|
williamr@2
|
481 |
#define MSG_EOR 0x8 /* data completes record */
|
williamr@2
|
482 |
#define MSG_TRUNC 0x10 /* data discarded before delivery */
|
williamr@2
|
483 |
#define MSG_CTRUNC 0x20 /* control data lost before delivery */
|
williamr@2
|
484 |
#define MSG_WAITALL 0x40 /* wait for full request or error */
|
williamr@2
|
485 |
#if __BSD_VISIBLE
|
williamr@2
|
486 |
#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
|
williamr@2
|
487 |
#define MSG_EOF 0x100 /* data completes connection */
|
williamr@2
|
488 |
#define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */
|
williamr@2
|
489 |
#define MSG_COMPAT 0x8000 /* used in sendit() */
|
williamr@2
|
490 |
#endif
|
williamr@2
|
491 |
#ifdef _KERNEL
|
williamr@2
|
492 |
#define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */
|
williamr@2
|
493 |
#endif
|
williamr@2
|
494 |
#if __BSD_VISIBLE
|
williamr@2
|
495 |
#define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */
|
williamr@2
|
496 |
#endif
|
williamr@2
|
497 |
|
williamr@2
|
498 |
/*
|
williamr@2
|
499 |
* Header for ancillary data objects in msg_control buffer.
|
williamr@2
|
500 |
* Used for additional information with/about a datagram
|
williamr@2
|
501 |
* not expressible by flags. The format is a sequence
|
williamr@2
|
502 |
* of message elements headed by cmsghdr structures.
|
williamr@2
|
503 |
*/
|
williamr@2
|
504 |
struct cmsghdr {
|
williamr@2
|
505 |
socklen_t cmsg_len; /* data byte count, including hdr */
|
williamr@2
|
506 |
int cmsg_level; /* originating protocol */
|
williamr@2
|
507 |
int cmsg_type; /* protocol-specific type */
|
williamr@2
|
508 |
/* followed by u_char cmsg_data[]; */
|
williamr@2
|
509 |
};
|
williamr@2
|
510 |
|
williamr@2
|
511 |
#if __BSD_VISIBLE
|
williamr@2
|
512 |
/*
|
williamr@2
|
513 |
* While we may have more groups than this, the cmsgcred struct must
|
williamr@2
|
514 |
* be able to fit in an mbuf, and NGROUPS_MAX is too large to allow
|
williamr@2
|
515 |
* this.
|
williamr@2
|
516 |
*/
|
williamr@2
|
517 |
#define CMGROUP_MAX 16
|
williamr@2
|
518 |
|
williamr@2
|
519 |
/*
|
williamr@2
|
520 |
* Credentials structure, used to verify the identity of a peer
|
williamr@2
|
521 |
* process that has sent us a message. This is allocated by the
|
williamr@2
|
522 |
* peer process but filled in by the kernel. This prevents the
|
williamr@2
|
523 |
* peer from lying about its identity. (Note that cmcred_groups[0]
|
williamr@2
|
524 |
* is the effective GID.)
|
williamr@2
|
525 |
*/
|
williamr@2
|
526 |
struct cmsgcred {
|
williamr@2
|
527 |
pid_t cmcred_pid; /* PID of sending process */
|
williamr@2
|
528 |
uid_t cmcred_uid; /* real UID of sending process */
|
williamr@2
|
529 |
uid_t cmcred_euid; /* effective UID of sending process */
|
williamr@2
|
530 |
gid_t cmcred_gid; /* real GID of sending process */
|
williamr@2
|
531 |
short cmcred_ngroups; /* number or groups */
|
williamr@2
|
532 |
gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
|
williamr@2
|
533 |
};
|
williamr@2
|
534 |
|
williamr@2
|
535 |
/*
|
williamr@2
|
536 |
* Socket credentials.
|
williamr@2
|
537 |
*/
|
williamr@2
|
538 |
struct sockcred {
|
williamr@2
|
539 |
uid_t sc_uid; /* real user id */
|
williamr@2
|
540 |
uid_t sc_euid; /* effective user id */
|
williamr@2
|
541 |
gid_t sc_gid; /* real group id */
|
williamr@2
|
542 |
gid_t sc_egid; /* effective group id */
|
williamr@2
|
543 |
int sc_ngroups; /* number of supplemental groups */
|
williamr@2
|
544 |
gid_t sc_groups[1]; /* variable length */
|
williamr@2
|
545 |
};
|
williamr@2
|
546 |
|
williamr@2
|
547 |
/*
|
williamr@2
|
548 |
* Compute size of a sockcred structure with groups.
|
williamr@2
|
549 |
*/
|
williamr@2
|
550 |
#define SOCKCREDSIZE(ngrps) \
|
williamr@2
|
551 |
(sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
|
williamr@2
|
552 |
|
williamr@2
|
553 |
#endif /* __BSD_VISIBLE */
|
williamr@2
|
554 |
|
williamr@2
|
555 |
/* given pointer to struct cmsghdr, return pointer to data */
|
williamr@2
|
556 |
#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
|
williamr@2
|
557 |
_ALIGN(sizeof(struct cmsghdr)))
|
williamr@2
|
558 |
|
williamr@2
|
559 |
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
|
williamr@2
|
560 |
#define CMSG_NXTHDR(mhdr, cmsg) \
|
williamr@2
|
561 |
(((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
|
williamr@2
|
562 |
_ALIGN(sizeof(struct cmsghdr)) > \
|
williamr@2
|
563 |
(char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
|
williamr@2
|
564 |
(struct cmsghdr *)0 : \
|
williamr@2
|
565 |
(struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
|
williamr@2
|
566 |
|
williamr@2
|
567 |
/*
|
williamr@2
|
568 |
* RFC 2292 requires to check msg_controllen, in case that the kernel returns
|
williamr@2
|
569 |
* an empty list for some reasons.
|
williamr@2
|
570 |
*/
|
williamr@2
|
571 |
#define CMSG_FIRSTHDR(mhdr) \
|
williamr@2
|
572 |
((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
|
williamr@2
|
573 |
(struct cmsghdr *)(mhdr)->msg_control : \
|
williamr@2
|
574 |
(struct cmsghdr *)NULL)
|
williamr@2
|
575 |
|
williamr@2
|
576 |
#if __BSD_VISIBLE
|
williamr@2
|
577 |
/* RFC 2292 additions */
|
williamr@2
|
578 |
#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
|
williamr@2
|
579 |
#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l))
|
williamr@2
|
580 |
#endif
|
williamr@2
|
581 |
|
williamr@2
|
582 |
#ifdef _KERNEL
|
williamr@2
|
583 |
#define CMSG_ALIGN(n) _ALIGN(n)
|
williamr@2
|
584 |
#endif
|
williamr@2
|
585 |
|
williamr@2
|
586 |
/* "Socket"-level control message types: */
|
williamr@2
|
587 |
#define SCM_RIGHTS 0x01 /* access rights (array of int) */
|
williamr@2
|
588 |
#if __BSD_VISIBLE
|
williamr@2
|
589 |
#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */
|
williamr@2
|
590 |
#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */
|
williamr@2
|
591 |
#define SCM_BINTIME 0x04 /* timestamp (struct bintime) */
|
williamr@2
|
592 |
#endif
|
williamr@2
|
593 |
|
williamr@2
|
594 |
#if __BSD_VISIBLE
|
williamr@2
|
595 |
/*
|
williamr@2
|
596 |
* 4.3 compat sockaddr, move to compat file later
|
williamr@2
|
597 |
*/
|
williamr@2
|
598 |
struct osockaddr {
|
williamr@2
|
599 |
unsigned short sa_family; /* address family */
|
williamr@2
|
600 |
char sa_data[14]; /* up to 14 bytes of direct address */
|
williamr@2
|
601 |
};
|
williamr@2
|
602 |
|
williamr@2
|
603 |
/*
|
williamr@2
|
604 |
* 4.3-compat message header (move to compat file later).
|
williamr@2
|
605 |
*/
|
williamr@2
|
606 |
struct omsghdr {
|
williamr@2
|
607 |
char *msg_name; /* optional address */
|
williamr@2
|
608 |
int msg_namelen; /* size of address */
|
williamr@2
|
609 |
struct iovec *msg_iov; /* scatter/gather array */
|
williamr@2
|
610 |
int msg_iovlen; /* # elements in msg_iov */
|
williamr@2
|
611 |
char *msg_accrights; /* access rights sent/received */
|
williamr@2
|
612 |
int msg_accrightslen;
|
williamr@2
|
613 |
};
|
williamr@2
|
614 |
#endif
|
williamr@2
|
615 |
|
williamr@2
|
616 |
/*
|
williamr@2
|
617 |
* howto arguments for shutdown(2), specified by Posix.1g.
|
williamr@2
|
618 |
*/
|
williamr@2
|
619 |
#define SHUT_RD 0 /* shut down the reading side */
|
williamr@2
|
620 |
#define SHUT_WR 1 /* shut down the writing side */
|
williamr@2
|
621 |
#define SHUT_RDWR 2 /* shut down both sides */
|
williamr@2
|
622 |
|
williamr@2
|
623 |
#if __BSD_VISIBLE
|
williamr@2
|
624 |
/*
|
williamr@2
|
625 |
* sendfile(2) header/trailer struct
|
williamr@2
|
626 |
*/
|
williamr@2
|
627 |
struct sf_hdtr {
|
williamr@2
|
628 |
struct iovec *headers; /* pointer to an array of header struct iovec's */
|
williamr@2
|
629 |
int hdr_cnt; /* number of header iovec's */
|
williamr@2
|
630 |
struct iovec *trailers; /* pointer to an array of trailer struct iovec's */
|
williamr@2
|
631 |
int trl_cnt; /* number of trailer iovec's */
|
williamr@2
|
632 |
};
|
williamr@2
|
633 |
|
williamr@2
|
634 |
/*
|
williamr@2
|
635 |
* Sendfile-specific flag(s)
|
williamr@2
|
636 |
*/
|
williamr@2
|
637 |
#define SF_NODISKIO 0x00000001
|
williamr@2
|
638 |
#endif
|
williamr@2
|
639 |
|
williamr@2
|
640 |
#ifndef _KERNEL
|
williamr@2
|
641 |
|
williamr@2
|
642 |
#include <sys/cdefs.h>
|
williamr@2
|
643 |
|
williamr@2
|
644 |
__BEGIN_DECLS
|
williamr@2
|
645 |
IMPORT_C int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
|
williamr@2
|
646 |
IMPORT_C int bind(int, const struct sockaddr *, socklen_t);
|
williamr@2
|
647 |
IMPORT_C int connect(int, const struct sockaddr *, socklen_t);
|
williamr@2
|
648 |
IMPORT_C int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
|
williamr@2
|
649 |
IMPORT_C int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
|
williamr@2
|
650 |
IMPORT_C int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
|
williamr@2
|
651 |
IMPORT_C int listen(int, int);
|
williamr@2
|
652 |
IMPORT_C ssize_t recv(int, void *, size_t, int);
|
williamr@2
|
653 |
IMPORT_C ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict);
|
williamr@2
|
654 |
IMPORT_C ssize_t recvmsg(int, struct msghdr *, int);
|
williamr@2
|
655 |
IMPORT_C ssize_t send(int, const void *, size_t, int);
|
williamr@2
|
656 |
IMPORT_C ssize_t sendto(int, const void *,
|
williamr@2
|
657 |
size_t, int, const struct sockaddr *, socklen_t);
|
williamr@2
|
658 |
IMPORT_C ssize_t sendmsg(int, const struct msghdr *, int);
|
williamr@2
|
659 |
IMPORT_C int setsockopt(int, int, int, const void *, socklen_t);
|
williamr@2
|
660 |
IMPORT_C int shutdown(int, int);
|
williamr@2
|
661 |
IMPORT_C int sockatmark(int);
|
williamr@2
|
662 |
IMPORT_C int socket(int, int, int);
|
williamr@2
|
663 |
__END_DECLS
|
williamr@2
|
664 |
|
williamr@2
|
665 |
#endif /* !_KERNEL */
|
williamr@2
|
666 |
|
williamr@2
|
667 |
#endif /* !_SYS_SOCKET_H_ */
|