]>
git.saurik.com Git - apple/xnu.git/blob - bsd/kern/kpi_socket.c
2 * Copyright (c) 2003-2008 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@
30 #include <sys/systm.h>
31 #include <sys/kernel.h>
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <sys/socketvar.h>
35 #include <sys/param.h>
37 #include <sys/errno.h>
38 #include <sys/malloc.h>
39 #include <sys/protosw.h>
40 #include <sys/domain.h>
42 #include <sys/fcntl.h>
43 #include <sys/filio.h>
44 #include <sys/uio_internal.h>
45 #include <kern/lock.h>
46 #include <netinet/in.h>
47 #include <libkern/OSAtomic.h>
49 extern int soclose_locked(struct socket
*so
);
50 extern void soclose_wait_locked(struct socket
*so
);
51 extern int so_isdstlocal(struct socket
*so
);
53 errno_t
sock_send_internal(
55 const struct msghdr
*msg
,
60 typedef void (*so_upcall
)(struct socket
*, caddr_t
, int );
66 struct sockaddr
*from
,
74 struct socket
*new_so
;
75 lck_mtx_t
*mutex_held
;
79 if (sock
== NULL
|| new_sock
== NULL
) return EINVAL
;
81 if ((sock
->so_options
& SO_ACCEPTCONN
) == 0) {
82 socket_unlock(sock
, 1);
85 if ((flags
& ~(MSG_DONTWAIT
)) != 0) {
86 socket_unlock(sock
, 1);
89 if (((flags
& MSG_DONTWAIT
) != 0 || (sock
->so_state
& SS_NBIO
) != 0) &&
90 sock
->so_comp
.tqh_first
== NULL
) {
91 socket_unlock(sock
, 1);
95 if (sock
->so_proto
->pr_getlock
!= NULL
) {
96 mutex_held
= (*sock
->so_proto
->pr_getlock
)(sock
, 0);
100 mutex_held
= sock
->so_proto
->pr_domain
->dom_mtx
;
104 while (TAILQ_EMPTY(&sock
->so_comp
) && sock
->so_error
== 0) {
105 if (sock
->so_state
& SS_CANTRCVMORE
) {
106 sock
->so_error
= ECONNABORTED
;
109 error
= msleep((caddr_t
)&sock
->so_timeo
, mutex_held
, PSOCK
| PCATCH
, "sock_accept", NULL
);
111 socket_unlock(sock
, 1);
115 if (sock
->so_error
) {
116 error
= sock
->so_error
;
118 socket_unlock(sock
, 1);
122 new_so
= TAILQ_FIRST(&sock
->so_comp
);
123 TAILQ_REMOVE(&sock
->so_comp
, new_so
, so_list
);
127 * Pass the pre-accepted socket to any interested socket filter(s).
128 * Upon failure, the socket would have been closed by the callee.
130 if (new_so
->so_filt
!= NULL
) {
132 * Temporarily drop the listening socket's lock before we
133 * hand off control over to the socket filter(s), but keep
134 * a reference so that it won't go away. We'll grab it
135 * again once we're done with the filter(s).
137 socket_unlock(sock
, 0);
138 if ((error
= soacceptfilter(new_so
)) != 0) {
139 /* Drop reference on listening socket */
143 socket_lock(sock
, 0);
147 lck_mtx_assert(new_so
->so_proto
->pr_getlock(new_so
, 0),
148 LCK_MTX_ASSERT_NOTOWNED
);
149 socket_lock(new_so
, 1);
152 new_so
->so_state
&= ~SS_COMP
;
153 new_so
->so_head
= NULL
;
154 (void) soacceptlock(new_so
, &sa
, 0);
156 socket_unlock(sock
, 1); /* release the head */
159 new_so
->so_upcall
= (so_upcall
) callback
;
160 new_so
->so_upcallarg
= cookie
;
161 new_so
->so_rcv
.sb_flags
|= SB_UPCALL
;
163 new_so
->so_snd
.sb_flags
|= SB_UPCALL
;
169 if (fromlen
> sa
->sa_len
) fromlen
= sa
->sa_len
;
170 memcpy(from
, sa
, fromlen
);
172 if (sa
) FREE(sa
, M_SONAME
);
175 * If the socket has been marked as inactive by soacceptfilter(),
176 * disallow further operations on it. We explicitly call shutdown
177 * on both data directions to ensure that SS_CANT{RCV,SEND}MORE
178 * states are set for the socket. This would also flush out data
179 * hanging off the receive list of this socket.
181 if (new_so
->so_flags
& SOF_DEFUNCT
) {
182 (void) soshutdownlock(new_so
, SHUT_RD
);
183 (void) soshutdownlock(new_so
, SHUT_WR
);
184 (void) sodisconnectlocked(new_so
);
189 socket_unlock(new_so
, 1);
196 const struct sockaddr
*to
)
198 if (sock
== NULL
|| to
== NULL
) return EINVAL
;
200 return sobind(sock
, (struct sockaddr
*)(uintptr_t)to
);
206 const struct sockaddr
*to
,
210 lck_mtx_t
*mutex_held
;
212 if (sock
== NULL
|| to
== NULL
) return EINVAL
;
214 socket_lock(sock
, 1);
216 if ((sock
->so_state
& SS_ISCONNECTING
) &&
217 ((sock
->so_state
& SS_NBIO
) != 0 ||
218 (flags
& MSG_DONTWAIT
) != 0)) {
219 socket_unlock(sock
, 1);
222 error
= soconnectlock(sock
, (struct sockaddr
*)(uintptr_t)to
, 0);
224 if ((sock
->so_state
& SS_ISCONNECTING
) &&
225 ((sock
->so_state
& SS_NBIO
) != 0 || (flags
& MSG_DONTWAIT
) != 0)) {
226 socket_unlock(sock
, 1);
230 if (sock
->so_proto
->pr_getlock
!= NULL
)
231 mutex_held
= (*sock
->so_proto
->pr_getlock
)(sock
, 0);
233 mutex_held
= sock
->so_proto
->pr_domain
->dom_mtx
;
235 while ((sock
->so_state
& SS_ISCONNECTING
) && sock
->so_error
== 0) {
236 error
= msleep((caddr_t
)&sock
->so_timeo
, mutex_held
, PSOCK
| PCATCH
,
237 "sock_connect", NULL
);
243 error
= sock
->so_error
;
248 sock
->so_state
&= ~SS_ISCONNECTING
;
250 socket_unlock(sock
, 1);
257 const struct timeval
*tv
)
259 lck_mtx_t
* mutex_held
;
263 socket_lock(sock
, 1);
265 // Check if we're already connected or if we've already errored out
266 if ((sock
->so_state
& SS_ISCONNECTING
) == 0 || sock
->so_error
) {
267 if (sock
->so_error
) {
268 retval
= sock
->so_error
;
272 if ((sock
->so_state
& SS_ISCONNECTED
) != 0)
280 // copied translation from timeval to hertz from SO_RCVTIMEO handling
281 if (tv
->tv_sec
< 0 || tv
->tv_sec
> SHRT_MAX
/ hz
||
282 tv
->tv_usec
< 0 || tv
->tv_usec
>= 1000000) {
287 ts
.tv_sec
= tv
->tv_sec
;
288 ts
.tv_nsec
= (tv
->tv_usec
* NSEC_PER_USEC
);
289 if ( (ts
.tv_sec
+ (ts
.tv_nsec
/NSEC_PER_SEC
))/100 > SHRT_MAX
) {
294 if (sock
->so_proto
->pr_getlock
!= NULL
)
295 mutex_held
= (*sock
->so_proto
->pr_getlock
)(sock
, 0);
297 mutex_held
= sock
->so_proto
->pr_domain
->dom_mtx
;
299 msleep((caddr_t
)&sock
->so_timeo
, mutex_held
, PSOCK
, "sock_connectwait", &ts
);
301 // Check if we're still waiting to connect
302 if ((sock
->so_state
& SS_ISCONNECTING
) && sock
->so_error
== 0) {
303 retval
= EINPROGRESS
;
307 if (sock
->so_error
) {
308 retval
= sock
->so_error
;
313 socket_unlock(sock
, 1);
322 socket_lock(sock
, 1);
325 sock
->so_rcv
.sb_flags
|= SB_NOINTR
; // This isn't safe
326 sock
->so_snd
.sb_flags
|= SB_NOINTR
; // This isn't safe
329 sock
->so_rcv
.sb_flags
&= ~SB_NOINTR
; // This isn't safe
330 sock
->so_snd
.sb_flags
&= ~SB_NOINTR
; // This isn't safe
333 socket_unlock(sock
, 1);
339 sock_getpeername(socket_t sock
, struct sockaddr
*peername
, int peernamelen
)
342 struct sockaddr
*sa
= NULL
;
344 if (sock
== NULL
|| peername
== NULL
|| peernamelen
< 0)
347 socket_lock(sock
, 1);
348 if (!(sock
->so_state
& (SS_ISCONNECTED
|SS_ISCONFIRMING
))) {
349 socket_unlock(sock
, 1);
352 error
= sogetaddr_locked(sock
, &sa
, 1);
353 socket_unlock(sock
, 1);
355 if (peernamelen
> sa
->sa_len
)
356 peernamelen
= sa
->sa_len
;
357 memcpy(peername
, sa
, peernamelen
);
364 sock_getsockname(socket_t sock
, struct sockaddr
*sockname
, int socknamelen
)
367 struct sockaddr
*sa
= NULL
;
369 if (sock
== NULL
|| sockname
== NULL
|| socknamelen
< 0)
372 socket_lock(sock
, 1);
373 error
= sogetaddr_locked(sock
, &sa
, 0);
374 socket_unlock(sock
, 1);
376 if (socknamelen
> sa
->sa_len
)
377 socknamelen
= sa
->sa_len
;
378 memcpy(sockname
, sa
, socknamelen
);
384 __private_extern__
int
385 sogetaddr_locked(struct socket
*so
, struct sockaddr
**psa
, int peer
)
389 if (so
== NULL
|| psa
== NULL
)
393 error
= peer
? so
->so_proto
->pr_usrreqs
->pru_peeraddr(so
, psa
) :
394 so
->so_proto
->pr_usrreqs
->pru_sockaddr(so
, psa
);
396 if (error
== 0 && *psa
== NULL
) {
398 } else if (error
!= 0 && *psa
!= NULL
) {
399 FREE(*psa
, M_SONAME
);
406 sock_getaddr(socket_t sock
, struct sockaddr
**psa
, int peer
)
410 if (sock
== NULL
|| psa
== NULL
)
413 socket_lock(sock
, 1);
414 error
= sogetaddr_locked(sock
, psa
, peer
);
415 socket_unlock(sock
, 1);
421 sock_freeaddr(struct sockaddr
*sa
)
438 if (sock
== NULL
|| optval
== NULL
|| optlen
== NULL
) return EINVAL
;
439 sopt
.sopt_dir
= SOPT_GET
;
440 sopt
.sopt_level
= level
;
441 sopt
.sopt_name
= optname
;
442 sopt
.sopt_val
= CAST_USER_ADDR_T(optval
);
443 sopt
.sopt_valsize
= *optlen
;
444 sopt
.sopt_p
= kernproc
;
445 error
= sogetopt(sock
, &sopt
); /* will lock socket */
446 if (error
== 0) *optlen
= sopt
.sopt_valsize
;
453 unsigned long request
,
456 return soioctl(sock
, request
, argp
, kernproc
); /* will lock socket */
469 if (sock
== NULL
|| optval
== NULL
) return EINVAL
;
470 sopt
.sopt_dir
= SOPT_SET
;
471 sopt
.sopt_level
= level
;
472 sopt
.sopt_name
= optname
;
473 sopt
.sopt_val
= CAST_USER_ADDR_T(optval
);
474 sopt
.sopt_valsize
= optlen
;
475 sopt
.sopt_p
= kernproc
;
476 return sosetopt(sock
, &sopt
); /* will lock socket */
488 if (sock
== NULL
|| optval
== NULL
|| optlen
== 0) return EINVAL
;
490 sopt
.sopt_dir
= SOPT_SET
;
491 sopt
.sopt_val
= CAST_USER_ADDR_T(optval
);
492 sopt
.sopt_valsize
= optlen
;
493 sopt
.sopt_p
= kernproc
;
495 socket_lock(sock
, 1);
496 if (!(sock
->so_state
& SS_ISCONNECTED
)) {
497 /* If the socket is not connected then we don't know
498 * if the destination is on LAN or not. Skip
499 * setting traffic class in this case
505 if (sock
->so_proto
== NULL
|| sock
->so_proto
->pr_domain
== NULL
|| sock
->so_pcb
== NULL
) {
510 /* Check if the destination address is LAN or link local address.
511 * We do not want to set traffic class bits if the destination
514 if (!so_isdstlocal(sock
)) {
518 switch (sock
->so_proto
->pr_domain
->dom_family
) {
520 sopt
.sopt_level
= IPPROTO_IP
;
521 sopt
.sopt_name
= IP_TOS
;
524 sopt
.sopt_level
= IPPROTO_IPV6
;
525 sopt
.sopt_name
= IPV6_TCLASS
;
532 socket_unlock(sock
, 1);
533 return sosetopt(sock
, &sopt
);
535 socket_unlock(sock
, 1);
548 if (sock
== NULL
|| optval
== NULL
|| optlen
== NULL
) return EINVAL
;
550 sopt
.sopt_dir
= SOPT_GET
;
551 sopt
.sopt_val
= CAST_USER_ADDR_T(optval
);
552 sopt
.sopt_valsize
= *optlen
;
553 sopt
.sopt_p
= kernproc
;
555 socket_lock(sock
, 1);
556 if (sock
->so_proto
== NULL
|| sock
->so_proto
->pr_domain
== NULL
) {
557 socket_unlock(sock
, 1);
561 switch (sock
->so_proto
->pr_domain
->dom_family
) {
563 sopt
.sopt_level
= IPPROTO_IP
;
564 sopt
.sopt_name
= IP_TOS
;
567 sopt
.sopt_level
= IPPROTO_IPV6
;
568 sopt
.sopt_name
= IPV6_TCLASS
;
571 socket_unlock(sock
, 1);
575 socket_unlock(sock
, 1);
576 error
= sogetopt(sock
, &sopt
); /* will lock socket */
577 if (error
== 0) *optlen
= sopt
.sopt_valsize
;
586 if (sock
== NULL
) return EINVAL
;
587 return solisten(sock
, backlog
); /* will lock socket */
591 sock_receive_internal(
599 struct mbuf
*control
= NULL
;
602 struct sockaddr
*fromsa
;
603 char uio_buf
[ UIO_SIZEOF((msg
!= NULL
) ? msg
->msg_iovlen
: 0) ];
605 if (sock
== NULL
) return EINVAL
;
607 auio
= uio_createwithbuffer(((msg
!= NULL
) ? msg
->msg_iovlen
: 0),
608 0, UIO_SYSSPACE
, UIO_READ
,
609 &uio_buf
[0], sizeof(uio_buf
));
610 if (msg
&& data
== NULL
) {
612 struct iovec
*tempp
= msg
->msg_iov
;
614 for (i
= 0; i
< msg
->msg_iovlen
; i
++) {
615 uio_addiov(auio
, CAST_USER_ADDR_T((tempp
+ i
)->iov_base
), (tempp
+ i
)->iov_len
);
617 if (uio_resid(auio
) < 0) return EINVAL
;
620 uio_setresid(auio
, (uio_resid(auio
) + *recvdlen
));
622 length
= uio_resid(auio
);
627 /* let pru_soreceive handle the socket locking */
628 error
= sock
->so_proto
->pr_usrreqs
->pru_soreceive(sock
, &fromsa
, auio
,
629 data
, (msg
&& msg
->msg_control
) ? &control
: NULL
, &flags
);
630 if (error
) goto cleanup
;
633 *recvdlen
= length
- uio_resid(auio
);
635 msg
->msg_flags
= flags
;
640 salen
= msg
->msg_namelen
;
641 if (msg
->msg_namelen
> 0 && fromsa
!= 0)
643 salen
= MIN(salen
, fromsa
->sa_len
);
644 memcpy(msg
->msg_name
, fromsa
,
645 msg
->msg_namelen
> fromsa
->sa_len
? fromsa
->sa_len
: msg
->msg_namelen
);
649 if (msg
->msg_control
)
651 struct mbuf
* m
= control
;
652 u_char
* ctlbuf
= msg
->msg_control
;
653 int clen
= msg
->msg_controllen
;
654 msg
->msg_controllen
= 0;
656 while (m
&& clen
> 0)
659 if (clen
>= m
->m_len
)
665 msg
->msg_flags
|= MSG_CTRUNC
;
668 memcpy(ctlbuf
, mtod(m
, caddr_t
), tocopy
);
673 msg
->msg_controllen
= (uintptr_t)ctlbuf
- (uintptr_t)msg
->msg_control
;
678 if (control
) m_freem(control
);
679 if (fromsa
) FREE(fromsa
, M_SONAME
);
691 (msg
->msg_iovlen
< 1) ||
692 (msg
->msg_iov
[0].iov_len
== 0) ||
693 (msg
->msg_iov
[0].iov_base
== NULL
))
695 return sock_receive_internal(sock
, msg
, NULL
, flags
, recvdlen
);
706 if (data
== NULL
|| recvlen
== 0 || *recvlen
<= 0 || (msg
&&
707 (msg
->msg_iov
!= NULL
|| msg
->msg_iovlen
!= 0)))
709 return sock_receive_internal(sock
, msg
, data
, flags
, recvlen
);
715 const struct msghdr
*msg
,
721 struct mbuf
*control
= NULL
;
724 char uio_buf
[ UIO_SIZEOF((msg
!= NULL
? msg
->msg_iovlen
: 1)) ];
731 if (data
== 0 && msg
!= NULL
) {
732 struct iovec
*tempp
= msg
->msg_iov
;
734 auio
= uio_createwithbuffer(msg
->msg_iovlen
, 0, UIO_SYSSPACE
, UIO_WRITE
,
735 &uio_buf
[0], sizeof(uio_buf
));
740 for (i
= 0; i
< msg
->msg_iovlen
; i
++) {
741 uio_addiov(auio
, CAST_USER_ADDR_T((tempp
+ i
)->iov_base
), (tempp
+ i
)->iov_len
);
744 if (uio_resid(auio
) < 0) {
755 datalen
= uio_resid(auio
);
757 datalen
= data
->m_pkthdr
.len
;
759 if (msg
&& msg
->msg_control
)
761 if ((size_t)msg
->msg_controllen
< sizeof(struct cmsghdr
)) return EINVAL
;
762 if ((size_t)msg
->msg_controllen
> MLEN
) return EINVAL
;
763 control
= m_get(M_NOWAIT
, MT_CONTROL
);
764 if (control
== NULL
) {
768 memcpy(mtod(control
, caddr_t
), msg
->msg_control
, msg
->msg_controllen
);
769 control
->m_len
= msg
->msg_controllen
;
772 error
= sock
->so_proto
->pr_usrreqs
->pru_sosend(sock
, msg
!= NULL
?
773 (struct sockaddr
*)msg
->msg_name
: NULL
, auio
, data
, control
, flags
);
776 * Residual data is possible in the case of IO vectors but not
777 * in the mbuf case since the latter is treated as atomic send.
778 * If pru_sosend() consumed a portion of the iovecs data and
779 * the error returned is transient, treat it as success; this
780 * is consistent with sendit() behavior.
782 if (auio
!= NULL
&& uio_resid(auio
) != datalen
&&
783 (error
== ERESTART
|| error
== EINTR
|| error
== EWOULDBLOCK
))
786 if (error
== 0 && sentlen
!= NULL
) {
788 *sentlen
= datalen
- uio_resid(auio
);
796 * In cases where we detect an error before returning, we need to
797 * free the mbuf chain if there is one. sosend (and pru_sosend) will
798 * free the mbuf chain if they encounter an error.
813 const struct msghdr
*msg
,
817 if (msg
== NULL
|| msg
->msg_iov
== NULL
|| msg
->msg_iovlen
< 1)
819 return sock_send_internal(sock
, msg
, NULL
, flags
, sentlen
);
825 const struct msghdr
*msg
,
830 if (data
== NULL
|| (msg
&&
831 (msg
->msg_iov
!= NULL
|| msg
->msg_iovlen
!= 0))) {
836 return sock_send_internal(sock
, msg
, data
, flags
, sentlen
);
844 if (sock
== NULL
) return EINVAL
;
845 return soshutdown(sock
, how
);
854 sock_upcall callback
,
859 if (new_so
== NULL
) return EINVAL
;
860 /* socreate will create an initial so_count */
861 error
= socreate(domain
, new_so
, type
, protocol
);
862 if (error
== 0 && callback
)
864 (*new_so
)->so_rcv
.sb_flags
|= SB_UPCALL
;
866 (*new_so
)->so_snd
.sb_flags
|= SB_UPCALL
;
868 (*new_so
)->so_upcall
= (so_upcall
)callback
;
869 (*new_so
)->so_upcallarg
= context
;
878 if (sock
== NULL
) return;
882 /* Do we want this to be APPLE_PRIVATE API?: YES (LD 12/23/04)*/
887 if (sock
== NULL
) return;
888 socket_lock(sock
, 1);
889 sock
->so_retaincnt
++;
890 sock
->so_usecount
++; /* add extra reference for holding the socket */
891 socket_unlock(sock
, 1);
894 /* Do we want this to be APPLE_PRIVATE API? */
896 sock_release(socket_t sock
)
900 socket_lock(sock
, 1);
902 if (sock
->so_flags
& SOF_UPCALLINUSE
)
903 soclose_wait_locked(sock
);
905 sock
->so_retaincnt
--;
906 if (sock
->so_retaincnt
< 0)
907 panic("sock_release: negative retain count for sock=%p "
908 "cnt=%x\n", sock
, sock
->so_retaincnt
);
909 if ((sock
->so_retaincnt
== 0) && (sock
->so_usecount
== 2)) {
910 /* close socket only if the FD is not holding it */
911 soclose_locked(sock
);
913 /* remove extra reference holding the socket */
916 socket_unlock(sock
, 1);
924 if (sock
== NULL
) return EINVAL
;
925 socket_lock(sock
, 1);
928 sock
->so_state
|= SS_PRIV
;
932 sock
->so_state
&= ~SS_PRIV
;
934 socket_unlock(sock
, 1);
943 socket_lock(sock
, 1);
944 retval
= (sock
->so_state
& SS_ISCONNECTED
) != 0;
945 socket_unlock(sock
, 1);
954 socket_lock(sock
, 1);
955 retval
= (sock
->so_state
& SS_NBIO
) != 0;
956 socket_unlock(sock
, 1);
967 socket_lock(sock
, 1);
969 *outDomain
= sock
->so_proto
->pr_domain
->dom_family
;
971 *outType
= sock
->so_type
;
973 *outProtocol
= sock
->so_proto
->pr_protocol
;
974 socket_unlock(sock
, 1);
979 * Return the listening socket of a pre-accepted socket. It returns the
980 * listener (so_head) value of a given socket. This is intended to be
981 * called by a socket filter during a filter attach (sf_attach) callback.
982 * The value returned by this routine is safe to be used only in the
983 * context of that callback, because we hold the listener's lock across
984 * the sflt_initsock() call.
987 sock_getlistener(socket_t sock
)
989 return (sock
->so_head
);
993 * Caller must have ensured socket is valid and won't be going away.
996 socket_set_traffic_mgt_flags(socket_t sock
, u_int32_t flags
)
998 (void) OSBitOrAtomic(flags
, &sock
->so_traffic_mgt_flags
);
1002 * Caller must have ensured socket is valid and won't be going away.
1005 socket_clear_traffic_mgt_flags(socket_t sock
, u_int32_t flags
)
1007 (void) OSBitAndAtomic(~flags
, &sock
->so_traffic_mgt_flags
);