X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/e5568f75972dfc723778653c11cb6b4dc825716a..eee3565979933af707c711411001ba11fe406a3c:/bsd/net/kext_net.h diff --git a/bsd/net/kext_net.h b/bsd/net/kext_net.h index ebe88e6c3..e9c9a6a6a 100644 --- a/bsd/net/kext_net.h +++ b/bsd/net/kext_net.h @@ -1,98 +1,87 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2013 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ -/* Copyright (C) 1999 Apple Computer, Inc. */ + /* - * Support for network filter kernel extensions - * Justin C. Walker, 990319 + * Support for socket filter kernel extensions */ + #ifndef NET_KEXT_NET_H -#define NET_KEXT_NET_H +#define NET_KEXT_NET_H + #include #include -#include - -struct mbuf; -struct socket; -struct uio; -struct sockbuf; -struct sockaddr; -struct kextcb; -struct protosw; -struct sockif; -struct sockutil; -struct sockopt; - -#ifdef __APPLE_API_UNSTABLE +#include +#ifdef BSD_KERNEL_PRIVATE /* - * This structure gives access to the functionality of the filter. - * The kextcb provides the link from the socket structure. + * Internal implementation bits */ -struct NFDescriptor -{ TAILQ_ENTRY(NFDescriptor) nf_next; /* protosw chain */ - TAILQ_ENTRY(NFDescriptor) nf_list; /* descriptor list */ - unsigned int nf_handle; /* Identifier */ - int nf_flags; - /* Dispatch for PF_FILTER control */ - int (*nf_connect)(); /* Make contact */ - void (*nf_disconnect)(); /* Break contact */ - int (*nf_read)(); /* Get data from filter */ - int (*nf_write)(); /* Send data to filter */ - int (*nf_get)(); /* Get filter config */ - int (*nf_set)(); /* Set filter config */ - /* - * Socket function dispatch vectors - copied to kextcb - * during socreate() - */ - struct sockif *nf_soif; /* Socket functions */ - struct sockutil *nf_soutil; /* Sockbuf utility functions */ - u_long reserved[4]; /* for future use if needed */ -}; - -#define NFD_GLOBAL 0x01 -#define NFD_PROG 0x02 -#define NFD_VISIBLE 0x80000000 +#include -#define NFF_BEFORE 0x01 -#define NFF_AFTER 0x02 +struct socket; +struct sockopt; +struct inpcb; -#ifdef KERNEL -/* How to register: filter, insert location, target protosw, flags */ -extern int register_sockfilter(struct NFDescriptor *, - struct NFDescriptor *, - struct protosw *, int); -/* How to unregister: filter, original protosw, flags */ -extern int unregister_sockfilter(struct NFDescriptor *, struct protosw *, int); +/* Private, internal implementation functions */ +extern void sflt_init(void); +extern int sflt_permission_check(struct inpcb *inp); +extern void sflt_initsock(struct socket *so); +extern void sflt_termsock(struct socket *so); +extern errno_t sflt_attach_internal(struct socket *so, sflt_handle handle); +extern void sflt_notify(struct socket *so, sflt_event_t event, void *param); +extern int sflt_ioctl(struct socket *so, u_long cmd, caddr_t data); +extern int sflt_bind(struct socket *so, const struct sockaddr *nam); +extern int sflt_listen(struct socket *so); +extern int sflt_accept(struct socket *head, struct socket *so, + const struct sockaddr *local, + const struct sockaddr *remote); +extern int sflt_getsockname(struct socket *so, struct sockaddr **local); +extern int sflt_getpeername(struct socket *so, struct sockaddr **remote); +extern int sflt_connectin(struct socket *head, + const struct sockaddr *remote); +extern int sflt_connectout(struct socket *so, const struct sockaddr *nam); +extern int sflt_connectxout(struct socket *so, + struct sockaddr_list **nam_sl); +extern int sflt_setsockopt(struct socket *so, struct sockopt *sopt); +extern int sflt_getsockopt(struct socket *so, struct sockopt *sopt); +extern int sflt_data_out(struct socket *so, const struct sockaddr *to, + mbuf_t *data, mbuf_t *control, sflt_data_flag_t flags); +extern int sflt_data_in(struct socket *so, const struct sockaddr *from, + mbuf_t *data, mbuf_t *control, sflt_data_flag_t flags); -#ifdef __APPLE_API_PRIVATE -TAILQ_HEAD(nf_list, NFDescriptor); +#endif /* BSD_KERNEL_PRIVATE */ -extern struct nf_list nf_list; -#endif /* __APPLE_API_PRIVATE */ -#endif +#define NFF_BEFORE 0x01 +#define NFF_AFTER 0x02 -#define NKE_OK 0 -#define NKE_REMOVE -1 +#define NKE_OK 0 +#define NKE_REMOVE (-1) /* * Interface structure for inserting an installed socket NKE into an @@ -102,109 +91,14 @@ extern struct nf_list nf_list; * the 'where' NKE. If the latter is NULL, the flags indicate "first" * or "last" */ -struct so_nke -{ unsigned int nke_handle; +#pragma pack(4) + +struct so_nke { + unsigned int nke_handle; unsigned int nke_where; int nke_flags; /* NFF_BEFORE, NFF_AFTER: net/kext_net.h */ - unsigned long reserved[4]; /* for future use */ -}; - -/* - * sockif: - * Contains socket interface: - * dispatch vector abstracting the interface between protocols and - * the socket layer. - * TODO: add sf_sosense() - */ -struct sockif -{ int (*sf_soabort)(struct socket *, struct kextcb *); - int (*sf_soaccept)(struct socket *, struct sockaddr **, - struct kextcb *); - int (*sf_sobind)(struct socket *, struct sockaddr *, struct kextcb *); - int (*sf_soclose)(struct socket *, struct kextcb *); - int (*sf_soconnect)(struct socket *, struct sockaddr *, - struct kextcb *); - int (*sf_soconnect2)(struct socket *, struct socket *, - struct kextcb *); - int (*sf_socontrol)(struct socket *, struct sockopt *, - struct kextcb *); - int (*sf_socreate)(struct socket *, struct protosw *, struct kextcb *); - int (*sf_sodisconnect)(struct socket *, struct kextcb *); - int (*sf_sofree)(struct socket *, struct kextcb *); - int (*sf_sogetopt)(struct socket *, int, int, struct mbuf **, - struct kextcb *); - int (*sf_sohasoutofband)(struct socket *, struct kextcb *); - int (*sf_solisten)(struct socket *, struct kextcb *); - int (*sf_soreceive)(struct socket *, struct sockaddr **, struct uio **, - struct mbuf **, struct mbuf **, int *, - struct kextcb *); - int (*sf_sorflush)(struct socket *, struct kextcb *); - int (*sf_sosend)(struct socket *, struct sockaddr **, struct uio **, - struct mbuf **, struct mbuf **, int *, - struct kextcb *); - int (*sf_sosetopt)(struct socket *, int, int, struct mbuf *, - struct kextcb *); - int (*sf_soshutdown)(struct socket *, int, struct kextcb *); - /* Calls sorwakeup() */ - int (*sf_socantrcvmore)(struct socket *, struct kextcb *); - /* Calls sowwakeup() */ - int (*sf_socantsendmore)(struct socket *, struct kextcb *); - /* Calls soqinsque(), sorwakeup(), sowwakeup() */ - int (*sf_soisconnected)(struct socket *, struct kextcb *); - int (*sf_soisconnecting)(struct socket *, struct kextcb *); - /* Calls sowwakeup(), sorwakeup() */ - int (*sf_soisdisconnected)(struct socket *, struct kextcb *); - /* Calls sowwakeup(), sorwakeup() */ - int (*sf_soisdisconnecting)(struct socket *, struct kextcb *); - /* Calls soreserve(), soqinsque(), soqremque(), sorwakeup() */ - int (*sf_sonewconn)(struct socket *, int, struct kextcb *); - int (*sf_soqinsque)(struct socket *, struct socket *, int, - struct kextcb *); - int (*sf_soqremque)(struct socket *, int, struct kextcb *); - int (*sf_soreserve)(struct socket *, u_long, u_long, struct kextcb *); - int (*sf_sowakeup)(struct socket *, struct sockbuf *, - struct kextcb *); - u_long reserved[4]; -}; - - -/* - * sockutil: - * Contains the utility functions for socket layer access - */ -struct sockutil -{ /* Sleeps if locked */ - int (*su_sb_lock)(struct sockbuf *, struct kextcb *); - /* Conditionally calls sbappendrecord, Calls sbcompress */ - int (*su_sbappend)(struct sockbuf *, struct mbuf *, struct kextcb *); - /* Calls sbspace(), sballoc() */ - int (*su_sbappendaddr)(struct sockbuf *, struct sockaddr *, - struct mbuf *, struct mbuf *, struct kextcb *); - /* Calls sbspace(), sballoc() */ - int (*su_sbappendcontrol)(struct sockbuf *, struct mbuf *, - struct mbuf *, struct kextcb *); - /* Calls sballoc(), sbcompress() */ - int (*su_sbappendrecord)(struct sockbuf *, struct mbuf *, - struct kextcb *); - /* Calls sballoc() */ - int (*su_sbcompress)(struct sockbuf *, struct mbuf *, struct mbuf *, - struct kextcb *); - /* Calls sbfree() */ - int (*su_sbdrop)(struct sockbuf *, int, struct kextcb *); - /* Calls sbfree() */ - int (*su_sbdroprecord)(struct sockbuf *, struct kextcb *); - /* Calls sbdrop() */ - int (*su_sbflush)(struct sockbuf *, struct kextcb *); - /* Calls sballoc(), sbcompress() */ - int (*su_sbinsertoob)(struct sockbuf *, struct mbuf *, - struct kextcb *); - /* Calls sbflush() */ - int (*su_sbrelease)(struct sockbuf *, struct kextcb *); - int (*su_sbreserve)(struct sockbuf *, u_long, struct kextcb *); - /* Calls tsleep() */ - int (*su_sbwait)(struct sockbuf *, struct kextcb *); - u_long reserved[4]; + u_int32_t reserved[4]; /* for future use */ }; -#endif /* __APPLE_API_UNSTABLE */ -#endif +#pragma pack() +#endif /* NET_KEXT_NET_H */