]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/kpi_socket.h
xnu-1504.7.4.tar.gz
[apple/xnu.git] / bsd / sys / kpi_socket.h
index 1e63945cf7bdde85e4abaecc0931a67756ef28d0..5e380f5a795dc00b1c644823fcf8fd7d498d4746 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2008 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -62,7 +62,7 @@ struct timeval;
        @param cookie The cookie passed in when the socket was created.
        @param waitf Indicates whether or not it's safe to block.
 */
-typedef void (*sock_upcall)(socket_t so, voidcookie, int waitf);
+typedef void (*sock_upcall)(socket_t so, void *cookie, int waitf);
 
 /*!
        @function sock_accept
@@ -85,8 +85,8 @@ typedef void (*sock_upcall)(socket_t so, void* cookie, int waitf);
                socket for tracking the connection.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_accept(socket_t so, struct sockaddr *from, int fromlen,
-    int flags, sock_upcall callback, voidcookie, socket_t *new_so);
+extern errno_t sock_accept(socket_t so, struct sockaddr *from, int fromlen,
+    int flags, sock_upcall callback, void *cookie, socket_t *new_so);
 
 /*!
        @function sock_bind
@@ -96,7 +96,7 @@ errno_t sock_accept(socket_t so, struct sockaddr *from, int fromlen,
        @param to The local address the socket should be bound to.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_bind(socket_t so, const struct sockaddr *to);
+extern errno_t sock_bind(socket_t so, const struct sockaddr *to);
 
 /*!
        @function sock_connect
@@ -112,7 +112,7 @@ errno_t sock_bind(socket_t so, const struct sockaddr *to);
        @result 0 on success, EINPROGRESS for a non-blocking connect that
                has not completed, otherwise the errno error.
  */
-errno_t sock_connect(socket_t so, const struct sockaddr *to, int flags);
+extern errno_t sock_connect(socket_t so, const struct sockaddr *to, int flags);
 
 #ifdef KERNEL_PRIVATE
 /*
@@ -132,7 +132,7 @@ errno_t sock_connect(socket_t so, const struct sockaddr *to, int flags);
                returned if the connection did not complete in the timeout
                specified.
  */
-errno_t sock_connectwait(socket_t so, const struct timeval *tv);
+extern errno_t sock_connectwait(socket_t so, const struct timeval *tv);
 #endif /* KERNEL_PRIVATE */
 
 /*!
@@ -144,7 +144,7 @@ errno_t sock_connectwait(socket_t so, const struct timeval *tv);
        @param peernamelen Length of storage for the peer name.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_getpeername(socket_t so, struct sockaddr *peername,
+extern errno_t sock_getpeername(socket_t so, struct sockaddr *peername,
     int peernamelen);
 
 /*!
@@ -156,7 +156,7 @@ errno_t sock_getpeername(socket_t so, struct sockaddr *peername,
        @param socknamelen Length of storage for the socket name.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_getsockname(socket_t so, struct sockaddr *sockname,
+extern errno_t sock_getsockname(socket_t so, struct sockaddr *sockname,
     int socknamelen);
 
 /*!
@@ -169,8 +169,8 @@ errno_t sock_getsockname(socket_t so, struct sockaddr *sockname,
        @param optlen The length of optval, returns the actual length.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_getsockopt(socket_t so, int level, int optname, void *optval,
-    int *optlen);
+extern errno_t sock_getsockopt(socket_t so, int level, int optname,
+    void *optval, int *optlen);
 
 /*!
        @function sock_ioctl
@@ -180,7 +180,7 @@ errno_t sock_getsockopt(socket_t so, int level, int optname, void *optval,
        @param argp The argument.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_ioctl(socket_t so, unsigned long request, void *argp);
+extern errno_t sock_ioctl(socket_t so, unsigned long request, void *argp);
 
 /*!
        @function sock_setsockopt
@@ -192,8 +192,46 @@ errno_t sock_ioctl(socket_t so, unsigned long request, void *argp);
        @param optlen The length of optval.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_setsockopt(socket_t so, int level, int optname, const void *optval,
-    int optlen);
+extern errno_t sock_setsockopt(socket_t so, int level, int optname,
+    const void *optval, int optlen);
+
+#ifdef KERNEL_PRIVATE
+/*
+       This function was added to support AFP setting the traffic class
+       for a backup stream within a wireless LAN or over link-local address.
+
+       If you feel you need to use this function, please contact us to
+       explain why.
+
+       @function sock_settclassopt
+       @discussion Allows a caller to set the traffic class.
+       @param so The socket.
+       @param optval The option value.
+       @param optlen The length of optval.
+       @result 0 on success otherwise the errno error.
+ */
+extern errno_t sock_settclassopt(socket_t so, const void* optval, size_t optlen);
+
+/*
+       This function was added to support AFP getting the traffic class
+       set on a stream.
+
+       This is also a private API, please contact us if you need to use it.
+
+       @function sockgettclassopt
+       @discussion Allows a caller to get the traffic class.
+       @param so The socket.
+       @param optval The option value.
+       @param optlen The length of optval, returns the actual length.
+       @result 0 on success otherwise the errno error.
+*/
+extern errno_t sock_gettclassopt(socket_t so, void* optval, size_t* optlen);
+
+#ifdef BSD_KERNEL_PRIVATE
+extern void socket_set_traffic_mgt_flags(socket_t so, u_int32_t flags);
+extern void socket_clear_traffic_mgt_flags(socket_t so, u_int32_t flags);
+#endif /* BSD_KERNEL_PRIVATE */
+#endif
 
 /*!
        @function sock_listen
@@ -203,7 +241,7 @@ errno_t sock_setsockopt(socket_t so, int level, int optname, const void *optval,
        @param backlog The maximum length of the queue of pending connections.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_listen(socket_t so, int backlog);
+extern errno_t sock_listen(socket_t so, int backlog);
 
 /*!
        @function sock_receive
@@ -217,7 +255,7 @@ errno_t sock_listen(socket_t so, int backlog);
        @result 0 on success, EWOULDBLOCK if non-blocking and operation
                would cause the thread to block, otherwise the errno error.
  */
