]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ff6e181a 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. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
91447636 | 12 | * |
ff6e181a A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
91447636 A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ff6e181a A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
91447636 A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /*! | |
24 | @header kpi_interface.h | |
25 | This header defines an API to interact with network interfaces in | |
26 | the kernel. The network interface KPI may be used to implement | |
27 | network interfaces or to attach protocols to existing interfaces. | |
28 | */ | |
29 | ||
30 | #ifndef __KPI_INTERFACE__ | |
31 | #define __KPI_INTERFACE__ | |
32 | #include <sys/kernel_types.h> | |
33 | ||
34 | #ifndef _SA_FAMILY_T | |
35 | #define _SA_FAMILY_T | |
36 | typedef __uint8_t sa_family_t; | |
37 | #endif | |
38 | ||
39 | struct timeval; | |
40 | struct sockaddr; | |
41 | struct sockaddr_dl; | |
42 | struct kern_event_msg; | |
43 | struct kev_msg; | |
44 | struct ifnet_demux_desc; | |
45 | ||
46 | /*! | |
47 | @enum Interface Families | |
48 | @abstract Constants defining interface families. | |
49 | @constant IFNET_FAMILY_ANY Match interface of any family type. | |
50 | @constant IFNET_FAMILY_LOOPBACK A software loopback interface. | |
51 | @constant IFNET_FAMILY_ETHERNET An Ethernet interface. | |
52 | @constant IFNET_FAMILY_SLIP A SLIP interface. | |
53 | @constant IFNET_FAMILY_TUN A tunnel interface. | |
54 | @constant IFNET_FAMILY_VLAN A virtual LAN interface. | |
55 | @constant IFNET_FAMILY_PPP A PPP interface. | |
56 | @constant IFNET_FAMILY_PVC A PVC interface. | |
57 | @constant IFNET_FAMILY_DISC A DISC interface. | |
58 | @constant IFNET_FAMILY_MDECAP A MDECAP interface. | |
59 | @constant IFNET_FAMILY_GIF A generic tunnel interface. | |
60 | @constant IFNET_FAMILY_FAITH A FAITH (IPv4/IPv6 translation) interface. | |
61 | @constant IFNET_FAMILY_STF A 6to4 interface. | |
62 | @constant IFNET_FAMILY_FIREWIRE An IEEE 1394 (firewire) interface. | |
63 | @constant IFNET_FAMILY_BOND A virtual bonded interface. | |
64 | */ | |
65 | ||
66 | enum { | |
67 | IFNET_FAMILY_ANY = 0, | |
68 | IFNET_FAMILY_LOOPBACK = 1, | |
69 | IFNET_FAMILY_ETHERNET = 2, | |
70 | IFNET_FAMILY_SLIP = 3, | |
71 | IFNET_FAMILY_TUN = 4, | |
72 | IFNET_FAMILY_VLAN = 5, | |
73 | IFNET_FAMILY_PPP = 6, | |
74 | IFNET_FAMILY_PVC = 7, | |
75 | IFNET_FAMILY_DISC = 8, | |
76 | IFNET_FAMILY_MDECAP = 9, | |
77 | IFNET_FAMILY_GIF = 10, | |
78 | IFNET_FAMILY_FAITH = 11, | |
79 | IFNET_FAMILY_STF = 12, | |
80 | IFNET_FAMILY_FIREWIRE = 13, | |
81 | IFNET_FAMILY_BOND = 14 | |
82 | }; | |
83 | /*! | |
84 | @typedef ifnet_family_t | |
85 | @abstract Storage type for the interface family. | |
86 | */ | |
87 | typedef u_int32_t ifnet_family_t; | |
88 | ||
89 | /*! | |
90 | @enum BPF tap mode | |
91 | @abstract Constants defining interface families. | |
92 | @constant BPF_MODE_DISABLED Disable bpf. | |
93 | @constant BPF_MODE_INPUT Enable input only. | |
94 | @constant BPF_MODE_OUTPUT Enable output only. | |
95 | @constant BPF_MODE_INPUT_OUTPUT Enable input and output. | |
96 | */ | |
97 | ||
98 | enum { | |
99 | BPF_MODE_DISABLED = 0, | |
100 | BPF_MODE_INPUT = 1, | |
101 | BPF_MODE_OUTPUT = 2, | |
102 | BPF_MODE_INPUT_OUTPUT = 3 | |
103 | }; | |
104 | /*! | |
105 | @typedef bpf_tap_mode | |
106 | @abstract Mode for tapping. BPF_MODE_DISABLED/BPF_MODE_INPUT_OUTPUT etc. | |
107 | */ | |
108 | typedef u_int32_t bpf_tap_mode; | |
109 | ||
110 | /*! | |
111 | @typedef protocol_family_t | |
112 | @abstract Storage type for the protocol family. | |
113 | */ | |
114 | typedef u_int32_t protocol_family_t; | |
115 | ||
116 | /*! | |
117 | @enum Interface Abilities | |
118 | @abstract Constants defining interface offload support. | |
119 | @constant IFNET_CSUM_IP Hardware will calculate IPv4 checksums. | |
120 | @constant IFNET_CSUM_TCP Hardware will calculate TCP checksums. | |
121 | @constant IFNET_CSUM_UDP Hardware will calculate UDP checksums. | |
122 | @constant IFNET_CSUM_FRAGMENT Hardware will checksum IP fragments. | |
123 | @constant IFNET_IP_FRAGMENT Hardware will fragment IP packets. | |
124 | @constant IFNET_VLAN_TAGGING Hardware will generate VLAN headers. | |
125 | @constant IFNET_VLAN_MTU Hardware supports VLAN MTU. | |
126 | */ | |
127 | ||
128 | enum { | |
129 | IFNET_CSUM_IP = 0x00000001, | |
130 | IFNET_CSUM_TCP = 0x00000002, | |
131 | IFNET_CSUM_UDP = 0x00000004, | |
132 | IFNET_CSUM_FRAGMENT = 0x00000008, | |
133 | IFNET_IP_FRAGMENT = 0x00000010, | |
134 | #ifdef KERNEL_PRIVATE | |
135 | IFNET_CSUM_SUM16 = 0x00001000, | |
136 | #endif | |
137 | IFNET_VLAN_TAGGING = 0x00010000, | |
138 | IFNET_VLAN_MTU = 0x00020000, | |
139 | }; | |
140 | /*! | |
141 | @typedef ifnet_offload_t | |
142 | @abstract Flags indicating the offload support of the interface. | |
143 | */ | |
144 | typedef u_int32_t ifnet_offload_t; | |
145 | ||
146 | /* | |
147 | * Callbacks | |
148 | * | |
149 | * These are function pointers you supply to the kernel in the interface. | |
150 | */ | |
151 | /*! | |
152 | @typedef bpf_packet_func | |
153 | ||
154 | @discussion bpf_packet_func The bpf_packet_func is used to intercept | |
155 | inbound and outbound packets. The tap function will never free | |
156 | the mbuf. The tap function will only copy the mbuf in to various | |
157 | bpf file descriptors tapping this interface. | |
158 | @param interface The interface being sent or received on. | |
159 | @param data The packet to be transmitted or received. | |
160 | @result An errno value or zero upon success. | |
161 | */ | |
162 | /* Fast path - do not block or spend excessive amounts of time */ | |
163 | typedef errno_t (*bpf_packet_func)(ifnet_t interface, mbuf_t data); | |
164 | ||
165 | /*! | |
166 | @typedef ifnet_output_func | |
167 | ||
168 | @discussion ifnet_output_func is used to transmit packets. The stack | |
169 | will pass fully formed packets, including frame header, to the | |
170 | ifnet_output function for an interface. The driver is | |
171 | responsible for freeing the mbuf. | |
172 | @param interface The interface being sent on. | |
173 | @param data The packet to be sent. | |
174 | */ | |
175 | /* Fast path - do not block or spend excessive amounts of time */ | |
176 | typedef errno_t (*ifnet_output_func)(ifnet_t interface, mbuf_t data); | |
177 | ||
178 | /*! | |
179 | @typedef ifnet_ioctl_func | |
180 | @discussion ifnet_ioctl_func is used to communicate ioctls from the | |
181 | stack to the driver. | |
182 | @param interface The interface the ioctl is being sent to. | |
183 | @param proto_family The protocol family to handle the ioctl, may be | |
184 | zero for no protocol_family. | |
185 | @param cmd The ioctl command. | |
186 | @param data A pointer to any data related to the ioctl. | |
187 | */ | |
188 | typedef errno_t (*ifnet_ioctl_func)(ifnet_t interface, u_int32_t cmd, void *data); | |
189 | ||
190 | /*! | |
191 | @typedef ifnet_set_bpf_tap | |
192 | @discussion ifnet_set_bpf_tap is used to set the bpf tap function to | |
193 | be called when packets are sent and/or received. | |
194 | @param interface The interface the bpf tap function is being set on. | |
195 | @param mode Sets the mode of the tap to either disabled, input, | |
196 | output, or input/output. | |
197 | @param callback A function pointer to be called when a packet is | |
198 | sent or received. | |
199 | */ | |
200 | typedef errno_t (*ifnet_set_bpf_tap)(ifnet_t interface, bpf_tap_mode mode, | |
201 | bpf_packet_func callback); | |
202 | ||
203 | /*! | |
204 | @typedef ifnet_detached_func | |
205 | @discussion ifnet_detached_func is called an interface is detached | |
206 | from the list of interfaces. When ifnet_detach is called, it may | |
207 | not detach the interface immediately if protocols are attached. | |
208 | ifnet_detached_func is used to notify the interface that it has | |
209 | been detached from the networking stack. This is the last | |
210 | function that will be called on an interface. Until this | |
211 | function returns, you must not unload a kext supplying function | |
212 | pointers to this interface, even if ifnet_detacah has been | |
213 | called. Your detach function may be called during your call to | |
214 | ifnet_detach. | |
215 | @param interface The interface that has been detached. | |
216 | event. | |
217 | */ | |
218 | typedef void (*ifnet_detached_func)(ifnet_t interface); | |
219 | ||
220 | /*! | |
221 | @typedef ifnet_demux_func | |
222 | @discussion ifnet_demux_func is called for each inbound packet to determine | |
223 | which protocol family the packet belongs to. This information is then | |
224 | used by the stack to determine which protocol to pass the packet to. | |
225 | This function may return protocol families for protocols that are | |
226 | not attached. If the protocol family has not been attached to the | |
227 | interface, the packet will be discarded. | |
228 | @param interface The interface the packet was received on. | |
229 | @param packet The mbuf containing the packet. | |
230 | @param frame_header A pointer to the frame header. | |
231 | @param protocol_family Upon return, the protocol family matching the | |
232 | packet should be stored here. | |
233 | @result | |
234 | If the result is zero, processing will continue normally. | |
235 | If the result is EJUSTRETURN, processing will stop but the packet will not be freed. | |
236 | If the result is anything else, the processing will stop and the packet will be freed. | |
237 | */ | |
238 | typedef errno_t (*ifnet_demux_func)(ifnet_t interface, mbuf_t packet, | |
239 | char *frame_header, | |
240 | protocol_family_t *protocol_family); | |
241 | ||
242 | /*! | |
243 | @typedef ifnet_event_func | |
244 | @discussion ifnet_event_func is called when an event occurs on a | |
245 | specific interface. | |
246 | @param interface The interface the event occurred on. | |
247 | @param event_ptr Pointer to a kern_event structure describing the | |
248 | event. | |
249 | */ | |
250 | typedef void (*ifnet_event_func)(ifnet_t interface, const struct kev_msg *msg); | |
251 | ||
252 | /*! | |
253 | @typedef ifnet_framer_func | |
254 | @discussion ifnet_framer_func is called for each outbound packet to | |
255 | give the interface an opportunity to prepend interface specific | |
256 | headers. | |
257 | @param interface The interface the packet is being sent on. | |
258 | @param packet Pointer to the mbuf containing the packet, caller may | |
259 | set this to a different mbuf upon return. This can happen if the | |
260 | frameout function needs to prepend another mbuf to the chain to | |
261 | have enough space for the header. | |
262 | @param dest The higher layer protocol destination (i.e. IP address). | |
263 | @param dest_linkaddr The link layer address as determined by the | |
264 | protocol's pre-output function. | |
265 | @param frame_type The frame type as determined by the protocol's | |
266 | pre-output function. | |
267 | @result | |
268 | If the result is zero, processing will continue normally. | |
269 | If the result is EJUSTRETURN, processing will stop but the packet will not be freed. | |
270 | If the result is anything else, the processing will stop and the packet will be freed. | |
271 | */ | |
272 | typedef errno_t (*ifnet_framer_func)(ifnet_t interface, mbuf_t *packet, | |
273 | const struct sockaddr *dest, | |
274 | const char *desk_linkaddr, | |
275 | const char *frame_type); | |
276 | ||
277 | /*! | |
278 | @typedef ifnet_add_proto_func | |
279 | @discussion if_add_proto_func is called by the stack when a protocol | |
280 | is attached to an interface. This gives the interface an | |
281 | opportunity to get a list of protocol description structures | |
282 | for demuxing packets to this protocol (demux descriptors). | |
283 | @param interface The interface the protocol will be attached to. | |
284 | @param protocol_family The family of the protocol being attached. | |
285 | @param demux_array An array of demux descriptors that describe | |
286 | the interface specific ways of identifying packets belonging | |
287 | to this protocol family. | |
288 | @param demux_count The number of demux descriptors in the array. | |
289 | @result | |
290 | If the result is zero, processing will continue normally. | |
291 | If the result is anything else, the add protocol will be aborted. | |
292 | */ | |
293 | typedef errno_t (*ifnet_add_proto_func)(ifnet_t interface, | |
294 | protocol_family_t protocol_family, | |
295 | const struct ifnet_demux_desc *demux_array, | |
296 | u_int32_t demux_count); | |
297 | ||
298 | /*! | |
299 | @typedef if_del_proto_func | |
300 | @discussion if_del_proto_func is called by the stack when a protocol | |
301 | is being detached from an interface. This gives the interface an | |
302 | opportunity to free any storage related to this specific | |
303 | protocol being attached to this interface. | |
304 | @param interface The interface the protocol will be detached from. | |
305 | @param protocol_family The family of the protocol being detached. | |
306 | @result | |
307 | If the result is zero, processing will continue normally. | |
308 | If the result is anything else, the detach will continue | |
309 | and the error will be returned to the caller. | |
310 | */ | |
311 | typedef errno_t (*ifnet_del_proto_func)(ifnet_t interface, | |
312 | protocol_family_t protocol_family); | |
313 | ||
314 | /*! | |
315 | @typedef ifnet_check_multi | |
316 | @discussion ifnet_check_multi is called for each multicast address | |
317 | added to an interface. This gives the interface an opportunity | |
318 | to reject invalid multicast addresses before they are attached | |
319 | to the interface. | |
320 | ||
321 | To prevent an address from being added to your multicast list, | |
322 | return EADDRNOTAVAIL. If you don't know how to parse/translate | |
323 | the address, return EOPNOTSUPP. | |
324 | @param The interface. | |
325 | @param mcast The multicast address. | |
326 | @result | |
327 | Zero upon success, EADDRNOTAVAIL on invalid multicast, | |
328 | EOPNOTSUPP for addresses the interface does not understand. | |
329 | */ | |
330 | typedef errno_t (*ifnet_check_multi)(ifnet_t interface, | |
331 | const struct sockaddr* mcast); | |
332 | ||
333 | /*! | |
334 | @typedef proto_media_input | |
335 | @discussion proto_media_input is called for all inbound packets for | |
336 | a specific protocol on a specific interface. This function is | |
337 | registered on an interface using ifnet_attach_protocol. | |
338 | @param ifp The interface the packet was received on. | |
339 | @param protocol_family The protocol of the packet received. | |
340 | @param packet The packet being input. | |
341 | @param header The frame header. | |
342 | @result | |
343 | If the result is zero, the caller will assume the packet was passed | |
344 | to the protocol. | |
345 | If the result is non-zero and not EJUSTRETURN, the caller will free | |
346 | the packet. | |
347 | */ | |
348 | typedef errno_t (*proto_media_input)(ifnet_t ifp, protocol_family_t protocol, | |
349 | mbuf_t packet, char* header); | |
350 | ||
351 | /*! | |
352 | @typedef proto_media_preout | |
353 | @discussion proto_media_preout is called just before the packet | |
354 | is transmitted. This gives the proto_media_preout function an | |
355 | opportunity to specify the media specific frame type and | |
356 | destination. | |
357 | @param ifp The interface the packet will be sent on. | |
358 | @param protocol_family The protocol of the packet being sent | |
359 | (PF_INET/etc...). | |
360 | @param packet The packet being sent. | |
361 | @param dest The protocol level destination address. | |
362 | @param route A pointer to the routing structure for the packet. | |
363 | @param frame_type The media specific frame type. | |
364 | @param link_layer_dest The media specific destination. | |
365 | @result | |
366 | If the result is zero, processing will continue normally. If the | |
367 | result is non-zero, processing will stop. If the result is | |
368 | non-zero and not EJUSTRETURN, the packet will be freed by the | |
369 | caller. | |
370 | */ | |
371 | typedef errno_t (*proto_media_preout)(ifnet_t ifp, protocol_family_t protocol, | |
372 | mbuf_t *packet, const struct sockaddr *dest, | |
373 | void *route, char *frame_type, char *link_layer_dest); | |
374 | ||
375 | /*! | |
376 | @typedef proto_media_event | |
377 | @discussion proto_media_event is called to notify this layer of | |
378 | interface specific events. | |
379 | @param ifp The interface. | |
380 | @param protocol_family The protocol family. | |
381 | @param kev_msg The event. | |
382 | */ | |
383 | typedef void (*proto_media_event)(ifnet_t ifp, protocol_family_t protocol, | |
384 | const struct kev_msg *event); | |
385 | ||
386 | /*! | |
387 | @typedef proto_media_ioctl | |
388 | @discussion proto_media_event allows this layer to handle ioctls. | |
389 | When an ioctl is handled, it is passed to the interface filters, | |
390 | protocol filters, protocol, and interface. If you do not support | |
391 | this ioctl, return EOPNOTSUPP. If you successfully handle the | |
392 | ioctl, return zero. If you return any error other than | |
393 | EOPNOTSUPP, other parts of the stack may not get an opportunity | |
394 | to process the ioctl. If you return EJUSTRETURN, processing will | |
395 | stop and a result of zero will be returned to the caller. | |
396 | @param ifp The interface. | |
397 | @param protocol_family The protocol family. | |
398 | @param command The ioctl command. | |
399 | @param argument The argument to the ioctl. | |
400 | @result | |
401 | See the discussion. | |
402 | */ | |
403 | typedef errno_t (*proto_media_ioctl)(ifnet_t ifp, protocol_family_t protocol, | |
404 | u_int32_t command, void* argument); | |
405 | ||
406 | /*! | |
407 | @typedef proto_media_detached | |
408 | @discussion proto_media_detached notifies you that your protocol | |
409 | has been detached. | |
410 | @param ifp The interface. | |
411 | @param protocol_family The protocol family. | |
412 | @result | |
413 | See the discussion. | |
414 | */ | |
415 | typedef errno_t (*proto_media_detached)(ifnet_t ifp, protocol_family_t protocol); | |
416 | ||
417 | ||
418 | /*! | |
419 | @typedef proto_media_resolve_multi | |
420 | @discussion proto_media_resolve_multi is called to resolve a | |
421 | protocol layer mulitcast address to a link layer multicast | |
422 | address. | |
423 | @param ifp The interface. | |
424 | @param proto_addr The protocol address. | |
425 | @param out_ll A sockaddr_dl to copy the link layer multicast in to. | |
426 | @param ll_len The length of data allocated for out_ll. | |
427 | @result Return zero on success or an errno error value on failure. | |
428 | */ | |
429 | typedef errno_t (*proto_media_resolve_multi)(ifnet_t ifp, | |
430 | const struct sockaddr *proto_addr, | |
431 | struct sockaddr_dl *out_ll, size_t ll_len); | |
432 | ||
433 | /*! | |
434 | @typedef proto_media_send_arp | |
435 | @discussion proto_media_send_arp is called by the stack to generate | |
436 | an ARP packet. This field is currently only used with IP. This | |
437 | function should inspect the parameters and transmit an arp | |
438 | packet using the information passed in. | |
439 | @param ifp The interface the arp packet should be sent on. | |
440 | @param protocol_family The protocol family of the addresses | |
441 | (PF_INET). | |
442 | @param arpop The arp operation (usually ARPOP_REQUEST or | |
443 | ARPOP_REPLY). | |
444 | @param sender_hw The value to use for the sender hardware | |
445 | address field. If this is NULL, use the hardware address | |
446 | of the interface. | |
447 | @param sender_proto The value to use for the sender protocol | |
448 | address field. This will not be NULL. | |
449 | @param target_hw The value to use for the target hardware address. | |
450 | If this is NULL, the target hardware address in the ARP packet | |
451 | should be NULL and the link-layer destination for the back | |
452 | should be a broadcast. If this is not NULL, this value should be | |
453 | used for both the link-layer destination and the target hardware | |
454 | address. | |
455 | @param target_proto The target protocol address. This will not be | |
456 | NULL. | |
457 | @result Return zero on success or an errno error value on failure. | |
458 | */ | |
459 | typedef errno_t (*proto_media_send_arp)(ifnet_t ifp, | |
460 | u_short arpop, | |
461 | const struct sockaddr_dl* sender_hw, | |
462 | const struct sockaddr* sender_proto, | |
463 | const struct sockaddr_dl* target_hw, | |
464 | const struct sockaddr* target_proto); | |
465 | ||
466 | /*! | |
467 | @struct ifnet_stat_increment_param | |
468 | @discussion This structure is used increment the counters on a | |
469 | network interface. | |
470 | @field packets_in The number of packets received. | |
471 | @field bytes_in The number of bytes received. | |
472 | @field errors_in The number of receive errors. | |
473 | @field packets_out The number of packets transmitted. | |
474 | @field bytes_out The number of bytes transmitted. | |
475 | @field errors_out The number of transmission errors. | |
476 | @field collisions The number of collisions seen by this interface. | |
477 | @field dropped The number of packets dropped. | |
478 | */ | |
479 | ||
480 | struct ifnet_stat_increment_param { | |
481 | u_int32_t packets_in; | |
482 | u_int32_t bytes_in; | |
483 | u_int32_t errors_in; | |
484 | ||
485 | u_int32_t packets_out; | |
486 | u_int32_t bytes_out; | |
487 | u_int32_t errors_out; | |
488 | ||
489 | u_int32_t collisions; | |
490 | u_int32_t dropped; | |
491 | }; | |
492 | ||
493 | /*! | |
494 | @struct ifnet_init_params | |
495 | @discussion This structure is used to define various properties of | |
496 | the interface when calling ifnet_init. A copy of these values | |
497 | will be stored in the ifnet and can not be modified while the | |
498 | interface is attached. | |
499 | @field uniqueid An identifier unique to this instance of the | |
500 | interface. | |
501 | @field uniqueid_len The length, in bytes, of the uniqueid. | |
502 | @field name The interface name (i.e. en). | |
503 | @field unit The interface unit number (en0's unit number is 0). | |
504 | @field family The interface family. | |
505 | @field type The interface type (see sys/if_types.h). Must be less | |
506 | than 256. For new types, use IFT_OTHER. | |
507 | @field output The output function for the interface. Every packet the | |
508 | stack attempts to send through this interface will go out through | |
509 | this function. | |
510 | @field demux The function used to determine the protocol family of an | |
511 | incoming packet. | |
512 | @field add_proto The function used to attach a protocol to this interface. | |
513 | @field del_proto The function used to remove a protocol from this interface. | |
514 | @field framer The function used to frame outbound packets, may be NULL. | |
515 | @field softc Driver specific storage. This value can be retrieved from the | |
516 | ifnet using the ifnet_softc function. | |
517 | @field ioctl The function used to handle ioctls. | |
518 | @field set_bpf_tap The function used to set the bpf_tap function. | |
519 | @field detach The function called to let the driver know the interface has been detached. | |
520 | @field event The function to notify the interface of various interface specific kernel events. | |
521 | @field broadcast_addr The link-layer broadcast address for this interface. | |
522 | @field broadcast_len The length of the link-layer broadcast address. | |
523 | */ | |
524 | ||
525 | struct ifnet_init_params { | |
526 | /* used to match recycled interface */ | |
527 | const void* uniqueid; /* optional */ | |
528 | u_int32_t uniqueid_len; /* optional */ | |
529 | ||
530 | /* used to fill out initial values for interface */ | |
531 | const char* name; /* required */ | |
532 | u_int32_t unit; /* required */ | |
533 | ifnet_family_t family; /* required */ | |
534 | u_int32_t type; /* required */ | |
535 | ifnet_output_func output; /* required */ | |
536 | ifnet_demux_func demux; /* required */ | |
537 | ifnet_add_proto_func add_proto; /* required */ | |
538 | ifnet_del_proto_func del_proto; /* required */ | |
539 | ifnet_check_multi check_multi; /* required for non point-to-point interfaces */ | |
540 | ifnet_framer_func framer; /* optional */ | |
541 | void* softc; /* optional */ | |
542 | ifnet_ioctl_func ioctl; /* optional */ | |
543 | ifnet_set_bpf_tap set_bpf_tap; /* optional */ | |
544 | ifnet_detached_func detach; /* optional */ | |
545 | ifnet_event_func event; /* optional */ | |
546 | const void *broadcast_addr;/* required for non point-to-point interfaces */ | |
547 | u_int32_t broadcast_len; /* required for non point-to-point interfaces */ | |
548 | }; | |
549 | ||
550 | /*! | |
551 | @struct ifnet_stats_param | |
552 | @discussion This structure is used get and set the interface | |
553 | statistics. | |
554 | @field packets_in The number of packets received. | |
555 | @field bytes_in The number of bytes received. | |
556 | @field errors_in The number of receive errors. | |
557 | @field packets_out The number of packets transmitted. | |
558 | @field bytes_out The number of bytes transmitted. | |
559 | @field errors_out The number of transmission errors. | |
560 | @field collisions The number of collisions seen by this interface. | |
561 | @field dropped The number of packets dropped. | |
562 | */ | |
563 | ||
564 | struct ifnet_stats_param { | |
565 | u_int64_t packets_in; | |
566 | u_int64_t bytes_in; | |
567 | u_int64_t multicasts_in; | |
568 | u_int64_t errors_in; | |
569 | ||
570 | u_int64_t packets_out; | |
571 | u_int64_t bytes_out; | |
572 | u_int64_t multicasts_out; | |
573 | u_int64_t errors_out; | |
574 | ||
575 | u_int64_t collisions; | |
576 | u_int64_t dropped; | |
577 | u_int64_t no_protocol; | |
578 | }; | |
579 | ||
580 | /*! | |
581 | @struct ifnet_demux_desc | |
582 | @discussion This structure is to identify packets that belong to a | |
583 | specific protocol. The types supported are interface specific. | |
584 | Ethernet supports ETHER_DESC_ETYPE2, ETHER_DESC_SAP, and | |
585 | ETHER_DESC_SNAP. The type defines the offset in the packet where | |
586 | the data will be matched as well as context. For example, if | |
587 | ETHER_DESC_SNAP is specified, the only valid datalen is 5 and | |
588 | only in the 5 bytes will only be matched when the packet header | |
589 | indicates that the packet is a SNAP packet. | |
590 | @field type The type of identifier data (i.e. ETHER_DESC_ETYPE2) | |
591 | @field data A pointer to an entry of type (i.e. pointer to 0x0800). | |
592 | @field datalen The number of bytes of data used to describe the | |
593 | packet. | |
594 | */ | |
595 | ||
596 | struct ifnet_demux_desc { | |
597 | u_int32_t type; | |
598 | void* data; | |
599 | u_int32_t datalen; | |
600 | }; | |
601 | ||
602 | /*! | |
603 | @struct ifnet_attach_proto_param | |
604 | @discussion This structure is used to attach a protocol to an | |
605 | interface. This structure provides the various functions for | |
606 | handling operations related to the protocol on the interface as | |
607 | well as information for how to demux packets for this protocol. | |
608 | @field demux_array An array of ifnet_demux_desc structures | |
609 | describing the protocol. | |
610 | @field demux_count The number of entries in the demux_array array. | |
611 | @field input The function to be called for inbound packets. | |
612 | @field pre_output The function to be called for outbound packets. | |
613 | @field event The function to be called for interface events. | |
614 | @field ioctl The function to be called for ioctls. | |
615 | @field detached The function to be called for handling the detach. | |
616 | */ | |
617 | #ifdef KERNEL_PRIVATE | |
618 | #define demux_list demux_array | |
619 | #endif /* KERNEL_PRIVATE */ | |
620 | ||
621 | struct ifnet_attach_proto_param { | |
622 | struct ifnet_demux_desc *demux_array; /* interface may/may not require */ | |
623 | u_int32_t demux_count; /* interface may/may not require */ | |
624 | ||
625 | proto_media_input input; /* required */ | |
626 | proto_media_preout pre_output; /* required */ | |
627 | proto_media_event event; /* optional */ | |
628 | proto_media_ioctl ioctl; /* optional */ | |
629 | proto_media_detached detached; /* optional */ | |
630 | proto_media_resolve_multi resolve; /* optional */ | |
631 | proto_media_send_arp send_arp; /* optional */ | |
632 | }; | |
633 | ||
634 | __BEGIN_DECLS | |
635 | ||
636 | /* | |
637 | * Ifnet creation and reference counting | |
638 | */ | |
639 | ||
640 | /*! | |
641 | @function ifnet_allocate | |
642 | @discussion Allocate an ifnet_t with an initial refcount of 1. Many | |
643 | parts of the stack do not properly refcount the ifnet_t. In | |
644 | order to avoid freeing the ifnet_t while some parts of the stack | |
645 | may contain a reference to it, the ifnet_ts are only recycled, | |
646 | never freed. A unique id is used to try and recycle the same | |
647 | ifnet_t when allocating an interface. For example, for an | |
648 | ethernet interface, the hardware address of the ethernet card is | |
649 | usually used for the uniqueid. If a PC Card is removed and | |
650 | inserted again, if the ethernet address of the PC card is used, | |
651 | the same ifnet_t will be used for the card the second time it is | |
652 | inserted. In the future, when the ifnet_t is correctly | |
653 | refcounted by all of the stack, the interfaces may be freed and | |
654 | the unique ids ignored. | |
655 | @param init The initial values for the interface. These values can | |
656 | not be changed after the interface has been allocated. | |
657 | @param interface The interface allocated upon success. | |
658 | @result May return ENOMEM if there is insufficient memory or EEXIST | |
659 | if an interface with the same uniqueid and family has already | |
660 | been allocated and is in use. | |
661 | */ | |
662 | errno_t ifnet_allocate(const struct ifnet_init_params *init, ifnet_t *interface); | |
663 | ||
664 | /*! | |
665 | @function ifnet_reference | |
666 | @discussion Increment the reference count of the ifnet to assure | |
667 | that it will not go away. The interface must already have at | |
668 | least one reference. | |
669 | @param interface The interface to increment the reference count of. | |
670 | @result May return EINVAL if the interface is not valid. | |
671 | */ | |
672 | errno_t ifnet_reference(ifnet_t interface); | |
673 | ||
674 | /*! | |
675 | @function ifnet_release | |
676 | @discussion Release a reference of the ifnet, this may trigger a | |
677 | free if the reference count reaches 0. | |
678 | @param interface The interface to decrement the reference count of | |
679 | and possibly free. | |
680 | @result May return EINVAL if the interface is not valid. | |
681 | */ | |
682 | errno_t ifnet_release(ifnet_t interface); | |
683 | ||
684 | /*! | |
685 | @function ifnet_attach | |
686 | @discussion Attaches an interface to the global interface list. The | |
687 | interface must be setup properly before calling attach. The | |
688 | stack will take a reference on the interface and hold it until | |
689 | ifnet_detach is called. | |
690 | ||
691 | This function is intended to be called by the driver. A kext | |
692 | must not call this function on an interface the kext does not | |
693 | own. | |
694 | @param interface The interface to attach. | |
695 | @param ll_addr The link layer address of the interface. This is used | |
696 | to fill out the first ifaddr in the list of addresses for the | |
697 | interface. This parameter is not required for interfaces such as | |
698 | PPP that have no link-layer address. | |
699 | @result Will return an error if there is anything wrong with the | |
700 | interface. | |
701 | */ | |
702 | errno_t ifnet_attach(ifnet_t interface, const struct sockaddr_dl *ll_addr); | |
703 | ||
704 | /*! | |
705 | @function ifnet_detach | |
706 | @discussion Detaches the interface. | |
707 | ||
708 | Call this to indicate this interface is no longer valid (i.e. PC | |
709 | Card was removed). This function will begin the process of | |
710 | removing knowledge of this interface from the stack. | |
711 | ||
712 | The function will return before the interface is detached. The | |
713 | functions you supplied in to the interface may continue to be | |
714 | called. When the detach has been completed, your detached | |
715 | function will be called. Your kext must not unload until the | |
716 | detached function has been called. The interface will be | |
717 | properly freed when the reference count reaches zero. | |
718 | ||
719 | An interface may not be attached again. You must call | |
720 | ifnet_allocate to create a new interface to attach. | |
721 | ||
722 | This function is intended to be called by the driver. A kext | |
723 | must not call this function on an interface the kext does not | |
724 | own. | |
725 | @param interface The interface to detach. | |
726 | @result 0 on success, otherwise errno error. | |
727 | */ | |
728 | errno_t ifnet_detach(ifnet_t interface); | |
729 | ||
730 | /* | |
731 | * Interface manipulation. | |
732 | */ | |
733 | ||
734 | /*! | |
735 | @function ifnet_softc | |
736 | @discussion Returns the driver's private storage on the interface. | |
737 | @param interface Interface to retrieve the storage from. | |
738 | @result Driver's private storage. | |
739 | */ | |
740 | void* ifnet_softc(ifnet_t interface); | |
741 | ||
742 | /*! | |
743 | @function ifnet_name | |
744 | @discussion Returns a pointer to the name of the interface. | |
745 | @param interface Interface to retrieve the name from. | |
746 | @result Pointer to the name. | |
747 | */ | |
748 | const char* ifnet_name(ifnet_t interface); | |
749 | ||
750 | /*! | |
751 | @function ifnet_family | |
752 | @discussion Returns the family of the interface. | |
753 | @param interface Interface to retrieve the unit number from. | |
754 | @result Unit number. | |
755 | */ | |
756 | ifnet_family_t ifnet_family(ifnet_t interface); | |
757 | ||
758 | /*! | |
759 | @function ifnet_unit | |
760 | @discussion Returns the unit number of the interface. | |
761 | @param interface Interface to retrieve the unit number from. | |
762 | @result Unit number. | |
763 | */ | |
764 | u_int32_t ifnet_unit(ifnet_t interface); | |
765 | ||
766 | /*! | |
767 | @function ifnet_index | |
768 | @discussion Returns the index of the interface. This index value | |
769 | will match the index you would find in a sockaddr_dl or using | |
770 | if_nametoindex or if_indextoname in user space. The value of the | |
771 | interface index is undefined for an interface that is not | |
772 | currently attached. | |
773 | @param interface Interface to retrieve the index of. | |
774 | @result Index. | |
775 | */ | |
776 | u_int32_t ifnet_index(ifnet_t interface); | |
777 | ||
778 | /*! | |
779 | @function ifnet_set_flags | |
780 | @discussion Sets the interface flags to match new_flags. | |
781 | @discussion Sets the interface flags to new_flags. This function | |
782 | lets you specify which flags you want to change using the mask. | |
783 | The kernel will effectively take the lock, then set the | |
784 | interface's flags to (if_flags & ~mask) | (new_flags & mask). | |
785 | @param interface Interface to set the flags on. | |
786 | @param new_flags The new set of flags that should be set. These | |
787 | flags are defined in net/if.h | |
788 | @result 0 on success otherwise the errno error. | |
789 | */ | |
790 | errno_t ifnet_set_flags(ifnet_t interface, u_int16_t new_flags, u_int16_t mask); | |
791 | ||
792 | /*! | |
793 | @function ifnet_flags | |
794 | @discussion Returns the interface flags that are set. | |
795 | @param interface Interface to retrieve the flags from. | |
796 | @result Flags. These flags are defined in net/if.h | |
797 | */ | |
798 | u_int16_t ifnet_flags(ifnet_t interface); | |
799 | ||
800 | ||
801 | #ifdef KERNEL_PRIVATE | |
802 | /*! | |
803 | @function ifnet_set_eflags | |
804 | @discussion Sets the extended interface flags to new_flags. This | |
805 | function lets you specify which flags you want to change using | |
806 | the mask. The kernel will effectively take the lock, then set | |
807 | the interface's extended flags to (if_eflags & ~mask) | | |
808 | (new_flags & mask). | |
809 | @param interface The interface. | |
810 | @param new_flags The new set of flags that should be set. These | |
811 | flags are defined in net/if.h | |
812 | @param mask The mask of flags to be modified. | |
813 | @result 0 on success otherwise the errno error. | |
814 | */ | |
815 | errno_t ifnet_set_eflags(ifnet_t interface, u_int32_t new_flags, u_int32_t mask); | |
816 | ||
817 | /*! | |
818 | @function ifnet_eflags | |
819 | @discussion Returns the extended interface flags that are set. | |
820 | @param interface Interface to retrieve the flags from. | |
821 | @result Extended flags. These flags are defined in net/if.h | |
822 | */ | |
823 | u_int32_t ifnet_eflags(ifnet_t interface); | |
824 | #endif | |
825 | ||
826 | /*! | |
827 | @function ifnet_set_offload | |
828 | @discussion Sets a bitfield to indicate special hardware offload | |
829 | support provided by the interface such as hardware checksums and | |
830 | VLAN. This replaces the if_hwassist flags field. Any flags | |
831 | unrecognized by the stack will not be set. | |
832 | @param interface The interface. | |
833 | @param offload The new set of flags indicating which offload options | |
834 | the device supports. | |
835 | @param mask The mask of flags to be modified. | |
836 | @result 0 on success otherwise the errno error. | |
837 | */ | |
838 | errno_t ifnet_set_offload(ifnet_t interface, ifnet_offload_t offload); | |
839 | ||
840 | /*! | |
841 | @function ifnet_offload | |
842 | @discussion Returns flags indicating which operations can be | |
843 | offloaded to the interface. | |
844 | @param interface Interface to retrieve the offload from. | |
845 | @result Abilities flags, see ifnet_offload_t. | |
846 | */ | |
847 | ifnet_offload_t ifnet_offload(ifnet_t interface); | |
848 | ||
849 | /*! | |
850 | @function ifnet_set_link_mib_data | |
851 | @discussion Sets the mib link data. The ifnet_t will store the | |
852 | pointer you supply and copy mibLen bytes from the pointer | |
853 | whenever the sysctl for getting interface specific MIB data is | |
854 | used. Since the ifnet_t stores a pointer to your data instead of | |
855 | a copy, you may update the data at the address at any time. | |
856 | ||
857 | This function is intended to be called by the driver. A kext | |
858 | must not call this function on an interface the kext does not | |
859 | own. | |
860 | @param interface Interface to set the unit number of. | |
861 | @param mibData A pointer to the data. | |
862 | @param mibLen Length of data pointed to. | |
863 | @result 0 on success otherwise the errno error. | |
864 | */ | |
865 | errno_t ifnet_set_link_mib_data(ifnet_t interface, void *mibData, u_int32_t mibLen); | |
866 | ||
867 | /*! | |
868 | @function ifnet_get_link_mib_data | |
869 | @discussion Copies the link MIB data in to mibData, up to mibLen | |
870 | bytes. Returns error if the buffer is too small to hold all of | |
871 | the MIB data. | |
872 | @param interface The interface. | |
873 | @param mibData A pointer to space for the mibData to be copied in | |
874 | to. | |
875 | @param mibLen When calling, this should be the size of the buffer | |
876 | passed in mibData. Upon return, this will be the size of data | |
877 | copied in to mibData. | |
878 | @result Returns an error if the buffer size is too small or there is | |
879 | no data. | |
880 | */ | |
881 | errno_t ifnet_get_link_mib_data(ifnet_t interface, void *mibData, u_int32_t *mibLen); | |
882 | ||
883 | /*! | |
884 | @function ifnet_get_link_mib_data_length | |
885 | @discussion Retrieve the size of the mib data. | |
886 | @param interface The interface. | |
887 | @result Returns the number of bytes of mib data associated with the | |
888 | interface. | |
889 | */ | |
890 | u_int32_t ifnet_get_link_mib_data_length(ifnet_t interface); | |
891 | ||
892 | /*! | |
893 | @function ifnet_attach_protocol | |
894 | @discussion Attaches a protocol to an interface. | |
895 | @param interface The interface. | |
896 | @param protocol_family The protocol family being attached | |
897 | (PF_INET/PF_APPLETALK/etc...). | |
898 | @param proto_details Details of the protocol being attached. | |
899 | @result 0 on success otherwise the errno error. | |
900 | */ | |
901 | errno_t ifnet_attach_protocol(ifnet_t interface, protocol_family_t protocol_family, | |
902 | const struct ifnet_attach_proto_param *proto_details); | |
903 | ||
904 | /*! | |
905 | @function ifnet_detach_protocol | |
906 | @discussion Detaches a protocol from an interface. | |
907 | @param interface The interface. | |
908 | @param protocol_family The protocol family of the protocol to | |
909 | detach. | |
910 | @result 0 on success otherwise the errno error. | |
911 | */ | |
912 | errno_t ifnet_detach_protocol(ifnet_t interface, protocol_family_t protocol_family); | |
913 | ||
914 | /*! | |
915 | @function ifnet_output | |
916 | @discussion Handles an outbound packet on the interface by calling | |
917 | any filters, a protocol preoutput function, the interface framer | |
918 | function, and finally the interface's output function. The | |
919 | protocol_family will be used to apply protocol filters and | |
920 | determine which preoutput function to call. The route and dest | |
921 | parameters will be passed to the preoutput function defined for | |
922 | the attachment of the specified protocol to the specified | |
923 | interface. ifnet_output will free the mbuf chain in the event of | |
924 | an error. | |
925 | @param interface The interface. | |
926 | @param protocol_family The family of the protocol generating this | |
927 | packet (i.e. AF_INET). | |
928 | @param packet The packet to be transmitted. | |
929 | @param route A pointer to a routing structure for this packet. The | |
930 | preoutput function determines whether this value may be NULL or | |
931 | not. | |
932 | @param dest The destination address of protocol_family type. This | |
933 | will be passed to the preoutput function. If the preoutput | |
934 | function does not require this value, you may pass NULL. | |
935 | @result 0 on success otherwise the errno error. | |
936 | */ | |
937 | errno_t ifnet_output(ifnet_t interface, protocol_family_t protocol_family, mbuf_t packet, | |
938 | void* route, const struct sockaddr *dest); | |
939 | ||
940 | /*! | |
941 | @function ifnet_output_raw | |
942 | @discussion Handles and outbond raw packet on the interface by | |
943 | calling any filters followed by the interface's output function. | |
944 | protocol_family may be zero. If the packet is from a specific | |
945 | protocol the protocol_family will be used to apply protocol | |
946 | filters. All interface filters will be applied to the outgoing | |
947 | packet. Processing, such as calling the protocol preoutput and | |
948 | interface framer functions will be bypassed. The packet will | |
949 | pass through the filters and be sent on the interface as is. | |
950 | ifnet_output_raw will free the packet chain in the event of an | |
951 | error. | |
952 | @param interface The interface. | |
953 | @param protocol_family The family of the protocol generating this | |
954 | packet (i.e. AF_INET). | |
955 | @param packet The fully formed packet to be transmitted. | |
956 | @result 0 on success otherwise the errno error. | |
957 | */ | |
958 | errno_t ifnet_output_raw(ifnet_t interface, protocol_family_t protocol_family, mbuf_t packet); | |
959 | ||
960 | /*! | |
961 | @function ifnet_input | |
962 | @discussion Inputs packets from the interface. The interface's demux | |
963 | will be called to determine the protocol. Once the protocol is | |
964 | determined, the interface filters and protocol filters will be | |
965 | called. From there, the packet will be passed to the registered | |
966 | protocol. If there is an error, the mbuf chain will be freed. | |
967 | @param interface The interface. | |
968 | @param first_packet The first packet in a chain of packets. | |
969 | @param stats Counts to be integrated in to the stats. The interface | |
970 | statistics will be incremented by the amounts specified in | |
971 | stats. This parameter may be NULL. | |
972 | @result 0 on success otherwise the errno error. | |
973 | */ | |
974 | errno_t ifnet_input(ifnet_t interface, mbuf_t first_packet, | |
975 | const struct ifnet_stat_increment_param *stats); | |
976 | ||
977 | /*! | |
978 | @function ifnet_ioctl | |
979 | @discussion Calls the interface's ioctl function with the parameters | |
980 | passed. | |
981 | @param interface The interface. | |
982 | @param protocol The protocol family of the protocol to send the | |
983 | ioctl to (may be zero). Some ioctls apply to a protocol while | |
984 | other ioctls apply to just an interface. | |
985 | @param ioctl_code The ioctl to perform. | |
986 | @param ioctl_arg Any parameters to the ioctl. | |
987 | @result 0 on success otherwise the errno error. | |
988 | */ | |
989 | errno_t ifnet_ioctl(ifnet_t interface, protocol_family_t protocol, | |
990 | u_int32_t ioctl_code, void *ioctl_arg); | |
991 | ||
992 | /*! | |
993 | @function ifnet_event | |
994 | @discussion Calls the interface's event function. | |
995 | @param interface The interface. | |
996 | @param event_ptr Pointer to an kern_event structure describing the | |
997 | event. | |
998 | @result 0 on success otherwise the errno error. | |
999 | */ | |
1000 | errno_t ifnet_event(ifnet_t interface, struct kern_event_msg* event_ptr); | |
1001 | ||
1002 | /*! | |
1003 | @function ifnet_set_mtu | |
1004 | @discussion Sets the value of the MTU in the interface structure. | |
1005 | Calling this function will not notify the driver that the MTU | |
1006 | should be changed. Use the appropriate ioctl. | |
1007 | ||
1008 | This function is intended to be called by the driver. A kext | |
1009 | must not call this function on an interface the kext does not | |
1010 | own. | |
1011 | @param interface The interface. | |
1012 | @param mtu The new MTU. | |
1013 | @result 0 on success otherwise the errno error. | |
1014 | */ | |
1015 | errno_t ifnet_set_mtu(ifnet_t interface, u_int32_t mtu); | |
1016 | ||
1017 | /*! | |
1018 | @function ifnet_mtu | |
1019 | @param interface The interface. | |
1020 | @result The MTU. | |
1021 | */ | |
1022 | u_int32_t ifnet_mtu(ifnet_t interface); | |
1023 | ||
1024 | /*! | |
1025 | @function ifnet_type | |
1026 | @param interface The interface. | |
1027 | @result The type. See net/if_types.h. | |
1028 | */ | |
1029 | u_int8_t ifnet_type(ifnet_t interface); | |
1030 | ||
1031 | /*! | |
1032 | @function ifnet_set_addrlen | |
1033 | @discussion | |
1034 | This function is intended to be called by the driver. A kext | |
1035 | must not call this function on an interface the kext does not | |
1036 | own. | |
1037 | @param interface The interface. | |
1038 | @param addrlen The new address length. | |
1039 | @result 0 on success otherwise the errno error. | |
1040 | */ | |
1041 | errno_t ifnet_set_addrlen(ifnet_t interface, u_int8_t addrlen); | |
1042 | ||
1043 | /*! | |
1044 | @function ifnet_addrlen | |
1045 | @param interface The interface. | |
1046 | @result The address length. | |
1047 | */ | |
1048 | u_int8_t ifnet_addrlen(ifnet_t interface); | |
1049 | ||
1050 | /*! | |
1051 | @function ifnet_set_hdrlen | |
1052 | @discussion | |
1053 | This function is intended to be called by the driver. A kext | |
1054 | must not call this function on an interface the kext does not | |
1055 | own. | |
1056 | @param interface The interface. | |
1057 | @param hdrlen The new header length. | |
1058 | @result 0 on success otherwise the errno error. | |
1059 | */ | |
1060 | errno_t ifnet_set_hdrlen(ifnet_t interface, u_int8_t hdrlen); | |
1061 | ||
1062 | /*! | |
1063 | @function ifnet_hdrlen | |
1064 | @param interface The interface. | |
1065 | @result The header length. | |
1066 | */ | |
1067 | u_int8_t ifnet_hdrlen(ifnet_t interface); | |
1068 | ||
1069 | /*! | |
1070 | @function ifnet_set_metric | |
1071 | @discussion | |
1072 | This function is intended to be called by the driver. A kext | |
1073 | must not call this function on an interface the kext does not | |
1074 | own. | |
1075 | @param interface The interface. | |
1076 | @param metric The new metric. | |
1077 | @result 0 on success otherwise the errno error. | |
1078 | */ | |
1079 | errno_t ifnet_set_metric(ifnet_t interface, u_int32_t metric); | |
1080 | ||
1081 | /*! | |
1082 | @function ifnet_metric | |
1083 | @param interface The interface. | |
1084 | @result The metric. | |
1085 | */ | |
1086 | u_int32_t ifnet_metric(ifnet_t interface); | |
1087 | ||
1088 | /*! | |
1089 | @function ifnet_set_baudrate | |
1090 | @discussion | |
1091 | This function is intended to be called by the driver. A kext | |
1092 | must not call this function on an interface the kext does not | |
1093 | own. | |
1094 | @param interface The interface. | |
1095 | @param baudrate The new baudrate. | |
1096 | @result 0 on success otherwise the errno error. | |
1097 | */ | |
1098 | errno_t ifnet_set_baudrate(ifnet_t interface, u_int64_t baudrate); | |
1099 | ||
1100 | /*! | |
1101 | @function ifnet_baudrate | |
1102 | @param interface The interface. | |
1103 | @result The baudrate. | |
1104 | */ | |
1105 | u_int64_t ifnet_baudrate(ifnet_t interface); | |
1106 | ||
1107 | /*! | |
1108 | @function ifnet_stat_increment | |
1109 | @discussion | |
1110 | This function is intended to be called by the driver. A kext | |
1111 | must not call this function on an interface the kext does not | |
1112 | own. | |
1113 | @param interface The interface. | |
1114 | @param counts A pointer to a structure containing the amount to | |
1115 | increment each counter by. Any counts not appearing in the | |
1116 | ifnet_counter_increment structure are handled in the stack. | |
1117 | @result 0 on success otherwise the errno error. | |
1118 | */ | |
1119 | errno_t ifnet_stat_increment(ifnet_t interface, | |
1120 | const struct ifnet_stat_increment_param *counts); | |
1121 | ||
1122 | /*! | |
1123 | @function ifnet_stat_increment_in | |
1124 | @discussion | |
1125 | This function is intended to be called by the driver. This | |
1126 | function allows a driver to update the inbound interface counts. | |
1127 | The most efficient time to update these counts is when calling | |
1128 | ifnet_input. | |
1129 | ||
1130 | A lock protects the counts, this makes the increment functions | |
1131 | expensive. The increment function will update the lastchanged | |
1132 | value. | |
1133 | @param interface The interface. | |
1134 | @param packets_in The number of additional packets received. | |
1135 | @param bytes_in The number of additional bytes received. | |
1136 | @param errors_in The number of additional receive errors. | |
1137 | @result 0 on success otherwise the errno error. | |
1138 | */ | |
1139 | errno_t ifnet_stat_increment_in(ifnet_t interface, | |
1140 | u_int32_t packets_in, u_int32_t bytes_in, | |
1141 | u_int32_t errors_in); | |
1142 | ||
1143 | /*! | |
1144 | @function ifnet_stat_increment_out | |
1145 | @discussion | |
1146 | This function is intended to be called by the driver. This | |
1147 | function allows a driver to update the outbound interface counts. | |
1148 | ||
1149 | A lock protects the counts, this makes the increment functions | |
1150 | expensive. The increment function will update the lastchanged | |
1151 | value. | |
1152 | @param interface The interface. | |
1153 | @param packets_out The number of additional packets sent. | |
1154 | @param bytes_out The number of additional bytes sent. | |
1155 | @param errors_out The number of additional send errors. | |
1156 | @result 0 on success otherwise the errno error. | |
1157 | */ | |
1158 | errno_t ifnet_stat_increment_out(ifnet_t interface, | |
1159 | u_int32_t packets_out, u_int32_t bytes_out, | |
1160 | u_int32_t errors_out); | |
1161 | ||
1162 | /*! | |
1163 | @function ifnet_set_stat | |
1164 | @discussion | |
1165 | This function is intended to be called by the driver. A kext | |
1166 | must not call this function on an interface the kext does not | |
1167 | own. | |
1168 | ||
1169 | The one exception would be the case where a kext wants to zero | |
1170 | all of the counters. | |
1171 | @param interface The interface. | |
1172 | @param counts The new stats values. | |
1173 | @result 0 on success otherwise the errno error. | |
1174 | */ | |
1175 | errno_t ifnet_set_stat(ifnet_t interface, | |
1176 | const struct ifnet_stats_param *stats); | |
1177 | ||
1178 | /*! | |
1179 | @function ifnet_stat | |
1180 | @param interface The interface. | |
1181 | @param out_stats Storage for the values. | |
1182 | @result 0 on success otherwise the errno error. | |
1183 | */ | |
1184 | errno_t ifnet_stat(ifnet_t interface, | |
1185 | struct ifnet_stats_param *out_stats); | |
1186 | ||
1187 | /*! | |
1188 | @function ifnet_set_promiscuous | |
1189 | @discussion Enable or disable promiscuous mode on the interface. The | |
1190 | interface keeps an internal count of the number of times | |
1191 | promiscuous mode has been enabled. Promiscuous mode is only | |
1192 | disabled when this count reaches zero. Be sure to disable | |
1193 | promiscuous mode only once for every time you enable it. | |
1194 | @param interface The interface to toggle promiscuous mode on. | |
1195 | @param on If set, the number of promicuous on requests will be | |
1196 | incremented. If this is the first requrest, promiscuous mode | |
1197 | will be enabled. If this is not set, the number of promiscous | |
1198 | clients will be decremented. If this causes the number to reach | |
1199 | zero, promiscuous mode will be disabled. | |
1200 | @result 0 on success otherwise the errno error. | |
1201 | */ | |
1202 | errno_t ifnet_set_promiscuous(ifnet_t interface, int on); | |
1203 | ||
1204 | /*! | |
1205 | @function ifnet_touch_lastchange | |
1206 | @discussion Updates the lastchange value to now. | |
1207 | @param interface The interface. | |
1208 | @result 0 on success otherwise the errno error. | |
1209 | */ | |
1210 | errno_t ifnet_touch_lastchange(ifnet_t interface); | |
1211 | ||
1212 | /*! | |
1213 | @function ifnet_lastchange | |
1214 | @param interface The interface. | |
1215 | @param last_change A timeval struct to copy the last time changed in | |
1216 | to. | |
1217 | */ | |
1218 | errno_t ifnet_lastchange(ifnet_t interface, struct timeval *last_change); | |
1219 | ||
1220 | /*! | |
1221 | @function ifnet_get_address_list | |
1222 | @discussion Get a list of addresses on the interface. Passing NULL | |
1223 | for the interface will return a list of all addresses. The | |
1224 | addresses will have their reference count bumped so they will | |
1225 | not go away. Calling ifnet_free_address_list will decrement the | |
1226 | refcount and free the array. If you wish to hold on to a | |
1227 | reference to an ifaddr_t, be sure to bump the reference count | |
1228 | before calling ifnet_free_address_list. | |
1229 | @param interface The interface. | |
1230 | @param addresses A pointer to a NULL terminated array of ifaddr_ts. | |
1231 | @result 0 on success otherwise the errno error. | |
1232 | */ | |
1233 | errno_t ifnet_get_address_list(ifnet_t interface, ifaddr_t **addresses); | |
1234 | ||
1235 | /*! | |
1236 | @function ifnet_get_address_list_family | |
1237 | @discussion Get a list of addresses on the interface. Passing NULL | |
1238 | for the interface will return a list of all addresses. The | |
1239 | addresses will have their reference count bumped so they will | |
1240 | not go away. Calling ifnet_free_address_list will decrement the | |
1241 | refcount and free the array. If you wish to hold on to a | |
1242 | reference to an ifaddr_t, be sure to bump the reference count | |
1243 | before calling ifnet_free_address_list. Unlike | |
1244 | ifnet_get_address_list, this function lets the caller specify | |
1245 | the address family to get a list of only a specific address type. | |
1246 | @param interface The interface. | |
1247 | @param addresses A pointer to a NULL terminated array of ifaddr_ts. | |
1248 | @result 0 on success otherwise the errno error. | |
1249 | */ | |
1250 | errno_t ifnet_get_address_list_family(ifnet_t interface, ifaddr_t **addresses, sa_family_t family); | |
1251 | ||
1252 | /*! | |
1253 | @function ifnet_free_address_list | |
1254 | @discussion Free a list of addresses returned from | |
1255 | ifnet_get_address_list. Decrements the refcounts and frees the | |
1256 | memory used for the array of references. | |
1257 | @param addresses An array of ifaddr_ts. | |
1258 | */ | |
1259 | void ifnet_free_address_list(ifaddr_t *addresses); | |
1260 | ||
1261 | /*! | |
1262 | @function ifnet_set_lladdr | |
1263 | @discussion Sets the link-layer address for this interface. | |
1264 | @param interface The interface the link layer address is being | |
1265 | changed on. | |
1266 | @param lladdr A pointer to the raw link layer address (pointer to | |
1267 | the 6 byte ethernet address for ethernet). | |
1268 | @param lladdr_len The length, in bytes, of the link layer address. | |
1269 | */ | |
1270 | errno_t ifnet_set_lladdr(ifnet_t interface, const void* lladdr, size_t lladdr_len); | |
1271 | ||
1272 | /*! | |
1273 | @function ifnet_lladdr_copy_bytes | |
1274 | @discussion Copies the bytes of the link-layer address in to the | |
1275 | specified buffer. | |
1276 | @param interface The interface to copy the link-layer address from. | |
1277 | @param lladdr The buffer to copy the link-layer address in to. | |
1278 | @param length The length of the buffer. This value must match the | |
1279 | length of the link-layer address. | |
1280 | */ | |
1281 | errno_t ifnet_lladdr_copy_bytes(ifnet_t interface, void* lladdr, size_t length); | |
1282 | ||
1283 | #ifdef KERNEL_PRIVATE | |
1284 | /*! | |
1285 | @function ifnet_lladdr | |
1286 | @discussion Returns a pointer to the link-layer address. | |
1287 | @param interface The interface the link-layer address is on. | |
1288 | */ | |
1289 | void* ifnet_lladdr(ifnet_t interface); | |
1290 | #endif KERNEL_PRIVATE | |
1291 | ||
1292 | /*! | |
1293 | @function ifnet_llbroadcast_copy_bytes | |
1294 | @discussion Retrieves the link-layer broadcast address for this | |
1295 | interface. | |
1296 | @param interface The interface. | |
1297 | @param addr A buffer to copy the broadcast address in to. | |
1298 | @param bufferlen The length of the buffer at addr. | |
1299 | @param addr_len On return, the length of the broadcast address. | |
1300 | @param lladdr_len The length, in bytes, of the link layer address. | |
1301 | */ | |
1302 | errno_t ifnet_llbroadcast_copy_bytes(ifnet_t interface, void* addr, | |
1303 | size_t bufferlen, size_t* addr_len); | |
1304 | ||
1305 | #ifdef KERNEL_PRIVATE | |
1306 | /*! | |
1307 | @function ifnet_set_lladdr_and_type | |
1308 | @discussion Sets the link-layer address as well as the type field in | |
1309 | the sockaddr_dl. Support for setting the type was added for vlan | |
1310 | and bond interfaces. | |
1311 | @param interface The interface the link layer address is being | |
1312 | changed on. | |
1313 | @param lladdr A pointer to the raw link layer address (pointer to | |
1314 | the 6 byte ethernet address for ethernet). | |
1315 | @param lladdr_len The length, in bytes, of the link layer address. | |
1316 | @param type The link-layer address type. | |
1317 | */ | |
1318 | errno_t ifnet_set_lladdr_and_type(ifnet_t interface, const void* lladdr, size_t length, u_char type); | |
1319 | #endif KERNEL_PRIVATE | |
1320 | ||
1321 | /*! | |
1322 | @function ifnet_add_multicast | |
1323 | @discussion Joins a multicast and returns an ifmultiaddr_t with the | |
1324 | reference count incremented for you. You are responsible for | |
1325 | decrementing the reference count after calling | |
1326 | ifnet_remove_multicast and making sure you no longer have any | |
1327 | references to the multicast. | |
1328 | @param interface The interface. | |
1329 | @param maddr The multicast address to join. Either a physical | |
1330 | address or logical address to be translated to a physical | |
1331 | address. | |
1332 | @param multicast The resulting ifmultiaddr_t multicast address. | |
1333 | @result 0 on success otherwise the errno error. | |
1334 | */ | |
1335 | errno_t ifnet_add_multicast(ifnet_t interface, const struct sockaddr *maddr, | |
1336 | ifmultiaddr_t *multicast); | |
1337 | ||
1338 | /*! | |
1339 | @function ifnet_remove_multicast | |
1340 | @discussion Causes the interface to leave the multicast group. The | |
1341 | stack keeps track of how many times ifnet_add_multicast has been | |
1342 | called for a given multicast address. The multicast will only be | |
1343 | removed when the number of times ifnet_remove_multicast has been | |
1344 | called matches the number of times ifnet_add_multicast has been | |
1345 | called. | |
1346 | ||
1347 | The memory for the multicast address is not actually freed until | |
1348 | the separate reference count has reached zero. Some parts of the | |
1349 | stack may keep a pointer to the multicast even after that | |
1350 | multicast has been removed from the interface. | |
1351 | ||
1352 | When an interface is detached, all of the multicasts are | |
1353 | removed. If the interface of the multicast passed in is no | |
1354 | longer attached, this function will gracefully return, | |
1355 | performing no work. | |
1356 | ||
1357 | It is the callers responsibility to release the multicast | |
1358 | address after calling this function. | |
1359 | @param multicast The multicast to be removed. | |
1360 | @result 0 on success otherwise the errno error. | |
1361 | */ | |
1362 | errno_t ifnet_remove_multicast(ifmultiaddr_t multicast); | |
1363 | ||
1364 | /*! | |
1365 | @function ifnet_get_multicast_list | |
1366 | @discussion Retrieves a list of multicast address the interface is | |
1367 | set to receive. This function allocates and returns an array of | |
1368 | references to the various multicast addresses. The multicasts | |
1369 | have their reference counts bumped on your behalf. Calling | |
1370 | ifnet_free_multicast_list will decrement the reference counts | |
1371 | and free the array. | |
1372 | @param interface The interface. | |
1373 | @param multicasts A pointer to a NULL terminated array of references | |
1374 | to the multicast addresses. | |
1375 | @result 0 on success otherwise the errno error. | |
1376 | */ | |
1377 | errno_t ifnet_get_multicast_list(ifnet_t interface, ifmultiaddr_t **addresses); | |
1378 | ||
1379 | /*! | |
1380 | @function ifnet_free_multicast_list | |
1381 | @discussion Frees a list of multicasts returned by | |
1382 | ifnet_get_multicast_list. Decrements the refcount on each | |
1383 | multicast address and frees the array. | |
1384 | @param multicasts An array of references to the multicast addresses. | |
1385 | @result 0 on success otherwise the errno error. | |
1386 | */ | |
1387 | void ifnet_free_multicast_list(ifmultiaddr_t *multicasts); | |
1388 | ||
1389 | /*! | |
1390 | @function ifnet_find_by_name | |
1391 | @discussion Find an interface by the name including the unit number. | |
1392 | Caller must call ifnet_release on any non-null interface return | |
1393 | value. | |
1394 | @param name The name of the interface, including any unit number | |
1395 | (i.e. "en0"). | |
1396 | @param interface A pointer to an interface reference. This will be | |
1397 | filled in if a matching interface is found. | |
1398 | @result 0 on success otherwise the errno error. | |
1399 | */ | |
1400 | errno_t ifnet_find_by_name(const char *ifname, ifnet_t *interface); | |
1401 | ||
1402 | /*! | |
1403 | @function ifnet_list_get | |
1404 | @discussion Get a list of attached interfaces. List will be set to | |
1405 | point to an array allocated by ifnet_list_get. The interfaces | |
1406 | are refcounted and the counts will be incremented before the | |
1407 | function returns. The list of interfaces must be freed using | |
1408 | ifnet_list_free. | |
1409 | @param family The interface family (i.e. IFNET_FAMILY_ETHERNET). To | |
1410 | find interfaces of all families, use IFNET_FAMILY_ANY. | |
1411 | @param interfaces A pointer to an array of interface references. | |
1412 | @param count A pointer that will be filled in with the number of | |
1413 | matching interfaces in the array. | |
1414 | @result 0 on success otherwise the errno error. | |
1415 | */ | |
1416 | errno_t ifnet_list_get(ifnet_family_t family, ifnet_t **interfaces, u_int32_t *count); | |
1417 | ||
1418 | /*! | |
1419 | @function ifnet_list_free | |
1420 | @discussion Free a list of interfaces returned by ifnet_list_get. | |
1421 | Decrements the reference count on each interface and frees the | |
1422 | array of references. If you keep a reference to an interface, be | |
1423 | sure to increment the reference count before calling | |
1424 | ifnet_list_free. | |
1425 | @param interfaces An array of interface references from ifnet_list_get. | |
1426 | */ | |
1427 | void ifnet_list_free(ifnet_t *interfaces); | |
1428 | ||
1429 | /********************************************************************************************/ | |
1430 | /* ifaddr_t accessors */ | |
1431 | /********************************************************************************************/ | |
1432 | ||
1433 | /*! | |
1434 | @function ifaddr_reference | |
1435 | @discussion Increment the reference count of an address tied to an | |
1436 | interface. | |
1437 | @param ifaddr The interface address. | |
1438 | @result 0 upon success | |
1439 | */ | |
1440 | errno_t ifaddr_reference(ifaddr_t ifaddr); | |
1441 | ||
1442 | /*! | |
1443 | @function ifaddr_release | |
1444 | @discussion Decrements the reference count of and possibly frees an | |
1445 | address tied to an interface. | |
1446 | @param ifaddr The interface address. | |
1447 | @result 0 upon success | |
1448 | */ | |
1449 | errno_t ifaddr_release(ifaddr_t ifaddr); | |
1450 | ||
1451 | /*! | |
1452 | @function ifaddr_address | |
1453 | @discussion Copies the address out of the ifaddr. | |
1454 | @param ifaddr The interface address. | |
1455 | @param out_addr The sockaddr storage for the address. | |
1456 | @param addr_size The size of the storage for the address. | |
1457 | @result 0 upon success | |
1458 | */ | |
1459 | errno_t ifaddr_address(ifaddr_t ifaddr, struct sockaddr *out_addr, u_int32_t addr_size); | |
1460 | ||
1461 | /*! | |
1462 | @function ifaddr_address | |
1463 | @discussion Returns the address family of the address. | |
1464 | @param ifaddr The interface address. | |
1465 | @result 0 on failure, address family on success. | |
1466 | */ | |
1467 | sa_family_t ifaddr_address_family(ifaddr_t ifaddr); | |
1468 | ||
1469 | /*! | |
1470 | @function ifaddr_dstaddress | |
1471 | @discussion Copies the destination address out of the ifaddr. | |
1472 | @param ifaddr The interface address. | |
1473 | @param out_dstaddr The sockaddr storage for the destination address. | |
1474 | @param dstaddr_size The size of the storage for the destination address. | |
1475 | @result 0 upon success | |
1476 | */ | |
1477 | errno_t ifaddr_dstaddress(ifaddr_t ifaddr, struct sockaddr *out_dstaddr, u_int32_t dstaddr_size); | |
1478 | ||
1479 | /*! | |
1480 | @function ifaddr_netmask | |
1481 | @discussion Copies the netmask out of the ifaddr. | |
1482 | @param ifaddr The interface address. | |
1483 | @param out_netmask The sockaddr storage for the netmask. | |
1484 | @param netmask_size The size of the storage for the netmask. | |
1485 | @result 0 upon success | |
1486 | */ | |
1487 | errno_t ifaddr_netmask(ifaddr_t ifaddr, struct sockaddr *out_netmask, u_int32_t netmask_size); | |
1488 | ||
1489 | /*! | |
1490 | @function ifaddr_ifnet | |
1491 | @discussion Returns the interface the address is attached to. The | |
1492 | reference is only valid until the ifaddr is released. If you | |
1493 | need to hold a reference to the ifnet for longer than you hold a | |
1494 | reference to the ifaddr, increment the reference using | |
1495 | ifnet_reference. | |
1496 | @param ifaddr The interface address. | |
1497 | @result A reference to the interface the address is attached to. | |
1498 | */ | |
1499 | ifnet_t ifaddr_ifnet(ifaddr_t ifaddr); | |
1500 | ||
1501 | /*! | |
1502 | @function ifaddr_withaddr | |
1503 | @discussion Returns an interface address with the address specified. | |
1504 | Increments the reference count on the ifaddr before returning to | |
1505 | the caller. Caller is responsible for calling ifaddr_release. | |
1506 | @param address The address to search for. | |
1507 | @result A reference to the interface address. | |
1508 | */ | |
1509 | ifaddr_t ifaddr_withaddr(const struct sockaddr* address); | |
1510 | ||
1511 | /*! | |
1512 | @function ifaddr_withdstaddr | |
1513 | @discussion Returns an interface address for the interface address | |
1514 | that matches the destination when the netmask is applied. | |
1515 | Increments the reference count on the ifaddr before returning to | |
1516 | the caller. Caller is responsible for calling ifaddr_release. | |
1517 | @param destination The destination to search for. | |
1518 | @result A reference to the interface address. | |
1519 | */ | |
1520 | ifaddr_t ifaddr_withdstaddr(const struct sockaddr* destination); | |
1521 | ||
1522 | /*! | |
1523 | @function ifaddr_withnet | |
1524 | @discussion Returns an interface address for the interface with the | |
1525 | network described by net. Increments the reference count on the | |
1526 | ifaddr before returning to the caller. Caller is responsible for | |
1527 | calling ifaddr_release. | |
1528 | @param net The network to search for. | |
1529 | @result A reference to the interface address. | |
1530 | */ | |
1531 | ifaddr_t ifaddr_withnet(const struct sockaddr* net); | |
1532 | ||
1533 | /*! | |
1534 | @function ifaddr_withroute | |
1535 | @discussion Returns an interface address given a destination and | |
1536 | gateway. Increments the reference count on the ifaddr before | |
1537 | returning to the caller. Caller is responsible for calling | |
1538 | ifaddr_release. | |
1539 | @param flags Routing flags. See net/route.h, RTF_GATEWAY etc. | |
1540 | @param destination The destination to search for. | |
1541 | @param gateway A gateway to search for. | |
1542 | @result A reference to the interface address. | |
1543 | */ | |
1544 | ifaddr_t ifaddr_withroute(int flags, const struct sockaddr* destination, | |
1545 | const struct sockaddr* gateway); | |
1546 | ||
1547 | /*! | |
1548 | @function ifaddr_findbestforaddr | |
1549 | @discussion Finds the best local address assigned to a specific | |
1550 | interface to use when communicating with another address. | |
1551 | Increments the reference count on the ifaddr before returning to | |
1552 | the caller. Caller is responsible for calling ifaddr_release. | |
1553 | @param addr The remote address. | |
1554 | @param interface The local interface. | |
1555 | @result A reference to the interface address. | |
1556 | */ | |
1557 | ifaddr_t ifaddr_findbestforaddr(const struct sockaddr *addr, ifnet_t interface); | |
1558 | ||
1559 | /********************************************************************************************/ | |
1560 | /* ifmultiaddr_t accessors */ | |
1561 | /********************************************************************************************/ | |
1562 | ||
1563 | /*! | |
1564 | @function ifmaddr_reference | |
1565 | @discussion Increment the reference count of an interface multicast | |
1566 | address. | |
1567 | @param ifmaddr The interface multicast address. | |
1568 | @result 0 on success. Only error will be EINVAL if ifmaddr is not valid. | |
1569 | */ | |
1570 | errno_t ifmaddr_reference(ifmultiaddr_t ifmaddr); | |
1571 | ||
1572 | /*! | |
1573 | @function ifmaddr_release | |
1574 | @discussion Decrement the reference count of an interface multicast | |
1575 | address. If the reference count reaches zero, the ifmultiaddr | |
1576 | will be removed from the interface and the ifmultiaddr will be | |
1577 | freed. | |
1578 | @param ifmaddr The interface multicast address. | |
1579 | @result 0 on success. Only error will be EINVAL if ifmaddr is not valid. | |
1580 | */ | |
1581 | errno_t ifmaddr_release(ifmultiaddr_t ifmaddr); | |
1582 | ||
1583 | /*! | |
1584 | @function ifmaddr_address | |
1585 | @discussion Copies the multicast address to out_multicast. | |
1586 | @param out_multicast Storage for a sockaddr. | |
1587 | @param addr_size Size of the storage. | |
1588 | @result 0 on success. | |
1589 | */ | |
1590 | errno_t ifmaddr_address(ifmultiaddr_t ifmaddr, struct sockaddr *out_multicast, u_int32_t addr_size); | |
1591 | ||
1592 | /*! | |
1593 | @function ifmaddr_lladdress | |
1594 | @discussion Copies the link layer multicast address to | |
1595 | out_link_layer_multicast. | |
1596 | @param out_link_layer_multicast Storage for a sockaddr. | |
1597 | @param addr_size Size of the storage. | |
1598 | @result 0 on success. | |
1599 | */ | |
1600 | errno_t ifmaddr_lladdress(ifmultiaddr_t ifmaddr, struct sockaddr *out_link_layer_multicast, | |
1601 | u_int32_t addr_size); | |
1602 | ||
1603 | /*! | |
1604 | @function ifmaddr_ifnet | |
1605 | @discussion Returns the interface this multicast address is attached | |
1606 | to. The interface reference count is not bumped by this | |
1607 | function. The interface is only valid as long as you don't | |
1608 | release the refernece to the multiast address. If you need to | |
1609 | maintain your pointer to the ifnet, call ifnet_reference | |
1610 | followed by ifnet_release when you're finished. | |
1611 | @param ifmaddr The interface multicast address. | |
1612 | @result A reference to the interface. | |
1613 | */ | |
1614 | ifnet_t ifmaddr_ifnet(ifmultiaddr_t ifmaddr); | |
1615 | ||
1616 | __END_DECLS | |
1617 | ||
1618 | #endif |