]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/kext_net.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / net / kext_net.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
A
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
1c79356b 29 */
91447636 30
1c79356b 31/*
91447636 32 * Support for socket filter kernel extensions
1c79356b 33 */
91447636 34
1c79356b
A
35#ifndef NET_KEXT_NET_H
36#define NET_KEXT_NET_H
91447636 37
9bccf70c 38#include <sys/appleapiopts.h>
1c79356b
A
39
40#include <sys/queue.h>
91447636 41#include <sys/cdefs.h>
1c79356b 42
91447636 43#ifdef BSD_KERNEL_PRIVATE
1c79356b 44
91447636 45#include <sys/kpi_socketfilter.h>
9bccf70c 46
1c79356b 47/*
91447636 48 * Internal implementation bits
1c79356b 49 */
91447636
A
50
51struct socket_filter;
52
3a60a9f5
A
53#define SFEF_DETACHUSEZERO 0x1 // Detach when use reaches zero
54#define SFEF_UNREGISTERING 0x2 // Remove due to unregister
91447636
A
55
56struct socket_filter_entry {
57 struct socket_filter_entry *sfe_next_onsocket;
58 struct socket_filter_entry *sfe_next_onfilter;
59
60 struct socket_filter *sfe_filter;
61 struct socket *sfe_socket;
62 void *sfe_cookie;
63
64 u_int32_t sfe_flags;
1c79356b
A
65};
66
91447636 67#define SFF_DETACHING 0x1
1c79356b 68
91447636
A
69struct 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;
73
74 struct protosw *sf_proto;
75 struct sflt_filter sf_filter;
76 u_int32_t sf_flags;
77 u_int32_t sf_usecount;
78};
1c79356b 79
91447636 80TAILQ_HEAD(socket_filter_list, socket_filter);
1c79356b 81
91447636
A
82/* Private, internal implementation functions */
83void sflt_init(void);
84void sflt_initsock(struct socket *so);
85void sflt_termsock(struct socket *so);
86void sflt_use(struct socket *so);
87void sflt_unuse(struct socket *so);
88void sflt_notify(struct socket *so, sflt_event_t event, void *param);
89int sflt_data_in(struct socket *so, const struct sockaddr *from, mbuf_t *data,
cc9f6e38 90 mbuf_t *control, sflt_data_flag_t flags, int *filtered);
91447636 91int sflt_attach_private(struct socket *so, struct socket_filter *filter, sflt_handle handle, int locked);
1c79356b 92
91447636
A
93#endif /* BSD_KERNEL_PRIVATE */
94
95#define NFF_BEFORE 0x01
96#define NFF_AFTER 0x02
1c79356b
A
97
98#define NKE_OK 0
99#define NKE_REMOVE -1
100
101/*
102 * Interface structure for inserting an installed socket NKE into an
103 * existing socket.
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"
107 * or "last"
108 */
8ad349bb
A
109#if __DARWIN_ALIGN_POWER
110#pragma options align=power
111#endif
91447636 112
1c79356b
A
113struct so_nke
114{ unsigned int nke_handle;
115 unsigned int nke_where;
116 int nke_flags; /* NFF_BEFORE, NFF_AFTER: net/kext_net.h */
0b4e3aa0 117 unsigned long reserved[4]; /* for future use */
1c79356b
A
118};
119
8ad349bb
A
120#if __DARWIN_ALIGN_POWER
121#pragma options align=reset
122#endif
1c79356b 123
91447636 124#endif /* NET_KEXT_NET_H */
1c79356b 125