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