]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/dlil.h
xnu-201.5.tar.gz
[apple/xnu.git] / bsd / net / dlil.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * Copyright (c) 1999 Apple Computer, Inc.
24 *
25 * Data Link Inteface Layer
26 * Author: Ted Walker
27 */
28
29
30#ifndef DLIL_H
31#define DLIL_H
32
33#if __STDC__
34
35struct ifnet;
36struct mbuf;
37struct ether_header;
38
39#endif
40
41
42
43#define DLIL_LAST_FILTER -1
44#define DLIL_NULL_FILTER -2
45
46#define DLIL_WAIT_FOR_FREE -2
47
48#define DLIL_BLUEBOX 1
49
50
51
52#include <net/if.h>
53#include <net/if_var.h>
54#include <sys/kern_event.h>
55
56enum {
57 BPF_TAP_DISABLE,
58 BPF_TAP_INPUT,
59 BPF_TAP_OUTPUT,
60 BPF_TAP_INPUT_OUTPUT
61};
62
63
64struct dl_tag_attr_str {
65 u_long dl_tag;
66 short if_flags;
67 short if_unit;
68 u_long if_family;
69 u_long protocol_family;
70};
71
72
73struct dlil_pr_flt_str {
74 caddr_t cookie;
75
76 int (*filter_dl_input)(caddr_t cookie,
77 struct mbuf **m,
78 char **frame_header,
79 struct ifnet **ifp);
80
81
82 int (*filter_dl_output)(caddr_t cookie,
83 struct mbuf **m,
84 struct ifnet **ifp,
85 struct sockaddr **dest,
86 char *dest_linkaddr,
87 char *frame_type);
88
89 int (*filter_dl_event)(caddr_t cookie,
90 struct kern_event_msg *event_msg);
91
92 int (*filter_dl_ioctl)(caddr_t cookie,
93 struct ifnet *ifp,
94 u_long ioctl_cmd,
95 caddr_t ioctl_arg);
96
97 int (*filter_detach)(caddr_t cookie);
0b4e3aa0 98 u_long reserved[2];
1c79356b
A
99};
100
101struct dlil_if_flt_str {
102 caddr_t cookie;
103 int (*filter_if_input)(caddr_t cookie,
104 struct ifnet **ifnet_ptr,
105 struct mbuf **mbuf_ptr,
106 char **frame_ptr);
107
108 int (*filter_if_event)(caddr_t cookie,
109 struct ifnet **ifnet_ptr,
110 struct kern_event_msg **event_msg_ptr);
111
112 int (*filter_if_output)(caddr_t cookie,
113 struct ifnet **ifnet_ptr,
114 struct mbuf **mbuf_ptr);
115
116
117 int (*filter_if_ioctl)(caddr_t cookie,
118 struct ifnet *ifnet_ptr,
119 u_long ioctl_code_ptr,
120 caddr_t ioctl_arg_ptr);
121
122 int (*filter_if_free)(caddr_t cookie,
123 struct ifnet *ifnet_ptr);
124
0b4e3aa0
A
125 int (*filter_detach)(caddr_t cookie);
126 u_long reserved[2];
1c79356b
A
127};
128
129
130#define DLIL_PR_FILTER 1
131#define DLIL_IF_FILTER 2
132
133
134
135typedef int (*dl_input_func)(struct mbuf *m, char *frame_header,
136 struct ifnet *ifp, u_long dl_tag, int sync_ok);
137typedef int (*dl_pre_output_func)(struct ifnet *ifp,
138 struct mbuf **m,
139 struct sockaddr *dest,
140 caddr_t route_entry,
141 char *frame_type,
142 char *dst_addr,
143 u_long dl_tag);
144
145typedef int (*dl_event_func)(struct kern_event_msg *event,
146 u_long dl_tag);
147
148typedef int (*dl_offer_func)(struct mbuf *m, char *frame_header);
149typedef int (*dl_ioctl_func)(u_long dl_tag,
150 struct ifnet *ifp,
151 u_long ioctl_cmd,
152 caddr_t ioctl_arg);
153
154
155
156struct dlil_filterq_entry {
157 TAILQ_ENTRY(dlil_filterq_entry) que;
158 u_long filter_id;
159 int type;
160 union {
161 struct dlil_if_flt_str if_filter;
162 struct dlil_pr_flt_str pr_filter;
163 } variants;
164};
165
166
167TAILQ_HEAD(dlil_filterq_head, dlil_filterq_entry);
168
169
170struct if_proto {
171 TAILQ_ENTRY(if_proto) next;
172 u_long dl_tag;
173 struct dlil_filterq_head pr_flt_head;
174 struct ifnet *ifp;
175 dl_input_func dl_input;
176 dl_pre_output_func dl_pre_output;
177 dl_event_func dl_event;
178 dl_offer_func dl_offer;
179 dl_ioctl_func dl_ioctl;
180 u_long protocol_family;
0b4e3aa0 181 u_long reserved[4];
1c79356b
A
182
183};
184
185TAILQ_HEAD(dlil_proto_head, if_proto);
186
187struct dlil_tag_list_entry {
188 TAILQ_ENTRY(dlil_tag_list_entry) next;
189 struct ifnet *ifp;
190 u_long dl_tag;
191};
192
193
194#define DLIL_DESC_RAW 1
195#define DLIL_DESC_802_2 2
196#define DLIL_DESC_802_2_SNAP 3
197
198struct dlil_demux_desc {
199 TAILQ_ENTRY(dlil_demux_desc) next;
200 int type;
201
202 u_char *native_type;
203 union {
204 struct {
205 u_long proto_id_length; /* IN LONGWORDS!!! */
206 u_char *proto_id;
207 u_char *proto_id_mask;
208
209 } bitmask;
210
211 struct {
212 u_char dsap;
213 u_char ssap;
214 u_char control_code;
215 u_char pad;
216 } desc_802_2;
217
218 struct {
219 u_char dsap;
220 u_char ssap;
221 u_char control_code;
222 u_char org[3];
223 u_short protocol_type;
224 } desc_802_2_SNAP;
225 } variants;
226};
227
228TAILQ_HEAD(ddesc_head_str, dlil_demux_desc);
229
230
231struct dlil_proto_reg_str {
232 struct ddesc_head_str demux_desc_head;
233 u_long interface_family;
234 u_long protocol_family;
235 short unit_number;
236 int default_proto; /* 0 or 1 */
237 dl_input_func input;
238 dl_pre_output_func pre_output;
239 dl_event_func event;
240 dl_offer_func offer;
241 dl_ioctl_func ioctl;
0b4e3aa0 242 u_long reserved[4];
1c79356b
A
243};
244
245
246int dlil_attach_interface_filter(struct ifnet *ifnet_ptr,
247 struct dlil_if_flt_str *interface_filter,
248 u_long *filter_id,
249 int insertion_point);
250
251int
252dlil_input(struct ifnet *ifp, struct mbuf *m_head, struct mbuf *m_tail);
253
254int
255dlil_output(u_long dl_tag,
256 struct mbuf *m,
257 caddr_t route,
258 struct sockaddr *dest,
259 int raw);
260
261
262int
263dlil_ioctl(u_long proto_family,
264 struct ifnet *ifp,
265 u_long ioctl_code,
266 caddr_t ioctl_arg);
267
268int
269dlil_attach_protocol(struct dlil_proto_reg_str *proto,
270 u_long *dl_tag);
271
272int
273dlil_detach_protocol(u_long dl_tag);
274
275int
276dlil_if_attach(struct ifnet *ifp);
277
278int
279dlil_attach_protocol_filter(u_long dl_tag,
280 struct dlil_pr_flt_str *proto_filter,
281 u_long *filter_id,
282 int insertion_point);
283int
284dlil_detach_filter(u_long filter_id);
285
286struct dlil_ifmod_reg_str {
287 int (*add_if)(struct ifnet *ifp);
288 int (*del_if)(struct ifnet *ifp);
289 int (*add_proto)(struct ddesc_head_str *demux_desc_head,
290 struct if_proto *proto, u_long dl_tag);
291 int (*del_proto)(struct if_proto *proto, u_long dl_tag);
292 int (*ifmod_ioctl)(struct ifnet *ifp, u_long ioctl_cmd, caddr_t data);
293 int (*shutdown)();
0b4e3aa0 294 u_long reserved[4];
1c79356b
A
295};
296
297
298int dlil_reg_if_modules(u_long interface_family,
299 struct dlil_ifmod_reg_str *ifmod_reg);
300
301int
302dlil_inject_if_input(struct mbuf *m, char *frame_header, u_long from_id);
303
304int
305dlil_inject_pr_input(struct mbuf *m, char *frame_header, u_long from_id);
306
307int
308dlil_inject_pr_output(struct mbuf *m,
309 struct sockaddr *dest,
310 int raw,
311 char *frame_type,
312 char *dst_linkaddr,
313 u_long from_id);
314
315int
316dlil_inject_if_output(struct mbuf *m, u_long from_id);
317
318int
319dlil_find_dltag(u_long if_family, short unit, u_long proto_family, u_long *dl_tag);
320
321
322int
323dlil_event(struct ifnet *ifp, struct kern_event_msg *event);
324
325int dlil_dereg_if_modules(u_long interface_family);
326
327int
328dlil_if_detach(struct ifnet *ifp);
329
330#endif /* DLIL_H */