]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
8f6c56a5 | 11 | * |
6601e61a A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b | 21 | */ |
91447636 | 22 | |
1c79356b | 23 | /* |
91447636 | 24 | * Support for socket filter kernel extensions |
1c79356b | 25 | */ |
91447636 | 26 | |
1c79356b A |
27 | #ifndef NET_KEXT_NET_H |
28 | #define NET_KEXT_NET_H | |
91447636 | 29 | |
9bccf70c | 30 | #include <sys/appleapiopts.h> |
1c79356b A |
31 | |
32 | #include <sys/queue.h> | |
91447636 | 33 | #include <sys/cdefs.h> |
1c79356b | 34 | |
91447636 | 35 | #ifdef BSD_KERNEL_PRIVATE |
1c79356b | 36 | |
91447636 | 37 | #include <sys/kpi_socketfilter.h> |
9bccf70c | 38 | |
1c79356b | 39 | /* |
91447636 | 40 | * Internal implementation bits |
1c79356b | 41 | */ |
91447636 A |
42 | |
43 | struct socket_filter; | |
44 | ||
3a60a9f5 A |
45 | #define SFEF_DETACHUSEZERO 0x1 // Detach when use reaches zero |
46 | #define SFEF_UNREGISTERING 0x2 // Remove due to unregister | |
91447636 A |
47 | |
48 | struct socket_filter_entry { | |
49 | struct socket_filter_entry *sfe_next_onsocket; | |
50 | struct socket_filter_entry *sfe_next_onfilter; | |
51 | ||
52 | struct socket_filter *sfe_filter; | |
53 | struct socket *sfe_socket; | |
54 | void *sfe_cookie; | |
55 | ||
56 | u_int32_t sfe_flags; | |
1c79356b A |
57 | }; |
58 | ||
91447636 | 59 | #define SFF_DETACHING 0x1 |
1c79356b | 60 | |
91447636 A |
61 | struct socket_filter { |
62 | TAILQ_ENTRY(socket_filter) sf_protosw_next; | |
63 | TAILQ_ENTRY(socket_filter) sf_global_next; | |
64 | struct socket_filter_entry *sf_entry_head; | |
65 | ||
66 | struct protosw *sf_proto; | |
67 | struct sflt_filter sf_filter; | |
68 | u_int32_t sf_flags; | |
69 | u_int32_t sf_usecount; | |
70 | }; | |
1c79356b | 71 | |
91447636 | 72 | TAILQ_HEAD(socket_filter_list, socket_filter); |
1c79356b | 73 | |
91447636 A |
74 | /* Private, internal implementation functions */ |
75 | void sflt_init(void); | |
76 | void sflt_initsock(struct socket *so); | |
77 | void sflt_termsock(struct socket *so); | |
78 | void sflt_use(struct socket *so); | |
79 | void sflt_unuse(struct socket *so); | |
80 | void sflt_notify(struct socket *so, sflt_event_t event, void *param); | |
81 | int sflt_data_in(struct socket *so, const struct sockaddr *from, mbuf_t *data, | |
cc9f6e38 | 82 | mbuf_t *control, sflt_data_flag_t flags, int *filtered); |
91447636 | 83 | int sflt_attach_private(struct socket *so, struct socket_filter *filter, sflt_handle handle, int locked); |
1c79356b | 84 | |
91447636 A |
85 | #endif /* BSD_KERNEL_PRIVATE */ |
86 | ||
87 | #define NFF_BEFORE 0x01 | |
88 | #define NFF_AFTER 0x02 | |
1c79356b A |
89 | |
90 | #define NKE_OK 0 | |
91 | #define NKE_REMOVE -1 | |
92 | ||
93 | /* | |
94 | * Interface structure for inserting an installed socket NKE into an | |
95 | * existing socket. | |
96 | * 'handle' is the NKE to be inserted, 'where' is an insertion point, | |
97 | * and flags dictate the position of the to-be-inserted NKE relative to | |
98 | * the 'where' NKE. If the latter is NULL, the flags indicate "first" | |
99 | * or "last" | |
100 | */ | |
0c530ab8 | 101 | #pragma pack(4) |
91447636 | 102 | |
1c79356b A |
103 | struct so_nke |
104 | { unsigned int nke_handle; | |
105 | unsigned int nke_where; | |
106 | int nke_flags; /* NFF_BEFORE, NFF_AFTER: net/kext_net.h */ | |
0b4e3aa0 | 107 | unsigned long reserved[4]; /* for future use */ |
1c79356b A |
108 | }; |
109 | ||
0c530ab8 | 110 | #pragma pack() |
1c79356b | 111 | |
91447636 | 112 | #endif /* NET_KEXT_NET_H */ |
1c79356b | 113 |