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
);
101 struct dlil_if_flt_str
{
103 int (*filter_if_input
)(caddr_t cookie
,
104 struct ifnet
**ifnet_ptr
,
105 struct mbuf
**mbuf_ptr
,
108 int (*filter_if_event
)(caddr_t cookie
,
109 struct ifnet
**ifnet_ptr
,
110 struct kern_event_msg
**event_msg_ptr
);
112 int (*filter_if_output
)(caddr_t cookie
,
113 struct ifnet
**ifnet_ptr
,
114 struct mbuf
**mbuf_ptr
);
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
);
122 int (*filter_if_free
)(caddr_t cookie
,
123 struct ifnet
*ifnet_ptr
);
125 int (*filter_detach
)(caddr_t cookie
);
130 #define DLIL_PR_FILTER 1
131 #define DLIL_IF_FILTER 2
135 typedef int (*dl_input_func
)(struct mbuf
*m
, char *frame_header
,
136 struct ifnet
*ifp
, u_long dl_tag
, int sync_ok
);
137 typedef int (*dl_pre_output_func
)(struct ifnet
*ifp
,
139 struct sockaddr
*dest
,
145 typedef int (*dl_event_func
)(struct kern_event_msg
*event
,
148 typedef int (*dl_offer_func
)(struct mbuf
*m
, char *frame_header
);
149 typedef int (*dl_ioctl_func
)(u_long dl_tag
,
156 struct dlil_filterq_entry
{
157 TAILQ_ENTRY(dlil_filterq_entry
) que
;
161 struct dlil_if_flt_str if_filter
;
162 struct dlil_pr_flt_str pr_filter
;
167 TAILQ_HEAD(dlil_filterq_head
, dlil_filterq_entry
);
171 TAILQ_ENTRY(if_proto
) next
;
173 struct dlil_filterq_head pr_flt_head
;
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
;
185 TAILQ_HEAD(dlil_proto_head
, if_proto
);
187 struct dlil_tag_list_entry
{
188 TAILQ_ENTRY(dlil_tag_list_entry
) next
;
194 #define DLIL_DESC_RAW 1
195 #define DLIL_DESC_802_2 2
196 #define DLIL_DESC_802_2_SNAP 3
198 struct dlil_demux_desc
{
199 TAILQ_ENTRY(dlil_demux_desc
) next
;
205 u_long proto_id_length
; /* IN LONGWORDS!!! */
207 u_char
*proto_id_mask
;
223 u_short protocol_type
;
228 TAILQ_HEAD(ddesc_head_str
, dlil_demux_desc
);
231 struct dlil_proto_reg_str
{
232 struct ddesc_head_str demux_desc_head
;
233 u_long interface_family
;
234 u_long protocol_family
;
236 int default_proto
; /* 0 or 1 */
238 dl_pre_output_func pre_output
;
246 int dlil_attach_interface_filter(struct ifnet
*ifnet_ptr
,
247 struct dlil_if_flt_str
*interface_filter
,
249 int insertion_point
);
252 dlil_input(struct ifnet
*ifp
, struct mbuf
*m_head
, struct mbuf
*m_tail
);
255 dlil_output(u_long dl_tag
,
258 struct sockaddr
*dest
,
263 dlil_ioctl(u_long proto_family
,
269 dlil_attach_protocol(struct dlil_proto_reg_str
*proto
,
273 dlil_detach_protocol(u_long dl_tag
);
276 dlil_if_attach(struct ifnet
*ifp
);
279 dlil_attach_protocol_filter(u_long dl_tag
,
280 struct dlil_pr_flt_str
*proto_filter
,
282 int insertion_point
);
284 dlil_detach_filter(u_long filter_id
);
286 struct 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
);
298 int dlil_reg_if_modules(u_long interface_family
,
299 struct dlil_ifmod_reg_str
*ifmod_reg
);
302 dlil_inject_if_input(struct mbuf
*m
, char *frame_header
, u_long from_id
);
305 dlil_inject_pr_input(struct mbuf
*m
, char *frame_header
, u_long from_id
);
308 dlil_inject_pr_output(struct mbuf
*m
,
309 struct sockaddr
*dest
,
316 dlil_inject_if_output(struct mbuf
*m
, u_long from_id
);
319 dlil_find_dltag(u_long if_family
, short unit
, u_long proto_family
, u_long
*dl_tag
);
323 dlil_event(struct ifnet
*ifp
, struct kern_event_msg
*event
);
325 int dlil_dereg_if_modules(u_long interface_family
);
328 dlil_if_detach(struct ifnet
*ifp
);