|
|
1.1 root 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:
35: struct ifnet;
36: struct mbuf;
37: struct 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:
55: enum {
56: BPF_TAP_DISABLE,
57: BPF_TAP_INPUT,
58: BPF_TAP_OUTPUT,
59: BPF_TAP_INPUT_OUTPUT
60: };
61:
62:
63: struct dl_tag_attr_str {
64: u_long dl_tag;
65: short if_flags;
66: short if_unit;
67: u_long if_family;
68: u_long protocol_family;
69: };
70:
71:
72: struct dlil_pr_flt_str {
73: caddr_t cookie;
74:
75: int (*filter_dl_input)(caddr_t cookie,
76: struct mbuf **m,
77: char **frame_header,
78: struct ifnet **ifp);
79:
80:
81: int (*filter_dl_output)(caddr_t cookie,
82: struct mbuf **m,
83: struct ifnet **ifp,
84: struct sockaddr **dest,
85: char *dest_linkaddr,
86: char *frame_type);
87:
88: int (*filter_dl_event)(caddr_t cookie,
89: struct event_msg *event_msg);
90:
91: int (*filter_dl_ioctl)(caddr_t cookie,
92: struct ifnet *ifp,
93: u_long ioctl_cmd,
94: caddr_t ioctl_arg);
95:
96: int (*filter_detach)(caddr_t cookie);
97: };
98:
99: struct dlil_if_flt_str {
100: caddr_t cookie;
101: int (*filter_if_input)(caddr_t cookie,
102: struct ifnet **ifnet_ptr,
103: struct mbuf **mbuf_ptr,
104: char **frame_ptr);
105:
106: int (*filter_if_event)(caddr_t cookie,
107: struct ifnet **ifnet_ptr,
108: struct event_msg **event_msg_ptr);
109:
110: int (*filter_if_output)(caddr_t cookie,
111: struct ifnet **ifnet_ptr,
112: struct mbuf **mbuf_ptr);
113:
114:
115: int (*filter_if_ioctl)(caddr_t cookie,
116: struct ifnet *ifnet_ptr,
117: u_long ioctl_code_ptr,
118: caddr_t ioctl_arg_ptr);
119:
120: int (*filter_if_free)(caddr_t cookie,
121: struct ifnet *ifnet_ptr);
122:
123: int (*filter_detach)(caddr_t cookie);
124: };
125:
126:
127: #define DLIL_PR_FILTER 1
128: #define DLIL_IF_FILTER 2
129:
130:
131:
132: typedef int (*dl_input_func)(struct mbuf *m, char *frame_header,
133: struct ifnet *ifp, u_long dl_tag, int sync_ok);
134: typedef int (*dl_pre_output_func)(struct ifnet *ifp,
135: struct mbuf **m,
136: struct sockaddr *dest,
137: caddr_t route_entry,
138: char *frame_type,
139: char *dst_addr,
140: u_long dl_tag);
141:
142: typedef int (*dl_event_func)(struct event_msg event,
143: u_long dl_tag);
144:
145: typedef int (*dl_offer_func)(struct mbuf *m, char *frame_header);
146: typedef int (*dl_ioctl_func)(u_long dl_tag,
147: struct ifnet *ifp,
148: u_long ioctl_cmd,
149: caddr_t ioctl_arg);
150:
151:
152:
153: struct dlil_filterq_entry {
154: TAILQ_ENTRY(dlil_filterq_entry) que;
155: u_long filter_id;
156: int type;
157: union {
158: struct dlil_if_flt_str if_filter;
159: struct dlil_pr_flt_str pr_filter;
160: } variants;
161: };
162:
163:
164: TAILQ_HEAD(dlil_filterq_head, dlil_filterq_entry);
165:
166:
167: struct if_proto {
168: TAILQ_ENTRY(if_proto) next;
169: u_long dl_tag;
170: struct dlil_filterq_head pr_flt_head;
171: struct ifnet *ifp;
172: dl_input_func dl_input;
173: dl_pre_output_func dl_pre_output;
174: dl_event_func dl_event;
175: dl_offer_func dl_offer;
176: dl_ioctl_func dl_ioctl;
177: u_long protocol_family;
178:
179: };
180:
181: TAILQ_HEAD(dlil_proto_head, if_proto);
182:
183: struct dlil_tag_list_entry {
184: TAILQ_ENTRY(dlil_tag_list_entry) next;
185: struct ifnet *ifp;
186: u_long dl_tag;
187: };
188:
189:
190: #define DLIL_DESC_RAW 1
191: #define DLIL_DESC_802_2 2
192: #define DLIL_DESC_802_2_SNAP 3
193:
194: struct dlil_demux_desc {
195: TAILQ_ENTRY(dlil_demux_desc) next;
196: int type;
197:
198: u_char *native_type;
199: union {
200: struct {
201: u_long proto_id_length; /* IN LONGWORDS!!! */
202: u_char *proto_id;
203: u_char *proto_id_mask;
204:
205: } bitmask;
206:
207: struct {
208: u_char dsap;
209: u_char ssap;
210: u_char control_code;
211: u_char pad;
212: } desc_802_2;
213:
214: struct {
215: u_char dsap;
216: u_char ssap;
217: u_char control_code;
218: u_char org[3];
219: u_short protocol_type;
220: } desc_802_2_SNAP;
221: } variants;
222: };
223:
224: TAILQ_HEAD(ddesc_head_str, dlil_demux_desc);
225:
226:
227: struct dlil_proto_reg_str {
228: struct ddesc_head_str demux_desc_head;
229: u_long interface_family;
230: u_long protocol_family;
231: short unit_number;
232: int default_proto; /* 0 or 1 */
233: dl_input_func input;
234: dl_pre_output_func pre_output;
235: dl_event_func event;
236: dl_offer_func offer;
237: dl_ioctl_func ioctl;
238: };
239:
240:
241: int dlil_attach_interface_filter(struct ifnet *ifnet_ptr,
242: struct dlil_if_flt_str *interface_filter,
243: u_long *filter_id,
244: int insertion_point);
245:
246: int
247: dlil_input(struct ifnet *ifp, struct mbuf *m, char *frame_ptr);
248:
249: int
250: dlil_output(u_long dl_tag,
251: struct mbuf *m,
252: caddr_t route,
253: struct sockaddr *dest,
254: int raw);
255:
256:
257: int
258: dlil_ioctl(u_long dl_tag,
259: struct ifnet *ifp,
260: u_long ioctl_code,
261: caddr_t ioctl_arg);
262:
263: int
264: dlil_attach_protocol(struct dlil_proto_reg_str *proto,
265: u_long *dl_tag);
266:
267: int
268: dlil_detach_protocol(u_long dl_tag);
269:
270: int
271: dlil_if_attach(struct ifnet *ifp);
272:
273: int
274: dlil_attach_protocol_filter(u_long dl_tag,
275: struct dlil_pr_flt_str *proto_filter,
276: u_long *filter_id,
277: int insertion_point);
278: int
279: dlil_detach_filter(u_long filter_id);
280:
281:
282: int
283: dlil_reg_if_modules(
284: u_long interface_family,
285: int (*add_if)(struct ifnet *ifp),
286: int (*del_if)(struct ifnet *ifp),
287: int (*add_proto)(struct ddesc_head_str *demux_desc_head,
288: struct if_proto *proto, u_long dl_tag),
289: int (*del_proto)(struct if_proto *proto, u_long dl_tag),
290: int (*shutdown)());
291:
292: int
293: dlil_inject_if_input(struct mbuf *m, char *frame_header, u_long from_id);
294:
295: int
296: dlil_inject_pr_input(struct mbuf *m, char *frame_header, u_long from_id);
297:
298: int
299: dlil_inject_pr_output(struct mbuf *m,
300: struct sockaddr *dest,
301: int raw,
302: char *frame_type,
303: char *dst_linkaddr,
304: u_long from_id);
305:
306: int
307: dlil_inject_if_output(struct mbuf *m, u_long from_id);
308:
309: int
310: dlil_find_dltag(u_long if_family, short unit, u_long proto_family, u_long *dl_tag);
311:
312: #endif /* DLIL_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.