2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1999 Apple Computer, Inc.
25 * Data Link Inteface Layer
43 #define DLIL_LAST_FILTER -1
44 #define DLIL_NULL_FILTER -2
46 #define DLIL_WAIT_FOR_FREE -2
48 #define DLIL_BLUEBOX 1
53 #include <net/if_var.h>
54 #include <sys/kern_event.h>
64 struct dl_tag_attr_str
{
69 u_long protocol_family
;
73 struct dlil_pr_flt_str
{
76 int (*filter_dl_input
)(caddr_t cookie
,
82 int (*filter_dl_output
)(caddr_t cookie
,
85 struct sockaddr
**dest
,
89 int (*filter_dl_event
)(caddr_t cookie
,
90 struct kern_event_msg
*event_msg
);
92 int (*filter_dl_ioctl
)(caddr_t cookie
,
97 int (*filter_detach
)(caddr_t cookie
);
100 struct dlil_if_flt_str
{
102 int (*filter_if_input
)(caddr_t cookie
,
103 struct ifnet
**ifnet_ptr
,
104 struct mbuf
**mbuf_ptr
,
107 int (*filter_if_event
)(caddr_t cookie
,
108 struct ifnet
**ifnet_ptr
,
109 struct kern_event_msg
**event_msg_ptr
);
111 int (*filter_if_output
)(caddr_t cookie
,
112 struct ifnet
**ifnet_ptr
,
113 struct mbuf
**mbuf_ptr
);
116 int (*filter_if_ioctl
)(caddr_t cookie
,
117 struct ifnet
*ifnet_ptr
,
118 u_long ioctl_code_ptr
,
119 caddr_t ioctl_arg_ptr
);
121 int (*filter_if_free
)(caddr_t cookie
,
122 struct ifnet
*ifnet_ptr
);
124 int (*filter_detach
)(caddr_t cookie
);
128 #define DLIL_PR_FILTER 1
129 #define DLIL_IF_FILTER 2
133 typedef int (*dl_input_func
)(struct mbuf
*m
, char *frame_header
,
134 struct ifnet
*ifp
, u_long dl_tag
, int sync_ok
);
135 typedef int (*dl_pre_output_func
)(struct ifnet
*ifp
,
137 struct sockaddr
*dest
,
143 typedef int (*dl_event_func
)(struct kern_event_msg
*event
,
146 typedef int (*dl_offer_func
)(struct mbuf
*m
, char *frame_header
);
147 typedef int (*dl_ioctl_func
)(u_long dl_tag
,
154 struct dlil_filterq_entry
{
155 TAILQ_ENTRY(dlil_filterq_entry
) que
;
159 struct dlil_if_flt_str if_filter
;
160 struct dlil_pr_flt_str pr_filter
;
165 TAILQ_HEAD(dlil_filterq_head
, dlil_filterq_entry
);
169 TAILQ_ENTRY(if_proto
) next
;
171 struct dlil_filterq_head pr_flt_head
;
173 dl_input_func dl_input
;
174 dl_pre_output_func dl_pre_output
;
175 dl_event_func dl_event
;
176 dl_offer_func dl_offer
;
177 dl_ioctl_func dl_ioctl
;
178 u_long protocol_family
;
182 TAILQ_HEAD(dlil_proto_head
, if_proto
);
184 struct dlil_tag_list_entry
{
185 TAILQ_ENTRY(dlil_tag_list_entry
) next
;
191 #define DLIL_DESC_RAW 1
192 #define DLIL_DESC_802_2 2
193 #define DLIL_DESC_802_2_SNAP 3
195 struct dlil_demux_desc
{
196 TAILQ_ENTRY(dlil_demux_desc
) next
;
202 u_long proto_id_length
; /* IN LONGWORDS!!! */
204 u_char
*proto_id_mask
;
220 u_short protocol_type
;
225 TAILQ_HEAD(ddesc_head_str
, dlil_demux_desc
);
228 struct dlil_proto_reg_str
{
229 struct ddesc_head_str demux_desc_head
;
230 u_long interface_family
;
231 u_long protocol_family
;
233 int default_proto
; /* 0 or 1 */
235 dl_pre_output_func pre_output
;
242 int dlil_attach_interface_filter(struct ifnet
*ifnet_ptr
,
243 struct dlil_if_flt_str
*interface_filter
,
245 int insertion_point
);
248 dlil_input(struct ifnet
*ifp
, struct mbuf
*m_head
, struct mbuf
*m_tail
);
251 dlil_output(u_long dl_tag
,
254 struct sockaddr
*dest
,
259 dlil_ioctl(u_long proto_family
,
265 dlil_attach_protocol(struct dlil_proto_reg_str
*proto
,
269 dlil_detach_protocol(u_long dl_tag
);
272 dlil_if_attach(struct ifnet
*ifp
);
275 dlil_attach_protocol_filter(u_long dl_tag
,
276 struct dlil_pr_flt_str
*proto_filter
,
278 int insertion_point
);
280 dlil_detach_filter(u_long filter_id
);
282 struct dlil_ifmod_reg_str
{
283 int (*add_if
)(struct ifnet
*ifp
);
284 int (*del_if
)(struct ifnet
*ifp
);
285 int (*add_proto
)(struct ddesc_head_str
*demux_desc_head
,
286 struct if_proto
*proto
, u_long dl_tag
);
287 int (*del_proto
)(struct if_proto
*proto
, u_long dl_tag
);
288 int (*ifmod_ioctl
)(struct ifnet
*ifp
, u_long ioctl_cmd
, caddr_t data
);
293 int dlil_reg_if_modules(u_long interface_family
,
294 struct dlil_ifmod_reg_str
*ifmod_reg
);
297 dlil_inject_if_input(struct mbuf
*m
, char *frame_header
, u_long from_id
);
300 dlil_inject_pr_input(struct mbuf
*m
, char *frame_header
, u_long from_id
);
303 dlil_inject_pr_output(struct mbuf
*m
,
304 struct sockaddr
*dest
,
311 dlil_inject_if_output(struct mbuf
*m
, u_long from_id
);
314 dlil_find_dltag(u_long if_family
, short unit
, u_long proto_family
, u_long
*dl_tag
);
318 dlil_event(struct ifnet
*ifp
, struct kern_event_msg
*event
);
320 int dlil_dereg_if_modules(u_long interface_family
);
323 dlil_if_detach(struct ifnet
*ifp
);