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
;
195 #define DLIL_DESC_RAW 1
196 #define DLIL_DESC_802_2 2
197 #define DLIL_DESC_802_2_SNAP 3
199 * DLIL_DESC_RAW - obsolete type, data in variants.bitmask or native_type
200 * if variants.bitmask.proto_id_length, native_type in host
202 * DLIL_DESC_802_2 - obsolete, data in variants.desc_802_2
203 * DLIL_DESC_802_2_SNAP - obsolete, data in variants.desc_802_2_SNAP
204 * protocol field in host byte order
207 /* Ehernet specific types */
208 #define DLIL_DESC_ETYPE2 4
209 #define DLIL_DESC_SAP 5
210 #define DLIL_DESC_SNAP 6
212 * DLIL_DESC_ETYPE2 - native_type must point to 2 byte ethernet raw protocol,
213 * variants.native_type_length must be set to 2
214 * DLIL_DESC_SAP - native_type must point to 3 byte SAP protocol
215 * variants.native_type_length must be set to 3
216 * DLIL_DESC_SNAP - native_type must point to 5 byte SNAP protocol
217 * variants.native_type_length must be set to 5
219 * All protocols must be in Network byte order.
221 * Future interface families may define more protocol types they know about.
222 * The type implies the offset and context of the protocol data at native_type.
223 * The length of the protocol data specified at native_type must be set in
224 * variants.native_type_length.
227 struct dlil_demux_desc
{
228 TAILQ_ENTRY(dlil_demux_desc
) next
;
234 /* Structs in this union are obsolete. They exist for binary compatability only */
235 /* Only the native_type_length is used */
237 u_long proto_id_length
; /* IN LONGWORDS!!! */
238 u_char
*proto_id
; /* No longer supported by Ethernet family */
239 u_char
*proto_id_mask
;
250 u_char dsap
; /* Ignored, assumed to be 0xAA */
251 u_char ssap
; /* Ignored, assumed to be 0xAA */
252 u_char control_code
; /* Ignored, assumed to be 0x03 */
254 u_short protocol_type
; /* In host byte order */
257 /* Length of data pointed to by native_type, must be set correctly */
258 u_int32_t native_type_length
;
262 TAILQ_HEAD(ddesc_head_str
, dlil_demux_desc
);
265 struct dlil_proto_reg_str
{
266 struct ddesc_head_str demux_desc_head
;
267 u_long interface_family
;
268 u_long protocol_family
;
270 int default_proto
; /* 0 or 1 */
272 dl_pre_output_func pre_output
;
280 int dlil_attach_interface_filter(struct ifnet
*ifnet_ptr
,
281 struct dlil_if_flt_str
*interface_filter
,
283 int insertion_point
);
286 dlil_input(struct ifnet
*ifp
, struct mbuf
*m_head
, struct mbuf
*m_tail
);
289 dlil_output(u_long dl_tag
,
292 struct sockaddr
*dest
,
297 dlil_ioctl(u_long proto_family
,
303 dlil_attach_protocol(struct dlil_proto_reg_str
*proto
,
307 dlil_detach_protocol(u_long dl_tag
);
310 dlil_if_attach(struct ifnet
*ifp
);
313 dlil_attach_protocol_filter(u_long dl_tag
,
314 struct dlil_pr_flt_str
*proto_filter
,
316 int insertion_point
);
318 dlil_detach_filter(u_long filter_id
);
320 struct dlil_ifmod_reg_str
{
321 int (*add_if
)(struct ifnet
*ifp
);
322 int (*del_if
)(struct ifnet
*ifp
);
323 int (*add_proto
)(struct ddesc_head_str
*demux_desc_head
,
324 struct if_proto
*proto
, u_long dl_tag
);
325 int (*del_proto
)(struct if_proto
*proto
, u_long dl_tag
);
326 int (*ifmod_ioctl
)(struct ifnet
*ifp
, u_long ioctl_cmd
, caddr_t data
);
332 int dlil_reg_if_modules(u_long interface_family
,
333 struct dlil_ifmod_reg_str
*ifmod_reg
);
336 dlil_inject_if_input(struct mbuf
*m
, char *frame_header
, u_long from_id
);
339 dlil_inject_pr_input(struct mbuf
*m
, char *frame_header
, u_long from_id
);
342 dlil_inject_pr_output(struct mbuf
*m
,
343 struct sockaddr
*dest
,
350 dlil_inject_if_output(struct mbuf
*m
, u_long from_id
);
353 dlil_find_dltag(u_long if_family
, short unit
, u_long proto_family
, u_long
*dl_tag
);
357 dlil_event(struct ifnet
*ifp
, struct kern_event_msg
*event
);
359 int dlil_dereg_if_modules(u_long interface_family
);
362 dlil_if_detach(struct ifnet
*ifp
);