+/*
+ * @function sock_nointerrupt
+ * @discussion Disables interrupt on socket buffers (sets SB_NOINTR on
+ * send and receive socket buffers).
+ * @param so The socket to modify.
+ * @param on Indicate whether or not the SB_NOINTR flag should be set.
+ * @result 0 on success otherwise the errno error.
+ */
+extern errno_t sock_nointerrupt(socket_t so, int on);
+
+/*
+ * @function sock_getlistener
+ * @discussion Retrieves the listening socket of a pre-accepted socket,
+ * i.e. a socket which is still in the incomplete/completed list.
+ * Once a socket has been accepted, the information pertaining
+ * to its listener is no longer available. Therefore, modules
+ * interested in finding out the listening socket should install
+ * the appropriate socket filter callback (sf_attach) which gets
+ * invoked prior to the socket being fully accepted, and call
+ * this routine at such a time to obtain the listener. Callers
+ * are guaranteed that the listener socket will not go away
+ * during the sf_attach callback, and therefore the value is
+ * safe to be used only in that callback context. Callers should
+ * therefore take note that the listening socket's lock will be
+ * held throughout the duration of the callback.
+ * @param so The pre-accepted socket.
+ * @result Non-NULL value which indicates the listening socket; otherwise,
+ * NULL if the socket is not in the incomplete/completed list
+ * of a listener.
+ */
+extern socket_t sock_getlistener(socket_t so);
+
+/*
+ * @function sock_getaddr
+ * @discussion Retrieves the local or remote address of a socket.
+ * This is a composite of sock_getpeername and sock_getsockname,
+ * except that the allocated socket address is returned to the
+ * caller, and that the caller is reponsible for calling
+ * sock_freeaddr once finished with it.
+ * @param so The socket.
+ * @param psockname Pointer to the storage for the socket name.
+ * @param peername 0 for local address, and non-zero for peer address.
+ * @result 0 on success otherwise the errno error.
+ */
+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.
+ */
+extern void sock_freeaddr(struct sockaddr *sockname);
+
+/*
+ * @function sock_setupcall
+ * @discussion Set the notifier function to be called when an event
+ * occurs on the socket. This may be set to NULL to disable
+ * further notifications. Setting the function does not
+ * affect currently notifications about to be sent or being sent.
+ * Note: When this function is used on a socket passed from
+ * userspace it is crucial to call sock_retain() on the socket
+ * otherwise a callback could be dispatched on a closed socket
+ * and cause a crash.
+ * @param sock The socket.
+ * @param callback The notifier function
+ * @param context A cookie passed directly to the callback
+ */
+extern errno_t sock_setupcall(socket_t sock, sock_upcall callback,
+ void *context);
+
+/*
+ * @function sock_setupcalls
+ * @discussion Set the notifier function to be called when an event
+ * occurs on the socket. This may be set to NULL to disable
+ * further notifications. Setting the function does not
+ * affect currently notifications about to be sent or being sent.
+ * Note: When this function is used on a socket passed from
+ * userspace it is crucial to call sock_retain() on the socket
+ * otherwise a callback could be dispatched on a closed socket
+ * and cause a crash.
+ * @param sock The socket.
+ * @param read_callback The read notifier function
+ * @param read_context A cookie passed directly to the read callback
+ * @param write_callback The write notifier function
+ * @param write_context A cookie passed directly to the write callback
+ */
+extern errno_t sock_setupcalls(socket_t sock, sock_upcall read_callback,
+ void *read_context, sock_upcall write_callback, void *write_context);
+
+/*
+ * @function sock_setupcalls_locked
+ * @discussion The locked version of sock_setupcalls
+ * @param locked: When sets, indicates that the callbacks expect to be
+ * on a locked socket. Thus, no unlock is done prior to
+ * calling the callback.
+ */
+extern void sock_setupcalls_locked(socket_t sock,
+ sock_upcall rcallback, void *rcontext,
+ sock_upcall wcallback, void *wcontext, int locked);
+
+/*
+ * @function sock_catchevents
+ * @discussion Set the notifier function to be called when an event
+ * occurs on the socket. This may be set to NULL to disable
+ * further notifications. Setting the function does not
+ * affect currently notifications about to be sent or being sent.
+ * @param sock The socket.
+ * @param event_callback The event notifier function
+ * @param event_context A cookie passed directly to the event callback
+ * @param event_mask One or more SO_FILT_HINT_* values OR'ed together,
+ * indicating the registered event(s).
+ */
+extern errno_t sock_catchevents(socket_t sock, sock_evupcall event_callback,
+ void *event_context, u_int32_t event_mask);
+
+extern void sock_catchevents_locked(socket_t sock, sock_evupcall ecallback,
+ void *econtext, u_int32_t emask);
+
+
+/*
+ * @function sock_iskernel
+ * @discussion Returns true if the socket was created by the kernel or
+ * is owned by the kernel.
+ * @param sock The socket.
+ * @result True if the kernel owns the socket.
+ */
+extern int sock_iskernel(socket_t);
+#endif /* KERNEL_PRIVATE */
+
+__END_DECLS
+#endif /* __KPI_SOCKET__ */