]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
8f6c56a5 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Copyright (c) 1999 Apple Computer, Inc. | |
30 | * | |
31 | * Data Link Inteface Layer | |
32 | * Author: Ted Walker | |
33 | */ | |
1c79356b A |
34 | #ifndef DLIL_H |
35 | #define DLIL_H | |
91447636 A |
36 | #ifdef KERNEL |
37 | #include <sys/kernel_types.h> | |
38 | #include <net/kpi_interface.h> | |
1c79356b A |
39 | |
40 | #if __STDC__ | |
41 | ||
42 | struct ifnet; | |
43 | struct mbuf; | |
44 | struct ether_header; | |
91447636 | 45 | struct sockaddr_dl; |
1c79356b A |
46 | |
47 | #endif | |
48 | ||
49 | ||
91447636 | 50 | #ifdef KERNEL_PRIVATE |
1c79356b A |
51 | #define DLIL_LAST_FILTER -1 |
52 | #define DLIL_NULL_FILTER -2 | |
53 | ||
54 | #define DLIL_WAIT_FOR_FREE -2 | |
55 | ||
56 | #define DLIL_BLUEBOX 1 | |
57 | ||
58 | ||
59 | ||
60 | #include <net/if.h> | |
61 | #include <net/if_var.h> | |
62 | #include <sys/kern_event.h> | |
63 | ||
91447636 A |
64 | #endif KERNEL_PRIVATE |
65 | ||
1c79356b A |
66 | enum { |
67 | BPF_TAP_DISABLE, | |
68 | BPF_TAP_INPUT, | |
69 | BPF_TAP_OUTPUT, | |
70 | BPF_TAP_INPUT_OUTPUT | |
71 | }; | |
72 | ||
91447636 A |
73 | #ifdef KERNEL_PRIVATE |
74 | struct kev_msg; | |
75 | struct iff_filter; | |
1c79356b A |
76 | |
77 | struct dlil_if_flt_str { | |
78 | caddr_t cookie; | |
79 | int (*filter_if_input)(caddr_t cookie, | |
91447636 | 80 | struct ifnet **ifp, |
1c79356b A |
81 | struct mbuf **mbuf_ptr, |
82 | char **frame_ptr); | |
83 | ||
84 | int (*filter_if_event)(caddr_t cookie, | |
91447636 A |
85 | struct ifnet *ifp, |
86 | struct kev_msg *event_msg_ptr); | |
1c79356b A |
87 | |
88 | int (*filter_if_output)(caddr_t cookie, | |
91447636 | 89 | struct ifnet **ifp, |
1c79356b A |
90 | struct mbuf **mbuf_ptr); |
91 | ||
92 | ||
93 | int (*filter_if_ioctl)(caddr_t cookie, | |
91447636 | 94 | struct ifnet *ifp, |
1c79356b A |
95 | u_long ioctl_code_ptr, |
96 | caddr_t ioctl_arg_ptr); | |
97 | ||
98 | int (*filter_if_free)(caddr_t cookie, | |
91447636 | 99 | struct ifnet *ifp); |
1c79356b | 100 | |
91447636 | 101 | int (*filter_detach)(caddr_t cookie); |
0b4e3aa0 | 102 | u_long reserved[2]; |
1c79356b A |
103 | }; |
104 | ||
1c79356b A |
105 | #define DLIL_PR_FILTER 1 |
106 | #define DLIL_IF_FILTER 2 | |
107 | ||
108 | ||
109 | ||
110 | typedef int (*dl_input_func)(struct mbuf *m, char *frame_header, | |
91447636 | 111 | struct ifnet *ifp, u_long protocol_family, int sync_ok); |
1c79356b | 112 | typedef int (*dl_pre_output_func)(struct ifnet *ifp, |
91447636 A |
113 | u_long protocol_family, |
114 | struct mbuf **m, | |
115 | const struct sockaddr *dest, | |
116 | caddr_t route_entry, | |
117 | char *frame_type, | |
118 | char *dst_addr); | |
1c79356b | 119 | |
91447636 | 120 | typedef void (*dl_event_func)(struct ifnet *ifp, struct kev_msg *event); |
1c79356b A |
121 | |
122 | typedef int (*dl_offer_func)(struct mbuf *m, char *frame_header); | |
91447636 | 123 | typedef int (*dl_ioctl_func)(u_long protocol_family, |
1c79356b A |
124 | struct ifnet *ifp, |
125 | u_long ioctl_cmd, | |
126 | caddr_t ioctl_arg); | |
91447636 | 127 | typedef int (*dl_detached_func)(u_long protocol_family, struct ifnet *ifp); |
1c79356b | 128 | |
7b1edb79 | 129 | /* Obsolete types */ |
1c79356b A |
130 | #define DLIL_DESC_RAW 1 |
131 | #define DLIL_DESC_802_2 2 | |
132 | #define DLIL_DESC_802_2_SNAP 3 | |
7b1edb79 A |
133 | /* |
134 | * DLIL_DESC_RAW - obsolete type, data in variants.bitmask or native_type | |
135 | * if variants.bitmask.proto_id_length, native_type in host | |
136 | * byte order. | |
137 | * DLIL_DESC_802_2 - obsolete, data in variants.desc_802_2 | |
138 | * DLIL_DESC_802_2_SNAP - obsolete, data in variants.desc_802_2_SNAP | |
139 | * protocol field in host byte order | |
140 | */ | |
91447636 | 141 | #endif KERNEL_PRIVATE |
7b1edb79 | 142 | |
91447636 | 143 | /* Ethernet specific types */ |
7b1edb79 A |
144 | #define DLIL_DESC_ETYPE2 4 |
145 | #define DLIL_DESC_SAP 5 | |
146 | #define DLIL_DESC_SNAP 6 | |
147 | /* | |
148 | * DLIL_DESC_ETYPE2 - native_type must point to 2 byte ethernet raw protocol, | |
149 | * variants.native_type_length must be set to 2 | |
150 | * DLIL_DESC_SAP - native_type must point to 3 byte SAP protocol | |
151 | * variants.native_type_length must be set to 3 | |
152 | * DLIL_DESC_SNAP - native_type must point to 5 byte SNAP protocol | |
153 | * variants.native_type_length must be set to 5 | |
154 | * | |
155 | * All protocols must be in Network byte order. | |
156 | * | |
157 | * Future interface families may define more protocol types they know about. | |
158 | * The type implies the offset and context of the protocol data at native_type. | |
159 | * The length of the protocol data specified at native_type must be set in | |
160 | * variants.native_type_length. | |
161 | */ | |
1c79356b | 162 | |
91447636 | 163 | #ifdef KERNEL_PRIVATE |
1c79356b A |
164 | struct dlil_demux_desc { |
165 | TAILQ_ENTRY(dlil_demux_desc) next; | |
7b1edb79 A |
166 | |
167 | int type; | |
168 | u_char *native_type; | |
169 | ||
1c79356b | 170 | union { |
7b1edb79 A |
171 | /* Structs in this union are obsolete. They exist for binary compatability only */ |
172 | /* Only the native_type_length is used */ | |
173 | struct { | |
174 | u_long proto_id_length; /* IN LONGWORDS!!! */ | |
175 | u_char *proto_id; /* No longer supported by Ethernet family */ | |
176 | u_char *proto_id_mask; | |
177 | } bitmask; | |
178 | ||
179 | struct { | |
180 | u_char dsap; | |
181 | u_char ssap; | |
182 | u_char control_code; | |
183 | u_char pad; | |
184 | } desc_802_2; | |
185 | ||
186 | struct { | |
187 | u_char dsap; /* Ignored, assumed to be 0xAA */ | |
188 | u_char ssap; /* Ignored, assumed to be 0xAA */ | |
189 | u_char control_code; /* Ignored, assumed to be 0x03 */ | |
190 | u_char org[3]; | |
191 | u_short protocol_type; /* In host byte order */ | |
192 | } desc_802_2_SNAP; | |
193 | ||
194 | /* Length of data pointed to by native_type, must be set correctly */ | |
195 | u_int32_t native_type_length; | |
1c79356b A |
196 | } variants; |
197 | }; | |
198 | ||
199 | TAILQ_HEAD(ddesc_head_str, dlil_demux_desc); | |
200 | ||
1c79356b A |
201 | struct dlil_proto_reg_str { |
202 | struct ddesc_head_str demux_desc_head; | |
203 | u_long interface_family; | |
204 | u_long protocol_family; | |
205 | short unit_number; | |
206 | int default_proto; /* 0 or 1 */ | |
207 | dl_input_func input; | |
7b1edb79 | 208 | dl_pre_output_func pre_output; |
1c79356b A |
209 | dl_event_func event; |
210 | dl_offer_func offer; | |
211 | dl_ioctl_func ioctl; | |
91447636 A |
212 | dl_detached_func detached; |
213 | u_long reserved[3]; | |
1c79356b A |
214 | }; |
215 | ||
216 | ||
91447636 A |
217 | int dlil_attach_filter(struct ifnet *ifp, const struct iff_filter *if_filter, |
218 | interface_filter_t *filter_ref); | |
219 | ||
220 | struct ifnet_stat_increment_param; | |
221 | ||
222 | int | |
223 | dlil_input_with_stats(struct ifnet *ifp, struct mbuf *m_head, struct mbuf *m_tail, | |
224 | const struct ifnet_stat_increment_param *stats); | |
1c79356b A |
225 | |
226 | int | |
227 | dlil_input(struct ifnet *ifp, struct mbuf *m_head, struct mbuf *m_tail); | |
228 | ||
229 | int | |
91447636 A |
230 | dlil_output_list( |
231 | struct ifnet *ifp, | |
232 | u_long protocol_family, | |
233 | struct mbuf *packetlist, | |
234 | caddr_t route, | |
235 | const struct sockaddr *dest, | |
236 | int raw); | |
237 | ||
238 | int | |
239 | dlil_output( | |
240 | struct ifnet *ifp, | |
241 | u_long protocol_family, | |
1c79356b A |
242 | struct mbuf *m, |
243 | caddr_t route, | |
91447636 | 244 | const struct sockaddr *dest, |
1c79356b A |
245 | int raw); |
246 | ||
247 | ||
248 | int | |
249 | dlil_ioctl(u_long proto_family, | |
250 | struct ifnet *ifp, | |
251 | u_long ioctl_code, | |
252 | caddr_t ioctl_arg); | |
253 | ||
91447636 A |
254 | errno_t |
255 | dlil_resolve_multi( | |
256 | struct ifnet *ifp, | |
257 | const struct sockaddr *proto_addr, | |
258 | struct sockaddr *ll_addr, | |
259 | size_t ll_len); | |
260 | ||
261 | /* | |
262 | * Send arp internal bypasses the check for | |
263 | * IPv4LL. | |
264 | */ | |
265 | errno_t | |
266 | dlil_send_arp_internal( | |
267 | ifnet_t ifp, | |
268 | u_int16_t arpop, | |
269 | const struct sockaddr_dl* sender_hw, | |
270 | const struct sockaddr* sender_proto, | |
271 | const struct sockaddr_dl* target_hw, | |
272 | const struct sockaddr* target_proto); | |
273 | ||
274 | errno_t | |
275 | dlil_send_arp( | |
276 | ifnet_t ifp, | |
277 | u_int16_t arpop, | |
278 | const struct sockaddr_dl* sender_hw, | |
279 | const struct sockaddr* sender_proto, | |
280 | const struct sockaddr_dl* target_hw, | |
281 | const struct sockaddr* target_proto); | |
282 | ||
283 | int | |
284 | dlil_ioctl_locked(u_long proto_family, | |
285 | struct ifnet *ifp, | |
286 | u_long ioctl_code, | |
287 | caddr_t ioctl_arg); | |
288 | ||
1c79356b | 289 | int |
91447636 | 290 | dlil_attach_protocol(struct dlil_proto_reg_str *proto); |
1c79356b A |
291 | |
292 | int | |
91447636 | 293 | dlil_detach_protocol(struct ifnet *ifp, u_long protocol_family); |
1c79356b A |
294 | |
295 | int | |
296 | dlil_if_attach(struct ifnet *ifp); | |
297 | ||
91447636 A |
298 | #ifdef BSD_KERNEL_PRIVATE |
299 | ||
1c79356b | 300 | int |
91447636 A |
301 | dlil_if_attach_with_address( |
302 | struct ifnet *ifp, | |
303 | const struct sockaddr_dl *ll_addr); | |
304 | ||
1c79356b | 305 | int |
91447636 A |
306 | dlil_attach_protocol_kpi(ifnet_t ifp, protocol_family_t protocol, |
307 | const struct ifnet_attach_proto_param *proto_details); | |
308 | ||
309 | errno_t dlil_set_bpf_tap(ifnet_t ifp, bpf_tap_mode mode, | |
310 | bpf_packet_func callback); | |
311 | ||
312 | #endif | |
313 | ||
314 | void | |
315 | dlil_detach_filter(interface_filter_t filter); | |
1c79356b A |
316 | |
317 | struct dlil_ifmod_reg_str { | |
318 | int (*add_if)(struct ifnet *ifp); | |
319 | int (*del_if)(struct ifnet *ifp); | |
91447636 A |
320 | int (*add_proto)(struct ifnet *ifp, u_long protocol_family, |
321 | struct ddesc_head_str *demux_desc_head); | |
322 | #ifdef __KPI_INTERFACE__ | |
323 | ifnet_del_proto_func del_proto; | |
324 | ifnet_ioctl_func ifmod_ioctl; | |
325 | #else | |
326 | void* del_proto; | |
327 | void* ifmod_ioctl; | |
328 | #endif | |
329 | int (*shutdown)(void); | |
9bccf70c A |
330 | int (*init_if)(struct ifnet *ifp); |
331 | u_long reserved[3]; | |
1c79356b A |
332 | }; |
333 | ||
334 | ||
335 | int dlil_reg_if_modules(u_long interface_family, | |
336 | struct dlil_ifmod_reg_str *ifmod_reg); | |
337 | ||
55e303ae A |
338 | /* |
339 | ||
340 | Function : dlil_reg_proto_module | |
341 | ||
342 | A DLIL protocol module is a piece of code that know how to handle a certain type | |
343 | of protocol (PF_INET, PF_INET6, ...) for a certain family of interface (APPLE_IF_FAM_ETHERNET, | |
344 | APPLE_IF_FAM_PPP, ...). | |
345 | ||
346 | dlil_reg_proto_module() allows the registration of such a protocol/interface handler before any | |
347 | interface is attached. | |
348 | Typically, the attach and detach function of the protocol handler will call | |
349 | dlil_{attach/detach}_protocol with the parameter specific to the protocol. | |
350 | ||
351 | The goal of this modules is to insulate the actual protocol (IP, IPv6) from the DLIL details. | |
352 | ||
353 | Parameters : | |
354 | 'protocol_family' is PF_INET, PF_INET6, ... | |
355 | 'interface_family' is APPLE_IF_FAM_ETHERNET, APPLE_IF_FAM_PPP, ... | |
356 | 'protomod_reg' is the protocol registration structure. | |
357 | 'attach_proto' funtion is mandatory. | |
358 | 'detach_proto' funtion is optional (DLIL will manage it). | |
359 | ||
360 | Return code : | |
361 | ||
362 | 0 : | |
363 | ||
364 | No error. | |
365 | ||
366 | ENOMEM: | |
367 | ||
368 | No memory can be allocated for internal data structure. | |
369 | ||
370 | EEXIST: | |
371 | ||
372 | The protocol family has already been registered for this interface family. | |
373 | ||
374 | EINVAL: | |
375 | ||
376 | The dlil_protomod_reg_str structure contains incorrect values. | |
377 | ||
378 | */ | |
379 | ||
380 | int dlil_reg_proto_module(u_long protocol_family, u_long interface_family, | |
91447636 A |
381 | int (*attach)(struct ifnet *ifp, u_long protocol_family), |
382 | int (*detach)(struct ifnet *ifp, u_long protocol_family)); | |
55e303ae A |
383 | |
384 | /* | |
385 | ||
386 | Function : dlil_dereg_proto_module | |
387 | ||
388 | dlil_dereg_proto_module() will unregister the protocol module previously | |
389 | registered with dlil_dereg_proto_module(). | |
390 | ||
391 | There is no restriction when to call it. | |
392 | Interfaces or protoco can be attached, it will not prevent the deregistration of the module. | |
393 | ||
394 | Parameters : | |
395 | 'protocol_family' is PF_INET, PF_INET6, ... | |
396 | 'interface_family' is APPLE_IF_FAM_ETHERNET, APPLE_IF_FAM_PPP, ... | |
397 | ||
398 | Return code : | |
399 | ||
400 | 0 : | |
401 | ||
402 | No error. | |
403 | ||
404 | ENOENT: | |
405 | ||
406 | No module was registered.. | |
407 | ||
408 | */ | |
409 | ||
410 | int dlil_dereg_proto_module(u_long protocol_family, u_long interface_family); | |
411 | ||
412 | /* | |
413 | ||
414 | Function : dlil_plumb_protocol | |
415 | ||
416 | dlil_plumb_protocol() will plumb a protocol to an actual interface. | |
417 | This will find a registered protocol module and call its attach function. | |
91447636 A |
418 | The module will typically call dlil_attach_protocol with the appropriate parameters. |
419 | ||
55e303ae A |
420 | Parameters : |
421 | 'protocol_family' is PF_INET, PF_INET6, ... | |
422 | 'ifp' is the interface to plumb the protocol to. | |
55e303ae A |
423 | |
424 | Return code : | |
425 | ||
426 | 0 : | |
427 | ||
428 | No error. | |
429 | ||
430 | ENOENT: | |
431 | ||
432 | No module was registered. | |
433 | ||
434 | other: | |
435 | ||
436 | Error returned by the attach_proto function | |
437 | ||
438 | */ | |
91447636 | 439 | int dlil_plumb_protocol(u_long protocol_family, struct ifnet *ifp); |
55e303ae A |
440 | |
441 | /* | |
442 | ||
443 | Function : dlil_unplumb_protocol | |
444 | ||
445 | dlil_unplumb_protocol() will unplumb a protocol from an interface. | |
446 | This will find a registered protocol module and call its detach function. | |
447 | The module will typically call dlil_detach_protocol with the appropriate parameters. | |
448 | If no module is found, this function will call dlil_detach_protocol directly. | |
449 | ||
450 | Parameters : | |
451 | 'protocol_family' is PF_INET, PF_INET6, ... | |
452 | 'ifp' is APPLE_IF_FAM_ETHERNET, APPLE_IF_FAM_PPP, ... | |
453 | ||
454 | Return code : | |
455 | ||
456 | 0 : | |
457 | ||
458 | No error. | |
459 | ||
460 | ENOENT: | |
461 | ||
462 | No module was registered. | |
463 | ||
464 | other: | |
465 | ||
466 | Error returned by the attach_proto function | |
467 | ||
468 | */ | |
469 | int dlil_unplumb_protocol(u_long protocol_family, struct ifnet *ifp); | |
470 | ||
1c79356b A |
471 | int |
472 | dlil_inject_if_input(struct mbuf *m, char *frame_header, u_long from_id); | |
473 | ||
474 | int | |
475 | dlil_inject_pr_input(struct mbuf *m, char *frame_header, u_long from_id); | |
476 | ||
477 | int | |
478 | dlil_inject_pr_output(struct mbuf *m, | |
479 | struct sockaddr *dest, | |
480 | int raw, | |
481 | char *frame_type, | |
482 | char *dst_linkaddr, | |
483 | u_long from_id); | |
484 | ||
485 | int | |
486 | dlil_inject_if_output(struct mbuf *m, u_long from_id); | |
487 | ||
91447636 A |
488 | #ifdef KERNEL_PRIVATE |
489 | void | |
490 | dlil_post_msg(struct ifnet *ifp,u_long event_subclass, u_long event_code, | |
491 | struct net_event_data *event_data, u_long event_data_len); | |
492 | #endif | |
1c79356b A |
493 | |
494 | int | |
495 | dlil_event(struct ifnet *ifp, struct kern_event_msg *event); | |
496 | ||
497 | int dlil_dereg_if_modules(u_long interface_family); | |
498 | ||
499 | int | |
500 | dlil_if_detach(struct ifnet *ifp); | |
501 | ||
91447636 A |
502 | void |
503 | ifp_reference(struct ifnet *ifp); | |
504 | ||
505 | void | |
506 | ifp_release(struct ifnet *ifp); | |
507 | ||
9bccf70c A |
508 | |
509 | /* | |
510 | ||
511 | Function : dlil_if_acquire | |
512 | ||
513 | DLIL manages the list of ifnet interfaces allocated using the dlil_if_acquire | |
514 | function. This list if not the same as the list of attached interfaces, | |
515 | visible with ifconfig. | |
516 | This list contains attached as well as detached interfaces. | |
517 | Detached interfaces are kept in the list to prevent the kernel from crashing | |
518 | by using an old ifp. | |
519 | ||
520 | if it succeeds, dlil_if_acquire returns an ifnet data structure. | |
521 | This ifnet can either be a new allocated block of memory, or an ifnet | |
522 | that already existed and that DLIL has found in its list of unused | |
523 | interface and that matches the family/uniqueid tuple. | |
524 | ||
525 | dlil_if_acquire can fail if the requested interface is already in use, | |
526 | or if no memory is available to create a new interface. | |
527 | ||
528 | The typical sequence of call for a driver will be : | |
529 | dlil_if_acquire(... &ifp) | |
530 | ... Fill in the ifnet ... | |
531 | dlil_if_attach(ifp) | |
532 | ... Driver work ... | |
533 | dlil_if_detach(ifp) | |
534 | dlil_if_release(ifp) | |
535 | ||
536 | Important : ifnet allocated by DLIL are managed by DLIL. DLIL takes care | |
537 | of them, and keeps them until a driver wants to reuse them, but DLIL may | |
538 | also decide to free them when not in use by a driver. | |
539 | ||
540 | Note : the structure returned will actually be large enough to contain | |
541 | an arpcom structure (ifnet + ethernet) structure. | |
542 | Drivers cannot extend the structure and must to store their private | |
543 | information in if_sofc and if_private. | |
544 | ||
545 | Parameters : | |
546 | 'family' uniquely identifies DLIL interface family. | |
547 | 'uniqueid' is a unique identifier for that interface, managed by the | |
548 | driver (for example MAC address for ethernet). | |
549 | 'uniqueid_len' is the length of the unique id. | |
550 | 'ifp' contains on output the allocated ifnet. | |
551 | ||
552 | Return code : | |
553 | ||
554 | 0 : | |
555 | ||
556 | If an ifnet matching the uniqueid is found, the matching ifnet is returned | |
557 | in ifp and the flags IFEF_REUSE and IF_INUSE are set in the if_eflags. | |
558 | The fields in the ifnet are NOT zeroed and may contain old values that | |
559 | the driver can reuse. [They are not necessarily the values that were | |
560 | there when the driver released the ifnet, as protocol might have | |
561 | continued to update them]. | |
562 | ||
563 | If no matching ifnet is found, a new structure is allocated and returned | |
564 | in ifp with all fields initialized to 0. | |
565 | The flag IF_INUSE is set in the if_eflags. IFEF_REUSE is NOT set. | |
566 | dlil_if_acquire will copy the uniqueid and keep it for matching purpose. | |
567 | ||
568 | If 'uniqueid' is NULL, then dlil_if_acquire will return the first | |
569 | ifnet that contains a null uniqueid for that family, with the flags | |
570 | IFEF_REUSE and IF_INUSE set. | |
571 | If no ifnet is available, a new one will be created. | |
572 | ||
573 | ENOMEM: | |
574 | ||
575 | If no matching interface is found, and no memory can be allocated, | |
576 | dlil_if_acquire will return ENOMEM. | |
577 | ||
578 | ||
579 | EBUSY: | |
580 | ||
581 | If the unique id matches the id of an interface currently in use, | |
582 | dlil_if_acquire will return EBUSY. | |
583 | An interface 'in use' is an allocated interface, not necessarily attached. | |
584 | ||
585 | */ | |
586 | ||
91447636 | 587 | int dlil_if_acquire(u_long family, const void *uniqueid, size_t uniqueid_len, |
9bccf70c A |
588 | struct ifnet **ifp); |
589 | ||
590 | ||
591 | /* | |
592 | ||
593 | Function : dlil_if_release | |
594 | ||
595 | dlil_if_release will transfer control of the ifnet to DLIL. | |
596 | DLIL will keep the interface in its list, marking it unused. | |
597 | The fields will be left in their current state, so the driver can reuse | |
598 | the ifnet later, by calling dlil_if_acquire. | |
599 | The if_eflags IF_INUSE will be cleared. | |
600 | The fields if_output, if_ioctl, if_free and if_set_bpf_tap will be changed | |
601 | to point to DLIL private functions. | |
91447636 | 602 | After calling dlil_if_release, the driver can safely terminate and |
9bccf70c | 603 | unload if necessary. |
91447636 A |
604 | Note: your driver should only call dlil_if_release once your if_free |
605 | function has been called. | |
9bccf70c A |
606 | |
607 | Parameters : | |
608 | ifp is the pointer to the ifnet to release. | |
609 | ||
610 | */ | |
611 | ||
612 | void dlil_if_release(struct ifnet *ifp); | |
613 | ||
91447636 A |
614 | #endif /* KERNEL_PRIVATE */ |
615 | #endif /* KERNEL */ | |
1c79356b | 616 | #endif /* DLIL_H */ |