1*a325d9c4SApple OSS Distributions /* 2*a325d9c4SApple OSS Distributions * Copyright (c) 2008-2017 Apple Inc. All rights reserved. 3*a325d9c4SApple OSS Distributions * 4*a325d9c4SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*a325d9c4SApple OSS Distributions * 6*a325d9c4SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*a325d9c4SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*a325d9c4SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*a325d9c4SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*a325d9c4SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*a325d9c4SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*a325d9c4SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*a325d9c4SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*a325d9c4SApple OSS Distributions * 15*a325d9c4SApple OSS Distributions * Please obtain a copy of the License at 16*a325d9c4SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*a325d9c4SApple OSS Distributions * 18*a325d9c4SApple OSS Distributions * The Original Code and all software distributed under the License are 19*a325d9c4SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*a325d9c4SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*a325d9c4SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*a325d9c4SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*a325d9c4SApple OSS Distributions * Please see the License for the specific language governing rights and 24*a325d9c4SApple OSS Distributions * limitations under the License. 25*a325d9c4SApple OSS Distributions * 26*a325d9c4SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*a325d9c4SApple OSS Distributions */ 28*a325d9c4SApple OSS Distributions /*! 29*a325d9c4SApple OSS Distributions * @header kpi_socket.h 30*a325d9c4SApple OSS Distributions * This header defines an API for creating and interacting with sockets 31*a325d9c4SApple OSS Distributions * in the kernel. It is possible to create sockets in the kernel 32*a325d9c4SApple OSS Distributions * without an associated file descriptor. In some cases, a reference to 33*a325d9c4SApple OSS Distributions * the socket may be known while the file descriptor is not. These 34*a325d9c4SApple OSS Distributions * functions can be used for interacting with sockets in the kernel. 35*a325d9c4SApple OSS Distributions * The API is similar to the user space socket API. 36*a325d9c4SApple OSS Distributions */ 37*a325d9c4SApple OSS Distributions #ifndef __KPI_SOCKET__ 38*a325d9c4SApple OSS Distributions #define __KPI_SOCKET__ 39*a325d9c4SApple OSS Distributions 40*a325d9c4SApple OSS Distributions #include <sys/types.h> 41*a325d9c4SApple OSS Distributions #include <sys/kernel_types.h> 42*a325d9c4SApple OSS Distributions #include <sys/socket.h> 43*a325d9c4SApple OSS Distributions 44*a325d9c4SApple OSS Distributions #ifndef PRIVATE 45*a325d9c4SApple OSS Distributions #include <Availability.h> 46*a325d9c4SApple OSS Distributions #define __NKE_API_DEPRECATED __API_DEPRECATED("Network Kernel Extension KPI is deprecated", macos(10.4, 10.15)) 47*a325d9c4SApple OSS Distributions #else 48*a325d9c4SApple OSS Distributions #define __NKE_API_DEPRECATED 49*a325d9c4SApple OSS Distributions #endif /* PRIVATE */ 50*a325d9c4SApple OSS Distributions 51*a325d9c4SApple OSS Distributions __BEGIN_DECLS 52*a325d9c4SApple OSS Distributions 53*a325d9c4SApple OSS Distributions struct timeval; 54*a325d9c4SApple OSS Distributions 55*a325d9c4SApple OSS Distributions /*! 56*a325d9c4SApple OSS Distributions * @typedef sock_upcall 57*a325d9c4SApple OSS Distributions * 58*a325d9c4SApple OSS Distributions * @discussion sock_upcall is used by a socket to notify an in kernel 59*a325d9c4SApple OSS Distributions * client that data is waiting. Instead of making blocking calls in 60*a325d9c4SApple OSS Distributions * the kernel, a client can specify an upcall which will be called 61*a325d9c4SApple OSS Distributions * when data is available or the socket is ready for sending. 62*a325d9c4SApple OSS Distributions * 63*a325d9c4SApple OSS Distributions * Calls to your upcall function are not serialized and may be 64*a325d9c4SApple OSS Distributions * called concurrently from multiple threads in the kernel. 65*a325d9c4SApple OSS Distributions * 66*a325d9c4SApple OSS Distributions * Your upcall function will be called: 67*a325d9c4SApple OSS Distributions * when there is data more than the low water mark for reading, 68*a325d9c4SApple OSS Distributions * or when there is space for a write, 69*a325d9c4SApple OSS Distributions * or when there is a connection to accept, 70*a325d9c4SApple OSS Distributions * or when a socket is connected, 71*a325d9c4SApple OSS Distributions * or when a socket is closed or disconnected 72*a325d9c4SApple OSS Distributions * 73*a325d9c4SApple OSS Distributions * @param so A reference to the socket that's ready. 74*a325d9c4SApple OSS Distributions * @param cookie The cookie passed in when the socket was created. 75*a325d9c4SApple OSS Distributions * @param waitf Indicates whether or not it's safe to block. 76*a325d9c4SApple OSS Distributions */ 77*a325d9c4SApple OSS Distributions typedef void (*sock_upcall)(socket_t so, void *cookie, int waitf); 78*a325d9c4SApple OSS Distributions 79*a325d9c4SApple OSS Distributions #ifdef KERNEL_PRIVATE 80*a325d9c4SApple OSS Distributions /*! 81*a325d9c4SApple OSS Distributions * @typedef sock_evupcall 82*a325d9c4SApple OSS Distributions * 83*a325d9c4SApple OSS Distributions * @discussion sock_evupcall is used by a socket to notify an in kernel 84*a325d9c4SApple OSS Distributions * client when an event occurs. Instead of making blocking calls in 85*a325d9c4SApple OSS Distributions * the kernel, a client can specify an upcall which will be called 86*a325d9c4SApple OSS Distributions * when an event status is available. 87*a325d9c4SApple OSS Distributions * @param so A reference to the socket that's ready. 88*a325d9c4SApple OSS Distributions * @param cookie The cookie passed in when the socket was created. 89*a325d9c4SApple OSS Distributions * @param event Indicates the event as defined by SO_FILT_HINT_* 90*a325d9c4SApple OSS Distributions */ 91*a325d9c4SApple OSS Distributions typedef void (*sock_evupcall)(socket_t so, void *cookie, long event); 92*a325d9c4SApple OSS Distributions #endif /* KERNEL_PRIVATE */ 93*a325d9c4SApple OSS Distributions 94*a325d9c4SApple OSS Distributions /*! 95*a325d9c4SApple OSS Distributions * @function sock_accept 96*a325d9c4SApple OSS Distributions * @discussion Accepts an incoming connection on a socket. See 'man 2 97*a325d9c4SApple OSS Distributions * accept' for more information. Allocating a socket in this manner 98*a325d9c4SApple OSS Distributions * creates a socket with no associated file descriptor. 99*a325d9c4SApple OSS Distributions * @param so The listening socket you'd like to accept a connection on. 100*a325d9c4SApple OSS Distributions * @param from A pointer to a socket address that will be filled in 101*a325d9c4SApple OSS Distributions * with the address the connection is from. 102*a325d9c4SApple OSS Distributions * @param fromlen Maximum length of from. 103*a325d9c4SApple OSS Distributions * @param flags Supports MSG_DONTWAIT and MSG_USEUPCALL. If 104*a325d9c4SApple OSS Distributions * MSG_DONTWAIT is set, accept will return EWOULDBLOCK if there are 105*a325d9c4SApple OSS Distributions * no connections ready to be accepted. If MSG_USEUPCALL is set, 106*a325d9c4SApple OSS Distributions * the created socket will use the same upcall function attached to 107*a325d9c4SApple OSS Distributions * the original socket. 108*a325d9c4SApple OSS Distributions * @param callback A notifier function to be called when an event 109*a325d9c4SApple OSS Distributions * occurs on the socket. This may be NULL. 110*a325d9c4SApple OSS Distributions * @param cookie A cookie passed directly to the callback. 111*a325d9c4SApple OSS Distributions * @param new_so Upon success, *new_so will be a reference to a new 112*a325d9c4SApple OSS Distributions * socket for tracking the connection. 113*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 114*a325d9c4SApple OSS Distributions */ 115*a325d9c4SApple OSS Distributions #ifdef KERNEL_PRIVATE 116*a325d9c4SApple OSS Distributions extern errno_t sock_accept_internal(socket_t so, struct sockaddr *from, int fromlen, 117*a325d9c4SApple OSS Distributions int flags, sock_upcall callback, void *cookie, socket_t *new_so); 118*a325d9c4SApple OSS Distributions 119*a325d9c4SApple OSS Distributions #define sock_accept(so, from, fromlen, flags, callback, cookie, new_so) \ 120*a325d9c4SApple OSS Distributions sock_accept_internal((so), (from), (fromlen), (flags), (callback), \ 121*a325d9c4SApple OSS Distributions (cookie), (new_so)) 122*a325d9c4SApple OSS Distributions #else 123*a325d9c4SApple OSS Distributions extern errno_t sock_accept(socket_t so, struct sockaddr *from, int fromlen, 124*a325d9c4SApple OSS Distributions int flags, sock_upcall callback, void *cookie, socket_t *new_so) 125*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 126*a325d9c4SApple OSS Distributions #endif /* KERNEL_PRIVATE */ 127*a325d9c4SApple OSS Distributions 128*a325d9c4SApple OSS Distributions /*! 129*a325d9c4SApple OSS Distributions * @function sock_bind 130*a325d9c4SApple OSS Distributions * @discussion Binds a socket to a specific address. See 'man 2 bind' 131*a325d9c4SApple OSS Distributions * for more information. 132*a325d9c4SApple OSS Distributions * @param so The socket to be bound. 133*a325d9c4SApple OSS Distributions * @param to The local address the socket should be bound to. 134*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 135*a325d9c4SApple OSS Distributions */ 136*a325d9c4SApple OSS Distributions extern errno_t sock_bind(socket_t so, const struct sockaddr *to) 137*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 138*a325d9c4SApple OSS Distributions 139*a325d9c4SApple OSS Distributions /*! 140*a325d9c4SApple OSS Distributions * @function sock_connect 141*a325d9c4SApple OSS Distributions * @discussion Initiates a connection on the socket. See 'man 2 142*a325d9c4SApple OSS Distributions * connect' for more information. 143*a325d9c4SApple OSS Distributions * @param so The socket to be connect. 144*a325d9c4SApple OSS Distributions * @param to The remote address the socket should connect to. 145*a325d9c4SApple OSS Distributions * @param flags Flags for connecting. The only flag supported so far is 146*a325d9c4SApple OSS Distributions * MSG_DONTWAIT. MSG_DONTWAIT will perform a non-blocking connect. 147*a325d9c4SApple OSS Distributions * sock_connect will return immediately with EINPROGRESS. The 148*a325d9c4SApple OSS Distributions * upcall, if supplied, will be called when the connection is 149*a325d9c4SApple OSS Distributions * completed. 150*a325d9c4SApple OSS Distributions * @result 0 on success, EINPROGRESS for a non-blocking connect that 151*a325d9c4SApple OSS Distributions * has not completed, otherwise the errno error. 152*a325d9c4SApple OSS Distributions */ 153*a325d9c4SApple OSS Distributions extern errno_t sock_connect(socket_t so, const struct sockaddr *to, int flags) 154*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 155*a325d9c4SApple OSS Distributions 156*a325d9c4SApple OSS Distributions #ifdef KERNEL_PRIVATE 157*a325d9c4SApple OSS Distributions /* 158*a325d9c4SApple OSS Distributions * This function was added to support NFS. NFS does something funny, 159*a325d9c4SApple OSS Distributions * setting a short timeout and checking to see if it should abort the 160*a325d9c4SApple OSS Distributions * connect every two seconds. Ideally, NFS would use the upcall to be 161*a325d9c4SApple OSS Distributions * notified when the connect is complete. 162*a325d9c4SApple OSS Distributions * 163*a325d9c4SApple OSS Distributions * If you feel you need to use this function, please contact us to 164*a325d9c4SApple OSS Distributions * explain why. 165*a325d9c4SApple OSS Distributions * 166*a325d9c4SApple OSS Distributions * @function sock_connectwait 167*a325d9c4SApple OSS Distributions * @discussion Allows a caller to wait on a socket connect. 168*a325d9c4SApple OSS Distributions * @param so The socket being connected. 169*a325d9c4SApple OSS Distributions * @param tv The amount of time to wait. 170*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. EINPROGRESS will be 171*a325d9c4SApple OSS Distributions * returned if the connection did not complete in the timeout 172*a325d9c4SApple OSS Distributions * specified. 173*a325d9c4SApple OSS Distributions */ 174*a325d9c4SApple OSS Distributions extern errno_t sock_connectwait(socket_t so, const struct timeval *tv); 175*a325d9c4SApple OSS Distributions #endif /* KERNEL_PRIVATE */ 176*a325d9c4SApple OSS Distributions 177*a325d9c4SApple OSS Distributions /*! 178*a325d9c4SApple OSS Distributions * @function sock_getpeername 179*a325d9c4SApple OSS Distributions * @discussion Retrieves the remote address of a connected socket. See 180*a325d9c4SApple OSS Distributions * 'man 2 getpeername'. 181*a325d9c4SApple OSS Distributions * @param so The socket. 182*a325d9c4SApple OSS Distributions * @param peername Storage for the peer name. 183*a325d9c4SApple OSS Distributions * @param peernamelen Length of storage for the peer name. 184*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 185*a325d9c4SApple OSS Distributions */ 186*a325d9c4SApple OSS Distributions extern errno_t sock_getpeername(socket_t so, struct sockaddr *peername, 187*a325d9c4SApple OSS Distributions int peernamelen) 188*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 189*a325d9c4SApple OSS Distributions 190*a325d9c4SApple OSS Distributions /*! 191*a325d9c4SApple OSS Distributions * @function sock_getsockname 192*a325d9c4SApple OSS Distributions * @discussion Retrieves the local address of a socket. See 'man 2 193*a325d9c4SApple OSS Distributions * getsockname'. 194*a325d9c4SApple OSS Distributions * @param so The socket. 195*a325d9c4SApple OSS Distributions * @param sockname Storage for the local name. 196*a325d9c4SApple OSS Distributions * @param socknamelen Length of storage for the socket name. 197*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 198*a325d9c4SApple OSS Distributions */ 199*a325d9c4SApple OSS Distributions extern errno_t sock_getsockname(socket_t so, struct sockaddr *sockname, 200*a325d9c4SApple OSS Distributions int socknamelen) 201*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 202*a325d9c4SApple OSS Distributions 203*a325d9c4SApple OSS Distributions /*! 204*a325d9c4SApple OSS Distributions * @function sock_getsockopt 205*a325d9c4SApple OSS Distributions * @discussion Retrieves a socket option. See 'man 2 getsockopt'. 206*a325d9c4SApple OSS Distributions * @param so The socket. 207*a325d9c4SApple OSS Distributions * @param level Level of the socket option. 208*a325d9c4SApple OSS Distributions * @param optname The option name. 209*a325d9c4SApple OSS Distributions * @param optval The option value. 210*a325d9c4SApple OSS Distributions * @param optlen The length of optval, returns the actual length. 211*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 212*a325d9c4SApple OSS Distributions */ 213*a325d9c4SApple OSS Distributions extern errno_t sock_getsockopt(socket_t so, int level, int optname, 214*a325d9c4SApple OSS Distributions void *optval, int *optlen) 215*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 216*a325d9c4SApple OSS Distributions 217*a325d9c4SApple OSS Distributions /*! 218*a325d9c4SApple OSS Distributions * @function sock_ioctl 219*a325d9c4SApple OSS Distributions * @discussion Performs an ioctl operation on a socket. See 'man 2 ioctl'. 220*a325d9c4SApple OSS Distributions * @param so The socket. 221*a325d9c4SApple OSS Distributions * @param request The ioctl name. 222*a325d9c4SApple OSS Distributions * @param argp The argument. 223*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 224*a325d9c4SApple OSS Distributions */ 225*a325d9c4SApple OSS Distributions extern errno_t sock_ioctl(socket_t so, unsigned long request, void *argp) 226*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 227*a325d9c4SApple OSS Distributions 228*a325d9c4SApple OSS Distributions /*! 229*a325d9c4SApple OSS Distributions * @function sock_setsockopt 230*a325d9c4SApple OSS Distributions * @discussion Sets a socket option. See 'man 2 setsockopt'. 231*a325d9c4SApple OSS Distributions * @param so The socket. 232*a325d9c4SApple OSS Distributions * @param level Level of the socket option. 233*a325d9c4SApple OSS Distributions * @param optname The option name. 234*a325d9c4SApple OSS Distributions * @param optval The option value. 235*a325d9c4SApple OSS Distributions * @param optlen The length of optval. 236*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 237*a325d9c4SApple OSS Distributions */ 238*a325d9c4SApple OSS Distributions extern errno_t sock_setsockopt(socket_t so, int level, int optname, 239*a325d9c4SApple OSS Distributions const void *optval, int optlen) 240*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 241*a325d9c4SApple OSS Distributions 242*a325d9c4SApple OSS Distributions #ifdef KERNEL_PRIVATE 243*a325d9c4SApple OSS Distributions /* 244*a325d9c4SApple OSS Distributions * This function was added to support AFP setting the traffic class 245*a325d9c4SApple OSS Distributions * for a backup stream within a wireless LAN or over link-local address. 246*a325d9c4SApple OSS Distributions * 247*a325d9c4SApple OSS Distributions * If you feel you need to use this function, please contact us to 248*a325d9c4SApple OSS Distributions * explain why. 249*a325d9c4SApple OSS Distributions * 250*a325d9c4SApple OSS Distributions * @function sock_settclassopt 251*a325d9c4SApple OSS Distributions * @discussion Allows a caller to set the traffic class. 252*a325d9c4SApple OSS Distributions * @param so The socket. 253*a325d9c4SApple OSS Distributions * @param optval The option value. 254*a325d9c4SApple OSS Distributions * @param optlen The length of optval. 255*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 256*a325d9c4SApple OSS Distributions */ 257*a325d9c4SApple OSS Distributions extern errno_t sock_settclassopt(socket_t so, const void* optval, size_t optlen); 258*a325d9c4SApple OSS Distributions 259*a325d9c4SApple OSS Distributions /* 260*a325d9c4SApple OSS Distributions * This function was added to support AFP getting the traffic class 261*a325d9c4SApple OSS Distributions * set on a stream. 262*a325d9c4SApple OSS Distributions * 263*a325d9c4SApple OSS Distributions * This is also a private API, please contact us if you need to use it. 264*a325d9c4SApple OSS Distributions * 265*a325d9c4SApple OSS Distributions * @function sockgettclassopt 266*a325d9c4SApple OSS Distributions * @discussion Allows a caller to get the traffic class. 267*a325d9c4SApple OSS Distributions * @param so The socket. 268*a325d9c4SApple OSS Distributions * @param optval The option value. 269*a325d9c4SApple OSS Distributions * @param optlen The length of optval, returns the actual length. 270*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 271*a325d9c4SApple OSS Distributions */ 272*a325d9c4SApple OSS Distributions extern errno_t sock_gettclassopt(socket_t so, void* optval, size_t* optlen); 273*a325d9c4SApple OSS Distributions 274*a325d9c4SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE 275*a325d9c4SApple OSS Distributions extern void socket_set_traffic_mgt_flags_locked(socket_t so, u_int8_t flags); 276*a325d9c4SApple OSS Distributions extern void socket_clear_traffic_mgt_flags_locked(socket_t so, u_int8_t flags); 277*a325d9c4SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */ 278*a325d9c4SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE 279*a325d9c4SApple OSS Distributions extern void socket_set_traffic_mgt_flags(socket_t so, u_int8_t flags); 280*a325d9c4SApple OSS Distributions extern void socket_clear_traffic_mgt_flags(socket_t so, u_int8_t flags); 281*a325d9c4SApple OSS Distributions extern errno_t socket_defunct(struct proc *, socket_t so, int); 282*a325d9c4SApple OSS Distributions extern errno_t sock_receive_internal(socket_t, struct msghdr *, mbuf_t *, 283*a325d9c4SApple OSS Distributions int, size_t *); 284*a325d9c4SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */ 285*a325d9c4SApple OSS Distributions #endif /* KERNEL_PRIVATE */ 286*a325d9c4SApple OSS Distributions 287*a325d9c4SApple OSS Distributions /*! 288*a325d9c4SApple OSS Distributions * @function sock_listen 289*a325d9c4SApple OSS Distributions * @discussion Indicate that the socket should start accepting incoming 290*a325d9c4SApple OSS Distributions * connections. See 'man 2 listen'. 291*a325d9c4SApple OSS Distributions * @param so The socket. 292*a325d9c4SApple OSS Distributions * @param backlog The maximum length of the queue of pending connections. 293*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 294*a325d9c4SApple OSS Distributions */ 295*a325d9c4SApple OSS Distributions extern errno_t sock_listen(socket_t so, int backlog) 296*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 297*a325d9c4SApple OSS Distributions 298*a325d9c4SApple OSS Distributions /*! 299*a325d9c4SApple OSS Distributions * @function sock_receive 300*a325d9c4SApple OSS Distributions * @discussion Receive data from a socket. Similar to recvmsg. See 'man 301*a325d9c4SApple OSS Distributions * 2 recvmsg' for more information about receiving data. 302*a325d9c4SApple OSS Distributions * @param so The socket. 303*a325d9c4SApple OSS Distributions * @param msg The msg describing how the data should be received. 304*a325d9c4SApple OSS Distributions * @param flags See 'man 2 recvmsg'. 305*a325d9c4SApple OSS Distributions * @param recvdlen Number of bytes received, same as return value of 306*a325d9c4SApple OSS Distributions * userland recvmsg. 307*a325d9c4SApple OSS Distributions * @result 0 on success, EWOULDBLOCK if non-blocking and operation 308*a325d9c4SApple OSS Distributions * would cause the thread to block, otherwise the errno error. 309*a325d9c4SApple OSS Distributions */ 310*a325d9c4SApple OSS Distributions extern errno_t sock_receive(socket_t so, struct msghdr *msg, int flags, 311*a325d9c4SApple OSS Distributions size_t *recvdlen) 312*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 313*a325d9c4SApple OSS Distributions 314*a325d9c4SApple OSS Distributions /*! 315*a325d9c4SApple OSS Distributions * @function sock_receivembuf 316*a325d9c4SApple OSS Distributions * @discussion Receive data from a socket. Similar to sock_receive 317*a325d9c4SApple OSS Distributions * though data is returned as a chain of mbufs. See 'man 2 recvmsg' 318*a325d9c4SApple OSS Distributions * for more information about receiving data. 319*a325d9c4SApple OSS Distributions * @param so The socket. 320*a325d9c4SApple OSS Distributions * @param msg The msg describing how the data should be received. May 321*a325d9c4SApple OSS Distributions * be NULL. The msg_iov is ignored. 322*a325d9c4SApple OSS Distributions * @param data Upon return *data will be a reference to an mbuf chain 323*a325d9c4SApple OSS Distributions * containing the data received. This eliminates copying the data 324*a325d9c4SApple OSS Distributions * out of the mbufs. Caller is responsible for freeing the mbufs. 325*a325d9c4SApple OSS Distributions * @param flags See 'man 2 recvmsg'. 326*a325d9c4SApple OSS Distributions * @param recvlen Maximum number of bytes to receive in the mbuf chain. 327*a325d9c4SApple OSS Distributions * Upon return, this value will be set to the number of bytes 328*a325d9c4SApple OSS Distributions * received, same as return value of userland recvmsg. 329*a325d9c4SApple OSS Distributions * @result 0 on success, EWOULDBLOCK if non-blocking and operation 330*a325d9c4SApple OSS Distributions * would cause the thread to block, otherwise the errno error. 331*a325d9c4SApple OSS Distributions */ 332*a325d9c4SApple OSS Distributions extern errno_t sock_receivembuf(socket_t so, struct msghdr *msg, mbuf_t *data, 333*a325d9c4SApple OSS Distributions int flags, size_t *recvlen) 334*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 335*a325d9c4SApple OSS Distributions 336*a325d9c4SApple OSS Distributions /*! 337*a325d9c4SApple OSS Distributions * @function sock_send 338*a325d9c4SApple OSS Distributions * @discussion Send data on a socket. Similar to sendmsg. See 'man 2 339*a325d9c4SApple OSS Distributions * sendmsg' for more information about sending data. 340*a325d9c4SApple OSS Distributions * @param so The socket. 341*a325d9c4SApple OSS Distributions * @param msg The msg describing how the data should be sent. Any 342*a325d9c4SApple OSS Distributions * pointers must point to data in the kernel. 343*a325d9c4SApple OSS Distributions * @param flags See 'man 2 sendmsg'. 344*a325d9c4SApple OSS Distributions * @param sentlen The number of bytes sent. 345*a325d9c4SApple OSS Distributions * @result 0 on success, EWOULDBLOCK if non-blocking and operation 346*a325d9c4SApple OSS Distributions * would cause the thread to block, otherwise the errno error. 347*a325d9c4SApple OSS Distributions */ 348*a325d9c4SApple OSS Distributions extern errno_t sock_send(socket_t so, const struct msghdr *msg, int flags, 349*a325d9c4SApple OSS Distributions size_t *sentlen) 350*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 351*a325d9c4SApple OSS Distributions 352*a325d9c4SApple OSS Distributions /*! 353*a325d9c4SApple OSS Distributions * @function sock_sendmbuf 354*a325d9c4SApple OSS Distributions * @discussion Send data in an mbuf on a socket. Similar to sock_send 355*a325d9c4SApple OSS Distributions * only the data to be sent is taken from the mbuf chain. 356*a325d9c4SApple OSS Distributions * @param so The socket. 357*a325d9c4SApple OSS Distributions * @param msg The msg describing how the data should be sent. The 358*a325d9c4SApple OSS Distributions * msg_iov is ignored. msg may be NULL. 359*a325d9c4SApple OSS Distributions * @param data The mbuf chain of data to send. 360*a325d9c4SApple OSS Distributions * @param flags See 'man 2 sendmsg'. 361*a325d9c4SApple OSS Distributions * @param sentlen The number of bytes sent. 362*a325d9c4SApple OSS Distributions * @result 0 on success, EWOULDBLOCK if non-blocking and operation 363*a325d9c4SApple OSS Distributions * would cause the thread to block, otherwise the errno error. 364*a325d9c4SApple OSS Distributions * Regardless of return value, the mbuf chain 'data' will be freed. 365*a325d9c4SApple OSS Distributions */ 366*a325d9c4SApple OSS Distributions extern errno_t sock_sendmbuf(socket_t so, const struct msghdr *msg, mbuf_t data, 367*a325d9c4SApple OSS Distributions int flags, size_t *sentlen) 368*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 369*a325d9c4SApple OSS Distributions 370*a325d9c4SApple OSS Distributions /*! 371*a325d9c4SApple OSS Distributions * @function sock_shutdown 372*a325d9c4SApple OSS Distributions * @discussion Shutdown one or both directions of a connection. See 373*a325d9c4SApple OSS Distributions * 'man 2 shutdown' for more information. 374*a325d9c4SApple OSS Distributions * @param so The socket. 375*a325d9c4SApple OSS Distributions * @param how SHUT_RD - shutdown receive. 376*a325d9c4SApple OSS Distributions * SHUT_WR - shutdown send. 377*a325d9c4SApple OSS Distributions * SHUT_RDWR - shutdown both. 378*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 379*a325d9c4SApple OSS Distributions */ 380*a325d9c4SApple OSS Distributions extern errno_t sock_shutdown(socket_t so, int how) 381*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 382*a325d9c4SApple OSS Distributions 383*a325d9c4SApple OSS Distributions /*! 384*a325d9c4SApple OSS Distributions * @function sock_socket 385*a325d9c4SApple OSS Distributions * @discussion Allocate a socket. Allocating a socket in this manner 386*a325d9c4SApple OSS Distributions * creates a socket with no associated file descriptor. For more 387*a325d9c4SApple OSS Distributions * information, see 'man 2 socket'. 388*a325d9c4SApple OSS Distributions * @param domain The socket domain (PF_INET, etc...). 389*a325d9c4SApple OSS Distributions * @param type The socket type (SOCK_STREAM, SOCK_DGRAM, etc...). 390*a325d9c4SApple OSS Distributions * @param protocol The socket protocol. 391*a325d9c4SApple OSS Distributions * @param callback A notifier function to be called when an event 392*a325d9c4SApple OSS Distributions * occurs on the socket. This may be NULL. 393*a325d9c4SApple OSS Distributions * @param cookie A cookie passed directly to the callback. 394*a325d9c4SApple OSS Distributions * @param new_so Upon success, a reference to the new socket. 395*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 396*a325d9c4SApple OSS Distributions */ 397*a325d9c4SApple OSS Distributions #ifdef KERNEL_PRIVATE 398*a325d9c4SApple OSS Distributions extern errno_t sock_socket_internal(int domain, int type, int protocol, 399*a325d9c4SApple OSS Distributions sock_upcall callback, void *cookie, socket_t *new_so); 400*a325d9c4SApple OSS Distributions 401*a325d9c4SApple OSS Distributions #define sock_socket(domain, type, protocol, callback, cookie, new_so) \ 402*a325d9c4SApple OSS Distributions sock_socket_internal((domain), (type), (protocol), \ 403*a325d9c4SApple OSS Distributions (callback), (cookie), (new_so)) 404*a325d9c4SApple OSS Distributions #else 405*a325d9c4SApple OSS Distributions extern errno_t sock_socket(int domain, int type, int protocol, 406*a325d9c4SApple OSS Distributions sock_upcall callback, void *cookie, socket_t *new_so) 407*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 408*a325d9c4SApple OSS Distributions #endif /* KERNEL_PRIVATE */ 409*a325d9c4SApple OSS Distributions 410*a325d9c4SApple OSS Distributions /*! 411*a325d9c4SApple OSS Distributions * @function sock_close 412*a325d9c4SApple OSS Distributions * @discussion Close the socket. 413*a325d9c4SApple OSS Distributions * @param so The socket to close. This should only ever be a socket 414*a325d9c4SApple OSS Distributions * created with sock_socket. Closing a socket created in user space 415*a325d9c4SApple OSS Distributions * using sock_close may leave a file descriptor pointing to the 416*a325d9c4SApple OSS Distributions * closed socket, resulting in undefined behavior. 417*a325d9c4SApple OSS Distributions */ 418*a325d9c4SApple OSS Distributions extern void sock_close(socket_t so) 419*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 420*a325d9c4SApple OSS Distributions 421*a325d9c4SApple OSS Distributions /* 422*a325d9c4SApple OSS Distributions * @function sock_retain 423*a325d9c4SApple OSS Distributions * @discussion Prevents the socket from closing 424*a325d9c4SApple OSS Distributions * @param so The socket to close. Increment a retain count on the 425*a325d9c4SApple OSS Distributions * socket, preventing it from being closed when sock_close is 426*a325d9c4SApple OSS Distributions * called. This is used when a File Descriptor is passed (and 427*a325d9c4SApple OSS Distributions * closed) from userland and the kext wants to keep ownership of 428*a325d9c4SApple OSS Distributions * that socket. It is used in conjunction with 429*a325d9c4SApple OSS Distributions * sock_release(socket_t so). 430*a325d9c4SApple OSS Distributions */ 431*a325d9c4SApple OSS Distributions extern void sock_retain(socket_t so) 432*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 433*a325d9c4SApple OSS Distributions 434*a325d9c4SApple OSS Distributions /* 435*a325d9c4SApple OSS Distributions * @function sock_release 436*a325d9c4SApple OSS Distributions * @discussion Decrement the retain count and close the socket if the 437*a325d9c4SApple OSS Distributions * retain count reaches zero. 438*a325d9c4SApple OSS Distributions * @param so The socket to release. This is used to release ownership 439*a325d9c4SApple OSS Distributions * on a socket acquired with sock_retain. When the last retain 440*a325d9c4SApple OSS Distributions * count is reached, this will call sock_close to close the socket. 441*a325d9c4SApple OSS Distributions */ 442*a325d9c4SApple OSS Distributions extern void sock_release(socket_t so) 443*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 444*a325d9c4SApple OSS Distributions 445*a325d9c4SApple OSS Distributions /*! 446*a325d9c4SApple OSS Distributions * @function sock_setpriv 447*a325d9c4SApple OSS Distributions * @discussion Set the privileged bit in the socket. Allows for 448*a325d9c4SApple OSS Distributions * operations that require root privileges. 449*a325d9c4SApple OSS Distributions * @param so The socket on which to modify the SS_PRIV flag. 450*a325d9c4SApple OSS Distributions * @param on Indicate whether or not the SS_PRIV flag should be set. 451*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 452*a325d9c4SApple OSS Distributions */ 453*a325d9c4SApple OSS Distributions extern errno_t sock_setpriv(socket_t so, int on) 454*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 455*a325d9c4SApple OSS Distributions 456*a325d9c4SApple OSS Distributions /*! 457*a325d9c4SApple OSS Distributions * @function sock_isconnected 458*a325d9c4SApple OSS Distributions * @discussion Returns whether or not the socket is connected. 459*a325d9c4SApple OSS Distributions * @param so The socket to check. 460*a325d9c4SApple OSS Distributions * @result 0 - socket is not connected. 1 - socket is connected. 461*a325d9c4SApple OSS Distributions */ 462*a325d9c4SApple OSS Distributions extern int sock_isconnected(socket_t so) 463*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 464*a325d9c4SApple OSS Distributions 465*a325d9c4SApple OSS Distributions /*! 466*a325d9c4SApple OSS Distributions * @function sock_isnonblocking 467*a325d9c4SApple OSS Distributions * @discussion Returns whether or not the socket is non-blocking. In 468*a325d9c4SApple OSS Distributions * the context of this KPI, non-blocking means that functions to 469*a325d9c4SApple OSS Distributions * perform operations on a socket will not wait for completion. 470*a325d9c4SApple OSS Distributions * 471*a325d9c4SApple OSS Distributions * To enable or disable blocking, use the FIONBIO ioctl. The 472*a325d9c4SApple OSS Distributions * parameter is an int. If the int is zero, the socket will block. 473*a325d9c4SApple OSS Distributions * If the parameter is non-zero, the socket will not block. 474*a325d9c4SApple OSS Distributions * @result 0 - socket will block. 1 - socket will not block. 475*a325d9c4SApple OSS Distributions */ 476*a325d9c4SApple OSS Distributions extern int sock_isnonblocking(socket_t so) 477*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 478*a325d9c4SApple OSS Distributions 479*a325d9c4SApple OSS Distributions /*! 480*a325d9c4SApple OSS Distributions * @function sock_gettype 481*a325d9c4SApple OSS Distributions * @discussion Retrieves information about the socket. This is the same 482*a325d9c4SApple OSS Distributions * information that was used to create the socket. If any of the 483*a325d9c4SApple OSS Distributions * parameters following so are NULL, that information is not 484*a325d9c4SApple OSS Distributions * retrieved. 485*a325d9c4SApple OSS Distributions * @param so The socket to check. 486*a325d9c4SApple OSS Distributions * @param domain The domain of the socket (PF_INET, ...). May be NULL. 487*a325d9c4SApple OSS Distributions * @param type The socket type (SOCK_STREAM, SOCK_DGRAM, ...). May be NULL. 488*a325d9c4SApple OSS Distributions * @param protocol The socket protocol. May be NULL. 489*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 490*a325d9c4SApple OSS Distributions */ 491*a325d9c4SApple OSS Distributions extern errno_t sock_gettype(socket_t so, int *domain, int *type, int *protocol) 492*a325d9c4SApple OSS Distributions __NKE_API_DEPRECATED; 493*a325d9c4SApple OSS Distributions 494*a325d9c4SApple OSS Distributions #ifdef KERNEL_PRIVATE 495*a325d9c4SApple OSS Distributions /* 496*a325d9c4SApple OSS Distributions * @function sock_nointerrupt 497*a325d9c4SApple OSS Distributions * @discussion Disables interrupt on socket buffers (sets SB_NOINTR on 498*a325d9c4SApple OSS Distributions * send and receive socket buffers). 499*a325d9c4SApple OSS Distributions * @param so The socket to modify. 500*a325d9c4SApple OSS Distributions * @param on Indicate whether or not the SB_NOINTR flag should be set. 501*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 502*a325d9c4SApple OSS Distributions */ 503*a325d9c4SApple OSS Distributions extern errno_t sock_nointerrupt(socket_t so, int on); 504*a325d9c4SApple OSS Distributions 505*a325d9c4SApple OSS Distributions /* 506*a325d9c4SApple OSS Distributions * @function sock_getlistener 507*a325d9c4SApple OSS Distributions * @discussion Retrieves the listening socket of a pre-accepted socket, 508*a325d9c4SApple OSS Distributions * i.e. a socket which is still in the incomplete/completed list. 509*a325d9c4SApple OSS Distributions * Once a socket has been accepted, the information pertaining 510*a325d9c4SApple OSS Distributions * to its listener is no longer available. Therefore, modules 511*a325d9c4SApple OSS Distributions * interested in finding out the listening socket should install 512*a325d9c4SApple OSS Distributions * the appropriate socket filter callback (sf_attach) which gets 513*a325d9c4SApple OSS Distributions * invoked prior to the socket being fully accepted, and call 514*a325d9c4SApple OSS Distributions * this routine at such a time to obtain the listener. Callers 515*a325d9c4SApple OSS Distributions * are guaranteed that the listener socket will not go away 516*a325d9c4SApple OSS Distributions * during the sf_attach callback, and therefore the value is 517*a325d9c4SApple OSS Distributions * safe to be used only in that callback context. Callers should 518*a325d9c4SApple OSS Distributions * therefore take note that the listening socket's lock will be 519*a325d9c4SApple OSS Distributions * held throughout the duration of the callback. 520*a325d9c4SApple OSS Distributions * @param so The pre-accepted socket. 521*a325d9c4SApple OSS Distributions * @result Non-NULL value which indicates the listening socket; otherwise, 522*a325d9c4SApple OSS Distributions * NULL if the socket is not in the incomplete/completed list 523*a325d9c4SApple OSS Distributions * of a listener. 524*a325d9c4SApple OSS Distributions */ 525*a325d9c4SApple OSS Distributions extern socket_t sock_getlistener(socket_t so); 526*a325d9c4SApple OSS Distributions 527*a325d9c4SApple OSS Distributions /* 528*a325d9c4SApple OSS Distributions * @function sock_getaddr 529*a325d9c4SApple OSS Distributions * @discussion Retrieves the local or remote address of a socket. 530*a325d9c4SApple OSS Distributions * This is a composite of sock_getpeername and sock_getsockname, 531*a325d9c4SApple OSS Distributions * except that the allocated socket address is returned to the 532*a325d9c4SApple OSS Distributions * caller, and that the caller is reponsible for calling 533*a325d9c4SApple OSS Distributions * sock_freeaddr once finished with it. 534*a325d9c4SApple OSS Distributions * @param so The socket. 535*a325d9c4SApple OSS Distributions * @param psockname Pointer to the storage for the socket name. 536*a325d9c4SApple OSS Distributions * @param peername 0 for local address, and non-zero for peer address. 537*a325d9c4SApple OSS Distributions * @result 0 on success otherwise the errno error. 538*a325d9c4SApple OSS Distributions */ 539*a325d9c4SApple OSS Distributions extern errno_t sock_getaddr(socket_t so, struct sockaddr **psockname, 540*a325d9c4SApple OSS Distributions int peername); 541*a325d9c4SApple OSS Distributions 542*a325d9c4SApple OSS Distributions /* 543*a325d9c4SApple OSS Distributions * @function sock_freeaddr 544*a325d9c4SApple OSS Distributions * @discussion Frees the socket address allocated by sock_getaddr. 545*a325d9c4SApple OSS Distributions * @param sockname The socket name to be freed. 546*a325d9c4SApple OSS Distributions */ 547*a325d9c4SApple OSS Distributions extern void sock_freeaddr(struct sockaddr *sockname); 548*a325d9c4SApple OSS Distributions 549*a325d9c4SApple OSS Distributions /* 550*a325d9c4SApple OSS Distributions * @function sock_setupcall 551*a325d9c4SApple OSS Distributions * @discussion Set the notifier function to be called when an event 552*a325d9c4SApple OSS Distributions * occurs on the socket. This may be set to NULL to disable 553*a325d9c4SApple OSS Distributions * further notifications. Setting the function does not 554*a325d9c4SApple OSS Distributions * affect currently notifications about to be sent or being sent. 555*a325d9c4SApple OSS Distributions * Note: When this function is used on a socket passed from 556*a325d9c4SApple OSS Distributions * userspace it is crucial to call sock_retain() on the socket 557*a325d9c4SApple OSS Distributions * otherwise a callback could be dispatched on a closed socket 558*a325d9c4SApple OSS Distributions * and cause a crash. 559*a325d9c4SApple OSS Distributions * @param sock The socket. 560*a325d9c4SApple OSS Distributions * @param callback The notifier function 561*a325d9c4SApple OSS Distributions * @param context A cookie passed directly to the callback 562*a325d9c4SApple OSS Distributions */ 563*a325d9c4SApple OSS Distributions extern errno_t sock_setupcall(socket_t sock, sock_upcall callback, 564*a325d9c4SApple OSS Distributions void *context); 565*a325d9c4SApple OSS Distributions 566*a325d9c4SApple OSS Distributions /* 567*a325d9c4SApple OSS Distributions * @function sock_setupcalls 568*a325d9c4SApple OSS Distributions * @discussion Set the notifier function to be called when an event 569*a325d9c4SApple OSS Distributions * occurs on the socket. This may be set to NULL to disable 570*a325d9c4SApple OSS Distributions * further notifications. Setting the function does not 571*a325d9c4SApple OSS Distributions * affect currently notifications about to be sent or being sent. 572*a325d9c4SApple OSS Distributions * Note: When this function is used on a socket passed from 573*a325d9c4SApple OSS Distributions * userspace it is crucial to call sock_retain() on the socket 574*a325d9c4SApple OSS Distributions * otherwise a callback could be dispatched on a closed socket 575*a325d9c4SApple OSS Distributions * and cause a crash. 576*a325d9c4SApple OSS Distributions * @param sock The socket. 577*a325d9c4SApple OSS Distributions * @param read_callback The read notifier function 578*a325d9c4SApple OSS Distributions * @param read_context A cookie passed directly to the read callback 579*a325d9c4SApple OSS Distributions * @param write_callback The write notifier function 580*a325d9c4SApple OSS Distributions * @param write_context A cookie passed directly to the write callback 581*a325d9c4SApple OSS Distributions */ 582*a325d9c4SApple OSS Distributions extern errno_t sock_setupcalls(socket_t sock, sock_upcall read_callback, 583*a325d9c4SApple OSS Distributions void *read_context, sock_upcall write_callback, void *write_context); 584*a325d9c4SApple OSS Distributions 585*a325d9c4SApple OSS Distributions /* 586*a325d9c4SApple OSS Distributions * @function sock_setupcalls_locked 587*a325d9c4SApple OSS Distributions * @discussion The locked version of sock_setupcalls 588*a325d9c4SApple OSS Distributions * @param locked: When sets, indicates that the callbacks expect to be 589*a325d9c4SApple OSS Distributions * on a locked socket. Thus, no unlock is done prior to 590*a325d9c4SApple OSS Distributions * calling the callback. 591*a325d9c4SApple OSS Distributions */ 592*a325d9c4SApple OSS Distributions extern void sock_setupcalls_locked(socket_t sock, 593*a325d9c4SApple OSS Distributions sock_upcall rcallback, void *rcontext, 594*a325d9c4SApple OSS Distributions sock_upcall wcallback, void *wcontext, int locked); 595*a325d9c4SApple OSS Distributions 596*a325d9c4SApple OSS Distributions /* 597*a325d9c4SApple OSS Distributions * @function sock_catchevents 598*a325d9c4SApple OSS Distributions * @discussion Set the notifier function to be called when an event 599*a325d9c4SApple OSS Distributions * occurs on the socket. This may be set to NULL to disable 600*a325d9c4SApple OSS Distributions * further notifications. Setting the function does not 601*a325d9c4SApple OSS Distributions * affect currently notifications about to be sent or being sent. 602*a325d9c4SApple OSS Distributions * @param sock The socket. 603*a325d9c4SApple OSS Distributions * @param event_callback The event notifier function 604*a325d9c4SApple OSS Distributions * @param event_context A cookie passed directly to the event callback 605*a325d9c4SApple OSS Distributions * @param event_mask One or more SO_FILT_HINT_* values OR'ed together, 606*a325d9c4SApple OSS Distributions * indicating the registered event(s). 607*a325d9c4SApple OSS Distributions */ 608*a325d9c4SApple OSS Distributions extern errno_t sock_catchevents(socket_t sock, sock_evupcall event_callback, 609*a325d9c4SApple OSS Distributions void *event_context, long event_mask); 610*a325d9c4SApple OSS Distributions 611*a325d9c4SApple OSS Distributions extern void sock_catchevents_locked(socket_t sock, sock_evupcall ecallback, 612*a325d9c4SApple OSS Distributions void *econtext, long emask); 613*a325d9c4SApple OSS Distributions 614*a325d9c4SApple OSS Distributions 615*a325d9c4SApple OSS Distributions /* 616*a325d9c4SApple OSS Distributions * @function sock_iskernel 617*a325d9c4SApple OSS Distributions * @discussion Returns true if the socket was created by the kernel or 618*a325d9c4SApple OSS Distributions * is owned by the kernel. 619*a325d9c4SApple OSS Distributions * @param sock The socket. 620*a325d9c4SApple OSS Distributions * @result True if the kernel owns the socket. 621*a325d9c4SApple OSS Distributions */ 622*a325d9c4SApple OSS Distributions extern int sock_iskernel(socket_t); 623*a325d9c4SApple OSS Distributions #endif /* KERNEL_PRIVATE */ 624*a325d9c4SApple OSS Distributions 625*a325d9c4SApple OSS Distributions __END_DECLS 626*a325d9c4SApple OSS Distributions #undef __NKE_API_DEPRECATED 627*a325d9c4SApple OSS Distributions #endif /* __KPI_SOCKET__ */ 628