2 * Copyright (c) 2004-2011 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 @header kpi_interface.h
30 This header defines an API to interact with network interfaces in
31 the kernel. The network interface KPI may be used to implement
32 network interfaces or to attach protocols to existing interfaces.
35 #ifndef __KPI_INTERFACE__
36 #define __KPI_INTERFACE__
37 #include <sys/kernel_types.h>
41 typedef __uint8_t sa_family_t
;
47 struct kern_event_msg
;
49 struct ifnet_demux_desc
;
52 @enum Interface Families
53 @abstract Constants defining interface families.
54 @constant IFNET_FAMILY_ANY Match interface of any family type.
55 @constant IFNET_FAMILY_LOOPBACK A software loopback interface.
56 @constant IFNET_FAMILY_ETHERNET An Ethernet interface.
57 @constant IFNET_FAMILY_SLIP A SLIP interface.
58 @constant IFNET_FAMILY_TUN A tunnel interface.
59 @constant IFNET_FAMILY_VLAN A virtual LAN interface.
60 @constant IFNET_FAMILY_PPP A PPP interface.
61 @constant IFNET_FAMILY_PVC A PVC interface.
62 @constant IFNET_FAMILY_DISC A DISC interface.
63 @constant IFNET_FAMILY_MDECAP A MDECAP interface.
64 @constant IFNET_FAMILY_GIF A generic tunnel interface.
65 @constant IFNET_FAMILY_FAITH A FAITH (IPv4/IPv6 translation) interface.
66 @constant IFNET_FAMILY_STF A 6to4 interface.
67 @constant IFNET_FAMILY_FIREWIRE An IEEE 1394 (firewire) interface.
68 @constant IFNET_FAMILY_BOND A virtual bonded interface.
69 @constant IFNET_FAMILY_CELLULAR A cellular interface.
74 IFNET_FAMILY_LOOPBACK
= 1,
75 IFNET_FAMILY_ETHERNET
= 2,
76 IFNET_FAMILY_SLIP
= 3,
78 IFNET_FAMILY_VLAN
= 5,
81 IFNET_FAMILY_DISC
= 8,
82 IFNET_FAMILY_MDECAP
= 9,
83 IFNET_FAMILY_GIF
= 10,
84 IFNET_FAMILY_FAITH
= 11,
85 IFNET_FAMILY_STF
= 12,
86 IFNET_FAMILY_FIREWIRE
= 13,
87 IFNET_FAMILY_BOND
= 14,
88 IFNET_FAMILY_CELLULAR
= 15
91 @typedef ifnet_family_t
92 @abstract Storage type for the interface family.
94 typedef u_int32_t ifnet_family_t
;
96 #ifndef BPF_TAP_MODE_T
97 #define BPF_TAP_MODE_T
100 @abstract Constants defining interface families.
101 @constant BPF_MODE_DISABLED Disable bpf.
102 @constant BPF_MODE_INPUT Enable input only.
103 @constant BPF_MODE_OUTPUT Enable output only.
104 @constant BPF_MODE_INPUT_OUTPUT Enable input and output.
108 BPF_MODE_DISABLED
= 0,
111 BPF_MODE_INPUT_OUTPUT
= 3
114 @typedef bpf_tap_mode
115 @abstract Mode for tapping. BPF_MODE_DISABLED/BPF_MODE_INPUT_OUTPUT etc.
117 typedef u_int32_t bpf_tap_mode
;
118 #endif /* !BPF_TAP_MODE_T */
121 @typedef protocol_family_t
122 @abstract Storage type for the protocol family.
124 typedef u_int32_t protocol_family_t
;
127 @enum Interface Abilities
128 @abstract Constants defining interface offload support.
129 @constant IFNET_CSUM_IP Hardware will calculate IPv4 checksums.
130 @constant IFNET_CSUM_TCP Hardware will calculate TCP checksums.
131 @constant IFNET_CSUM_UDP Hardware will calculate UDP checksums.
132 @constant IFNET_CSUM_FRAGMENT Hardware will checksum IP fragments.
133 @constant IFNET_IP_FRAGMENT Hardware will fragment IP packets.
134 @constant IFNET_CSUM_TCPIPV6 Hardware will calculate TCP IPv6 checksums.
135 @constant IFNET_CSUM_UDPIPV6 Hardware will calculate UDP IPv6 checksums.
136 @constant IFNET_IPV6_FRAGMENT Hardware will fragment IPv6 packets.
137 @constant IFNET_VLAN_TAGGING Hardware will generate VLAN headers.
138 @constant IFNET_VLAN_MTU Hardware supports VLAN MTU.
139 @constant IFNET_MULTIPAGES Driver is capable of handling packets
140 coming down from the network stack that reside in virtually,
141 but not in physically contiguous span of the external mbuf
142 clusters. In this case, the data area of a packet in the
143 external mbuf cluster might cross one or more physical
144 pages that are disjoint, depending on the interface MTU
145 and the packet size. Such a use of larger than system page
146 size clusters by the network stack is done for better system
147 efficiency. Drivers that utilize the IOMbufNaturalMemoryCursor
148 with the getPhysicalSegmentsWithCoalesce interfaces and
149 enumerate the list of vectors should set this flag for
150 possible gain in performance during bulk data transfer.
151 @constant IFNET_TSO_IPV4 Hardware supports IPv4 TCP Segment Offloading.
152 If the Interface driver sets this flag, TCP will send larger frames (up to 64KB) as one
153 frame to the adapter which will perform the final packetization. The maximum TSO segment
154 supported by the interface can be set with "ifnet_set_tso_mtu". To retreive the real MTU
155 for the TCP connection the function "mbuf_get_tso_requested" is used by the driver. Note
156 that if TSO is active, all the packets will be flagged for TSO, not just large packets.
157 @constant IFNET_TSO_IPV6 Hardware supports IPv6 TCP Segment Offloading.
158 If the Interface driver sets this flag, TCP IPv6 will send larger frames (up to 64KB) as one
159 frame to the adapter which will perform the final packetization. The maximum TSO segment
160 supported by the interface can be set with "ifnet_set_tso_mtu". To retreive the real MTU
161 for the TCP IPv6 connection the function "mbuf_get_tso_requested" is used by the driver.
162 Note that if TSO is active, all the packets will be flagged for TSO, not just large packets.
167 IFNET_CSUM_IP
= 0x00000001,
168 IFNET_CSUM_TCP
= 0x00000002,
169 IFNET_CSUM_UDP
= 0x00000004,
170 IFNET_CSUM_FRAGMENT
= 0x00000008,
171 IFNET_IP_FRAGMENT
= 0x00000010,
172 IFNET_CSUM_TCPIPV6
= 0x00000020,
173 IFNET_CSUM_UDPIPV6
= 0x00000040,
174 IFNET_IPV6_FRAGMENT
= 0x00000080,
175 #ifdef KERNEL_PRIVATE
176 IFNET_CSUM_SUM16
= 0x00001000,
177 #endif /* KERNEL_PRIVATE */
178 IFNET_VLAN_TAGGING
= 0x00010000,
179 IFNET_VLAN_MTU
= 0x00020000,
180 IFNET_MULTIPAGES
= 0x00100000,
181 IFNET_TSO_IPV4
= 0x00200000,
182 IFNET_TSO_IPV6
= 0x00400000,
185 @typedef ifnet_offload_t
186 @abstract Flags indicating the offload support of the interface.
188 typedef u_int32_t ifnet_offload_t
;
193 * These are function pointers you supply to the kernel in the interface.
196 @typedef bpf_packet_func
198 @discussion bpf_packet_func The bpf_packet_func is used to intercept
199 inbound and outbound packets. The tap function will never free
200 the mbuf. The tap function will only copy the mbuf in to various
201 bpf file descriptors tapping this interface.
202 @param interface The interface being sent or received on.
203 @param data The packet to be transmitted or received.
204 @result An errno value or zero upon success.
206 /* Fast path - do not block or spend excessive amounts of time */
207 typedef errno_t (*bpf_packet_func
)(ifnet_t interface
, mbuf_t data
);
210 @typedef ifnet_output_func
212 @discussion ifnet_output_func is used to transmit packets. The stack
213 will pass fully formed packets, including frame header, to the
214 ifnet_output function for an interface. The driver is
215 responsible for freeing the mbuf.
216 @param interface The interface being sent on.
217 @param data The packet to be sent.
219 /* Fast path - do not block or spend excessive amounts of time */
220 typedef errno_t (*ifnet_output_func
)(ifnet_t interface
, mbuf_t data
);
223 @typedef ifnet_ioctl_func
224 @discussion ifnet_ioctl_func is used to communicate ioctls from the
227 All undefined ioctls are reserved for future use by Apple. If
228 you need to communicate with your kext using an ioctl, please
229 use SIOCSIFKPI and SIOCGIFKPI.
230 @param interface The interface the ioctl is being sent to.
231 @param proto_family The protocol family to handle the ioctl, may be
232 zero for no protocol_family.
233 @param cmd The ioctl command.
234 @param data A pointer to any data related to the ioctl.
236 typedef errno_t (*ifnet_ioctl_func
)(ifnet_t interface
, unsigned long cmd
,
240 @typedef ifnet_set_bpf_tap
241 @discussion Deprecated. Specify NULL. Call bpf_tap_in/bpf_tap_out
244 typedef errno_t (*ifnet_set_bpf_tap
)(ifnet_t interface
, bpf_tap_mode mode
,
245 bpf_packet_func callback
);
248 @typedef ifnet_detached_func
249 @discussion ifnet_detached_func is called an interface is detached
250 from the list of interfaces. When ifnet_detach is called, it may
251 not detach the interface immediately if protocols are attached.
252 ifnet_detached_func is used to notify the interface that it has
253 been detached from the networking stack. This is the last
254 function that will be called on an interface. Until this
255 function returns, you must not unload a kext supplying function
256 pointers to this interface, even if ifnet_detacah has been
257 called. Your detach function may be called during your call to
259 @param interface The interface that has been detached.
262 typedef void (*ifnet_detached_func
)(ifnet_t interface
);
265 @typedef ifnet_demux_func
266 @discussion ifnet_demux_func is called for each inbound packet to
267 determine which protocol family the packet belongs to. This
268 information is then used by the stack to determine which
269 protocol to pass the packet to. This function may return
270 protocol families for protocols that are not attached. If the
271 protocol family has not been attached to the interface, the
272 packet will be discarded.
273 @param interface The interface the packet was received on.
274 @param packet The mbuf containing the packet.
275 @param frame_header A pointer to the frame header.
276 @param protocol_family Upon return, the protocol family matching the
277 packet should be stored here.
279 If the result is zero, processing will continue normally.
280 If the result is EJUSTRETURN, processing will stop but the
281 packet will not be freed.
282 If the result is anything else, the processing will stop and
283 the packet will be freed.
285 typedef errno_t (*ifnet_demux_func
)(ifnet_t interface
, mbuf_t packet
,
286 char *frame_header
, protocol_family_t
*protocol_family
);
289 @typedef ifnet_event_func
290 @discussion ifnet_event_func is called when an event occurs on a
292 @param interface The interface the event occurred on.
293 @param event_ptr Pointer to a kern_event structure describing the
296 typedef void (*ifnet_event_func
)(ifnet_t interface
, const struct kev_msg
*msg
);
299 @typedef ifnet_framer_func
300 @discussion ifnet_framer_func is called for each outbound packet to
301 give the interface an opportunity to prepend interface specific
303 @param interface The interface the packet is being sent on.
304 @param packet Pointer to the mbuf containing the packet, caller may
305 set this to a different mbuf upon return. This can happen if the
306 frameout function needs to prepend another mbuf to the chain to
307 have enough space for the header.
308 @param dest The higher layer protocol destination (i.e. IP address).
309 @param dest_linkaddr The link layer address as determined by the
310 protocol's pre-output function.
311 @param frame_type The frame type as determined by the protocol's
314 If the result is zero, processing will continue normally.
315 If the result is EJUSTRETURN, processing will stop but the
316 packet will not be freed.
317 If the result is anything else, the processing will stop and
318 the packet will be freed.
320 typedef errno_t (*ifnet_framer_func
)(ifnet_t interface
, mbuf_t
*packet
,
321 const struct sockaddr
*dest
, const char *desk_linkaddr
,
322 const char *frame_type
);
325 @typedef ifnet_add_proto_func
326 @discussion if_add_proto_func is called by the stack when a protocol
327 is attached to an interface. This gives the interface an
328 opportunity to get a list of protocol description structures
329 for demuxing packets to this protocol (demux descriptors).
330 @param interface The interface the protocol will be attached to.
331 @param protocol_family The family of the protocol being attached.
332 @param demux_array An array of demux descriptors that describe
333 the interface specific ways of identifying packets belonging
334 to this protocol family.
335 @param demux_count The number of demux descriptors in the array.
337 If the result is zero, processing will continue normally.
338 If the result is anything else, the add protocol will be
341 typedef errno_t (*ifnet_add_proto_func
)(ifnet_t interface
,
342 protocol_family_t protocol_family
,
343 const struct ifnet_demux_desc
*demux_array
, u_int32_t demux_count
);
346 @typedef if_del_proto_func
347 @discussion if_del_proto_func is called by the stack when a protocol
348 is being detached from an interface. This gives the interface an
349 opportunity to free any storage related to this specific
350 protocol being attached to this interface.
351 @param interface The interface the protocol will be detached from.
352 @param protocol_family The family of the protocol being detached.
354 If the result is zero, processing will continue normally.
355 If the result is anything else, the detach will continue
356 and the error will be returned to the caller.
358 typedef errno_t (*ifnet_del_proto_func
)(ifnet_t interface
,
359 protocol_family_t protocol_family
);
362 @typedef ifnet_check_multi
363 @discussion ifnet_check_multi is called for each multicast address
364 added to an interface. This gives the interface an opportunity
365 to reject invalid multicast addresses before they are attached
368 To prevent an address from being added to your multicast list,
369 return EADDRNOTAVAIL. If you don't know how to parse/translate
370 the address, return EOPNOTSUPP.
371 @param The interface.
372 @param mcast The multicast address.
374 Zero upon success, EADDRNOTAVAIL on invalid multicast,
375 EOPNOTSUPP for addresses the interface does not understand.
377 typedef errno_t (*ifnet_check_multi
)(ifnet_t interface
,
378 const struct sockaddr
*mcast
);
381 @typedef proto_media_input
382 @discussion proto_media_input is called for all inbound packets for
383 a specific protocol on a specific interface. This function is
384 registered on an interface using ifnet_attach_protocol.
385 @param ifp The interface the packet was received on.
386 @param protocol_family The protocol of the packet received.
387 @param packet The packet being input.
388 @param header The frame header.
390 If the result is zero, the caller will assume the packet was
391 passed to the protocol.
392 If the result is non-zero and not EJUSTRETURN, the caller will
395 typedef errno_t (*proto_media_input
)(ifnet_t ifp
, protocol_family_t protocol
,
396 mbuf_t packet
, char *header
);
399 @typedef proto_media_input_v2
400 @discussion proto_media_input_v2 is called for all inbound packets for
401 a specific protocol on a specific interface. This function is
402 registered on an interface using ifnet_attach_protocolv2.
403 proto_media_input_v2 differs from proto_media_input in that it
404 will be called for a list of packets instead of once for each
405 individual packet. The frame header can be retrieved using
407 @param ifp The interface the packet was received on.
408 @param protocol_family The protocol of the packet received.
409 @param packet The packet being input.
411 If the result is zero, the caller will assume the packets were
412 passed to the protocol.
413 If the result is non-zero and not EJUSTRETURN, the caller will
416 typedef errno_t (*proto_media_input_v2
)(ifnet_t ifp
, protocol_family_t protocol
,
420 @typedef proto_media_preout
421 @discussion proto_media_preout is called just before the packet
422 is transmitted. This gives the proto_media_preout function an
423 opportunity to specify the media specific frame type and
425 @param ifp The interface the packet will be sent on.
426 @param protocol_family The protocol of the packet being sent
428 @param packet The packet being sent.
429 @param dest The protocol level destination address.
430 @param route A pointer to the routing structure for the packet.
431 @param frame_type The media specific frame type.
432 @param link_layer_dest The media specific destination.
434 If the result is zero, processing will continue normally. If the
435 result is non-zero, processing will stop. If the result is
436 non-zero and not EJUSTRETURN, the packet will be freed by the
439 typedef errno_t (*proto_media_preout
)(ifnet_t ifp
, protocol_family_t protocol
,
440 mbuf_t
*packet
, const struct sockaddr
*dest
, void *route
, char *frame_type
,
441 char *link_layer_dest
);
444 @typedef proto_media_event
445 @discussion proto_media_event is called to notify this layer of
446 interface specific events.
447 @param ifp The interface.
448 @param protocol_family The protocol family.
449 @param kev_msg The event.
451 typedef void (*proto_media_event
)(ifnet_t ifp
, protocol_family_t protocol
,
452 const struct kev_msg
*event
);
455 @typedef proto_media_ioctl
456 @discussion proto_media_event allows this layer to handle ioctls.
457 When an ioctl is handled, it is passed to the interface filters,
458 protocol filters, protocol, and interface. If you do not support
459 this ioctl, return EOPNOTSUPP. If you successfully handle the
460 ioctl, return zero. If you return any error other than
461 EOPNOTSUPP, other parts of the stack may not get an opportunity
462 to process the ioctl. If you return EJUSTRETURN, processing will
463 stop and a result of zero will be returned to the caller.
465 All undefined ioctls are reserved for future use by Apple. If
466 you need to communicate with your kext using an ioctl, please
467 use SIOCSIFKPI and SIOCGIFKPI.
468 @param ifp The interface.
469 @param protocol_family The protocol family.
470 @param command The ioctl command.
471 @param argument The argument to the ioctl.
475 typedef errno_t (*proto_media_ioctl
)(ifnet_t ifp
, protocol_family_t protocol
,
476 unsigned long command
, void *argument
);
479 @typedef proto_media_detached
480 @discussion proto_media_detached notifies you that your protocol
482 @param ifp The interface.
483 @param protocol_family The protocol family.
487 typedef errno_t (*proto_media_detached
)(ifnet_t ifp
, protocol_family_t protocol
);
490 @typedef proto_media_resolve_multi
491 @discussion proto_media_resolve_multi is called to resolve a
492 protocol layer mulitcast address to a link layer multicast
494 @param ifp The interface.
495 @param proto_addr The protocol address.
496 @param out_ll A sockaddr_dl to copy the link layer multicast in to.
497 @param ll_len The length of data allocated for out_ll.
498 @result Return zero on success or an errno error value on failure.
500 typedef errno_t (*proto_media_resolve_multi
)(ifnet_t ifp
,
501 const struct sockaddr
*proto_addr
, struct sockaddr_dl
*out_ll
,
505 @typedef proto_media_send_arp
506 @discussion proto_media_send_arp is called by the stack to generate
507 an ARP packet. This field is currently only used with IP. This
508 function should inspect the parameters and transmit an arp
509 packet using the information passed in.
510 @param ifp The interface the arp packet should be sent on.
511 @param protocol_family The protocol family of the addresses
513 @param arpop The arp operation (usually ARPOP_REQUEST or
515 @param sender_hw The value to use for the sender hardware
516 address field. If this is NULL, use the hardware address
518 @param sender_proto The value to use for the sender protocol
519 address field. This will not be NULL.
520 @param target_hw The value to use for the target hardware address.
521 If this is NULL, the target hardware address in the ARP packet
522 should be NULL and the link-layer destination for the back
523 should be a broadcast. If this is not NULL, this value should be
524 used for both the link-layer destination and the target hardware
526 @param target_proto The target protocol address. This will not be
528 @result Return zero on success or an errno error value on failure.
530 typedef errno_t (*proto_media_send_arp
)(ifnet_t ifp
, u_short arpop
,
531 const struct sockaddr_dl
*sender_hw
, const struct sockaddr
*sender_proto
,
532 const struct sockaddr_dl
*target_hw
, const struct sockaddr
*target_proto
);
535 @struct ifnet_stat_increment_param
536 @discussion This structure is used increment the counters on a
538 @field packets_in The number of packets received.
539 @field bytes_in The number of bytes received.
540 @field errors_in The number of receive errors.
541 @field packets_out The number of packets transmitted.
542 @field bytes_out The number of bytes transmitted.
543 @field errors_out The number of transmission errors.
544 @field collisions The number of collisions seen by this interface.
545 @field dropped The number of packets dropped.
547 struct ifnet_stat_increment_param
{
548 u_int32_t packets_in
;
552 u_int32_t packets_out
;
554 u_int32_t errors_out
;
556 u_int32_t collisions
;
561 @struct ifnet_init_params
562 @discussion This structure is used to define various properties of
563 the interface when calling ifnet_init. A copy of these values
564 will be stored in the ifnet and can not be modified while the
565 interface is attached.
566 @field uniqueid An identifier unique to this instance of the
568 @field uniqueid_len The length, in bytes, of the uniqueid.
569 @field name The interface name (i.e. en).
570 @field unit The interface unit number (en0's unit number is 0).
571 @field family The interface family.
572 @field type The interface type (see sys/if_types.h). Must be less
573 than 256. For new types, use IFT_OTHER.
574 @field output The output function for the interface. Every packet the
575 stack attempts to send through this interface will go out
576 through this function.
577 @field demux The function used to determine the protocol family of an
579 @field add_proto The function used to attach a protocol to this
581 @field del_proto The function used to remove a protocol from this
583 @field framer The function used to frame outbound packets, may be NULL.
584 @field softc Driver specific storage. This value can be retrieved from
585 the ifnet using the ifnet_softc function.
586 @field ioctl The function used to handle ioctls.
587 @field set_bpf_tap The function used to set the bpf_tap function.
588 @field detach The function called to let the driver know the interface
590 @field event The function to notify the interface of various interface
591 specific kernel events.
592 @field broadcast_addr The link-layer broadcast address for this
594 @field broadcast_len The length of the link-layer broadcast address.
596 struct ifnet_init_params
{
597 /* used to match recycled interface */
598 const void *uniqueid
; /* optional */
599 u_int32_t uniqueid_len
; /* optional */
601 /* used to fill out initial values for interface */
602 const char *name
; /* required */
603 u_int32_t unit
; /* required */
604 ifnet_family_t family
; /* required */
605 u_int32_t type
; /* required */
606 ifnet_output_func output
; /* required */
607 ifnet_demux_func demux
; /* required */
608 ifnet_add_proto_func add_proto
; /* required */
609 ifnet_del_proto_func del_proto
; /* required */
610 ifnet_check_multi check_multi
; /* required for non point-to-point interfaces */
611 ifnet_framer_func framer
; /* optional */
612 void *softc
; /* optional */
613 ifnet_ioctl_func ioctl
; /* optional */
614 ifnet_set_bpf_tap set_bpf_tap
; /* deprecated */
615 ifnet_detached_func detach
; /* optional */
616 ifnet_event_func event
; /* optional */
617 const void *broadcast_addr
; /* required for non point-to-point interfaces */
618 u_int32_t broadcast_len
; /* required for non point-to-point interfaces */
622 @struct ifnet_stats_param
623 @discussion This structure is used get and set the interface
625 @field packets_in The number of packets received.
626 @field bytes_in The number of bytes received.
627 @field errors_in The number of receive errors.
628 @field packets_out The number of packets transmitted.
629 @field bytes_out The number of bytes transmitted.
630 @field errors_out The number of transmission errors.
631 @field collisions The number of collisions seen by this interface.
632 @field dropped The number of packets dropped.
634 struct ifnet_stats_param
{
635 u_int64_t packets_in
;
637 u_int64_t multicasts_in
;
640 u_int64_t packets_out
;
642 u_int64_t multicasts_out
;
643 u_int64_t errors_out
;
645 u_int64_t collisions
;
647 u_int64_t no_protocol
;
651 @struct ifnet_demux_desc
652 @discussion This structure is to identify packets that belong to a
653 specific protocol. The types supported are interface specific.
654 Ethernet supports ETHER_DESC_ETYPE2, ETHER_DESC_SAP, and
655 ETHER_DESC_SNAP. The type defines the offset in the packet where
656 the data will be matched as well as context. For example, if
657 ETHER_DESC_SNAP is specified, the only valid datalen is 5 and
658 only in the 5 bytes will only be matched when the packet header
659 indicates that the packet is a SNAP packet.
660 @field type The type of identifier data (i.e. ETHER_DESC_ETYPE2)
661 @field data A pointer to an entry of type (i.e. pointer to 0x0800).
662 @field datalen The number of bytes of data used to describe the
665 struct ifnet_demux_desc
{
672 @struct ifnet_attach_proto_param
673 @discussion This structure is used to attach a protocol to an
674 interface. This structure provides the various functions for
675 handling operations related to the protocol on the interface as
676 well as information for how to demux packets for this protocol.
677 @field demux_array An array of ifnet_demux_desc structures
678 describing the protocol.
679 @field demux_count The number of entries in the demux_array array.
680 @field input The function to be called for inbound packets.
681 @field pre_output The function to be called for outbound packets.
682 @field event The function to be called for interface events.
683 @field ioctl The function to be called for ioctls.
684 @field detached The function to be called for handling the detach.
686 #ifdef KERNEL_PRIVATE
687 #define demux_list demux_array
688 #endif /* KERNEL_PRIVATE */
690 struct ifnet_attach_proto_param
{
691 struct ifnet_demux_desc
*demux_array
; /* interface may/may not require */
692 u_int32_t demux_count
; /* interface may/may not require */
694 proto_media_input input
; /* required */
695 proto_media_preout pre_output
; /* required */
696 proto_media_event event
; /* optional */
697 proto_media_ioctl ioctl
; /* optional */
698 proto_media_detached detached
; /* optional */
699 proto_media_resolve_multi resolve
; /* optional */
700 proto_media_send_arp send_arp
; /* optional */
703 struct ifnet_attach_proto_param_v2
{
704 struct ifnet_demux_desc
*demux_array
; /* interface may/may not require */
705 u_int32_t demux_count
; /* interface may/may not require */
707 proto_media_input_v2 input
; /* required */
708 proto_media_preout pre_output
; /* required */
709 proto_media_event event
; /* optional */
710 proto_media_ioctl ioctl
; /* optional */
711 proto_media_detached detached
; /* optional */
712 proto_media_resolve_multi resolve
; /* optional */
713 proto_media_send_arp send_arp
; /* optional */
719 * Ifnet creation and reference counting
723 @function ifnet_allocate
724 @discussion Allocate an ifnet_t with an initial refcount of 1. Many
725 parts of the stack do not properly refcount the ifnet_t. In
726 order to avoid freeing the ifnet_t while some parts of the stack
727 may contain a reference to it, the ifnet_ts are only recycled,
728 never freed. A unique id is used to try and recycle the same
729 ifnet_t when allocating an interface. For example, for an
730 ethernet interface, the hardware address of the ethernet card is
731 usually used for the uniqueid. If a PC Card is removed and
732 inserted again, if the ethernet address of the PC card is used,
733 the same ifnet_t will be used for the card the second time it is
734 inserted. In the future, when the ifnet_t is correctly
735 refcounted by all of the stack, the interfaces may be freed and
736 the unique ids ignored.
737 @param init The initial values for the interface. These values can
738 not be changed after the interface has been allocated.
739 @param interface The interface allocated upon success.
740 @result May return ENOMEM if there is insufficient memory or EEXIST
741 if an interface with the same uniqueid and family has already
742 been allocated and is in use.
744 extern errno_t
ifnet_allocate(const struct ifnet_init_params
*init
,
748 @function ifnet_reference
749 @discussion Increment the reference count of the ifnet to assure
750 that it will not go away. The interface must already have at
752 @param interface The interface to increment the reference count of.
753 @result May return EINVAL if the interface is not valid.
755 extern errno_t
ifnet_reference(ifnet_t interface
);
758 @function ifnet_release
759 @discussion Release a reference of the ifnet, this may trigger a
760 free if the reference count reaches 0.
761 @param interface The interface to decrement the reference count of
763 @result May return EINVAL if the interface is not valid.
765 extern errno_t
ifnet_release(ifnet_t interface
);
768 @function ifnet_attach
769 @discussion Attaches an interface to the global interface list. The
770 interface must be setup properly before calling attach. The
771 stack will take a reference on the interface and hold it until
772 ifnet_detach is called.
774 This function is intended to be called by the driver. A kext
775 must not call this function on an interface the kext does not
777 @param interface The interface to attach.
778 @param ll_addr The link layer address of the interface. This is used
779 to fill out the first ifaddr in the list of addresses for the
780 interface. This parameter is not required for interfaces such as
781 PPP that have no link-layer address.
782 @result Will return an error if there is anything wrong with the
785 extern errno_t
ifnet_attach(ifnet_t interface
,
786 const struct sockaddr_dl
*ll_addr
);
789 @function ifnet_detach
790 @discussion Detaches the interface.
792 Call this to indicate this interface is no longer valid (i.e. PC
793 Card was removed). This function will begin the process of
794 removing knowledge of this interface from the stack.
796 The function will return before the interface is detached. The
797 functions you supplied in to the interface may continue to be
798 called. When the detach has been completed, your detached
799 function will be called. Your kext must not unload until the
800 detached function has been called. The interface will be
801 properly freed when the reference count reaches zero.
803 An interface may not be attached again. You must call
804 ifnet_allocate to create a new interface to attach.
806 This function is intended to be called by the driver. A kext
807 must not call this function on an interface the kext does not
809 @param interface The interface to detach.
810 @result 0 on success, otherwise errno error.
812 extern errno_t
ifnet_detach(ifnet_t interface
);
815 @function ifnet_interface_family_find
816 @discussion Look up the interface family identifier for a string.
817 If there is no interface family identifier assigned for this string
818 a new interface family identifier is created and assigned.
819 It is recommended to use the bundle id of the KEXT as the string
820 to avoid collisions with other KEXTs.
821 The lookup operation is not optimized so a module should call this
822 function once during startup and cache the interface family identifier.
823 The interface family identifier for a string will not be re-assigned until
825 @param module_string A unique string identifying your interface family
826 @param family_id Upon return, a unique interface family identifier for use with
827 ifnet_* functions. This identifier is valid until the system
829 @result 0 on success, otherwise errno error.
831 extern errno_t
ifnet_interface_family_find(const char *module_string
, ifnet_family_t
*family_id
);
834 * Interface manipulation.
838 @function ifnet_softc
839 @discussion Returns the driver's private storage on the interface.
840 @param interface Interface to retrieve the storage from.
841 @result Driver's private storage.
843 extern void *ifnet_softc(ifnet_t interface
);
847 @discussion Returns a pointer to the name of the interface.
848 @param interface Interface to retrieve the name from.
849 @result Pointer to the name.
851 extern const char *ifnet_name(ifnet_t interface
);
854 @function ifnet_family
855 @discussion Returns the family of the interface.
856 @param interface Interface to retrieve the unit number from.
857 @result Interface family type.
859 extern ifnet_family_t
ifnet_family(ifnet_t interface
);
863 @discussion Returns the unit number of the interface.
864 @param interface Interface to retrieve the unit number from.
867 extern u_int32_t
ifnet_unit(ifnet_t interface
);
870 @function ifnet_index
871 @discussion Returns the index of the interface. This index value
872 will match the index you would find in a sockaddr_dl or using
873 if_nametoindex or if_indextoname in user space. The value of the
874 interface index is undefined for an interface that is not
876 @param interface Interface to retrieve the index of.
879 extern u_int32_t
ifnet_index(ifnet_t interface
);
882 @function ifnet_set_flags
883 @discussion Sets the interface flags to match new_flags.
884 @discussion Sets the interface flags to new_flags. This function
885 lets you specify which flags you want to change using the mask.
886 The kernel will effectively take the lock, then set the
887 interface's flags to (if_flags & ~mask) | (new_flags & mask).
888 @param interface Interface to set the flags on.
889 @param new_flags The new set of flags that should be set. These
890 flags are defined in net/if.h
891 @result 0 on success otherwise the errno error.
893 extern errno_t
ifnet_set_flags(ifnet_t interface
, u_int16_t new_flags
,
897 @function ifnet_flags
898 @discussion Returns the interface flags that are set.
899 @param interface Interface to retrieve the flags from.
900 @result Flags. These flags are defined in net/if.h
902 extern u_int16_t
ifnet_flags(ifnet_t interface
);
905 #ifdef KERNEL_PRIVATE
907 @function ifnet_set_eflags
908 @discussion Sets the extended interface flags to new_flags. This
909 function lets you specify which flags you want to change using
910 the mask. The kernel will effectively take the lock, then set
911 the interface's extended flags to (if_eflags & ~mask) |
913 @param interface The interface.
914 @param new_flags The new set of flags that should be set. These
915 flags are defined in net/if.h
916 @param mask The mask of flags to be modified.
917 @result 0 on success otherwise the errno error.
919 extern errno_t
ifnet_set_eflags(ifnet_t interface
, u_int32_t new_flags
,
923 @function ifnet_eflags
924 @discussion Returns the extended interface flags that are set.
925 @param interface Interface to retrieve the flags from.
926 @result Extended flags. These flags are defined in net/if.h
928 extern u_int32_t
ifnet_eflags(ifnet_t interface
);
931 @function ifnet_set_idle_flags
932 @discussion Sets the if_idle_flags to new_flags. This function
933 lets you specify which flags you want to change using the
934 mask. The kernel will effectively take the lock, then set
935 the interface's idle flags to:
936 (if_idle_flags & ~mask) | (new_flags & mask).
937 Setting the flags to any non-zero value will cause the
938 networking stack to aggressively purge expired objects,
939 such as route entries, etc.
940 @param interface The interface.
941 @param new_flags The new set of flags that should be set. These
942 flags are defined in net/if.h
943 @param mask The mask of flags to be modified.
944 @result 0 on success otherwise the errno error. ENOTSUP is returned
945 when this call is made on non-supporting platforms.
947 extern errno_t
ifnet_set_idle_flags(ifnet_t interface
, u_int32_t new_flags
,
951 @function ifnet_idle_flags
952 @discussion Returns the value of if_idle_flags.
953 @param interface Interface to retrieve the flags from.
954 @result if_idle_flags. These flags are defined in net/if.h
956 extern u_int32_t
ifnet_idle_flags(ifnet_t interface
);
958 #endif /* KERNEL_PRIVATE */
961 @function ifnet_set_capabilities_supported
962 @discussion Specify the capabilities supported by the interface.
963 @discussion This function lets you specify which capabilities are supported
964 by the interface. Typically this function is called by the driver when
965 the interface gets attached to the system.
966 The mask allows to control which capability to set or unset.
967 The kernel will effectively take the lock, then set the
968 interface's flags to (if_capabilities & ~mask) | (new_caps & mask).
970 This function is intended to be called by the driver. A kext
971 must not call this function on an interface the kext does not
973 @param interface Interface to set the capabilities on.
974 @param new_caps The value of the capabilities that should be set or unset. These
975 flags are defined in net/if.h
976 @param mask Which capabilities that should be affected. These
977 flags are defined in net/if.h
978 @result 0 on success otherwise the errno error.
980 extern errno_t
ifnet_set_capabilities_supported(ifnet_t interface
, u_int32_t new_caps
,
984 @function ifnet_capabilities_supported
985 @discussion Retrieve the interface capabilities supported by the interface.
986 @param interface Interface to retrieve the capabilities from.
987 @result Flags. Capabilities flags are defined in net/if.h
989 extern u_int32_t
ifnet_capabilities_supported(ifnet_t interface
);
992 @function ifnet_set_capabilities_enabled
993 @discussion Enable and/or disable the interface capabilities to match new_caps.
994 @discussion Sets the interface capabilities to new_caps. This function
995 lets you specify which capabilities you want to change using the mask.
996 The kernel will effectively take the lock, then set the
997 interface's flags to (if_capenable & ~mask) | (new_caps & mask).
999 This function is intended to be called by the driver. A kext
1000 must not call this function on an interface the kext does not
1003 Typically this function is called by the driver when the interface is
1004 created to specify which of the supported capabilities are enabled by
1005 default. This function is also meant to be called when the driver handles
1006 the interface ioctl SIOCSIFCAP.
1008 The driver should call ifnet_set_offlad() to indicate the corresponding
1009 hardware offload bits that will be used by the networking stack.
1011 It is an error to enable a capability that is not marked as
1012 supported by the interface.
1013 @param interface Interface to set the capabilities on.
1014 @param new_caps The value of the capabilities that should be set or unset. These
1015 flags are defined in net/if.h
1016 @param mask Which capabilities that should be affected. These
1017 flags are defined in net/if.h
1018 @result 0 on success otherwise the errno error.
1020 extern errno_t
ifnet_set_capabilities_enabled(ifnet_t interface
, u_int32_t new_caps
,
1024 @function ifnet_capabilities_enabled
1025 @discussion Retrieve the interface capabilities enabled on the interface.
1026 @param interface Interface to retrieve the capabilities from.
1027 @result Flags. Capabilities flags are defined in net/if.h
1029 extern u_int32_t
ifnet_capabilities_enabled(ifnet_t interface
);
1033 @function ifnet_set_offload
1034 @discussion Sets a bitfield to indicate special hardware offload
1035 support provided by the interface such as hardware checksums and
1036 VLAN. This replaces the if_hwassist flags field. Any flags
1037 unrecognized by the stack will not be set.
1039 Note the system will automatically set the interface capabilities
1040 that correspond to the offload flags modified -- i.e. the driver
1041 does not have to call ifnet_set_capabilities_enabled() and
1042 ifnet_set_capabilities_supported().
1043 @param interface The interface.
1044 @param offload The new set of flags indicating which offload options
1045 the device supports.
1046 @result 0 on success otherwise the errno error.
1048 extern errno_t
ifnet_set_offload(ifnet_t interface
, ifnet_offload_t offload
);
1051 @function ifnet_offload
1052 @discussion Returns flags indicating which operations can be
1053 offloaded to the interface.
1054 @param interface Interface to retrieve the offload from.
1055 @result Abilities flags, see ifnet_offload_t.
1057 extern ifnet_offload_t
ifnet_offload(ifnet_t interface
);
1060 @function ifnet_set_tso_mtu
1061 @discussion Sets maximum TCP Segmentation Offload segment size for
1063 @param interface The interface.
1064 @param family The family for which the offload MTU is provided for
1065 (AF_INET or AF_INET6)
1066 @param mtuLen Maximum segment size supported by the interface
1067 @result 0 on success otherwise the errno error.
1069 extern errno_t
ifnet_set_tso_mtu(ifnet_t interface
, sa_family_t family
,
1073 @function ifnet_get_tso_mtu
1074 @discussion Returns maximum TCP Segmentation Offload segment size for
1076 @param interface The interface.
1077 @param family The family for which the offload MTU is provided for
1078 (AF_INET or AF_INET6)
1079 @param mtuLen Value of the maximum MTU supported for the interface
1080 and family provided.
1081 @result 0 on success otherwise the errno error.
1083 extern errno_t
ifnet_get_tso_mtu(ifnet_t interface
, sa_family_t family
,
1087 @enum Interface wake properties
1088 @abstract Constants defining Interface wake properties.
1089 @constant IFNET_WAKE_ON_MAGIC_PACKET Wake on Magic Packet.
1092 IFNET_WAKE_ON_MAGIC_PACKET
= 0x01
1096 @function ifnet_set_wake_flags
1097 @discussion Sets the wake properties of the underlying hardware. These are
1098 typically set by the driver.
1099 @param interface The interface.
1100 @param properties Properties to set or unset.
1101 @param mask Mask of the properties to set of unset.
1102 @result 0 on success otherwise the errno error.
1104 extern errno_t
ifnet_set_wake_flags(ifnet_t interface
, u_int32_t properties
, u_int32_t mask
);
1107 @function ifnet_get_wake_flags
1108 @discussion Returns the wake properties set on the interface.
1109 @param interface The interface.
1110 @result The wake properties
1112 extern u_int32_t
ifnet_get_wake_flags(ifnet_t interface
);
1115 @function ifnet_set_link_mib_data
1116 @discussion Sets the mib link data. The ifnet_t will store the
1117 pointer you supply and copy mibLen bytes from the pointer
1118 whenever the sysctl for getting interface specific MIB data is
1119 used. Since the ifnet_t stores a pointer to your data instead of
1120 a copy, you may update the data at the address at any time.
1122 This function is intended to be called by the driver. A kext
1123 must not call this function on an interface the kext does not
1125 @param interface Interface to set the unit number of.
1126 @param mibData A pointer to the data.
1127 @param mibLen Length of data pointed to.
1128 @result 0 on success otherwise the errno error.
1130 extern errno_t
ifnet_set_link_mib_data(ifnet_t interface
, void *mibData
,
1134 @function ifnet_get_link_mib_data
1135 @discussion Copies the link MIB data in to mibData, up to mibLen
1136 bytes. Returns error if the buffer is too small to hold all of
1138 @param interface The interface.
1139 @param mibData A pointer to space for the mibData to be copied in
1141 @param mibLen When calling, this should be the size of the buffer
1142 passed in mibData. Upon return, this will be the size of data
1143 copied in to mibData.
1144 @result Returns an error if the buffer size is too small or there is
1147 extern errno_t
ifnet_get_link_mib_data(ifnet_t interface
, void *mibData
,
1151 @function ifnet_get_link_mib_data_length
1152 @discussion Retrieve the size of the mib data.
1153 @param interface The interface.
1154 @result Returns the number of bytes of mib data associated with the
1157 extern u_int32_t
ifnet_get_link_mib_data_length(ifnet_t interface
);
1160 @function ifnet_attach_protocol
1161 @discussion Attaches a protocol to an interface.
1162 @param interface The interface.
1163 @param protocol_family The protocol family being attached
1164 (PF_INET/PF_APPLETALK/etc...).
1165 @param proto_details Details of the protocol being attached.
1166 @result 0 on success otherwise the errno error.
1168 extern errno_t
ifnet_attach_protocol(ifnet_t interface
,
1169 protocol_family_t protocol_family
,
1170 const struct ifnet_attach_proto_param
*proto_details
);
1173 @function ifnet_attach_protocol_v2
1174 @discussion Attaches a protocol to an interface using the newer
1175 version 2 style interface. So far the only difference is support
1176 for packet chains which improve performance.
1177 @param interface The interface.
1178 @param protocol_family The protocol family being attached
1179 (PF_INET/PF_APPLETALK/etc...).
1180 @param proto_details Details of the protocol being attached.
1181 @result 0 on success otherwise the errno error.
1183 extern errno_t
ifnet_attach_protocol_v2(ifnet_t interface
,
1184 protocol_family_t protocol_family
,
1185 const struct ifnet_attach_proto_param_v2
*proto_details
);
1188 @function ifnet_detach_protocol
1189 @discussion Detaches a protocol from an interface.
1190 @param interface The interface.
1191 @param protocol_family The protocol family of the protocol to
1193 @result 0 on success otherwise the errno error.
1195 extern errno_t
ifnet_detach_protocol(ifnet_t interface
,
1196 protocol_family_t protocol_family
);
1199 @function ifnet_output
1200 @discussion Handles an outbound packet on the interface by calling
1201 any filters, a protocol preoutput function, the interface framer
1202 function, and finally the interface's output function. The
1203 protocol_family will be used to apply protocol filters and
1204 determine which preoutput function to call. The route and dest
1205 parameters will be passed to the preoutput function defined for
1206 the attachment of the specified protocol to the specified
1207 interface. ifnet_output will always free the mbuf chain.
1208 @param interface The interface.
1209 @param protocol_family The family of the protocol generating this
1210 packet (i.e. AF_INET).
1211 @param packet The packet to be transmitted.
1212 @param route A pointer to a routing structure for this packet. The
1213 preoutput function determines whether this value may be NULL or
1215 @param dest The destination address of protocol_family type. This
1216 will be passed to the preoutput function. If the preoutput
1217 function does not require this value, you may pass NULL.
1218 @result 0 on success otherwise the errno error.
1220 extern errno_t
ifnet_output(ifnet_t interface
,
1221 protocol_family_t protocol_family
, mbuf_t packet
, void *route
,
1222 const struct sockaddr
*dest
);
1225 @function ifnet_output_raw
1226 @discussion Handles and outbond raw packet on the interface by
1227 calling any filters followed by the interface's output function.
1228 protocol_family may be zero. If the packet is from a specific
1229 protocol the protocol_family will be used to apply protocol
1230 filters. All interface filters will be applied to the outgoing
1231 packet. Processing, such as calling the protocol preoutput and
1232 interface framer functions will be bypassed. The packet will
1233 pass through the filters and be sent on the interface as is.
1234 ifnet_output_raw will always free the packet chain.
1235 @param interface The interface.
1236 @param protocol_family The family of the protocol generating this
1237 packet (i.e. AF_INET).
1238 @param packet The fully formed packet to be transmitted.
1239 @result 0 on success otherwise the errno error.
1241 extern errno_t
ifnet_output_raw(ifnet_t interface
,
1242 protocol_family_t protocol_family
, mbuf_t packet
);
1245 @function ifnet_input
1246 @discussion Inputs packets from the interface. The interface's demux
1247 will be called to determine the protocol. Once the protocol is
1248 determined, the interface filters and protocol filters will be
1249 called. From there, the packet will be passed to the registered
1250 protocol. If there is an error, the mbuf chain will be freed.
1251 @param interface The interface.
1252 @param first_packet The first packet in a chain of packets.
1253 @param stats Counts to be integrated in to the stats. The interface
1254 statistics will be incremented by the amounts specified in
1255 stats. This parameter may be NULL.
1256 @result 0 on success otherwise the errno error.
1258 extern errno_t
ifnet_input(ifnet_t interface
, mbuf_t first_packet
,
1259 const struct ifnet_stat_increment_param
*stats
);
1262 @function ifnet_ioctl
1263 @discussion Calls the interface's ioctl function with the parameters
1266 All undefined ioctls are reserved for future use by Apple. If
1267 you need to communicate with your kext using an ioctl, please
1268 use SIOCSIFKPI and SIOCGIFKPI.
1269 @param interface The interface.
1270 @param protocol The protocol family of the protocol to send the
1271 ioctl to (may be zero). Some ioctls apply to a protocol while
1272 other ioctls apply to just an interface.
1273 @param ioctl_code The ioctl to perform.
1274 @param ioctl_arg Any parameters to the ioctl.
1275 @result 0 on success otherwise the errno error.
1277 extern errno_t
ifnet_ioctl(ifnet_t interface
, protocol_family_t protocol
,
1278 unsigned long ioctl_code
, void *ioctl_arg
);
1281 @function ifnet_event
1282 @discussion Calls the interface's event function.
1283 @param interface The interface.
1284 @param event_ptr Pointer to an kern_event structure describing the
1286 @result 0 on success otherwise the errno error.
1288 extern errno_t
ifnet_event(ifnet_t interface
, struct kern_event_msg
*event_ptr
);
1291 @function ifnet_set_mtu
1292 @discussion Sets the value of the MTU in the interface structure.
1293 Calling this function will not notify the driver that the MTU
1294 should be changed. Use the appropriate ioctl.
1296 This function is intended to be called by the driver. A kext
1297 must not call this function on an interface the kext does not
1299 @param interface The interface.
1300 @param mtu The new MTU.
1301 @result 0 on success otherwise the errno error.
1303 extern errno_t
ifnet_set_mtu(ifnet_t interface
, u_int32_t mtu
);
1307 @param interface The interface.
1310 extern u_int32_t
ifnet_mtu(ifnet_t interface
);
1313 @function ifnet_type
1314 @param interface The interface.
1315 @result The type. See net/if_types.h.
1317 extern u_int8_t
ifnet_type(ifnet_t interface
);
1320 @function ifnet_set_addrlen
1322 This function is intended to be called by the driver. A kext
1323 must not call this function on an interface the kext does not
1325 @param interface The interface.
1326 @param addrlen The new address length.
1327 @result 0 on success otherwise the errno error.
1329 extern errno_t
ifnet_set_addrlen(ifnet_t interface
, u_int8_t addrlen
);
1332 @function ifnet_addrlen
1333 @param interface The interface.
1334 @result The address length.
1336 extern u_int8_t
ifnet_addrlen(ifnet_t interface
);
1339 @function ifnet_set_hdrlen
1341 This function is intended to be called by the driver. A kext
1342 must not call this function on an interface the kext does not
1344 @param interface The interface.
1345 @param hdrlen The new header length.
1346 @result 0 on success otherwise the errno error.
1348 extern errno_t
ifnet_set_hdrlen(ifnet_t interface
, u_int8_t hdrlen
);
1351 @function ifnet_hdrlen
1352 @param interface The interface.
1353 @result The header length.
1355 extern u_int8_t
ifnet_hdrlen(ifnet_t interface
);
1358 @function ifnet_set_metric
1360 This function is intended to be called by the driver. A kext
1361 must not call this function on an interface the kext does not
1363 @param interface The interface.
1364 @param metric The new metric.
1365 @result 0 on success otherwise the errno error.
1367 extern errno_t
ifnet_set_metric(ifnet_t interface
, u_int32_t metric
);
1370 @function ifnet_metric
1371 @param interface The interface.
1374 extern u_int32_t
ifnet_metric(ifnet_t interface
);
1377 @function ifnet_set_baudrate
1379 This function is intended to be called by the driver. A kext
1380 must not call this function on an interface the kext does not
1382 @param interface The interface.
1383 @param baudrate The new baudrate.
1384 @result 0 on success otherwise the errno error.
1386 extern errno_t
ifnet_set_baudrate(ifnet_t interface
, u_int64_t baudrate
);
1389 @function ifnet_baudrate
1390 @param interface The interface.
1391 @result The baudrate.
1393 extern u_int64_t
ifnet_baudrate(ifnet_t interface
);
1396 @function ifnet_stat_increment
1398 This function is intended to be called by the driver. A kext
1399 must not call this function on an interface the kext does not
1401 @param interface The interface.
1402 @param counts A pointer to a structure containing the amount to
1403 increment each counter by. Any counts not appearing in the
1404 ifnet_counter_increment structure are handled in the stack.
1405 @result 0 on success otherwise the errno error.
1407 extern errno_t
ifnet_stat_increment(ifnet_t interface
,
1408 const struct ifnet_stat_increment_param
*counts
);
1411 @function ifnet_stat_increment_in
1413 This function is intended to be called by the driver. This
1414 function allows a driver to update the inbound interface counts.
1415 The most efficient time to update these counts is when calling
1418 A lock protects the counts, this makes the increment functions
1419 expensive. The increment function will update the lastchanged
1421 @param interface The interface.
1422 @param packets_in The number of additional packets received.
1423 @param bytes_in The number of additional bytes received.
1424 @param errors_in The number of additional receive errors.
1425 @result 0 on success otherwise the errno error.
1427 extern errno_t
ifnet_stat_increment_in(ifnet_t interface
,
1428 u_int32_t packets_in
, u_int32_t bytes_in
, u_int32_t errors_in
);
1431 @function ifnet_stat_increment_out
1433 This function is intended to be called by the driver. This
1434 function allows a driver to update the outbound interface
1437 A lock protects the counts, this makes the increment functions
1438 expensive. The increment function will update the lastchanged
1440 @param interface The interface.
1441 @param packets_out The number of additional packets sent.
1442 @param bytes_out The number of additional bytes sent.
1443 @param errors_out The number of additional send errors.
1444 @result 0 on success otherwise the errno error.
1446 extern errno_t
ifnet_stat_increment_out(ifnet_t interface
,
1447 u_int32_t packets_out
, u_int32_t bytes_out
, u_int32_t errors_out
);
1450 @function ifnet_set_stat
1452 This function is intended to be called by the driver. A kext
1453 must not call this function on an interface the kext does not
1456 The one exception would be the case where a kext wants to zero
1457 all of the counters.
1458 @param interface The interface.
1459 @param counts The new stats values.
1460 @result 0 on success otherwise the errno error.
1462 extern errno_t
ifnet_set_stat(ifnet_t interface
,
1463 const struct ifnet_stats_param
*stats
);
1466 @function ifnet_stat
1467 @param interface The interface.
1468 @param out_stats Storage for the values.
1469 @result 0 on success otherwise the errno error.
1471 extern errno_t
ifnet_stat(ifnet_t interface
,
1472 struct ifnet_stats_param
*out_stats
);
1475 @function ifnet_set_promiscuous
1476 @discussion Enable or disable promiscuous mode on the interface. The
1477 interface keeps an internal count of the number of times
1478 promiscuous mode has been enabled. Promiscuous mode is only
1479 disabled when this count reaches zero. Be sure to disable
1480 promiscuous mode only once for every time you enable it.
1481 @param interface The interface to toggle promiscuous mode on.
1482 @param on If set, the number of promicuous on requests will be
1483 incremented. If this is the first requrest, promiscuous mode
1484 will be enabled. If this is not set, the number of promiscous
1485 clients will be decremented. If this causes the number to reach
1486 zero, promiscuous mode will be disabled.
1487 @result 0 on success otherwise the errno error.
1489 extern errno_t
ifnet_set_promiscuous(ifnet_t interface
, int on
);
1492 @function ifnet_touch_lastchange
1493 @discussion Updates the lastchange value to now.
1494 @param interface The interface.
1495 @result 0 on success otherwise the errno error.
1497 extern errno_t
ifnet_touch_lastchange(ifnet_t interface
);
1500 @function ifnet_lastchange
1501 @param interface The interface.
1502 @param last_change A timeval struct to copy the last time changed in
1505 extern errno_t
ifnet_lastchange(ifnet_t interface
, struct timeval
*last_change
);
1508 @function ifnet_get_address_list
1509 @discussion Get a list of addresses on the interface. Passing NULL
1510 for the interface will return a list of all addresses. The
1511 addresses will have their reference count bumped so they will
1512 not go away. Calling ifnet_free_address_list will decrement the
1513 refcount and free the array. If you wish to hold on to a
1514 reference to an ifaddr_t, be sure to bump the reference count
1515 before calling ifnet_free_address_list.
1516 @param interface The interface.
1517 @param addresses A pointer to a NULL terminated array of ifaddr_ts.
1518 @result 0 on success otherwise the errno error.
1520 extern errno_t
ifnet_get_address_list(ifnet_t interface
, ifaddr_t
**addresses
);
1523 @function ifnet_get_address_list_family
1524 @discussion Get a list of addresses on the interface. Passing NULL
1525 for the interface will return a list of all addresses. The
1526 addresses will have their reference count bumped so they will
1527 not go away. Calling ifnet_free_address_list will decrement the
1528 refcount and free the array. If you wish to hold on to a
1529 reference to an ifaddr_t, be sure to bump the reference count
1530 before calling ifnet_free_address_list. Unlike
1531 ifnet_get_address_list, this function lets the caller specify
1532 the address family to get a list of only a specific address type.
1533 @param interface The interface.
1534 @param addresses A pointer to a NULL terminated array of ifaddr_ts.
1535 @result 0 on success otherwise the errno error.
1537 extern errno_t
ifnet_get_address_list_family(ifnet_t interface
,
1538 ifaddr_t
**addresses
, sa_family_t family
);
1540 #ifdef KERNEL_PRIVATE
1541 __private_extern__ errno_t
ifnet_get_address_list_family_internal(ifnet_t
,
1542 ifaddr_t
**, sa_family_t
, int, int);
1543 #endif /* KERNEL_PRIVATE */
1546 @function ifnet_free_address_list
1547 @discussion Free a list of addresses returned from
1548 ifnet_get_address_list. Decrements the refcounts and frees the
1549 memory used for the array of references.
1550 @param addresses An array of ifaddr_ts.
1552 extern void ifnet_free_address_list(ifaddr_t
*addresses
);
1555 @function ifnet_set_lladdr
1556 @discussion Sets the link-layer address for this interface.
1557 @param interface The interface the link layer address is being
1559 @param lladdr A pointer to the raw link layer address (pointer to
1560 the 6 byte ethernet address for ethernet).
1561 @param lladdr_len The length, in bytes, of the link layer address.
1563 extern errno_t
ifnet_set_lladdr(ifnet_t interface
, const void *lladdr
,
1567 @function ifnet_lladdr_copy_bytes
1568 @discussion Copies the bytes of the link-layer address in to the
1570 @param interface The interface to copy the link-layer address from.
1571 @param lladdr The buffer to copy the link-layer address in to.
1572 @param length The length of the buffer. This value must match the
1573 length of the link-layer address.
1575 extern errno_t
ifnet_lladdr_copy_bytes(ifnet_t interface
, void *lladdr
,
1578 #ifdef KERNEL_PRIVATE
1580 @function ifnet_lladdr
1581 @discussion Returns a pointer to the link-layer address.
1582 @param interface The interface the link-layer address is on.
1584 extern void *ifnet_lladdr(ifnet_t interface
);
1585 #endif /* KERNEL_PRIVATE */
1588 @function ifnet_llbroadcast_copy_bytes
1589 @discussion Retrieves the link-layer broadcast address for this
1591 @param interface The interface.
1592 @param addr A buffer to copy the broadcast address in to.
1593 @param bufferlen The length of the buffer at addr.
1594 @param addr_len On return, the length of the broadcast address.
1595 @param lladdr_len The length, in bytes, of the link layer address.
1597 extern errno_t
ifnet_llbroadcast_copy_bytes(ifnet_t interface
, void *addr
,
1598 size_t bufferlen
, size_t *addr_len
);
1600 #ifdef KERNEL_PRIVATE
1602 @function ifnet_set_lladdr_and_type
1603 @discussion Sets the link-layer address as well as the type field in
1604 the sockaddr_dl. Support for setting the type was added for vlan
1605 and bond interfaces.
1606 @param interface The interface the link layer address is being
1608 @param lladdr A pointer to the raw link layer address (pointer to
1609 the 6 byte ethernet address for ethernet).
1610 @param lladdr_len The length, in bytes, of the link layer address.
1611 @param type The link-layer address type.
1613 extern errno_t
ifnet_set_lladdr_and_type(ifnet_t interface
, const void *lladdr
,
1614 size_t length
, u_char type
);
1615 #endif /* KERNEL_PRIVATE */
1618 @function ifnet_resolve_multicast
1619 @discussion Resolves a multicast address for an attached protocol to
1620 a link-layer address. If a link-layer address is passed in, the
1621 interface will verify that it is a valid multicast address.
1622 @param interface The interface.
1623 @param proto_addr A protocol address to be converted to a link-layer
1625 @param ll_addr Storage for the resulting link-layer address.
1626 @param ll_len Length of the storage for the link-layer address.
1627 @result 0 on success. EOPNOTSUPP indicates the multicast address was
1628 not supported or could not be translated. Other errors may
1629 indicate other failures.
1631 extern errno_t
ifnet_resolve_multicast(ifnet_t ifp
,
1632 const struct sockaddr
*proto_addr
, struct sockaddr
*ll_addr
, size_t ll_len
);
1635 @function ifnet_add_multicast
1636 @discussion Joins a multicast and returns an ifmultiaddr_t with the
1637 reference count incremented for you. You are responsible for
1638 decrementing the reference count after calling
1639 ifnet_remove_multicast and making sure you no longer have any
1640 references to the multicast.
1641 @param interface The interface.
1642 @param maddr The multicast address (AF_UNSPEC/AF_LINK) to join. Either
1643 a physical address or logical address to be translated to a
1645 @param multicast The resulting ifmultiaddr_t multicast address.
1646 @result 0 on success otherwise the errno error.
1648 extern errno_t
ifnet_add_multicast(ifnet_t interface
,
1649 const struct sockaddr
*maddr
, ifmultiaddr_t
*multicast
);
1652 @function ifnet_remove_multicast
1653 @discussion Causes the interface to leave the multicast group. The
1654 stack keeps track of how many times ifnet_add_multicast has been
1655 called for a given multicast address. The multicast will only be
1656 removed when the number of times ifnet_remove_multicast has been
1657 called matches the number of times ifnet_add_multicast has been
1660 The memory for the multicast address is not actually freed until
1661 the separate reference count has reached zero. Some parts of the
1662 stack may keep a pointer to the multicast even after that
1663 multicast has been removed from the interface.
1665 When an interface is detached, all of the multicasts are
1666 removed. If the interface of the multicast passed in is no
1667 longer attached, this function will gracefully return,
1670 It is the callers responsibility to release the multicast
1671 address after calling this function.
1672 @param multicast The multicast to be removed.
1673 @result 0 on success otherwise the errno error.
1675 extern errno_t
ifnet_remove_multicast(ifmultiaddr_t multicast
);
1678 @function ifnet_get_multicast_list
1679 @discussion Retrieves a list of multicast address the interface is
1680 set to receive. This function allocates and returns an array of
1681 references to the various multicast addresses. The multicasts
1682 have their reference counts bumped on your behalf. Calling
1683 ifnet_free_multicast_list will decrement the reference counts
1685 @param interface The interface.
1686 @param multicasts A pointer to a NULL terminated array of references
1687 to the multicast addresses.
1688 @result 0 on success otherwise the errno error.
1690 extern errno_t
ifnet_get_multicast_list(ifnet_t interface
,
1691 ifmultiaddr_t
**addresses
);
1694 @function ifnet_free_multicast_list
1695 @discussion Frees a list of multicasts returned by
1696 ifnet_get_multicast_list. Decrements the refcount on each
1697 multicast address and frees the array.
1698 @param multicasts An array of references to the multicast addresses.
1699 @result 0 on success otherwise the errno error.
1701 extern void ifnet_free_multicast_list(ifmultiaddr_t
*multicasts
);
1704 @function ifnet_find_by_name
1705 @discussion Find an interface by the name including the unit number.
1706 Caller must call ifnet_release on any non-null interface return
1708 @param name The name of the interface, including any unit number
1710 @param interface A pointer to an interface reference. This will be
1711 filled in if a matching interface is found.
1712 @result 0 on success otherwise the errno error.
1714 extern errno_t
ifnet_find_by_name(const char *ifname
, ifnet_t
*interface
);
1717 @function ifnet_list_get
1718 @discussion Get a list of attached interfaces. List will be set to
1719 point to an array allocated by ifnet_list_get. The interfaces
1720 are refcounted and the counts will be incremented before the
1721 function returns. The list of interfaces must be freed using
1723 @param family The interface family (i.e. IFNET_FAMILY_ETHERNET). To
1724 find interfaces of all families, use IFNET_FAMILY_ANY.
1725 @param interfaces A pointer to an array of interface references.
1726 @param count A pointer that will be filled in with the number of
1727 matching interfaces in the array.
1728 @result 0 on success otherwise the errno error.
1730 extern errno_t
ifnet_list_get(ifnet_family_t family
, ifnet_t
**interfaces
,
1733 #ifdef KERNEL_PRIVATE
1735 @function ifnet_list_get_all
1736 @discussion Get a list of attached interfaces. List will be set to
1737 point to an array allocated by ifnet_list_get. The interfaces
1738 are refcounted and the counts will be incremented before the
1739 function returns. The list of interfaces must be freed using
1740 ifnet_list_free. This is similar to ifnet_list_get, except
1741 that it includes interfaces that are detaching.
1742 @param family The interface family (i.e. IFNET_FAMILY_ETHERNET). To
1743 find interfaces of all families, use IFNET_FAMILY_ANY.
1744 @param interfaces A pointer to an array of interface references.
1745 @param count A pointer that will be filled in with the number of
1746 matching interfaces in the array.
1747 @result 0 on success otherwise the errno error.
1749 extern errno_t
ifnet_list_get_all(ifnet_family_t family
, ifnet_t
**interfaces
,
1751 #endif /* KERNEL_PRIVATE */
1754 @function ifnet_list_free
1755 @discussion Free a list of interfaces returned by ifnet_list_get.
1756 Decrements the reference count on each interface and frees the
1757 array of references. If you keep a reference to an interface, be
1758 sure to increment the reference count before calling
1760 @param interfaces An array of interface references from ifnet_list_get.
1762 extern void ifnet_list_free(ifnet_t
*interfaces
);
1764 /******************************************************************************/
1765 /* ifaddr_t accessors */
1766 /******************************************************************************/
1769 @function ifaddr_reference
1770 @discussion Increment the reference count of an address tied to an
1772 @param ifaddr The interface address.
1773 @result 0 upon success
1775 extern errno_t
ifaddr_reference(ifaddr_t ifaddr
);
1778 @function ifaddr_release
1779 @discussion Decrements the reference count of and possibly frees an
1780 address tied to an interface.
1781 @param ifaddr The interface address.
1782 @result 0 upon success
1784 extern errno_t
ifaddr_release(ifaddr_t ifaddr
);
1787 @function ifaddr_address
1788 @discussion Copies the address out of the ifaddr.
1789 @param ifaddr The interface address.
1790 @param out_addr The sockaddr storage for the address.
1791 @param addr_size The size of the storage for the address.
1792 @result 0 upon success
1794 extern errno_t
ifaddr_address(ifaddr_t ifaddr
, struct sockaddr
*out_addr
,
1795 u_int32_t addr_size
);
1798 @function ifaddr_address
1799 @discussion Returns the address family of the address.
1800 @param ifaddr The interface address.
1801 @result 0 on failure, address family on success.
1803 extern sa_family_t
ifaddr_address_family(ifaddr_t ifaddr
);
1806 @function ifaddr_dstaddress
1807 @discussion Copies the destination address out of the ifaddr.
1808 @param ifaddr The interface address.
1809 @param out_dstaddr The sockaddr storage for the destination address.
1810 @param dstaddr_size The size of the storage for the destination address.
1811 @result 0 upon success
1813 extern errno_t
ifaddr_dstaddress(ifaddr_t ifaddr
, struct sockaddr
*out_dstaddr
,
1814 u_int32_t dstaddr_size
);
1817 @function ifaddr_netmask
1818 @discussion Copies the netmask out of the ifaddr.
1819 @param ifaddr The interface address.
1820 @param out_netmask The sockaddr storage for the netmask.
1821 @param netmask_size The size of the storage for the netmask.
1822 @result 0 upon success
1824 extern errno_t
ifaddr_netmask(ifaddr_t ifaddr
, struct sockaddr
*out_netmask
,
1825 u_int32_t netmask_size
);
1828 @function ifaddr_ifnet
1829 @discussion Returns the interface the address is attached to. The
1830 reference is only valid until the ifaddr is released. If you
1831 need to hold a reference to the ifnet for longer than you hold a
1832 reference to the ifaddr, increment the reference using
1834 @param ifaddr The interface address.
1835 @result A reference to the interface the address is attached to.
1837 extern ifnet_t
ifaddr_ifnet(ifaddr_t ifaddr
);
1840 @function ifaddr_withaddr
1841 @discussion Returns an interface address with the address specified.
1842 Increments the reference count on the ifaddr before returning to
1843 the caller. Caller is responsible for calling ifaddr_release.
1844 @param address The address to search for.
1845 @result A reference to the interface address.
1847 extern ifaddr_t
ifaddr_withaddr(const struct sockaddr
*address
);
1850 @function ifaddr_withdstaddr
1851 @discussion Returns an interface address for the interface address
1852 that matches the destination when the netmask is applied.
1853 Increments the reference count on the ifaddr before returning to
1854 the caller. Caller is responsible for calling ifaddr_release.
1855 @param destination The destination to search for.
1856 @result A reference to the interface address.
1858 extern ifaddr_t
ifaddr_withdstaddr(const struct sockaddr
*destination
);
1861 @function ifaddr_withnet
1862 @discussion Returns an interface address for the interface with the
1863 network described by net. Increments the reference count on the
1864 ifaddr before returning to the caller. Caller is responsible for
1865 calling ifaddr_release.
1866 @param net The network to search for.
1867 @result A reference to the interface address.
1869 extern ifaddr_t
ifaddr_withnet(const struct sockaddr
*net
);
1872 @function ifaddr_withroute
1873 @discussion Returns an interface address given a destination and
1874 gateway. Increments the reference count on the ifaddr before
1875 returning to the caller. Caller is responsible for calling
1877 @param flags Routing flags. See net/route.h, RTF_GATEWAY etc.
1878 @param destination The destination to search for.
1879 @param gateway A gateway to search for.
1880 @result A reference to the interface address.
1882 extern ifaddr_t
ifaddr_withroute(int flags
, const struct sockaddr
*destination
,
1883 const struct sockaddr
*gateway
);
1886 @function ifaddr_findbestforaddr
1887 @discussion Finds the best local address assigned to a specific
1888 interface to use when communicating with another address.
1889 Increments the reference count on the ifaddr before returning to
1890 the caller. Caller is responsible for calling ifaddr_release.
1891 @param addr The remote address.
1892 @param interface The local interface.
1893 @result A reference to the interface address.
1895 extern ifaddr_t
ifaddr_findbestforaddr(const struct sockaddr
*addr
,
1898 /******************************************************************************/
1899 /* ifmultiaddr_t accessors */
1900 /******************************************************************************/
1903 @function ifmaddr_reference
1904 @discussion Increment the reference count of an interface multicast
1906 @param ifmaddr The interface multicast address.
1907 @result 0 on success. Only error will be EINVAL if ifmaddr is not valid.
1909 extern errno_t
ifmaddr_reference(ifmultiaddr_t ifmaddr
);
1912 @function ifmaddr_release
1913 @discussion Decrement the reference count of an interface multicast
1914 address. If the reference count reaches zero, the ifmultiaddr
1915 will be removed from the interface and the ifmultiaddr will be
1917 @param ifmaddr The interface multicast address.
1918 @result 0 on success. Only error will be EINVAL if ifmaddr is not valid.
1920 extern errno_t
ifmaddr_release(ifmultiaddr_t ifmaddr
);
1923 @function ifmaddr_address
1924 @discussion Copies the multicast address to out_multicast.
1925 @param out_multicast Storage for a sockaddr.
1926 @param addr_size Size of the storage.
1927 @result 0 on success.
1929 extern errno_t
ifmaddr_address(ifmultiaddr_t ifmaddr
,
1930 struct sockaddr
*out_multicast
, u_int32_t addr_size
);
1933 @function ifmaddr_lladdress
1934 @discussion Copies the link layer multicast address to
1935 out_link_layer_multicast.
1936 @param out_link_layer_multicast Storage for a sockaddr.
1937 @param addr_size Size of the storage.
1938 @result 0 on success.
1940 extern errno_t
ifmaddr_lladdress(ifmultiaddr_t ifmaddr
,
1941 struct sockaddr
*out_link_layer_multicast
, u_int32_t addr_size
);
1944 @function ifmaddr_ifnet
1945 @discussion Returns the interface this multicast address is attached
1946 to. The interface reference count is not bumped by this
1947 function. The interface is only valid as long as you don't
1948 release the refernece to the multiast address. If you need to
1949 maintain your pointer to the ifnet, call ifnet_reference
1950 followed by ifnet_release when you're finished.
1951 @param ifmaddr The interface multicast address.
1952 @result A reference to the interface.
1954 extern ifnet_t
ifmaddr_ifnet(ifmultiaddr_t ifmaddr
);
1956 #ifdef KERNEL_PRIVATE
1957 /******************************************************************************/
1958 /* interface cloner */
1959 /******************************************************************************/
1962 @typedef ifnet_clone_create_func
1963 @discussion ifnet_clone_create_func is called to create an interface.
1964 @param ifcloner The interface cloner.
1965 @param unit The interface unit number to create.
1966 @param params Additional information specific to the interface cloner.
1967 @result Return zero on success or an errno error value on failure.
1969 typedef errno_t (*ifnet_clone_create_func
)(if_clone_t ifcloner
, u_int32_t unit
, void *params
);
1972 @typedef ifnet_clone_destroy_func
1973 @discussion ifnet_clone_create_func is called to destroy an interface created
1974 by an interface cloner.
1975 @param interface The interface to destroy.
1976 @result Return zero on success or an errno error value on failure.
1978 typedef errno_t (*ifnet_clone_destroy_func
)(ifnet_t interface
);
1981 @struct ifnet_clone_params
1982 @discussion This structure is used to represent an interface cloner.
1983 @field ifc_name The interface name handled by this interface cloner.
1984 @field ifc_create The function to create an interface.
1985 @field ifc_destroy The function to destroy an interface.
1987 struct ifnet_clone_params
{
1988 const char *ifc_name
;
1989 ifnet_clone_create_func ifc_create
;
1990 ifnet_clone_destroy_func ifc_destroy
;
1994 @function ifnet_clone_attach
1995 @discussion Attaches a new interface cloner.
1996 @param cloner_params The structure that defines an interface cloner.
1997 @param interface A pointer to an opaque handle that represent the interface cloner
1998 that is attached upon success.
1999 @result Returns 0 on success.
2000 May return ENOBUFS if there is insufficient memory.
2001 May return EEXIST if an interface cloner with the same name is already attached.
2003 extern errno_t
ifnet_clone_attach(struct ifnet_clone_params
*cloner_params
, if_clone_t
*ifcloner
);
2006 @function ifnet_clone_detach
2007 @discussion Detaches a previously attached interface cloner.
2008 @param ifcloner The opaque handle returned when the interface cloner was attached.
2009 @result Returns 0 on success.
2011 extern errno_t
ifnet_clone_detach(if_clone_t ifcloner
);
2013 #endif /* KERNEL_PRIVATE */
2017 #endif /* __KPI_INTERFACE__ */