]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/kext_net.h
60fbe95cea27599778fc64b11e5afb8ec87134ac
2 * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 * Support for socket filter kernel extensions
35 #ifndef NET_KEXT_NET_H
36 #define NET_KEXT_NET_H
38 #include <sys/appleapiopts.h>
40 #include <sys/queue.h>
41 #include <sys/cdefs.h>
43 #ifdef BSD_KERNEL_PRIVATE
45 #include <sys/kpi_socketfilter.h>
48 * Internal implementation bits
53 #define SFEF_DETACHUSEZERO 0x1 // Detach when use reaches zero
54 #define SFEF_UNREGISTERING 0x2 // Remove due to unregister
56 struct socket_filter_entry
{
57 struct socket_filter_entry
*sfe_next_onsocket
;
58 struct socket_filter_entry
*sfe_next_onfilter
;
60 struct socket_filter
*sfe_filter
;
61 struct socket
*sfe_socket
;
67 #define SFF_DETACHING 0x1
69 struct socket_filter
{
70 TAILQ_ENTRY(socket_filter
) sf_protosw_next
;
71 TAILQ_ENTRY(socket_filter
) sf_global_next
;
72 struct socket_filter_entry
*sf_entry_head
;
74 struct protosw
*sf_proto
;
75 struct sflt_filter sf_filter
;
77 u_int32_t sf_usecount
;
80 TAILQ_HEAD(socket_filter_list
, socket_filter
);
82 /* Private, internal implementation functions */
84 void sflt_initsock(struct socket
*so
);
85 void sflt_termsock(struct socket
*so
);
86 void sflt_use(struct socket
*so
);
87 void sflt_unuse(struct socket
*so
);
88 void sflt_notify(struct socket
*so
, sflt_event_t event
, void *param
);
89 int sflt_data_in(struct socket
*so
, const struct sockaddr
*from
, mbuf_t
*data
,
90 mbuf_t
*control
, sflt_data_flag_t flags
, int *filtered
);
91 int sflt_attach_private(struct socket
*so
, struct socket_filter
*filter
, sflt_handle handle
, int locked
);
93 #endif /* BSD_KERNEL_PRIVATE */
95 #define NFF_BEFORE 0x01
96 #define NFF_AFTER 0x02
102 * Interface structure for inserting an installed socket NKE into an
104 * 'handle' is the NKE to be inserted, 'where' is an insertion point,
105 * and flags dictate the position of the to-be-inserted NKE relative to
106 * the 'where' NKE. If the latter is NULL, the flags indicate "first"
109 #if __DARWIN_ALIGN_POWER
110 #pragma options align=power
114 { unsigned int nke_handle
;
115 unsigned int nke_where
;
116 int nke_flags
; /* NFF_BEFORE, NFF_AFTER: net/kext_net.h */
117 unsigned long reserved
[4]; /* for future use */
120 #if __DARWIN_ALIGN_POWER
121 #pragma options align=reset
124 #endif /* NET_KEXT_NET_H */