]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* $NetBSD: socket.h,v 1.82 2006/06/27 03:49:08 mrg Exp $ */\r |
2 | \r | |
3 | /*\r | |
4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.\r | |
5 | * All rights reserved.\r | |
6 | *\r | |
7 | * Redistribution and use in source and binary forms, with or without\r | |
8 | * modification, are permitted provided that the following conditions\r | |
9 | * are met:\r | |
10 | * 1. Redistributions of source code must retain the above copyright\r | |
11 | * notice, this list of conditions and the following disclaimer.\r | |
12 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
13 | * notice, this list of conditions and the following disclaimer in the\r | |
14 | * documentation and/or other materials provided with the distribution.\r | |
15 | * 3. Neither the name of the project nor the names of its contributors\r | |
16 | * may be used to endorse or promote products derived from this software\r | |
17 | * without specific prior written permission.\r | |
18 | *\r | |
19 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND\r | |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE\r | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
29 | * SUCH DAMAGE.\r | |
30 | */\r | |
31 | \r | |
32 | /*\r | |
33 | * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994\r | |
34 | * The Regents of the University of California. All rights reserved.\r | |
35 | *\r | |
36 | * Redistribution and use in source and binary forms, with or without\r | |
37 | * modification, are permitted provided that the following conditions\r | |
38 | * are met:\r | |
39 | * 1. Redistributions of source code must retain the above copyright\r | |
40 | * notice, this list of conditions and the following disclaimer.\r | |
41 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
42 | * notice, this list of conditions and the following disclaimer in the\r | |
43 | * documentation and/or other materials provided with the distribution.\r | |
44 | * 3. Neither the name of the University nor the names of its contributors\r | |
45 | * may be used to endorse or promote products derived from this software\r | |
46 | * without specific prior written permission.\r | |
47 | *\r | |
48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r | |
49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r | |
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
58 | * SUCH DAMAGE.\r | |
59 | *\r | |
60 | * @(#)socket.h 8.6 (Berkeley) 5/3/95\r | |
61 | */\r | |
62 | \r | |
63 | #ifndef _SYS_SOCKET_H_\r | |
64 | #define _SYS_SOCKET_H_\r | |
65 | \r | |
66 | #include <sys/featuretest.h>\r | |
67 | \r | |
68 | /*\r | |
69 | * Definitions related to sockets: types, address families, options.\r | |
70 | */\r | |
71 | \r | |
72 | /*\r | |
73 | * Data types.\r | |
74 | */\r | |
75 | #include <sys/ansi.h>\r | |
76 | \r | |
77 | #ifndef sa_family_t\r | |
78 | typedef __sa_family_t sa_family_t;\r | |
79 | #define sa_family_t __sa_family_t\r | |
80 | #endif\r | |
81 | \r | |
82 | #ifndef socklen_t\r | |
83 | typedef __socklen_t socklen_t;\r | |
84 | #define socklen_t __socklen_t\r | |
85 | #endif\r | |
86 | \r | |
87 | #include <machine/ansi.h>\r | |
88 | \r | |
53e1e5c6 | 89 | #ifdef _EFI_SIZE_T_\r |
90 | typedef _EFI_SIZE_T_ size_t;\r | |
91 | #undef _EFI_SIZE_T_\r | |
2aa62f2b | 92 | #undef _BSD_SIZE_T_\r |
93 | #endif\r | |
94 | \r | |
95 | #ifdef _BSD_SSIZE_T_\r | |
96 | typedef _BSD_SSIZE_T_ ssize_t;\r | |
97 | #undef _BSD_SSIZE_T_\r | |
98 | #endif\r | |
99 | \r | |
100 | #include <sys/uio.h>\r | |
101 | \r | |
102 | /*\r | |
103 | * Socket types.\r | |
104 | */\r | |
105 | #define SOCK_STREAM 1 /* stream socket */\r | |
106 | #define SOCK_DGRAM 2 /* datagram socket */\r | |
107 | #define SOCK_RAW 3 /* raw-protocol interface */\r | |
108 | #define SOCK_RDM 4 /* reliably-delivered message */\r | |
109 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */\r | |
110 | \r | |
111 | /*\r | |
112 | * Option flags per-socket.\r | |
113 | */\r | |
114 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */\r | |
115 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */\r | |
116 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */\r | |
117 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */\r | |
118 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */\r | |
119 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */\r | |
120 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */\r | |
121 | #define SO_LINGER 0x0080 /* linger on close if data present */\r | |
122 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */\r | |
123 | #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */\r | |
124 | #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */\r | |
125 | \r | |
126 | \r | |
127 | /*\r | |
128 | * Additional options, not kept in so_options.\r | |
129 | */\r | |
130 | #define SO_SNDBUF 0x1001 /* send buffer size */\r | |
131 | #define SO_RCVBUF 0x1002 /* receive buffer size */\r | |
132 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */\r | |
133 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */\r | |
134 | #define SO_SNDTIMEO 0x1005 /* send timeout */\r | |
135 | #define SO_RCVTIMEO 0x1006 /* receive timeout */\r | |
136 | #define SO_ERROR 0x1007 /* get error status and clear */\r | |
137 | #define SO_TYPE 0x1008 /* get socket type */\r | |
138 | #define SO_OVERFLOWED 0x1009 /* datagrams: return packets dropped */\r | |
139 | \r | |
140 | /*\r | |
141 | * Structure used for manipulating linger option.\r | |
142 | */\r | |
143 | struct linger {\r | |
144 | int l_onoff; /* option on/off */\r | |
145 | int l_linger; /* linger time in seconds */\r | |
146 | };\r | |
147 | \r | |
148 | /*\r | |
149 | * Level number for (get/set)sockopt() to apply to socket itself.\r | |
150 | */\r | |
151 | #define SOL_SOCKET 0xffff /* options for socket level */\r | |
152 | \r | |
153 | /*\r | |
154 | * Address families.\r | |
155 | */\r | |
156 | #define AF_UNSPEC 0 /* unspecified */\r | |
157 | #define AF_LOCAL 1 /* local to host (pipes, portals) */\r | |
158 | #define AF_UNIX AF_LOCAL /* backward compatibility */\r | |
159 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */\r | |
160 | #define AF_IMPLINK 3 /* arpanet imp addresses */\r | |
161 | #define AF_PUP 4 /* pup protocols: e.g. BSP */\r | |
162 | #define AF_CHAOS 5 /* mit CHAOS protocols */\r | |
163 | #define AF_NS 6 /* XEROX NS protocols */\r | |
164 | #define AF_ISO 7 /* ISO protocols */\r | |
165 | #define AF_OSI AF_ISO\r | |
166 | #define AF_ECMA 8 /* european computer manufacturers */\r | |
167 | #define AF_DATAKIT 9 /* datakit protocols */\r | |
168 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */\r | |
169 | #define AF_SNA 11 /* IBM SNA */\r | |
170 | #define AF_DECnet 12 /* DECnet */\r | |
171 | #define AF_DLI 13 /* DEC Direct data link interface */\r | |
172 | #define AF_LAT 14 /* LAT */\r | |
173 | #define AF_HYLINK 15 /* NSC Hyperchannel */\r | |
174 | #define AF_APPLETALK 16 /* Apple Talk */\r | |
175 | #define AF_ROUTE 17 /* Internal Routing Protocol */\r | |
176 | #define AF_LINK 18 /* Link layer interface */\r | |
177 | #if defined(_NETBSD_SOURCE)\r | |
178 | #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */\r | |
179 | #endif\r | |
180 | #define AF_COIP 20 /* connection-oriented IP, aka ST II */\r | |
181 | #define AF_CNT 21 /* Computer Network Technology */\r | |
182 | #if defined(_NETBSD_SOURCE)\r | |
183 | #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */\r | |
184 | #endif\r | |
185 | #define AF_IPX 23 /* Novell Internet Protocol */\r | |
186 | #define AF_INET6 24 /* IP version 6 */\r | |
187 | #if defined(_NETBSD_SOURCE)\r | |
188 | #define pseudo_AF_PIP 25 /* Help Identify PIP packets */\r | |
189 | #endif\r | |
190 | #define AF_ISDN 26 /* Integrated Services Digital Network*/\r | |
191 | #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */\r | |
192 | #define AF_NATM 27 /* native ATM access */\r | |
193 | #define AF_ARP 28 /* (rev.) addr. res. prot. (RFC 826) */\r | |
194 | #if defined(_NETBSD_SOURCE)\r | |
195 | #define pseudo_AF_KEY 29 /* Internal key management protocol */\r | |
196 | #define pseudo_AF_HDRCMPLT 30 /* Used by BPF to not rewrite hdrs\r | |
197 | in interface output routine */\r | |
198 | #endif\r | |
199 | #define AF_BLUETOOTH 31\r | |
200 | \r | |
201 | #define AF_MAX 32\r | |
202 | \r | |
203 | /*\r | |
204 | * Structure used by kernel to store most\r | |
205 | * addresses.\r | |
206 | */\r | |
207 | struct sockaddr {\r | |
208 | __uint8_t sa_len; /* total length */\r | |
209 | sa_family_t sa_family; /* address family */\r | |
210 | char sa_data[14]; /* actually longer; address value */\r | |
211 | };\r | |
212 | \r | |
213 | #if defined(_KERNEL)\r | |
214 | /*\r | |
215 | * Structure used by kernel to pass protocol\r | |
216 | * information in raw sockets.\r | |
217 | */\r | |
218 | struct sockproto {\r | |
219 | u_short sp_family; /* address family */\r | |
220 | u_short sp_protocol; /* protocol */\r | |
221 | };\r | |
222 | #endif /* _KERNEL */\r | |
223 | \r | |
224 | #if 1\r | |
225 | /*\r | |
226 | * RFC 2553: protocol-independent placeholder for socket addresses\r | |
227 | */\r | |
228 | #define _SS_MAXSIZE 128\r | |
229 | #define _SS_ALIGNSIZE (sizeof(__int64_t))\r | |
230 | #define _SS_PAD1SIZE (_SS_ALIGNSIZE - 2)\r | |
231 | #define _SS_PAD2SIZE (_SS_MAXSIZE - 2 - \\r | |
232 | _SS_PAD1SIZE - _SS_ALIGNSIZE)\r | |
233 | \r | |
234 | #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)\r | |
235 | struct sockaddr_storage {\r | |
236 | __uint8_t ss_len; /* address length */\r | |
237 | sa_family_t ss_family; /* address family */\r | |
238 | char __ss_pad1[_SS_PAD1SIZE];\r | |
239 | __int64_t __ss_align;/* force desired structure storage alignment */\r | |
240 | char __ss_pad2[_SS_PAD2SIZE];\r | |
241 | };\r | |
242 | #endif /* _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */\r | |
243 | #endif /* 1 */\r | |
244 | \r | |
245 | /*\r | |
246 | * Protocol families, same as address families for now.\r | |
247 | */\r | |
248 | #define PF_UNSPEC AF_UNSPEC\r | |
249 | #define PF_LOCAL AF_LOCAL\r | |
250 | #define PF_UNIX PF_LOCAL /* backward compatibility */\r | |
251 | #define PF_INET AF_INET\r | |
252 | #define PF_IMPLINK AF_IMPLINK\r | |
253 | #define PF_PUP AF_PUP\r | |
254 | #define PF_CHAOS AF_CHAOS\r | |
255 | #define PF_NS AF_NS\r | |
256 | #define PF_ISO AF_ISO\r | |
257 | #define PF_OSI AF_ISO\r | |
258 | #define PF_ECMA AF_ECMA\r | |
259 | #define PF_DATAKIT AF_DATAKIT\r | |
260 | #define PF_CCITT AF_CCITT\r | |
261 | #define PF_SNA AF_SNA\r | |
262 | #define PF_DECnet AF_DECnet\r | |
263 | #define PF_DLI AF_DLI\r | |
264 | #define PF_LAT AF_LAT\r | |
265 | #define PF_HYLINK AF_HYLINK\r | |
266 | #define PF_APPLETALK AF_APPLETALK\r | |
267 | #define PF_ROUTE AF_ROUTE\r | |
268 | #define PF_LINK AF_LINK\r | |
269 | #if defined(_NETBSD_SOURCE)\r | |
270 | #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */\r | |
271 | #endif\r | |
272 | #define PF_COIP AF_COIP\r | |
273 | #define PF_CNT AF_CNT\r | |
274 | #define PF_INET6 AF_INET6\r | |
275 | #define PF_IPX AF_IPX /* same format as AF_NS */\r | |
276 | #if defined(_NETBSD_SOURCE)\r | |
277 | #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */\r | |
278 | #define PF_PIP pseudo_AF_PIP\r | |
279 | #endif\r | |
280 | #define PF_ISDN AF_ISDN /* same as E164 */\r | |
281 | #define PF_E164 AF_E164\r | |
282 | #define PF_NATM AF_NATM\r | |
283 | #define PF_ARP AF_ARP\r | |
284 | #if defined(_NETBSD_SOURCE)\r | |
285 | #define PF_KEY pseudo_AF_KEY /* like PF_ROUTE, only for key mgmt */\r | |
286 | #endif\r | |
287 | #define PF_BLUETOOTH AF_BLUETOOTH\r | |
288 | \r | |
289 | #define PF_MAX AF_MAX\r | |
290 | \r | |
291 | #if defined(_NETBSD_SOURCE)\r | |
292 | \r | |
293 | #ifndef gid_t\r | |
294 | typedef __gid_t gid_t; /* group id */\r | |
295 | #define gid_t __gid_t\r | |
296 | #endif\r | |
297 | \r | |
298 | #ifndef uid_t\r | |
299 | typedef __uid_t uid_t; /* user id */\r | |
300 | #define uid_t __uid_t\r | |
301 | #endif\r | |
302 | \r | |
303 | /*\r | |
304 | * Socket credentials.\r | |
305 | */\r | |
306 | struct sockcred {\r | |
307 | uid_t sc_uid; /* real user id */\r | |
308 | uid_t sc_euid; /* effective user id */\r | |
309 | gid_t sc_gid; /* real group id */\r | |
310 | gid_t sc_egid; /* effective group id */\r | |
311 | int sc_ngroups; /* number of supplemental groups */\r | |
312 | gid_t sc_groups[1]; /* variable length */\r | |
313 | };\r | |
314 | \r | |
315 | /*\r | |
316 | * Compute size of a sockcred structure with groups.\r | |
317 | */\r | |
318 | #define SOCKCREDSIZE(ngrps) \\r | |
319 | (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))\r | |
320 | #endif /* _NETBSD_SOURCE */\r | |
321 | \r | |
322 | \r | |
323 | #if defined(_NETBSD_SOURCE)\r | |
324 | /*\r | |
325 | * Definitions for network related sysctl, CTL_NET.\r | |
326 | *\r | |
327 | * Second level is protocol family.\r | |
328 | * Third level is protocol number.\r | |
329 | *\r | |
330 | * Further levels are defined by the individual families below.\r | |
331 | */\r | |
332 | #define NET_MAXID AF_MAX\r | |
333 | \r | |
334 | #define CTL_NET_NAMES { \\r | |
335 | { 0, 0 }, \\r | |
336 | { "local", CTLTYPE_NODE }, \\r | |
337 | { "inet", CTLTYPE_NODE }, \\r | |
338 | { "implink", CTLTYPE_NODE }, \\r | |
339 | { "pup", CTLTYPE_NODE }, \\r | |
340 | { "chaos", CTLTYPE_NODE }, \\r | |
341 | { "xerox_ns", CTLTYPE_NODE }, \\r | |
342 | { "iso", CTLTYPE_NODE }, \\r | |
343 | { "emca", CTLTYPE_NODE }, \\r | |
344 | { "datakit", CTLTYPE_NODE }, \\r | |
345 | { "ccitt", CTLTYPE_NODE }, \\r | |
346 | { "ibm_sna", CTLTYPE_NODE }, \\r | |
347 | { "decnet", CTLTYPE_NODE }, \\r | |
348 | { "dec_dli", CTLTYPE_NODE }, \\r | |
349 | { "lat", CTLTYPE_NODE }, \\r | |
350 | { "hylink", CTLTYPE_NODE }, \\r | |
351 | { "appletalk", CTLTYPE_NODE }, \\r | |
352 | { "route", CTLTYPE_NODE }, \\r | |
353 | { "link_layer", CTLTYPE_NODE }, \\r | |
354 | { "xtp", CTLTYPE_NODE }, \\r | |
355 | { "coip", CTLTYPE_NODE }, \\r | |
356 | { "cnt", CTLTYPE_NODE }, \\r | |
357 | { "rtip", CTLTYPE_NODE }, \\r | |
358 | { "ipx", CTLTYPE_NODE }, \\r | |
359 | { "inet6", CTLTYPE_NODE }, \\r | |
360 | { "pip", CTLTYPE_NODE }, \\r | |
361 | { "isdn", CTLTYPE_NODE }, \\r | |
362 | { "natm", CTLTYPE_NODE }, \\r | |
363 | { "arp", CTLTYPE_NODE }, \\r | |
364 | { "key", CTLTYPE_NODE }, \\r | |
365 | }\r | |
366 | \r | |
367 | struct kinfo_pcb {\r | |
368 | __uint64_t ki_pcbaddr; /* PTR: pcb addr */\r | |
369 | __uint64_t ki_ppcbaddr; /* PTR: ppcb addr */\r | |
370 | __uint64_t ki_sockaddr; /* PTR: socket addr */\r | |
371 | \r | |
372 | __uint32_t ki_family; /* INT: protocol family */\r | |
373 | __uint32_t ki_type; /* INT: socket type */\r | |
374 | __uint32_t ki_protocol; /* INT: protocol */\r | |
375 | __uint32_t ki_pflags; /* INT: generic protocol flags */\r | |
376 | \r | |
377 | __uint32_t ki_sostate; /* INT: socket state */\r | |
378 | __uint32_t ki_prstate; /* INT: protocol state */\r | |
379 | __int32_t ki_tstate; /* INT: tcp state */\r | |
380 | __uint32_t ki_tflags; /* INT: tcp flags */\r | |
381 | \r | |
382 | __uint64_t ki_rcvq; /* U_LONG: receive queue len */\r | |
383 | __uint64_t ki_sndq; /* U_LONG: send queue len */\r | |
384 | \r | |
385 | union {\r | |
386 | struct sockaddr _kis_src; /* STRUCT: local address */\r | |
387 | char _kis_pad[256 + 8]; /* pad to max addr length */\r | |
388 | } ki_s;\r | |
389 | union {\r | |
390 | struct sockaddr _kid_dst; /* STRUCT: remote address */\r | |
391 | char _kid_pad[256 + 8]; /* pad to max addr length */\r | |
392 | } ki_d;\r | |
393 | \r | |
394 | __uint64_t ki_inode; /* INO_T: fake inode number */\r | |
395 | __uint64_t ki_vnode; /* PTR: if associated with file */\r | |
396 | __uint64_t ki_conn; /* PTR: control block of peer */\r | |
397 | __uint64_t ki_refs; /* PTR: referencing socket */\r | |
398 | __uint64_t ki_nextref; /* PTR: link in refs list */\r | |
399 | };\r | |
400 | \r | |
401 | #define ki_src ki_s._kis_src\r | |
402 | #define ki_dst ki_d._kid_dst\r | |
403 | \r | |
404 | #define PCB_SLOP 20\r | |
405 | #define PCB_ALL 0\r | |
406 | \r | |
407 | #endif /* _NETBSD_SOURCE */\r | |
408 | \r | |
409 | #if defined(_NETBSD_SOURCE)\r | |
410 | /*\r | |
411 | * PF_ROUTE - Routing table\r | |
412 | *\r | |
413 | * Three additional levels are defined:\r | |
414 | * Fourth: address family, 0 is wildcard\r | |
415 | * Fifth: type of info, defined below\r | |
416 | * Sixth: flag(s) to mask with for NET_RT_FLAGS\r | |
417 | */\r | |
418 | #define NET_RT_DUMP 1 /* dump; may limit to a.f. */\r | |
419 | #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */\r | |
420 | #define NET_RT_OIFLIST 3 /* old NET_RT_IFLIST (pre 1.5) */\r | |
421 | #define NET_RT_IFLIST 4 /* survey interface list */\r | |
422 | #define NET_RT_MAXID 5\r | |
423 | \r | |
424 | #define CTL_NET_RT_NAMES { \\r | |
425 | { 0, 0 }, \\r | |
426 | { "dump", CTLTYPE_STRUCT }, \\r | |
427 | { "flags", CTLTYPE_STRUCT }, \\r | |
428 | { 0, 0 }, \\r | |
429 | { "iflist", CTLTYPE_STRUCT }, \\r | |
430 | }\r | |
431 | #endif /* _NETBSD_SOURCE */\r | |
432 | \r | |
433 | /*\r | |
434 | * Maximum queue length specifiable by listen(2).\r | |
435 | */\r | |
436 | #ifndef SOMAXCONN\r | |
437 | #define SOMAXCONN 128\r | |
438 | #endif\r | |
439 | \r | |
440 | /*\r | |
441 | * Message header for recvmsg and sendmsg calls.\r | |
442 | * Used value-result for recvmsg, value only for sendmsg.\r | |
443 | */\r | |
444 | struct msghdr {\r | |
445 | void *msg_name; /* optional address */\r | |
446 | socklen_t msg_namelen; /* size of address */\r | |
447 | struct iovec *msg_iov; /* scatter/gather array */\r | |
448 | int msg_iovlen; /* # elements in msg_iov */\r | |
449 | void *msg_control; /* ancillary data, see below */\r | |
450 | socklen_t msg_controllen; /* ancillary data buffer len */\r | |
451 | int msg_flags; /* flags on received message */\r | |
452 | };\r | |
453 | \r | |
454 | #define MSG_OOB 0x0001 /* process out-of-band data */\r | |
455 | #define MSG_PEEK 0x0002 /* peek at incoming message */\r | |
456 | #define MSG_DONTROUTE 0x0004 /* send without using routing tables */\r | |
457 | #define MSG_EOR 0x0008 /* data completes record */\r | |
458 | #define MSG_TRUNC 0x0010 /* data discarded before delivery */\r | |
459 | #define MSG_CTRUNC 0x0020 /* control data lost before delivery */\r | |
460 | #define MSG_WAITALL 0x0040 /* wait for full request or error */\r | |
461 | #define MSG_DONTWAIT 0x0080 /* this message should be nonblocking */\r | |
462 | #define MSG_BCAST 0x0100 /* this message was rcvd using link-level brdcst */\r | |
463 | #define MSG_MCAST 0x0200 /* this message was rcvd using link-level mcast */\r | |
464 | #define MSG_NOSIGNAL 0x0400 /* do not generate SIGPIPE on EOF */\r | |
465 | \r | |
466 | /*\r | |
467 | * Header for ancillary data objects in msg_control buffer.\r | |
468 | * Used for additional information with/about a datagram\r | |
469 | * not expressible by flags. The format is a sequence\r | |
470 | * of message elements headed by cmsghdr structures.\r | |
471 | */\r | |
472 | struct cmsghdr {\r | |
473 | socklen_t cmsg_len; /* data byte count, including hdr */\r | |
474 | int cmsg_level; /* originating protocol */\r | |
475 | int cmsg_type; /* protocol-specific type */\r | |
476 | /* followed by u_char cmsg_data[]; */\r | |
477 | };\r | |
478 | \r | |
479 | /* given pointer to struct cmsghdr, return pointer to data */\r | |
480 | #define CMSG_DATA(cmsg) \\r | |
481 | ((u_char *)(void *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr)))\r | |
482 | #define CCMSG_DATA(cmsg) \\r | |
483 | ((const u_char *)(const void *)(cmsg) + \\r | |
484 | __CMSG_ALIGN(sizeof(struct cmsghdr)))\r | |
485 | \r | |
486 | /*\r | |
487 | * Alignment requirement for CMSG struct manipulation.\r | |
488 | * This basically behaves the same as ALIGN() ARCH/include/param.h.\r | |
489 | * We declare it separately for two reasons:\r | |
490 | * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's\r | |
491 | * idea of ALIGNBYTES at runtime.\r | |
492 | * without (2), we can't guarantee binary compatibility in case of future\r | |
493 | * changes in ALIGNBYTES.\r | |
494 | */\r | |
495 | #define __CMSG_ALIGN(n) (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes())\r | |
496 | #ifdef _KERNEL\r | |
497 | #define CMSG_ALIGN(n) __CMSG_ALIGN(n)\r | |
498 | #endif\r | |
499 | \r | |
500 | /* given pointer to struct cmsghdr, return pointer to next cmsghdr */\r | |
501 | #define CMSG_NXTHDR(mhdr, cmsg) \\r | |
502 | (((__caddr_t)(cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len) + \\r | |
503 | __CMSG_ALIGN(sizeof(struct cmsghdr)) > \\r | |
504 | (((__caddr_t)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \\r | |
505 | (struct cmsghdr *)0 : \\r | |
506 | (struct cmsghdr *)((__caddr_t)(cmsg) + \\r | |
507 | __CMSG_ALIGN((cmsg)->cmsg_len)))\r | |
508 | \r | |
509 | /*\r | |
510 | * RFC 2292 requires to check msg_controllen, in case that the kernel returns\r | |
511 | * an empty list for some reasons.\r | |
512 | */\r | |
513 | #define CMSG_FIRSTHDR(mhdr) \\r | |
514 | ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \\r | |
515 | (struct cmsghdr *)(mhdr)->msg_control : \\r | |
516 | (struct cmsghdr *)0)\r | |
517 | \r | |
518 | #define CMSG_SPACE(l) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(l))\r | |
519 | #define CMSG_LEN(l) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))\r | |
520 | \r | |
521 | /* "Socket"-level control message types: */\r | |
522 | #define SCM_RIGHTS 0x01 /* access rights (array of int) */\r | |
523 | #if defined(_NETBSD_SOURCE)\r | |
524 | #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */\r | |
525 | #define SCM_CREDS 0x04 /* credentials (struct sockcred) */\r | |
526 | #endif\r | |
527 | \r | |
528 | /*\r | |
529 | * Types of socket shutdown(2).\r | |
530 | */\r | |
531 | #define SHUT_RD 0 /* Disallow further receives. */\r | |
532 | #define SHUT_WR 1 /* Disallow further sends. */\r | |
533 | #define SHUT_RDWR 2 /* Disallow further sends/receives. */\r | |
534 | \r | |
535 | #include <sys/EfiCdefs.h>\r | |
536 | \r | |
537 | __BEGIN_DECLS\r | |
538 | int __cmsg_alignbytes(void);\r | |
539 | __END_DECLS\r | |
540 | \r | |
541 | #ifndef _KERNEL\r | |
542 | \r | |
543 | __BEGIN_DECLS\r | |
544 | int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);\r | |
545 | int bind(int, const struct sockaddr *, socklen_t);\r | |
546 | int connect(int, const struct sockaddr *, socklen_t);\r | |
547 | int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);\r | |
548 | int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);\r | |
549 | int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);\r | |
550 | int listen(int, int);\r | |
551 | ssize_t recv(int, void *, size_t, int);\r | |
552 | ssize_t recvfrom(int, void * __restrict, size_t, int,\r | |
553 | struct sockaddr * __restrict, socklen_t * __restrict);\r | |
554 | ssize_t recvmsg(int, struct msghdr *, int);\r | |
555 | ssize_t send(int, const void *, size_t, int);\r | |
556 | ssize_t sendto(int, const void *,\r | |
557 | size_t, int, const struct sockaddr *, socklen_t);\r | |
558 | ssize_t sendmsg(int, const struct msghdr *, int);\r | |
559 | int setsockopt(int, int, int, const void *, socklen_t);\r | |
560 | int shutdown(int, int);\r | |
561 | int sockatmark(int);\r | |
562 | int socket(int, int, int)\r | |
563 | #if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)\r | |
564 | __RENAME(__socket30)\r | |
565 | #endif\r | |
566 | ;\r | |
567 | int socketpair(int, int, int, int *);\r | |
568 | __END_DECLS\r | |
569 | #endif /* !_KERNEL */\r | |
570 | \r | |
571 | #endif /* !_SYS_SOCKET_H_ */\r |