]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/kext_net.h
be3d99c6e30dd9db071bbf0c38c06b7e7e35cf67
2 * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * Support for socket filter kernel extensions
28 #ifndef NET_KEXT_NET_H
29 #define NET_KEXT_NET_H
31 #include <sys/appleapiopts.h>
33 #include <sys/queue.h>
34 #include <sys/cdefs.h>
36 #ifdef BSD_KERNEL_PRIVATE
38 #include <sys/kpi_socketfilter.h>
41 * Internal implementation bits
46 #define SFEF_DETACHUSEZERO 0x1 // Detach when use reaches zero
47 #define SFEF_UNREGISTERING 0x2 // Remove due to unregister
49 struct socket_filter_entry
{
50 struct socket_filter_entry
*sfe_next_onsocket
;
51 struct socket_filter_entry
*sfe_next_onfilter
;
53 struct socket_filter
*sfe_filter
;
54 struct socket
*sfe_socket
;
60 #define SFF_DETACHING 0x1
62 struct socket_filter
{
63 TAILQ_ENTRY(socket_filter
) sf_protosw_next
;
64 TAILQ_ENTRY(socket_filter
) sf_global_next
;
65 struct socket_filter_entry
*sf_entry_head
;
67 struct protosw
*sf_proto
;
68 struct sflt_filter sf_filter
;
70 u_int32_t sf_usecount
;
73 TAILQ_HEAD(socket_filter_list
, socket_filter
);
75 /* Private, internal implementation functions */
77 void sflt_initsock(struct socket
*so
);
78 void sflt_termsock(struct socket
*so
);
79 void sflt_use(struct socket
*so
);
80 void sflt_unuse(struct socket
*so
);
81 void sflt_notify(struct socket
*so
, sflt_event_t event
, void *param
);
82 int sflt_data_in(struct socket
*so
, const struct sockaddr
*from
, mbuf_t
*data
,
83 mbuf_t
*control
, sflt_data_flag_t flags
, int *filtered
);
84 int sflt_attach_private(struct socket
*so
, struct socket_filter
*filter
, sflt_handle handle
, int locked
);
86 #endif /* BSD_KERNEL_PRIVATE */
88 #define NFF_BEFORE 0x01
89 #define NFF_AFTER 0x02
95 * Interface structure for inserting an installed socket NKE into an
97 * 'handle' is the NKE to be inserted, 'where' is an insertion point,
98 * and flags dictate the position of the to-be-inserted NKE relative to
99 * the 'where' NKE. If the latter is NULL, the flags indicate "first"
102 #if __DARWIN_ALIGN_POWER
103 #pragma options align=power
107 { unsigned int nke_handle
;
108 unsigned int nke_where
;
109 int nke_flags
; /* NFF_BEFORE, NFF_AFTER: net/kext_net.h */
110 unsigned long reserved
[4]; /* for future use */
113 #if __DARWIN_ALIGN_POWER
114 #pragma options align=reset
117 #endif /* NET_KEXT_NET_H */