2 * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */
29 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
31 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
32 * The Regents of the University of California. All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. All advertising materials mentioning features or use of this software
43 * must display the following acknowledgement:
44 * This product includes software developed by the University of
45 * California, Berkeley and its contributors.
46 * 4. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * @(#)socket.h 8.4 (Berkeley) 2/21/94
63 * $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $
66 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
67 * support for mandatory and extensible security protections. This notice
68 * is included in support of clause 2.2 (b) of the Apple Public License,
72 #ifndef _SYS_SOCKET_H_
73 #define _SYS_SOCKET_H_
75 #include <sys/types.h>
76 #include <sys/cdefs.h>
77 #include <machine/_param.h>
80 #include <sys/param.h>
81 #include <uuid/uuid.h>
85 #include <Availability.h>
89 * Definitions related to sockets: types, address families, options.
96 #include <sys/_types/_gid_t.h>
97 #include <sys/_types/_off_t.h>
98 #include <sys/_types/_pid_t.h>
99 #include <sys/_types/_sa_family_t.h>
100 #include <sys/_types/_socklen_t.h>
102 /* XXX Not explicitly defined by POSIX, but function return types are */
103 #include <sys/_types/_size_t.h>
105 /* XXX Not explicitly defined by POSIX, but function return types are */
106 #include <sys/_types/_ssize_t.h>
109 * [XSI] The iovec structure shall be defined as described in <sys/uio.h>.
111 #include <sys/_types/_iovec_t.h>
114 #define SO_TCDBG_PID 0x01 /* Set/get traffic class for PID */
115 #define SO_TCDBG_PNAME 0x02 /* Set/get traffic class for processes of that name */
116 #define SO_TCDBG_PURGE 0x04 /* Purge entries for unused PIDs */
117 #define SO_TCDBG_FLUSH 0x08 /* Flush all entries */
118 #define SO_TCDBG_COUNT 0x10 /* Get count of entries */
119 #define SO_TCDBG_LIST 0x20 /* List entries */
120 #define SO_TCDBG_DELETE 0x40 /* Delete a process entry */
121 #define SO_TCDBG_TCFLUSH_PID 0x80 /* Flush traffic class for PID */
124 u_int32_t so_tcdbg_cmd
;
125 int32_t so_tcdbg_tclass
;
126 u_int32_t so_tcdbg_count
;
128 char so_tcdbg_pname
[MAXCOMLEN
+ 1];
129 int32_t so_tcdbg_opportunistic
; /* -1: unspecified, 0: off, 1: on, other: errors */
136 #define SOCK_STREAM 1 /* stream socket */
137 #define SOCK_DGRAM 2 /* datagram socket */
138 #define SOCK_RAW 3 /* raw-protocol interface */
139 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
140 #define SOCK_RDM 4 /* reliably-delivered message */
141 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
142 #define SOCK_SEQPACKET 5 /* sequenced packet stream */
145 * Option flags per-socket.
147 #define SO_DEBUG 0x0001 /* turn on debugging info recording */
148 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
149 #define SO_REUSEADDR 0x0004 /* allow local address reuse */
150 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
151 #define SO_DONTROUTE 0x0010 /* just use interface addresses */
152 #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
153 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
154 #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
155 #define SO_LINGER 0x0080 /* linger on close if data present (in ticks) */
157 #define SO_LINGER 0x1080 /* linger on close if data present (in seconds) */
158 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
159 #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
160 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
161 #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
162 #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */
163 #define SO_TIMESTAMP_MONOTONIC 0x0800 /* Monotonically increasing timestamp on rcvd dgram */
165 #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */
167 #define SO_DONTTRUNC 0x2000 /* APPLE: Retain unread data */
169 #define SO_WANTMORE 0x4000 /* APPLE: Give hint when more data ready */
170 #define SO_WANTOOBFLAG 0x8000 /* APPLE: Want OOB in MSG_FLAG on receive */
173 #define SO_NOWAKEFROMSLEEP 0x10000 /* Don't wake for traffic to this socket */
176 #endif /* (!__APPLE__) */
177 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
180 * Additional options, not kept in so_options.
182 #define SO_SNDBUF 0x1001 /* send buffer size */
183 #define SO_RCVBUF 0x1002 /* receive buffer size */
184 #define SO_SNDLOWAT 0x1003 /* send low-water mark */
185 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
186 #define SO_SNDTIMEO 0x1005 /* send timeout */
187 #define SO_RCVTIMEO 0x1006 /* receive timeout */
188 #define SO_ERROR 0x1007 /* get error status and clear */
189 #define SO_TYPE 0x1008 /* get socket type */
190 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
191 /*efine SO_PRIVSTATE 0x1009 get/deny privileged state */
192 #define SO_LABEL 0x1010 /* socket's MAC label */
193 #define SO_PEERLABEL 0x1011 /* socket's peer MAC label */
195 #define SO_NREAD 0x1020 /* APPLE: get 1st-packet byte count */
196 #define SO_NKE 0x1021 /* APPLE: Install socket-level NKE */
197 #define SO_NOSIGPIPE 0x1022 /* APPLE: No SIGPIPE on EPIPE */
198 #define SO_NOADDRERR 0x1023 /* APPLE: Returns EADDRNOTAVAIL when src is not available anymore */
199 #define SO_NWRITE 0x1024 /* APPLE: Get number of bytes currently in send socket buffer */
200 #define SO_REUSESHAREUID 0x1025 /* APPLE: Allow reuse of port/socket by different userids */
201 #ifdef __APPLE_API_PRIVATE
202 #define SO_NOTIFYCONFLICT 0x1026 /* APPLE: send notification if there is a bind on a port which is already in use */
203 #define SO_UPCALLCLOSEWAIT 0x1027 /* APPLE: block on close until an upcall returns */
205 #define SO_LINGER_SEC 0x1080 /* linger on close if data present (in seconds) */
207 #define SO_RESTRICTIONS 0x1081 /* APPLE: deny flag set */
208 #define SO_RESTRICT_DENY_IN 0x1 /* deny inbound (trapdoor) */
209 #define SO_RESTRICT_DENY_OUT 0x2 /* deny outbound (trapdoor) */
210 #define SO_RESTRICT_DENY_CELLULAR 0x4 /* deny use of cellular (trapdoor) */
211 #define SO_RESTRICT_DENY_EXPENSIVE 0x8 /* deny use of expensive if (trapdoor)*/
213 #define SO_RANDOMPORT 0x1082 /* APPLE: request local port randomization */
214 #define SO_NP_EXTENSIONS 0x1083 /* To turn off some POSIX behavior */
218 #define SO_EXECPATH 0x1085 /* Application Firewall Socket option */
220 * Traffic service class definitions (lowest to highest):
223 * "Background System-Initiated", high delay tolerant, high loss
224 * tolerant, elastic flow, variable size & long-lived. E.g: system-
225 * initiated iCloud synching or Time Capsule backup, for which there
226 * is no progress feedbacks.
229 * "Background", user-initiated, high delay tolerant, high loss tolerant,
230 * elastic flow, variable size. E.g. user-initiated iCloud synching or
231 * Time Capsule backup; or traffics of background applications, for which
232 * there is some progress feedbacks.
235 * "Best Effort", unclassified/standard. This is the default service
236 * class; pretty much a mix of everything.
239 * "Responsive Data", a notch higher than "Best Effort", medium delay
240 * tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email,
241 * instant messaging, for which there is a sense of interactivity and
242 * urgency (user waiting for output).
245 * "Operations, Administration, and Management", medium delay tolerant,
246 * low-medium loss tolerant, elastic & inelastic flows, variable size.
250 * "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium
251 * loss tolerant, elastic flow, constant packet interval, variable rate &
252 * size. E.g. AirPlay playback (both video and audio).
255 * "Responsive Multimedia Audio/Video", low delay tolerant, low-medium
256 * loss tolerant, elastic flow, variable packet interval, rate and size.
257 * E.g. AirPlay mirroring, screen sharing.
260 * "Interactive Video", low delay tolerant, low-medium loss tolerant,
261 * elastic flow, constant packet interval, variable rate & size. E.g.
265 * "Interactive Voice", low delay tolerant, low loss tolerant, inelastic
266 * flow, constant packet rate, somewhat fixed size. E.g. VoIP including
270 * "Network Control", low delay tolerant, low loss tolerant, inelastic
271 * flow, rate is bursty but short, variable size. E.g. DNS queries;
272 * certain types of locally-originated ICMP, ICMPv6; IGMP/MLD join/leave,
275 #define SO_TRAFFIC_CLASS 0x1086 /* Traffic service class (int) */
276 #define SO_TC_BK_SYS 100 /* lowest class */
280 #define SO_TC_OAM 400
285 #define SO_TC_CTL 900 /* highest class */
286 #define SO_TC_MAX 10 /* Total # of traffic classes */
287 #ifdef XNU_KERNEL_PRIVATE
288 #define _SO_TC_BK 1 /* deprecated */
289 #define _SO_TC_VI 2 /* deprecated */
290 #define _SO_TC_VO 3 /* deprecated */
291 #define _SO_TC_MAX 4 /* deprecated */
293 #define SO_VALID_TC(c) \
294 (c == SO_TC_BK_SYS || c == SO_TC_BK || c == SO_TC_BE || \
295 c == SO_TC_RD || c == SO_TC_OAM || c == SO_TC_AV || \
296 c == SO_TC_RV || c == SO_TC_VI || c == SO_TC_VO || c == SO_TC_CTL)
297 #endif /* XNU_KERNEL_PRIVATE */
299 /* Background socket configuration flags */
300 #define TRAFFIC_MGT_SO_BACKGROUND 0x0001 /* background socket */
301 #define TRAFFIC_MGT_TCP_RECVBG 0x0002 /* Only TCP sockets, receiver throttling */
303 #define SO_RECV_TRAFFIC_CLASS 0x1087 /* Receive traffic class (bool)*/
304 #define SO_TRAFFIC_CLASS_DBG 0x1088 /* Debug traffic class (struct so_tcdbg) */
305 #define SO_TRAFFIC_CLASS_STATS 0x1089 /* Traffic class statistics */
306 #define SO_PRIVILEGED_TRAFFIC_CLASS 0x1090 /* Privileged traffic class (bool) */
307 #define SO_DEFUNCTOK 0x1100 /* can be defunct'd */
308 #define SO_ISDEFUNCT 0x1101 /* get defunct status */
310 #define SO_OPPORTUNISTIC 0x1102 /* deprecated; use SO_TRAFFIC_CLASS */
313 * SO_FLUSH flushes any unsent data generated by a given socket. It takes
314 * an integer parameter, which can be any of the SO_TC traffic class values,
315 * or the special SO_TC_ALL value.
317 #define SO_FLUSH 0x1103 /* flush unsent data (int) */
318 #define SO_TC_ALL (-1)
320 #define SO_RECV_ANYIF 0x1104 /* unrestricted inbound processing */
321 #define SO_TRAFFIC_MGT_BACKGROUND 0x1105 /* Background traffic management */
323 #define SO_FLOW_DIVERT_TOKEN 0x1106 /* flow divert token */
325 #define SO_DELEGATED 0x1107 /* set socket as delegate (pid_t) */
326 #define SO_DELEGATED_UUID 0x1108 /* set socket as delegate (uuid_t) */
327 #define SO_NECP_ATTRIBUTES 0x1109 /* NECP socket attributes (domain, account, etc.) */
328 #define SO_CFIL_SOCK_ID 0x1110 /* get content filter socket ID (cfil_sock_id_t) */
330 #define SO_MPTCP_FASTJOIN 0x1111 /* fast join MPTCP */
333 #define SO_AWDL_UNRESTRICTED 0x1113 /* try to use AWDL in restricted mode */
336 #define SO_NUMRCVPKT 0x1112 /* number of datagrams in receive socket buffer */
338 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
341 * Structure used for manipulating linger option.
344 int l_onoff
; /* option on/off */
345 int l_linger
; /* linger time */
349 struct accept_filter_arg
{
355 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
359 * Structure to control non-portable Sockets extension to POSIX
361 struct so_np_extensions
{
366 #define SONPX_SETOPTSHUT 0x000000001 /* flag for allowing setsockopt after shutdown */
369 #ifdef KERNEL_PRIVATE
370 #define SONPX_MASK_VALID (SONPX_SETOPTSHUT)
371 #define IS_SO_TC_BACKGROUND(_tc_) ((_tc_) == SO_TC_BK || (_tc_) == SO_TC_BK_SYS)
372 #define IS_SO_TC_BACKGROUNDSYSTEM(_tc_) ((_tc_) == SO_TC_BK_SYS)
373 #endif /* KERNEL_PRIVATE */
379 * Level number for (get/set)sockopt() to apply to socket itself.
381 #define SOL_SOCKET 0xffff /* options for socket level */
387 #define AF_UNSPEC 0 /* unspecified */
388 #define AF_UNIX 1 /* local to host (pipes) */
389 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
390 #define AF_LOCAL AF_UNIX /* backward compatibility */
391 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
392 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
393 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
394 #define AF_IMPLINK 3 /* arpanet imp addresses */
395 #define AF_PUP 4 /* pup protocols: e.g. BSP */
396 #define AF_CHAOS 5 /* mit CHAOS protocols */
397 #define AF_NS 6 /* XEROX NS protocols */
398 #define AF_ISO 7 /* ISO protocols */
399 #define AF_OSI AF_ISO
400 #define AF_ECMA 8 /* European computer manufacturers */
401 #define AF_DATAKIT 9 /* datakit protocols */
402 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
403 #define AF_SNA 11 /* IBM SNA */
404 #define AF_DECnet 12 /* DECnet */
405 #define AF_DLI 13 /* DEC Direct data link interface */
406 #define AF_LAT 14 /* LAT */
407 #define AF_HYLINK 15 /* NSC Hyperchannel */
408 #define AF_APPLETALK 16 /* Apple Talk */
409 #define AF_ROUTE 17 /* Internal Routing Protocol */
410 #define AF_LINK 18 /* Link layer interface */
411 #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
412 #define AF_COIP 20 /* connection-oriented IP, aka ST II */
413 #define AF_CNT 21 /* Computer Network Technology */
414 #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
415 #define AF_IPX 23 /* Novell Internet Protocol */
416 #define AF_SIP 24 /* Simple Internet Protocol */
417 #define pseudo_AF_PIP 25 /* Help Identify PIP packets */
418 /*define pseudo_AF_BLUE 26 Identify packets for Blue Box - Not used */
419 #define AF_NDRV 27 /* Network Driver 'raw' access */
420 #define AF_ISDN 28 /* Integrated Services Digital Network*/
421 #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
422 #define pseudo_AF_KEY 29 /* Internal key-management function */
423 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
424 #define AF_INET6 30 /* IPv6 */
425 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
426 #define AF_NATM 31 /* native ATM access */
427 #define AF_SYSTEM 32 /* Kernel event messages */
428 #define AF_NETBIOS 33 /* NetBIOS */
429 #define AF_PPP 34 /* PPP communication protocol */
430 #define pseudo_AF_HDRCMPLT 35 /* Used by BPF to not rewrite headers
431 * in interface output routine */
433 #define AF_AFP 36 /* Used by AFP */
435 #define AF_RESERVED_36 36 /* Reserved for internal usage */
437 #define AF_IEEE80211 37 /* IEEE 802.11 protocol */
440 #define AF_MULTIPATH 39
443 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
446 * [XSI] Structure used by kernel to store most addresses.
449 __uint8_t sa_len
; /* total length */
450 sa_family_t sa_family
; /* [XSI] address family */
451 char sa_data
[14]; /* [XSI] addr value (actually larger) */
454 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
455 #define SOCK_MAXADDRLEN 255 /* longest possible addresses */
458 * Structure used by kernel to pass protocol
459 * information in raw sockets.
462 __uint16_t sp_family
; /* address family */
463 __uint16_t sp_protocol
; /* protocol */
465 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE)*/
468 * RFC 2553: protocol-independent placeholder for socket addresses
470 #define _SS_MAXSIZE 128
471 #define _SS_ALIGNSIZE (sizeof(__int64_t))
472 #define _SS_PAD1SIZE \
473 (_SS_ALIGNSIZE - sizeof(__uint8_t) - sizeof(sa_family_t))
474 #define _SS_PAD2SIZE \
475 (_SS_MAXSIZE - sizeof(__uint8_t) - sizeof(sa_family_t) - \
476 _SS_PAD1SIZE - _SS_ALIGNSIZE)
479 * [XSI] sockaddr_storage
481 struct sockaddr_storage
{
482 __uint8_t ss_len
; /* address length */
483 sa_family_t ss_family
; /* [XSI] address family */
484 char __ss_pad1
[_SS_PAD1SIZE
];
485 __int64_t __ss_align
; /* force structure storage alignment */
486 char __ss_pad2
[_SS_PAD2SIZE
];
489 #ifdef BSD_KERNEL_PRIVATE
490 #include <sys/queue.h>
492 struct sockaddr_entry
{
493 TAILQ_ENTRY(sockaddr_entry
) se_link
;
494 struct sockaddr
*se_addr
;
498 #define SEF_ATTACHED 1 /* attached to sockaddr_list */
500 struct sockaddr_list
{
501 TAILQ_HEAD(, sockaddr_entry
) sl_head
;
505 #endif /* BSD_KERNEL_PRIVATE */
508 * Protocol families, same as address families for now.
510 #define PF_UNSPEC AF_UNSPEC
511 #define PF_LOCAL AF_LOCAL
512 #define PF_UNIX PF_LOCAL /* backward compatibility */
513 #define PF_INET AF_INET
514 #define PF_IMPLINK AF_IMPLINK
515 #define PF_PUP AF_PUP
516 #define PF_CHAOS AF_CHAOS
518 #define PF_ISO AF_ISO
519 #define PF_OSI AF_ISO
520 #define PF_ECMA AF_ECMA
521 #define PF_DATAKIT AF_DATAKIT
522 #define PF_CCITT AF_CCITT
523 #define PF_SNA AF_SNA
524 #define PF_DECnet AF_DECnet
525 #define PF_DLI AF_DLI
526 #define PF_LAT AF_LAT
527 #define PF_HYLINK AF_HYLINK
528 #define PF_APPLETALK AF_APPLETALK
529 #define PF_ROUTE AF_ROUTE
530 #define PF_LINK AF_LINK
531 #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
532 #define PF_COIP AF_COIP
533 #define PF_CNT AF_CNT
534 #define PF_SIP AF_SIP
535 #define PF_IPX AF_IPX /* same format as AF_NS */
536 #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
537 #define PF_PIP pseudo_AF_PIP
538 #define PF_NDRV AF_NDRV
539 #define PF_ISDN AF_ISDN
540 #define PF_KEY pseudo_AF_KEY
541 #define PF_INET6 AF_INET6
542 #define PF_NATM AF_NATM
543 #define PF_SYSTEM AF_SYSTEM
544 #define PF_NETBIOS AF_NETBIOS
545 #define PF_PPP AF_PPP
547 #define PF_AFP AF_AFP
549 #define PF_RESERVED_36 AF_RESERVED_36
551 #define PF_UTUN AF_UTUN
553 #define PF_MULTIPATH AF_MULTIPATH
555 #define PF_MAX AF_MAX
558 * These do not have socket-layer support:
560 #define PF_VLAN ((uint32_t)0x766c616e) /* 'vlan' */
561 #define PF_BOND ((uint32_t)0x626f6e64) /* 'bond' */
562 #ifdef KERNEL_PRIVATE
563 #define PF_BRIDGE ((uint32_t)0x62726467) /* 'brdg' */
564 #endif /* KERNEL_PRIVATE */
567 * Definitions for network related sysctl, CTL_NET.
569 * Second level is protocol family.
570 * Third level is protocol number.
572 * Further levels are defined by the individual families below.
574 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
575 #define NET_MAXID AF_MAX
576 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
578 #ifdef KERNEL_PRIVATE
579 #define CTL_NET_NAMES { \
581 { "local", CTLTYPE_NODE }, \
582 { "inet", CTLTYPE_NODE }, \
583 { "implink", CTLTYPE_NODE }, \
584 { "pup", CTLTYPE_NODE }, \
585 { "chaos", CTLTYPE_NODE }, \
586 { "xerox_ns", CTLTYPE_NODE }, \
587 { "iso", CTLTYPE_NODE }, \
588 { "emca", CTLTYPE_NODE }, \
589 { "datakit", CTLTYPE_NODE }, \
590 { "ccitt", CTLTYPE_NODE }, \
591 { "ibm_sna", CTLTYPE_NODE }, \
592 { "decnet", CTLTYPE_NODE }, \
593 { "dec_dli", CTLTYPE_NODE }, \
594 { "lat", CTLTYPE_NODE }, \
595 { "hylink", CTLTYPE_NODE }, \
596 { "appletalk", CTLTYPE_NODE }, \
597 { "route", CTLTYPE_NODE }, \
598 { "link_layer", CTLTYPE_NODE }, \
599 { "xtp", CTLTYPE_NODE }, \
600 { "coip", CTLTYPE_NODE }, \
601 { "cnt", CTLTYPE_NODE }, \
602 { "rtip", CTLTYPE_NODE }, \
603 { "ipx", CTLTYPE_NODE }, \
604 { "sip", CTLTYPE_NODE }, \
605 { "pip", CTLTYPE_NODE }, \
607 { "ndrv", CTLTYPE_NODE }, \
608 { "isdn", CTLTYPE_NODE }, \
609 { "key", CTLTYPE_NODE }, \
610 { "inet6", CTLTYPE_NODE }, \
611 { "natm", CTLTYPE_NODE }, \
612 { "sys", CTLTYPE_NODE }, \
613 { "netbios", CTLTYPE_NODE }, \
614 { "ppp", CTLTYPE_NODE }, \
615 { "hdrcomplete", CTLTYPE_NODE }, \
617 #endif /* KERNEL_PRIVATE */
619 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
621 * PF_ROUTE - Routing table
623 * Three additional levels are defined:
624 * Fourth: address family, 0 is wildcard
625 * Fifth: type of info, defined below
626 * Sixth: flag(s) to mask with for NET_RT_FLAGS
628 #define NET_RT_DUMP 1 /* dump; may limit to a.f. */
629 #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
630 #define NET_RT_IFLIST 3 /* survey interface list */
631 #define NET_RT_STAT 4 /* routing statistics */
632 #define NET_RT_TRASH 5 /* routes not in table but not freed */
633 #define NET_RT_IFLIST2 6 /* interface list with addresses */
634 #define NET_RT_DUMP2 7 /* dump; may limit to a.f. */
636 #define NET_RT_DUMPX 8 /* private */
637 #define NET_RT_DUMPX_FLAGS 9 /* private */
639 #define NET_RT_MAXID 10
640 #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
642 #ifdef KERNEL_PRIVATE
643 #define CTL_NET_RT_NAMES { \
645 { "dump", CTLTYPE_STRUCT }, \
646 { "flags", CTLTYPE_STRUCT }, \
647 { "iflist", CTLTYPE_STRUCT }, \
648 { "stat", CTLTYPE_STRUCT }, \
649 { "trash", CTLTYPE_INT }, \
650 { "iflist2", CTLTYPE_STRUCT }, \
651 { "dump2", CTLTYPE_STRUCT }, \
652 { "dumpx", CTLTYPE_STRUCT }, \
653 { "dumpx_flags", CTLTYPE_STRUCT }, \
656 #endif /* KERNEL_PRIVATE */
659 * Maximum queue length specifiable by listen.
661 #define SOMAXCONN 128
664 * [XSI] Message header for recvmsg and sendmsg calls.
665 * Used value-result for recvmsg, value only for sendmsg.
668 void *msg_name
; /* [XSI] optional address */
669 socklen_t msg_namelen
; /* [XSI] size of address */
670 struct iovec
*msg_iov
; /* [XSI] scatter/gather array */
671 int msg_iovlen
; /* [XSI] # elements in msg_iov */
672 void *msg_control
; /* [XSI] ancillary data, see below */
673 socklen_t msg_controllen
; /* [XSI] ancillary data buffer len */
674 int msg_flags
; /* [XSI] flags on received message */
679 * Extended version for sendmsg_x() and recvmsg_x() calls
681 * For recvmsg_x(), the size of the data received is given by the field
684 * For sendmsg_x(), the size of the data to send is given by the length of
685 * the iovec array -- like sendmsg(). The field msg_datalen is ignored.
688 void *msg_name
; /* optional address */
689 socklen_t msg_namelen
; /* size of address */
690 struct iovec
*msg_iov
; /* scatter/gather array */
691 int msg_iovlen
; /* # elements in msg_iov */
692 void *msg_control
; /* ancillary data, see below */
693 socklen_t msg_controllen
; /* ancillary data buffer len */
694 int msg_flags
; /* flags on received message */
695 size_t msg_datalen
; /* byte length of buffer in msg_iov */
699 #ifdef XNU_KERNEL_PRIVATE
701 * In-kernel representation of "struct msghdr" from
702 * userspace. Has enough precision for 32-bit or
703 * 64-bit clients, but does not need to be packed.
707 user_addr_t msg_name
; /* optional address */
708 socklen_t msg_namelen
; /* size of address */
709 user_addr_t msg_iov
; /* scatter/gather array */
710 int msg_iovlen
; /* # elements in msg_iov */
711 user_addr_t msg_control
; /* ancillary data, see below */
712 socklen_t msg_controllen
; /* ancillary data buffer len */
713 int msg_flags
; /* flags on received message */
717 * LP64 user version of struct msghdr.
718 * WARNING - keep in sync with struct msghdr
721 struct user64_msghdr
{
722 user64_addr_t msg_name
; /* optional address */
723 socklen_t msg_namelen
; /* size of address */
724 user64_addr_t msg_iov
; /* scatter/gather array */
725 int msg_iovlen
; /* # elements in msg_iov */
726 user64_addr_t msg_control
; /* ancillary data, see below */
727 socklen_t msg_controllen
; /* ancillary data buffer len */
728 int msg_flags
; /* flags on received message */
732 * ILP32 user version of struct msghdr.
733 * WARNING - keep in sync with struct msghdr
736 struct user32_msghdr
{
737 user32_addr_t msg_name
; /* optional address */
738 socklen_t msg_namelen
; /* size of address */
739 user32_addr_t msg_iov
; /* scatter/gather array */
740 int msg_iovlen
; /* # elements in msg_iov */
741 user32_addr_t msg_control
; /* ancillary data, see below */
742 socklen_t msg_controllen
; /* ancillary data buffer len */
743 int msg_flags
; /* flags on received message */
747 * In-kernel representation of "struct msghdr_x" from
748 * userspace. Has enough precision for 32-bit or
749 * 64-bit clients, but does not need to be packed.
752 struct user_msghdr_x
{
753 user_addr_t msg_name
; /* optional address */
754 socklen_t msg_namelen
; /* size of address */
755 user_addr_t msg_iov
; /* scatter/gather array */
756 int msg_iovlen
; /* # elements in msg_iov */
757 user_addr_t msg_control
; /* ancillary data, see below */
758 socklen_t msg_controllen
; /* ancillary data buffer len */
759 int msg_flags
; /* flags on received message */
760 size_t msg_datalen
; /* byte length of buffer in msg_iov */
764 * LP64 user version of struct msghdr_x
765 * WARNING - keep in sync with struct msghdr_x
768 struct user64_msghdr_x
{
769 user64_addr_t msg_name
; /* optional address */
770 socklen_t msg_namelen
; /* size of address */
771 user64_addr_t msg_iov
; /* scatter/gather array */
772 int msg_iovlen
; /* # elements in msg_iov */
773 user64_addr_t msg_control
; /* ancillary data, see below */
774 socklen_t msg_controllen
; /* ancillary data buffer len */
775 int msg_flags
; /* flags on received message */
776 user64_size_t msg_datalen
; /* byte length of buffer in msg_iov */
780 * ILP32 user version of struct msghdr_x
781 * WARNING - keep in sync with struct msghdr_x
784 struct user32_msghdr_x
{
785 user32_addr_t msg_name
; /* optional address */
786 socklen_t msg_namelen
; /* size of address */
787 user32_addr_t msg_iov
; /* scatter/gather array */
788 int msg_iovlen
; /* # elements in msg_iov */
789 user32_addr_t msg_control
; /* ancillary data, see below */
790 socklen_t msg_controllen
; /* ancillary data buffer len */
791 int msg_flags
; /* flags on received message */
792 user32_size_t msg_datalen
; /* byte length of buffer in msg_iov */
795 #endif /* XNU_KERNEL_PRIVATE */
797 #define MSG_OOB 0x1 /* process out-of-band data */
798 #define MSG_PEEK 0x2 /* peek at incoming message */
799 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
800 #define MSG_EOR 0x8 /* data completes record */
801 #define MSG_TRUNC 0x10 /* data discarded before delivery */
802 #define MSG_CTRUNC 0x20 /* control data lost before delivery */
803 #define MSG_WAITALL 0x40 /* wait for full request or error */
804 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
805 #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
806 #define MSG_EOF 0x100 /* data completes connection */
809 #ifdef __APPLE_API_OBSOLETE
810 #define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */
813 #define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */
815 #define MSG_FLUSH 0x400 /* Start of 'hold' seq; dump so_temp */
816 #define MSG_HOLD 0x800 /* Hold frag in so_temp */
817 #define MSG_SEND 0x1000 /* Send the packet in so_temp */
818 #define MSG_HAVEMORE 0x2000 /* Data ready to be read */
819 #define MSG_RCVMORE 0x4000 /* Data remains in current pkt */
821 #ifdef KERNEL_PRIVATE
822 #define MSG_COMPAT 0x8000 /* deprecated */
823 #endif /* KERNEL_PRIVATE */
824 #define MSG_NEEDSA 0x10000 /* Fail receive if socket address cannot be allocated */
825 #ifdef KERNEL_PRIVATE
826 #define MSG_NBIO 0x20000 /* FIONBIO mode, used by fifofs */
827 #define MSG_SKIPCFIL 0x40000 /* skip pass content filter */
830 #define MSG_USEUPCALL 0x80000000 /* Inherit upcall in sock_accept */
832 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
835 * Header for ancillary data objects in msg_control buffer.
836 * Used for additional information with/about a datagram
837 * not expressible by flags. The format is a sequence
838 * of message elements headed by cmsghdr structures.
841 socklen_t cmsg_len
; /* [XSI] data byte count, including hdr */
842 int cmsg_level
; /* [XSI] originating protocol */
843 int cmsg_type
; /* [XSI] protocol-specific type */
844 /* followed by unsigned char cmsg_data[]; */
847 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
850 * While we may have more groups than this, the cmsgcred struct must
851 * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow
854 #define CMGROUP_MAX 16
857 * Credentials structure, used to verify the identity of a peer
858 * process that has sent us a message. This is allocated by the
859 * peer process but filled in by the kernel. This prevents the
860 * peer from lying about its identity. (Note that cmcred_groups[0]
861 * is the effective GID.)
864 pid_t cmcred_pid
; /* PID of sending process */
865 uid_t cmcred_uid
; /* real UID of sending process */
866 uid_t cmcred_euid
; /* effective UID of sending process */
867 gid_t cmcred_gid
; /* real GID of sending process */
868 short cmcred_ngroups
; /* number or groups */
869 gid_t cmcred_groups
[CMGROUP_MAX
]; /* groups */
872 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
874 /* given pointer to struct cmsghdr, return pointer to data */
875 #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
876 __DARWIN_ALIGN32(sizeof(struct cmsghdr)))
879 * RFC 2292 requires to check msg_controllen, in case that the kernel returns
880 * an empty list for some reasons.
882 #define CMSG_FIRSTHDR(mhdr) \
883 ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
884 (struct cmsghdr *)(mhdr)->msg_control : \
885 (struct cmsghdr *)0L)
889 * Given pointer to struct cmsghdr, return pointer to next cmsghdr
890 * RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr)
892 #define CMSG_NXTHDR(mhdr, cmsg) \
893 ((char *)(cmsg) == (char *)0L ? CMSG_FIRSTHDR(mhdr) : \
894 ((((unsigned char *)(cmsg) + \
895 __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len) + \
896 __DARWIN_ALIGN32(sizeof(struct cmsghdr))) > \
897 ((unsigned char *)(mhdr)->msg_control + \
898 (mhdr)->msg_controllen)) ? \
899 (struct cmsghdr *)0L /* NULL */ : \
900 (struct cmsghdr *)(void *)((unsigned char *)(cmsg) + \
901 __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len))))
903 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
904 /* RFC 2292 additions */
905 #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l))
906 #define CMSG_LEN(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + (l))
909 #define CMSG_ALIGN(n) __DARWIN_ALIGN32(n)
911 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
913 /* "Socket"-level control message types: */
914 #define SCM_RIGHTS 0x01 /* access rights (array of int) */
915 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
916 #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */
917 #define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */
918 #define SCM_TIMESTAMP_MONOTONIC 0x04 /* timestamp (uint64_t) */
921 #define SCM_SEQNUM 0x05 /* TCP unordered recv seq no */
922 #define SCM_MSG_PRIORITY 0x06 /* TCP unordered snd priority */
925 #ifdef KERNEL_PRIVATE
927 * 4.3 compat sockaddr (deprecated)
930 __uint16_t sa_family
; /* address family */
931 char sa_data
[14]; /* up to 14 bytes of direct address */
935 * 4.3-compat message header (deprecated)
938 void *msg_name
; /* optional address */
939 socklen_t msg_namelen
; /* size of address */
940 struct iovec
*msg_iov
; /* scatter/gather array */
941 int msg_iovlen
; /* # elements in msg_iov */
942 void *msg_accrights
; /* access rights sent/rcvd */
943 int msg_accrightslen
;
946 #define SA(s) ((struct sockaddr *)(void *)(s))
947 #endif /* KERNEL_PRIVATE */
948 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
951 * howto arguments for shutdown(2), specified by Posix.1g.
953 #define SHUT_RD 0 /* shut down the reading side */
954 #define SHUT_WR 1 /* shut down the writing side */
955 #define SHUT_RDWR 2 /* shut down both sides */
957 #if !defined(_POSIX_C_SOURCE)
959 * sendfile(2) header/trailer struct
962 struct iovec
*headers
; /* pointer to an array of header struct iovec's */
963 int hdr_cnt
; /* number of header iovec's */
964 struct iovec
*trailers
; /* pointer to an array of trailer struct iovec's */
965 int trl_cnt
; /* number of trailer iovec's */
970 /* In-kernel representation */
971 struct user_sf_hdtr
{
972 user_addr_t headers
; /* pointer to an array of header struct iovec's */
973 int hdr_cnt
; /* number of header iovec's */
974 user_addr_t trailers
; /* pointer to an array of trailer struct iovec's */
975 int trl_cnt
; /* number of trailer iovec's */
978 /* LP64 user version of struct sf_hdtr */
979 struct user64_sf_hdtr
{
980 user64_addr_t headers
; /* pointer to an array of header struct iovec's */
981 int hdr_cnt
; /* number of header iovec's */
982 user64_addr_t trailers
; /* pointer to an array of trailer struct iovec's */
983 int trl_cnt
; /* number of trailer iovec's */
986 /* ILP32 user version of struct sf_hdtr */
987 struct user32_sf_hdtr
{
988 user32_addr_t headers
; /* pointer to an array of header struct iovec's */
989 int hdr_cnt
; /* number of header iovec's */
990 user32_addr_t trailers
; /* pointer to an array of trailer struct iovec's */
991 int trl_cnt
; /* number of trailer iovec's */
996 #endif /* !_POSIX_C_SOURCE */
999 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
1000 typedef __uint32_t associd_t
;
1001 #define ASSOCID_ANY 0
1002 #define ASSOCID_ALL ((associd_t)(-1ULL))
1004 typedef __uint32_t connid_t
;
1005 #define CONNID_ANY 0
1006 #define CONNID_ALL ((connid_t)(-1ULL))
1009 * Structure for SIOCGASSOCIDS
1012 __uint32_t sar_cnt
; /* number of associations */
1013 associd_t
*sar_aidp
; /* array of association IDs */
1016 #ifdef BSD_KERNEL_PRIVATE
1017 struct so_aidreq32
{
1019 user32_addr_t sar_aidp
;
1022 struct so_aidreq64
{
1024 user64_addr_t sar_aidp
__attribute__((aligned(8)));
1026 #endif /* BSD_KERNEL_PRIVATE */
1029 * Structure for SIOCGCONNIDS
1032 associd_t scr_aid
; /* association ID */
1033 __uint32_t scr_cnt
; /* number of connections */
1034 connid_t
*scr_cidp
; /* array of connection IDs */
1037 #ifdef BSD_KERNEL_PRIVATE
1038 struct so_cidreq32
{
1041 user32_addr_t scr_cidp
;
1044 struct so_cidreq64
{
1047 user64_addr_t scr_cidp
__attribute__((aligned(8)));
1049 #endif /* BSD_KERNEL_PRIVATE */
1052 * Structure for SIOCGCONNINFO
1054 struct so_cinforeq
{
1055 connid_t scir_cid
; /* connection ID */
1056 __uint32_t scir_flags
; /* see flags below */
1057 __uint32_t scir_ifindex
; /* (last) outbound interface */
1058 __int32_t scir_error
; /* most recent error */
1059 struct sockaddr
*scir_src
; /* source address */
1060 socklen_t scir_src_len
; /* source address len */
1061 struct sockaddr
*scir_dst
; /* destination address */
1062 socklen_t scir_dst_len
; /* destination address len */
1063 __uint32_t scir_aux_type
; /* aux data type (CIAUX) */
1064 void *scir_aux_data
; /* aux data */
1065 __uint32_t scir_aux_len
; /* aux data len */
1068 #ifdef BSD_KERNEL_PRIVATE
1069 struct so_cinforeq32
{
1071 __uint32_t scir_flags
;
1072 __uint32_t scir_ifindex
;
1073 __int32_t scir_error
;
1074 user32_addr_t scir_src
;
1075 socklen_t scir_src_len
;
1076 user32_addr_t scir_dst
;
1077 socklen_t scir_dst_len
;
1078 __uint32_t scir_aux_type
;
1079 user32_addr_t scir_aux_data
;
1080 __uint32_t scir_aux_len
;
1083 struct so_cinforeq64
{
1085 __uint32_t scir_flags
;
1086 __uint32_t scir_ifindex
;
1087 __int32_t scir_error
;
1088 user64_addr_t scir_src
__attribute__((aligned(8)));
1089 socklen_t scir_src_len
;
1090 user64_addr_t scir_dst
__attribute__((aligned(8)));
1091 socklen_t scir_dst_len
;
1092 __uint32_t scir_aux_type
;
1093 user64_addr_t scir_aux_data
__attribute__((aligned(8)));
1094 __uint32_t scir_aux_len
;
1096 #endif /* BSD_KERNEL_PRIVATE */
1098 /* valid connection info flags */
1099 #define CIF_CONNECTING 0x1 /* connection was attempted */
1100 #define CIF_CONNECTED 0x2 /* connection is established */
1101 #define CIF_DISCONNECTING 0x4 /* disconnection was attempted */
1102 #define CIF_DISCONNECTED 0x8 /* has been disconnected */
1103 #define CIF_BOUND_IF 0x10 /* bound to an interface */
1104 #define CIF_BOUND_IP 0x20 /* bound to a src address */
1105 #define CIF_BOUND_PORT 0x40 /* bound to a src port */
1106 #define CIF_PREFERRED 0x80 /* connection is primary/preferred */
1107 #define CIF_MP_CAPABLE 0x100 /* supports multipath protocol */
1108 #define CIF_MP_READY 0x200 /* multipath protocol confirmed */
1109 #define CIF_MP_DEGRADED 0x400 /* has lost its multipath capability */
1110 #define CIF_MP_ACTIVE 0x800 /* this is the active subflow */
1112 /* valid connection info auxiliary data types */
1113 #define CIAUX_TCP 0x1 /* TCP auxiliary data (conninfo_tcp_t) */
1116 * Structure for SIOC{S,G}CONNORDER
1119 connid_t sco_cid
; /* connection ID */
1120 __uint32_t sco_rank
; /* rank (0 means unspecified) */
1124 * Network policy subclass (of KEV_NETWORK_CLASS)
1126 #define KEV_NETPOLICY_SUBCLASS 3
1128 #define KEV_NETPOLICY_IFDENIED 1 /* denied access to interface */
1131 * Common structure for KEV_NETPOLICY_SUBCLASS
1133 struct netpolicy_event_data
{
1134 __uint64_t eupid
; /* effective unique PID */
1135 pid_t epid
; /* effective PID */
1136 #if !defined(__LP64__)
1138 #endif /* __LP64__ */
1139 uuid_t euuid
; /* effective UUID */
1143 * NETPOLICY_IFDENIED event structure
1145 struct kev_netpolicy_ifdenied
{
1146 struct netpolicy_event_data ev_data
;
1150 * Socket subclass (of KEV_NETWORK_CLASS)
1152 #define KEV_SOCKET_SUBCLASS 4
1155 * Events for KEV_SOCKET_SUBCLASS of KEV_NETWORK_CLASS
1157 #define KEV_SOCKET_CLOSED 1 /* completely closed by protocol */
1160 * Common structure for KEV_SOCKET_SUBCLASS
1162 struct kev_socket_event_data
{
1163 struct sockaddr_storage kev_sockname
;
1164 struct sockaddr_storage kev_peername
;
1167 struct kev_socket_closed
{
1168 struct kev_socket_event_data ev_data
;
1173 extern int connectx(int s
, struct sockaddr
*, socklen_t
, struct sockaddr
*,
1174 socklen_t
, __uint32_t
, associd_t
, connid_t
*);
1175 extern int disconnectx(int s
, associd_t
, connid_t
);
1176 extern int peeloff(int s
, associd_t
);
1177 extern int socket_delegate(int, int, int, pid_t
);
1180 * recvmsg_x() is a system call similar to recvmsg(2) to receive
1181 * several datagrams at once in the array of message headers "msgp".
1183 * recvmsg_x() can be used only with protocols handlers that have been specially
1184 * modified to handle sending and receiving several datagrams at once.
1186 * The size of the array "msgp" is given by the argument "cnt".
1188 * The "flags" arguments supports only the value MSG_DONTWAIT.
1190 * Each member of "msgp" array is of type "struct msghdr_x".
1192 * The "msg_iov" and "msg_iovlen" are input parameters that describe where to
1193 * store a datagram in a scatter gather locations of buffers -- see recvmsg(2).
1194 * On output the field "msg_datalen" gives the length of the received datagram.
1196 * The field "msg_flags" must be set to zero on input. On output, "msg_flags"
1197 * may have MSG_TRUNC set to indicate the trailing portion of the datagram was
1198 * discarded because the datagram was larger than the buffer supplied.
1199 * recvmsg_x() returns as soon as a datagram is truncated.
1201 * recvmsg_x() may return with less than "cnt" datagrams received based on
1202 * the low water mark and the amount of data pending in the socket buffer.
1204 * Address and ancillary data are not supported so the following fields
1205 * must be set to zero on input:
1206 * "msg_name", "msg_namelen", "msg_control" and "msg_controllen".
1208 * recvmsg_x() returns the number of datagrams that have been received ,
1209 * or -1 if an error occurred.
1211 * NOTE: This a private system call, the API is subject to change.
1213 ssize_t
recvmsg_x(int s
, const struct msghdr_x
*msgp
, u_int cnt
, int flags
);
1216 * sendmsg_x() is a system call similar to send(2) to send
1217 * several datagrams at once in the array of message headers "msgp".
1219 * sendmsg_x() can be used only with protocols handlers that have been specially
1220 * modified to support to handle sending and receiving several datagrams at once.
1222 * The size of the array "msgp" is given by the argument "cnt".
1224 * The "flags" arguments supports only the value MSG_DONTWAIT.
1226 * Each member of "msgp" array is of type "struct msghdr_x".
1228 * The "msg_iov" and "msg_iovlen" are input parameters that specify the
1229 * data to be sent in a scatter gather locations of buffers -- see sendmsg(2).
1231 * sendmsg_x() fails with EMSGSIZE if the sum of the length of the datagrams
1232 * is greater than the high water mark.
1234 * Address and ancillary data are not supported so the following fields
1235 * must be set to zero on input:
1236 * "msg_name", "msg_namelen", "msg_control" and "msg_controllen".
1238 * The field "msg_flags" and "msg_datalen" must be set to zero on input.
1240 * sendmsg_x() returns the number of datagrams that have been sent,
1241 * or -1 if an error occurred.
1243 * NOTE: This a private system call, the API is subject to change.
1245 ssize_t
sendmsg_x(int s
, const struct msghdr_x
*msgp
, u_int cnt
, int flags
);
1247 #endif /* !KERNEL */
1248 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
1249 #endif /* PRIVATE */
1253 int accept(int, struct sockaddr
* __restrict
, socklen_t
* __restrict
)
1254 __DARWIN_ALIAS_C(accept
);
1255 int bind(int, const struct sockaddr
*, socklen_t
) __DARWIN_ALIAS(bind
);
1256 int connect(int, const struct sockaddr
*, socklen_t
) __DARWIN_ALIAS_C( connect
);
1257 int getpeername(int, struct sockaddr
* __restrict
, socklen_t
* __restrict
)
1258 __DARWIN_ALIAS(getpeername
);
1259 int getsockname(int, struct sockaddr
* __restrict
, socklen_t
* __restrict
)
1260 __DARWIN_ALIAS(getsockname
);
1261 int getsockopt(int, int, int, void * __restrict
, socklen_t
* __restrict
);
1262 int listen(int, int) __DARWIN_ALIAS(listen
);
1263 ssize_t
recv(int, void *, size_t, int) __DARWIN_ALIAS_C(recv
);
1264 ssize_t
recvfrom(int, void *, size_t, int, struct sockaddr
* __restrict
,
1265 socklen_t
* __restrict
) __DARWIN_ALIAS_C(recvfrom
);
1266 ssize_t
recvmsg(int, struct msghdr
*, int) __DARWIN_ALIAS_C(recvmsg
);
1267 ssize_t
send(int, const void *, size_t, int) __DARWIN_ALIAS_C(send
);
1268 ssize_t
sendmsg(int, const struct msghdr
*, int) __DARWIN_ALIAS_C(sendmsg
);
1269 ssize_t
sendto(int, const void *, size_t,
1270 int, const struct sockaddr
*, socklen_t
) __DARWIN_ALIAS_C(sendto
);
1271 int setsockopt(int, int, int, const void *, socklen_t
);
1272 int shutdown(int, int);
1273 int sockatmark(int) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
1274 int socket(int, int, int);
1275 int socketpair(int, int, int, int *) __DARWIN_ALIAS(socketpair
);
1277 #if !defined(_POSIX_C_SOURCE)
1278 int sendfile(int, int, off_t
, off_t
*, struct sf_hdtr
*, int);
1279 #endif /* !_POSIX_C_SOURCE */
1281 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
1282 void pfctlinput(int, struct sockaddr
*);
1283 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
1285 #endif /* !KERNEL */
1288 #include <sys/kpi_socket.h>
1291 #endif /* !_SYS_SOCKET_H_ */