-errno_t sock_receive(socket_t so, struct msghdr *msg, int flags,
+extern errno_t sock_receive(socket_t so, struct msghdr *msg, int flags,
     size_t *recvdlen);
 
 /*!
@@ -238,7 +276,7 @@ errno_t sock_receive(socket_t so, struct msghdr *msg, int flags,
        @result 0 on success, EWOULDBLOCK if non-blocking and operation
                would cause the thread to block, otherwise the errno error.
  */
-errno_t sock_receivembuf(socket_t so, struct msghdr *msg, mbuf_t *data,
+extern errno_t sock_receivembuf(socket_t so, struct msghdr *msg, mbuf_t *data,
     int flags, size_t *recvlen);
 
 /*!
@@ -253,7 +291,7 @@ errno_t sock_receivembuf(socket_t so, struct msghdr *msg, mbuf_t *data,
        @result 0 on success, EWOULDBLOCK if non-blocking and operation
                would cause the thread to block, otherwise the errno error.
  */
-errno_t sock_send(socket_t so, const struct msghdr *msg, int flags,
+extern errno_t sock_send(socket_t so, const struct msghdr *msg, int flags,
     size_t *sentlen);
 
 /*!
@@ -270,7 +308,7 @@ errno_t sock_send(socket_t so, const struct msghdr *msg, int flags,
                would cause the thread to block, otherwise the errno error.
                Regardless of return value, the mbuf chain 'data' will be freed.
  */
-errno_t sock_sendmbuf(socket_t so, const struct msghdr *msg, mbuf_t data,
+extern errno_t sock_sendmbuf(socket_t so, const struct msghdr *msg, mbuf_t data,
     int flags, size_t *sentlen);
 
 /*!
@@ -278,10 +316,12 @@ errno_t sock_sendmbuf(socket_t so, const struct msghdr *msg, mbuf_t data,
        @discussion Shutdown one or both directions of a connection. See
                'man 2 shutdown' for more information.
        @param so The socket.
-       @param how SHUT_RD - shutdown receive. SHUT_WR - shutdown send. SHUT_RDWR - shutdown both.
+       @param how SHUT_RD - shutdown receive.
+               SHUT_WR - shutdown send.
+               SHUT_RDWR - shutdown both.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_shutdown(socket_t so, int how);
+extern errno_t sock_shutdown(socket_t so, int how);
 
 /*!
        @function sock_socket
@@ -297,18 +337,18 @@ errno_t sock_shutdown(socket_t so, int how);
        @param new_so Upon success, a reference to the new socket.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_socket(int domain, int type, int protocol, sock_upcall callback,
-    void* cookie, socket_t *new_so);
+extern errno_t sock_socket(int domain, int type, int protocol,
+    sock_upcall callback, void *cookie, socket_t *new_so);
 
 /*!
        @function sock_close
        @discussion Close the socket.
        @param so The socket to close. This should only ever be a socket
                created with sock_socket. Closing a socket created in user space
-               using sock_close may leave a file descriptor pointing to the closed
-               socket, resulting in undefined behavior.
+               using sock_close may leave a file descriptor pointing to the
+               closed socket, resulting in undefined behavior.
  */
-void   sock_close(socket_t so);
+extern void sock_close(socket_t so);
 
 #ifdef KERNEL_PRIVATE
 /*
@@ -321,7 +361,7 @@ void        sock_close(socket_t so);
                that socket. It is used in conjunction with
                sock_release(socket_t so).
  */
-void   sock_retain(socket_t so);
+extern void sock_retain(socket_t so);
 
 /*
        @function sock_release
@@ -331,7 +371,7 @@ void        sock_retain(socket_t so);
                on a socket acquired with sock_retain. When the last retain
                count is reached, this will call sock_close to close the socket.
  */
-void   sock_release(socket_t so);
+extern void sock_release(socket_t so);
 #endif /* KERNEL_PRIVATE */
 
 /*!
@@ -342,7 +382,7 @@ void        sock_release(socket_t so);
        @param on Indicate whether or not the SS_PRIV flag should be set.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_setpriv(socket_t so, int on);
+extern errno_t sock_setpriv(socket_t so, int on);
 
 /*!
        @function sock_isconnected
@@ -350,7 +390,7 @@ errno_t sock_setpriv(socket_t so, int on);
        @param so The socket to check.
        @result 0 - socket is not connected. 1 - socket is connected.
  */
-int sock_isconnected(socket_t so);
+extern int sock_isconnected(socket_t so);
 
 /*!
        @function sock_isnonblocking
@@ -363,7 +403,7 @@ int sock_isconnected(socket_t so);
                If the parameter is non-zero, the socket will not block.
        @result 0 - socket will block. 1 - socket will not block.
  */
-int sock_isnonblocking(socket_t so);
+extern int sock_isnonblocking(socket_t so);
 
 /*!
        @function sock_gettype
@@ -372,12 +412,12 @@ int sock_isnonblocking(socket_t so);
                parameters following so are NULL, that information is not
                retrieved.
        @param so The socket to check.
-       @param domain The domain of the socket (PF_INET, etc...). May be NULL.
-       @param type The socket type (SOCK_STREAM, SOCK_DGRAM, etc...). May be NULL.
+       @param domain The domain of the socket (PF_INET, ...). May be NULL.
+       @param type The socket type (SOCK_STREAM, SOCK_DGRAM, ...). May be NULL.
        @param protocol The socket protocol. May be NULL.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_gettype(socket_t so, int *domain, int *type, int *protocol);
+extern errno_t sock_gettype(socket_t so, int *domain, int *type, int *protocol);
 
 #ifdef KERNEL_PRIVATE
 /*
@@ -388,7 +428,7 @@ errno_t sock_gettype(socket_t so, int *domain, int *type, int *protocol);
        @param on Indicate whether or not the SB_NOINTR flag should be set.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_nointerrupt(socket_t so, int on);
+extern errno_t sock_nointerrupt(socket_t so, int on);
 
 /*
        @function sock_getlistener
@@ -410,7 +450,7 @@ errno_t sock_nointerrupt(socket_t so, int on);
                NULL if the socket is not in the incomplete/completed list
                of a listener.
  */
-socket_t sock_getlistener(socket_t so);
+extern socket_t sock_getlistener(socket_t so);
 
 /*
        @function sock_getaddr
@@ -424,14 +464,15 @@ socket_t sock_getlistener(socket_t so);
        @param peername 0 for local address, and non-zero for peer address.
        @result 0 on success otherwise the errno error.
  */
-errno_t sock_getaddr(socket_t so, struct sockaddr **psockname, int peername);
+extern errno_t sock_getaddr(socket_t so, struct sockaddr **psockname,
+    int peername);
 
 /*
        @function sock_freeaddr
        @discussion Frees the socket address allocated by sock_getaddr.
        @param sockname The socket name to be freed.
  */
-void sock_freeaddr(struct sockaddr *sockname);
+extern void sock_freeaddr(struct sockaddr *sockname);
 #endif /* KERNEL_PRIVATE */
 
 __END_DECLS