X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..99c3a10404e5d1ef94397ab4df5a8b74711fc4d3:/bsd/net/kpi_interface.h diff --git a/bsd/net/kpi_interface.h b/bsd/net/kpi_interface.h index 3a7751e91..d4df862da 100644 --- a/bsd/net/kpi_interface.h +++ b/bsd/net/kpi_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2004-2012 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -34,13 +34,36 @@ #ifndef __KPI_INTERFACE__ #define __KPI_INTERFACE__ + +#ifndef XNU_KERNEL_PRIVATE +#include +#endif + #include +#ifdef KERNEL_PRIVATE +#include +#endif /* KERNEL_PRIVATE */ + #ifndef _SA_FAMILY_T #define _SA_FAMILY_T typedef __uint8_t sa_family_t; #endif +#ifdef XNU_KERNEL_PRIVATE +#if CONFIG_EMBEDDED + #define KPI_INTERFACE_EMBEDDED 1 +#else + #define KPI_INTERFACE_EMBEDDED 0 +#endif +#else +#if TARGET_OS_EMBEDDED + #define KPI_INTERFACE_EMBEDDED 1 +#else + #define KPI_INTERFACE_EMBEDDED 0 +#endif +#endif + struct timeval; struct sockaddr; struct sockaddr_dl; @@ -66,24 +89,26 @@ struct ifnet_demux_desc; @constant IFNET_FAMILY_STF A 6to4 interface. @constant IFNET_FAMILY_FIREWIRE An IEEE 1394 (firewire) interface. @constant IFNET_FAMILY_BOND A virtual bonded interface. + @constant IFNET_FAMILY_CELLULAR A cellular interface. */ enum { - IFNET_FAMILY_ANY = 0, - IFNET_FAMILY_LOOPBACK = 1, - IFNET_FAMILY_ETHERNET = 2, - IFNET_FAMILY_SLIP = 3, - IFNET_FAMILY_TUN = 4, - IFNET_FAMILY_VLAN = 5, - IFNET_FAMILY_PPP = 6, - IFNET_FAMILY_PVC = 7, - IFNET_FAMILY_DISC = 8, - IFNET_FAMILY_MDECAP = 9, - IFNET_FAMILY_GIF = 10, - IFNET_FAMILY_FAITH = 11, - IFNET_FAMILY_STF = 12, - IFNET_FAMILY_FIREWIRE = 13, - IFNET_FAMILY_BOND = 14 + IFNET_FAMILY_ANY = 0, + IFNET_FAMILY_LOOPBACK = 1, + IFNET_FAMILY_ETHERNET = 2, + IFNET_FAMILY_SLIP = 3, + IFNET_FAMILY_TUN = 4, + IFNET_FAMILY_VLAN = 5, + IFNET_FAMILY_PPP = 6, + IFNET_FAMILY_PVC = 7, + IFNET_FAMILY_DISC = 8, + IFNET_FAMILY_MDECAP = 9, + IFNET_FAMILY_GIF = 10, + IFNET_FAMILY_FAITH = 11, /* deprecated */ + IFNET_FAMILY_STF = 12, + IFNET_FAMILY_FIREWIRE = 13, + IFNET_FAMILY_BOND = 14, + IFNET_FAMILY_CELLULAR = 15 }; /*! @typedef ifnet_family_t @@ -91,6 +116,8 @@ enum { */ typedef u_int32_t ifnet_family_t; +#ifndef BPF_TAP_MODE_T +#define BPF_TAP_MODE_T /*! @enum BPF tap mode @abstract Constants defining interface families. @@ -101,16 +128,17 @@ typedef u_int32_t ifnet_family_t; */ enum { - BPF_MODE_DISABLED = 0, - BPF_MODE_INPUT = 1, - BPF_MODE_OUTPUT = 2, - BPF_MODE_INPUT_OUTPUT = 3 + BPF_MODE_DISABLED = 0, + BPF_MODE_INPUT = 1, + BPF_MODE_OUTPUT = 2, + BPF_MODE_INPUT_OUTPUT = 3 }; /*! @typedef bpf_tap_mode @abstract Mode for tapping. BPF_MODE_DISABLED/BPF_MODE_INPUT_OUTPUT etc. */ typedef u_int32_t bpf_tap_mode; +#endif /* !BPF_TAP_MODE_T */ /*! @typedef protocol_family_t @@ -126,21 +154,55 @@ typedef u_int32_t protocol_family_t; @constant IFNET_CSUM_UDP Hardware will calculate UDP checksums. @constant IFNET_CSUM_FRAGMENT Hardware will checksum IP fragments. @constant IFNET_IP_FRAGMENT Hardware will fragment IP packets. + @constant IFNET_CSUM_TCPIPV6 Hardware will calculate TCP IPv6 checksums. + @constant IFNET_CSUM_UDPIPV6 Hardware will calculate UDP IPv6 checksums. + @constant IFNET_IPV6_FRAGMENT Hardware will fragment IPv6 packets. @constant IFNET_VLAN_TAGGING Hardware will generate VLAN headers. @constant IFNET_VLAN_MTU Hardware supports VLAN MTU. + @constant IFNET_MULTIPAGES Driver is capable of handling packets + coming down from the network stack that reside in virtually, + but not in physically contiguous span of the external mbuf + clusters. In this case, the data area of a packet in the + external mbuf cluster might cross one or more physical + pages that are disjoint, depending on the interface MTU + and the packet size. Such a use of larger than system page + size clusters by the network stack is done for better system + efficiency. Drivers that utilize the IOMbufNaturalMemoryCursor + with the getPhysicalSegmentsWithCoalesce interfaces and + enumerate the list of vectors should set this flag for + possible gain in performance during bulk data transfer. + @constant IFNET_TSO_IPV4 Hardware supports IPv4 TCP Segment Offloading. + If the Interface driver sets this flag, TCP will send larger frames (up to 64KB) as one + frame to the adapter which will perform the final packetization. The maximum TSO segment + supported by the interface can be set with "ifnet_set_tso_mtu". To retreive the real MTU + for the TCP connection the function "mbuf_get_tso_requested" is used by the driver. Note + that if TSO is active, all the packets will be flagged for TSO, not just large packets. + @constant IFNET_TSO_IPV6 Hardware supports IPv6 TCP Segment Offloading. + If the Interface driver sets this flag, TCP IPv6 will send larger frames (up to 64KB) as one + frame to the adapter which will perform the final packetization. The maximum TSO segment + supported by the interface can be set with "ifnet_set_tso_mtu". To retreive the real MTU + for the TCP IPv6 connection the function "mbuf_get_tso_requested" is used by the driver. + Note that if TSO is active, all the packets will be flagged for TSO, not just large packets. + */ enum { - IFNET_CSUM_IP = 0x00000001, - IFNET_CSUM_TCP = 0x00000002, - IFNET_CSUM_UDP = 0x00000004, - IFNET_CSUM_FRAGMENT = 0x00000008, - IFNET_IP_FRAGMENT = 0x00000010, + IFNET_CSUM_IP = 0x00000001, + IFNET_CSUM_TCP = 0x00000002, + IFNET_CSUM_UDP = 0x00000004, + IFNET_CSUM_FRAGMENT = 0x00000008, + IFNET_IP_FRAGMENT = 0x00000010, + IFNET_CSUM_TCPIPV6 = 0x00000020, + IFNET_CSUM_UDPIPV6 = 0x00000040, + IFNET_IPV6_FRAGMENT = 0x00000080, #ifdef KERNEL_PRIVATE - IFNET_CSUM_SUM16 = 0x00001000, -#endif - IFNET_VLAN_TAGGING = 0x00010000, - IFNET_VLAN_MTU = 0x00020000, + IFNET_CSUM_SUM16 = 0x00001000, +#endif /* KERNEL_PRIVATE */ + IFNET_VLAN_TAGGING = 0x00010000, + IFNET_VLAN_MTU = 0x00020000, + IFNET_MULTIPAGES = 0x00100000, + IFNET_TSO_IPV4 = 0x00200000, + IFNET_TSO_IPV6 = 0x00400000, }; /*! @typedef ifnet_offload_t @@ -155,7 +217,7 @@ typedef u_int32_t ifnet_offload_t; */ /*! @typedef bpf_packet_func - + @discussion bpf_packet_func The bpf_packet_func is used to intercept inbound and outbound packets. The tap function will never free the mbuf. The tap function will only copy the mbuf in to various @@ -169,7 +231,7 @@ typedef errno_t (*bpf_packet_func)(ifnet_t interface, mbuf_t data); /*! @typedef ifnet_output_func - + @discussion ifnet_output_func is used to transmit packets. The stack will pass fully formed packets, including frame header, to the ifnet_output function for an interface. The driver is @@ -184,26 +246,26 @@ typedef errno_t (*ifnet_output_func)(ifnet_t interface, mbuf_t data); @typedef ifnet_ioctl_func @discussion ifnet_ioctl_func is used to communicate ioctls from the stack to the driver. + + All undefined ioctls are reserved for future use by Apple. If + you need to communicate with your kext using an ioctl, please + use SIOCSIFKPI and SIOCGIFKPI. @param interface The interface the ioctl is being sent to. @param proto_family The protocol family to handle the ioctl, may be zero for no protocol_family. @param cmd The ioctl command. @param data A pointer to any data related to the ioctl. */ -typedef errno_t (*ifnet_ioctl_func)(ifnet_t interface, u_int32_t cmd, void *data); +typedef errno_t (*ifnet_ioctl_func)(ifnet_t interface, unsigned long cmd, + void *data); /*! @typedef ifnet_set_bpf_tap - @discussion ifnet_set_bpf_tap is used to set the bpf tap function to - be called when packets are sent and/or received. - @param interface The interface the bpf tap function is being set on. - @param mode Sets the mode of the tap to either disabled, input, - output, or input/output. - @param callback A function pointer to be called when a packet is - sent or received. + @discussion Deprecated. Specify NULL. Call bpf_tap_in/bpf_tap_out + for all packets. */ typedef errno_t (*ifnet_set_bpf_tap)(ifnet_t interface, bpf_tap_mode mode, - bpf_packet_func callback); + bpf_packet_func callback); /*! @typedef ifnet_detached_func @@ -224,12 +286,13 @@ typedef void (*ifnet_detached_func)(ifnet_t interface); /*! @typedef ifnet_demux_func - @discussion ifnet_demux_func is called for each inbound packet to determine - which protocol family the packet belongs to. This information is then - used by the stack to determine which protocol to pass the packet to. - This function may return protocol families for protocols that are - not attached. If the protocol family has not been attached to the - interface, the packet will be discarded. + @discussion ifnet_demux_func is called for each inbound packet to + determine which protocol family the packet belongs to. This + information is then used by the stack to determine which + protocol to pass the packet to. This function may return + protocol families for protocols that are not attached. If the + protocol family has not been attached to the interface, the + packet will be discarded. @param interface The interface the packet was received on. @param packet The mbuf containing the packet. @param frame_header A pointer to the frame header. @@ -237,12 +300,13 @@ typedef void (*ifnet_detached_func)(ifnet_t interface); packet should be stored here. @result If the result is zero, processing will continue normally. - If the result is EJUSTRETURN, processing will stop but the packet will not be freed. - If the result is anything else, the processing will stop and the packet will be freed. + If the result is EJUSTRETURN, processing will stop but the + packet will not be freed. + If the result is anything else, the processing will stop and + the packet will be freed. */ typedef errno_t (*ifnet_demux_func)(ifnet_t interface, mbuf_t packet, - char *frame_header, - protocol_family_t *protocol_family); + char *frame_header, protocol_family_t *protocol_family); /*! @typedef ifnet_event_func @@ -269,15 +333,23 @@ typedef void (*ifnet_event_func)(ifnet_t interface, const struct kev_msg *msg); protocol's pre-output function. @param frame_type The frame type as determined by the protocol's pre-output function. + @param prepend_len The length of prepended bytes to the mbuf. + (ONLY used if KPI_INTERFACE_EMBEDDED is defined to 1) + @param postpend_len The length of the postpended bytes to the mbuf. + (ONLY used if KPI_INTERFACE_EMBEDDED is defined to 1) @result If the result is zero, processing will continue normally. - If the result is EJUSTRETURN, processing will stop but the packet will not be freed. - If the result is anything else, the processing will stop and the packet will be freed. + If the result is EJUSTRETURN, processing will stop but the + packet will not be freed. + If the result is anything else, the processing will stop and + the packet will be freed. */ typedef errno_t (*ifnet_framer_func)(ifnet_t interface, mbuf_t *packet, - const struct sockaddr *dest, - const char *desk_linkaddr, - const char *frame_type); + const struct sockaddr *dest, const char *desk_linkaddr, const char *frame_type +#if KPI_INTERFACE_EMBEDDED + , u_int32_t *prepend_len, u_int32_t *postpend_len +#endif /* KPI_INTERFACE_EMBEDDED */ + ); /*! @typedef ifnet_add_proto_func @@ -293,12 +365,12 @@ typedef errno_t (*ifnet_framer_func)(ifnet_t interface, mbuf_t *packet, @param demux_count The number of demux descriptors in the array. @result If the result is zero, processing will continue normally. - If the result is anything else, the add protocol will be aborted. + If the result is anything else, the add protocol will be + aborted. */ typedef errno_t (*ifnet_add_proto_func)(ifnet_t interface, - protocol_family_t protocol_family, - const struct ifnet_demux_desc *demux_array, - u_int32_t demux_count); + protocol_family_t protocol_family, + const struct ifnet_demux_desc *demux_array, u_int32_t demux_count); /*! @typedef if_del_proto_func @@ -314,7 +386,7 @@ typedef errno_t (*ifnet_add_proto_func)(ifnet_t interface, and the error will be returned to the caller. */ typedef errno_t (*ifnet_del_proto_func)(ifnet_t interface, - protocol_family_t protocol_family); + protocol_family_t protocol_family); /*! @typedef ifnet_check_multi @@ -322,7 +394,7 @@ typedef errno_t (*ifnet_del_proto_func)(ifnet_t interface, added to an interface. This gives the interface an opportunity to reject invalid multicast addresses before they are attached to the interface. - + To prevent an address from being added to your multicast list, return EADDRNOTAVAIL. If you don't know how to parse/translate the address, return EOPNOTSUPP. @@ -333,7 +405,7 @@ typedef errno_t (*ifnet_del_proto_func)(ifnet_t interface, EOPNOTSUPP for addresses the interface does not understand. */ typedef errno_t (*ifnet_check_multi)(ifnet_t interface, - const struct sockaddr* mcast); + const struct sockaddr *mcast); /*! @typedef proto_media_input @@ -345,13 +417,34 @@ typedef errno_t (*ifnet_check_multi)(ifnet_t interface, @param packet The packet being input. @param header The frame header. @result - If the result is zero, the caller will assume the packet was passed - to the protocol. - If the result is non-zero and not EJUSTRETURN, the caller will free - the packet. + If the result is zero, the caller will assume the packet was + passed to the protocol. + If the result is non-zero and not EJUSTRETURN, the caller will + free the packet. */ typedef errno_t (*proto_media_input)(ifnet_t ifp, protocol_family_t protocol, - mbuf_t packet, char* header); + mbuf_t packet, char *header); + +/*! + @typedef proto_media_input_v2 + @discussion proto_media_input_v2 is called for all inbound packets for + a specific protocol on a specific interface. This function is + registered on an interface using ifnet_attach_protocolv2. + proto_media_input_v2 differs from proto_media_input in that it + will be called for a list of packets instead of once for each + individual packet. The frame header can be retrieved using + mbuf_pkthdr_header. + @param ifp The interface the packet was received on. + @param protocol_family The protocol of the packet received. + @param packet The packet being input. + @result + If the result is zero, the caller will assume the packets were + passed to the protocol. + If the result is non-zero and not EJUSTRETURN, the caller will + free the packets. + */ +typedef errno_t (*proto_media_input_v2)(ifnet_t ifp, protocol_family_t protocol, + mbuf_t packet); /*! @typedef proto_media_preout @@ -374,8 +467,8 @@ typedef errno_t (*proto_media_input)(ifnet_t ifp, protocol_family_t protocol, caller. */ typedef errno_t (*proto_media_preout)(ifnet_t ifp, protocol_family_t protocol, - mbuf_t *packet, const struct sockaddr *dest, - void *route, char *frame_type, char *link_layer_dest); + mbuf_t *packet, const struct sockaddr *dest, void *route, char *frame_type, + char *link_layer_dest); /*! @typedef proto_media_event @@ -386,7 +479,7 @@ typedef errno_t (*proto_media_preout)(ifnet_t ifp, protocol_family_t protocol, @param kev_msg The event. */ typedef void (*proto_media_event)(ifnet_t ifp, protocol_family_t protocol, - const struct kev_msg *event); + const struct kev_msg *event); /*! @typedef proto_media_ioctl @@ -398,6 +491,10 @@ typedef void (*proto_media_event)(ifnet_t ifp, protocol_family_t protocol, EOPNOTSUPP, other parts of the stack may not get an opportunity to process the ioctl. If you return EJUSTRETURN, processing will stop and a result of zero will be returned to the caller. + + All undefined ioctls are reserved for future use by Apple. If + you need to communicate with your kext using an ioctl, please + use SIOCSIFKPI and SIOCGIFKPI. @param ifp The interface. @param protocol_family The protocol family. @param command The ioctl command. @@ -406,7 +503,7 @@ typedef void (*proto_media_event)(ifnet_t ifp, protocol_family_t protocol, See the discussion. */ typedef errno_t (*proto_media_ioctl)(ifnet_t ifp, protocol_family_t protocol, - u_int32_t command, void* argument); + unsigned long command, void *argument); /*! @typedef proto_media_detached @@ -419,7 +516,6 @@ typedef errno_t (*proto_media_ioctl)(ifnet_t ifp, protocol_family_t protocol, */ typedef errno_t (*proto_media_detached)(ifnet_t ifp, protocol_family_t protocol); - /*! @typedef proto_media_resolve_multi @discussion proto_media_resolve_multi is called to resolve a @@ -432,8 +528,8 @@ typedef errno_t (*proto_media_detached)(ifnet_t ifp, protocol_family_t protocol) @result Return zero on success or an errno error value on failure. */ typedef errno_t (*proto_media_resolve_multi)(ifnet_t ifp, - const struct sockaddr *proto_addr, - struct sockaddr_dl *out_ll, size_t ll_len); + const struct sockaddr *proto_addr, struct sockaddr_dl *out_ll, + size_t ll_len); /*! @typedef proto_media_send_arp @@ -461,12 +557,9 @@ typedef errno_t (*proto_media_resolve_multi)(ifnet_t ifp, NULL. @result Return zero on success or an errno error value on failure. */ -typedef errno_t (*proto_media_send_arp)(ifnet_t ifp, - u_short arpop, - const struct sockaddr_dl* sender_hw, - const struct sockaddr* sender_proto, - const struct sockaddr_dl* target_hw, - const struct sockaddr* target_proto); +typedef errno_t (*proto_media_send_arp)(ifnet_t ifp, u_short arpop, + const struct sockaddr_dl *sender_hw, const struct sockaddr *sender_proto, + const struct sockaddr_dl *target_hw, const struct sockaddr *target_proto); /*! @struct ifnet_stat_increment_param @@ -481,16 +574,15 @@ typedef errno_t (*proto_media_send_arp)(ifnet_t ifp, @field collisions The number of collisions seen by this interface. @field dropped The number of packets dropped. */ - struct ifnet_stat_increment_param { u_int32_t packets_in; u_int32_t bytes_in; u_int32_t errors_in; - + u_int32_t packets_out; u_int32_t bytes_out; u_int32_t errors_out; - + u_int32_t collisions; u_int32_t dropped; }; @@ -498,9 +590,9 @@ struct ifnet_stat_increment_param { /*! @struct ifnet_init_params @discussion This structure is used to define various properties of - the interface when calling ifnet_init. A copy of these values - will be stored in the ifnet and can not be modified while the - interface is attached. + the interface when calling ifnet_allocate. A copy of these + values will be stored in the ifnet and cannot be modified + while the interface is attached. @field uniqueid An identifier unique to this instance of the interface. @field uniqueid_len The length, in bytes, of the uniqueid. @@ -510,47 +602,290 @@ struct ifnet_stat_increment_param { @field type The interface type (see sys/if_types.h). Must be less than 256. For new types, use IFT_OTHER. @field output The output function for the interface. Every packet the - stack attempts to send through this interface will go out through - this function. + stack attempts to send through this interface will go out + through this function. @field demux The function used to determine the protocol family of an incoming packet. - @field add_proto The function used to attach a protocol to this interface. - @field del_proto The function used to remove a protocol from this interface. + @field add_proto The function used to attach a protocol to this + interface. + @field del_proto The function used to remove a protocol from this + interface. @field framer The function used to frame outbound packets, may be NULL. - @field softc Driver specific storage. This value can be retrieved from the - ifnet using the ifnet_softc function. + @field softc Driver specific storage. This value can be retrieved from + the ifnet using the ifnet_softc function. @field ioctl The function used to handle ioctls. @field set_bpf_tap The function used to set the bpf_tap function. - @field detach The function called to let the driver know the interface has been detached. - @field event The function to notify the interface of various interface specific kernel events. - @field broadcast_addr The link-layer broadcast address for this interface. + @field detach The function called to let the driver know the interface + has been detached. + @field event The function to notify the interface of various interface + specific kernel events. + @field broadcast_addr The link-layer broadcast address for this + interface. @field broadcast_len The length of the link-layer broadcast address. */ - struct ifnet_init_params { /* used to match recycled interface */ - const void* uniqueid; /* optional */ - u_int32_t uniqueid_len; /* optional */ - + const void *uniqueid; /* optional */ + u_int32_t uniqueid_len; /* optional */ + + /* used to fill out initial values for interface */ + const char *name; /* required */ + u_int32_t unit; /* required */ + ifnet_family_t family; /* required */ + u_int32_t type; /* required */ + ifnet_output_func output; /* required */ + ifnet_demux_func demux; /* required */ + ifnet_add_proto_func add_proto; /* required */ + ifnet_del_proto_func del_proto; /* required */ + ifnet_check_multi check_multi; /* required for non point-to-point interfaces */ + ifnet_framer_func framer; /* optional */ + void *softc; /* optional */ + ifnet_ioctl_func ioctl; /* optional */ + ifnet_set_bpf_tap set_bpf_tap; /* deprecated */ + ifnet_detached_func detach; /* optional */ + ifnet_event_func event; /* optional */ + const void *broadcast_addr; /* required for non point-to-point interfaces */ + u_int32_t broadcast_len; /* required for non point-to-point interfaces */ +}; + +#ifdef KERNEL_PRIVATE +/* Valid values for version */ +#define IFNET_INIT_VERSION_2 2 +#define IFNET_INIT_CURRENT_VERSION IFNET_INIT_VERSION_2 + +/* Valid values for flags */ +#define IFNET_INIT_LEGACY 0x1 /* legacy network interface model */ +#define IFNET_INIT_INPUT_POLL 0x2 /* opportunistic input polling model */ + +/* + @typedef ifnet_pre_enqueue_func + @discussion ifnet_pre_enqueue_func is called for each outgoing packet + for the interface. The driver may perform last-minute changes + on the (fully formed) packet, but it is responsible for calling + ifnet_enqueue() to enqueue the packet upon completion. + @param interface The interface being sent on. + @param data The packet to be sent. + */ +typedef errno_t (*ifnet_pre_enqueue_func)(ifnet_t interface, mbuf_t data); + +/* + @typedef ifnet_start_func + @discussion ifnet_start_func is used to indicate to the driver that + one or more packets may be dequeued by calling ifnet_dequeue() + or ifnet_dequeue_multi(). This routine gets invoked when + ifnet_start() is called; the ifnet_start_func callback will + be executed within the context of a dedicated kernel thread, + hence it is guaranteed to be single threaded. The driver must + employ additional serializations if this callback routine is + to be called directly from another context, in order to prevent + race condition related issues (e.g. out-of-order packets.) + The dequeued packets will be fully formed packets (including + frame headers). The packets must be freed by the driver. + @param interface The interface being sent on. + */ +typedef void (*ifnet_start_func)(ifnet_t interface); + +/* + @typedef ifnet_input_poll_func + @discussion ifnet_input_poll_func is called by the network stack to + retrieve one or more packets from the driver which implements + the new driver input model. + @param interface The interface to retrieve the packets from. + @param flags For future use. + @param max_count The maximum number of packets to be dequeued. + @param first_packet Pointer to the first packet being dequeued. + @param last_packet Pointer to the last packet being dequeued. + @param cnt Pointer to a storage for the number of packets dequeued. + @param len Pointer to a storage for the total length (in bytes) + of the dequeued packets. + */ +typedef void (*ifnet_input_poll_func)(ifnet_t interface, u_int32_t flags, + u_int32_t max_count, mbuf_t *first_packet, mbuf_t *last_packet, + u_int32_t *cnt, u_int32_t *len); + +/* + @enum Interface control commands + @abstract Constants defining control commands. + @constant IFNET_CTL_SET_INPUT_MODEL Set input model. + @constant IFNET_CTL_GET_INPUT_MODEL Get input model. + */ +enum { + IFNET_CTL_SET_INPUT_MODEL = 1, + IFNET_CTL_GET_INPUT_MODEL = 2, +}; + +/* + @typedef ifnet_ctl_cmd_t + @abstract Storage type for the interface control command. + */ +typedef u_int32_t ifnet_ctl_cmd_t; + +/* + @enum Interface model sub-commands + @abstract Constants defining model sub-commands. + @constant IFNET_MODEL_INPUT_POLL_OFF Polling is inactive. When set, + the network stack will no longer invoke the input_poll callback + until the next time polling is turned on; the driver should + proceed to pushing the packets up to the network stack as in + the legacy input model, and if applicable, the driver should + also enable receive interrupt for the hardware. During get, + this indicates that the driver is currently operating in + the legacy/push input model. + @constant IFNET_MODEL_INPUT_POLL_ON Polling is active. When set, the + network stack will begin to invoke the input_poll callback to + retrieve packets from the driver until the next time polling + is turned off; the driver should no longer be pushing packets + up to the network stack, and if applicable, the driver should + also disable receive interrupt for the hardware. During get, + this indicates that the driver is currently operating in + the new/pull input model. + */ +enum { + IFNET_MODEL_INPUT_POLL_OFF = 0, + IFNET_MODEL_INPUT_POLL_ON = 1, +}; + +/* + @typedef ifnet_model_t + @abstract Storage type for the interface model sub-command. + */ +typedef u_int32_t ifnet_model_t; + +/* + @struct ifnet_model_params + @discussion This structure is used as parameter to the ifnet model + sub-commands. + @field model The interface model. + */ +struct ifnet_model_params { + ifnet_model_t model; + u_int32_t reserved[3]; +}; + +/* + @typedef ifnet_ctl_func + @discussion ifnet_ctl_func is called by the network stack to inform + about changes in parameters, or retrieve the parameters + related to the output or input processing or capabilities. + @param interface The interface. + @param cmd The ifnet_ctl_cmd_t interface control command. + @param arglen The length of the command argument. + @param arg The command argument. + @result 0 upon success, otherwise errno error. + */ +typedef errno_t (*ifnet_ctl_func)(ifnet_t interface, ifnet_ctl_cmd_t cmd, + u_int32_t arglen, void *arg); + +/* + @struct ifnet_init_eparams + @discussion This structure is used to define various properties of + the interface when calling ifnet_allocate_extended. A copy of + these values will be stored in the ifnet and cannot be modified + while the interface is attached. + @field ver The current structure version (IFNET_INIT_CURRENT_VERSION) + @field len The length of this structure. + @field flags See above values for flags. + @field uniqueid An identifier unique to this instance of the + interface. + @field uniqueid_len The length, in bytes, of the uniqueid. + @field name The interface name (i.e. en). + @field unit The interface unit number (en0's unit number is 0). + @field family The interface family. + @field type The interface type (see sys/if_types.h). Must be less + than 256. For new types, use IFT_OTHER. + @field sndq_maxlen The maximum size of the output queue; valid only + if IFNET_INIT_LEGACY is not set. + @field output The output function for the interface. Every packet the + stack attempts to send through this interface will go out + through this function. + @field pre_enqueue The pre_enqueue function for the interface, valid + only if IFNET_INIT_LEGACY is not set, and optional if it is set. + @field start The start function for the interface, valid only if + IFNET_INIT_LEGACY is not set, and required if it is set. + @field output_ctl The output control function for the interface, valid + only if IFNET_INIT_LEGACY is not set. + @field output_sched_model The IFNET_SCHED_MODEL value for the output + queue, as defined in net/if.h + @field output_bw The effective output bandwidth (in bits per second.) + @field output_bw_max The maximum theoretical output bandwidth + (in bits per second.) + @field input_poll The poll function for the interface, valid only if + IFNET_INIT_LEGACY is not set and only if IFNET_INIT_INPUT_POLL + is set. + @field input_ctl The input control function for the interface, valid + only if IFNET_INIT_LEGACY is not set and only if opportunistic + input polling is enabled via IFNET_INIT_INPUT_POLL flag. + @field rcvq_maxlen The size of the driver's receive ring or the total + count of descriptors used in the receive path; valid only if + IFNET_INIT_INPUT_POLL is set. + @field input_bw The effective input bandwidth (in bits per second.) + @field input_bw_max The maximum theoretical input bandwidth + (in bits per second.) + @field demux The function used to determine the protocol family of an + incoming packet. + @field add_proto The function used to attach a protocol to this + interface. + @field del_proto The function used to remove a protocol from this + interface. + @field framer The function used to frame outbound packets, may be NULL. + @field softc Driver specific storage. This value can be retrieved from + the ifnet using the ifnet_softc function. + @field ioctl The function used to handle ioctls. + @field set_bpf_tap The function used to set the bpf_tap function. + @field detach The function called to let the driver know the interface + has been detached. + @field event The function to notify the interface of various interface + specific kernel events. + @field broadcast_addr The link-layer broadcast address for this + interface. + @field broadcast_len The length of the link-layer broadcast address. +*/ +struct ifnet_init_eparams { + u_int32_t ver; /* required */ + u_int32_t len; /* required */ + u_int32_t flags; /* optional */ + + /* used to match recycled interface */ + const void *uniqueid; /* optional */ + u_int32_t uniqueid_len; /* optional */ + /* used to fill out initial values for interface */ - const char* name; /* required */ - u_int32_t unit; /* required */ - ifnet_family_t family; /* required */ - u_int32_t type; /* required */ - ifnet_output_func output; /* required */ - ifnet_demux_func demux; /* required */ + const char *name; /* required */ + u_int32_t unit; /* required */ + ifnet_family_t family; /* required */ + u_int32_t type; /* required */ + u_int32_t sndq_maxlen; /* optional, only for new model */ + ifnet_output_func output; /* required only for legacy model */ + ifnet_pre_enqueue_func pre_enqueue; /* optional, only for new model */ + ifnet_start_func start; /* required only for new model */ + ifnet_ctl_func output_ctl; /* optional, only for new model */ + u_int32_t output_sched_model; /* optional, only for new model */ + u_int32_t reserved; /* for future use */ + u_int64_t output_bw; /* optional */ + u_int64_t output_bw_max; /* optional */ + u_int64_t _reserved[4]; /* for future use */ + ifnet_input_poll_func input_poll; /* optional, ignored for legacy model */ + ifnet_ctl_func input_ctl; /* required for opportunistic polling */ + u_int32_t rcvq_maxlen; /* optional, only for opportunistic polling */ + u_int32_t __reserved; /* for future use */ + u_int64_t input_bw; /* optional */ + u_int64_t input_bw_max; /* optional */ + u_int64_t ___reserved[4]; /* for future use */ + ifnet_demux_func demux; /* required */ ifnet_add_proto_func add_proto; /* required */ ifnet_del_proto_func del_proto; /* required */ - ifnet_check_multi check_multi; /* required for non point-to-point interfaces */ - ifnet_framer_func framer; /* optional */ - void* softc; /* optional */ - ifnet_ioctl_func ioctl; /* optional */ - ifnet_set_bpf_tap set_bpf_tap; /* optional */ - ifnet_detached_func detach; /* optional */ - ifnet_event_func event; /* optional */ - const void *broadcast_addr;/* required for non point-to-point interfaces */ - u_int32_t broadcast_len; /* required for non point-to-point interfaces */ + ifnet_check_multi check_multi; /* required for non point-to-point interfaces */ + ifnet_framer_func framer; /* optional */ + void *softc; /* optional */ + ifnet_ioctl_func ioctl; /* optional */ + ifnet_set_bpf_tap set_bpf_tap; /* deprecated */ + ifnet_detached_func detach; /* optional */ + ifnet_event_func event; /* optional */ + const void *broadcast_addr; /* required for non point-to-point interfaces */ + u_int32_t broadcast_len; /* required for non point-to-point interfaces */ + u_int64_t ____reserved[4]; /* for future use */ }; +#endif /* KERNEL_PRIVATE */ /*! @struct ifnet_stats_param @@ -565,18 +900,17 @@ struct ifnet_init_params { @field collisions The number of collisions seen by this interface. @field dropped The number of packets dropped. */ - struct ifnet_stats_param { u_int64_t packets_in; u_int64_t bytes_in; u_int64_t multicasts_in; u_int64_t errors_in; - + u_int64_t packets_out; u_int64_t bytes_out; u_int64_t multicasts_out; u_int64_t errors_out; - + u_int64_t collisions; u_int64_t dropped; u_int64_t no_protocol; @@ -597,10 +931,9 @@ struct ifnet_stats_param { @field datalen The number of bytes of data used to describe the packet. */ - struct ifnet_demux_desc { u_int32_t type; - void* data; + void *data; u_int32_t datalen; }; @@ -624,13 +957,26 @@ struct ifnet_demux_desc { #endif /* KERNEL_PRIVATE */ struct ifnet_attach_proto_param { - struct ifnet_demux_desc *demux_array; /* interface may/may not require */ - u_int32_t demux_count; /* interface may/may not require */ - - proto_media_input input; /* required */ - proto_media_preout pre_output; /* required */ - proto_media_event event; /* optional */ - proto_media_ioctl ioctl; /* optional */ + struct ifnet_demux_desc *demux_array; /* interface may/may not require */ + u_int32_t demux_count; /* interface may/may not require */ + + proto_media_input input; /* required */ + proto_media_preout pre_output; /* required */ + proto_media_event event; /* optional */ + proto_media_ioctl ioctl; /* optional */ + proto_media_detached detached; /* optional */ + proto_media_resolve_multi resolve; /* optional */ + proto_media_send_arp send_arp; /* optional */ +}; + +struct ifnet_attach_proto_param_v2 { + struct ifnet_demux_desc *demux_array; /* interface may/may not require */ + u_int32_t demux_count; /* interface may/may not require */ + + proto_media_input_v2 input; /* required */ + proto_media_preout pre_output; /* required */ + proto_media_event event; /* optional */ + proto_media_ioctl ioctl; /* optional */ proto_media_detached detached; /* optional */ proto_media_resolve_multi resolve; /* optional */ proto_media_send_arp send_arp; /* optional */ @@ -664,7 +1010,252 @@ __BEGIN_DECLS if an interface with the same uniqueid and family has already been allocated and is in use. */ -errno_t ifnet_allocate(const struct ifnet_init_params *init, ifnet_t *interface); +extern errno_t ifnet_allocate(const struct ifnet_init_params *init, + ifnet_t *interface); + +#ifdef KERNEL_PRIVATE +/* + @function ifnet_allocate_extended + @discussion An extended/newer variant of ifnet_allocate, with additional + support for the new output and input driver models. + @param init The initial values for the interface. These values can + not be changed after the interface has been allocated. + @param interface The interface allocated upon success. + @result May return ENOMEM if there is insufficient memory or EEXIST + if an interface with the same uniqueid and family has already + been allocated and is in use. + */ +extern errno_t ifnet_allocate_extended(const struct ifnet_init_eparams *init, + ifnet_t *interface); + +/* + @function ifnet_purge + @discussion Purge the output queue of an interface which implements + the new driver output model. + @param interface The interface to purge. + */ +extern void ifnet_purge(ifnet_t interface); + +/* + @function ifnet_enqueue + @discussion Enqueue a packet to the output queue of an interface + which implements the new driver output model. + @param interface The interface to enqueue the packet to. + @param packet The packet being enqueued; only one packet is allowed + to be enqueued at a time. + @result May return EINVAL if the parameters are invalid; ENXIO if + the interface doesn't implement the new driver output model; + EQFULL if the output queue is flow-controlled; or EQSUSPENDED + if the output queue is suspended. This routine either frees + or consumes the packet; the caller must not modify or free + it after calling this routine. Any attempt to enqueue more + than one packet will cause the entire packet chain to be freed. + */ +extern errno_t ifnet_enqueue(ifnet_t interface, mbuf_t packet); + +/* + @function ifnet_dequeue + @discussion Dequeue a packet from the output queue of an interface + which implements the new driver output model, and that the + output scheduling model is set to IFNET_SCHED_MODEL_NORMAL. + @param interface The interface to dequeue the packet from. + @param packet Pointer to the packet being dequeued. + @result May return EINVAL if the parameters are invalid, ENXIO if + the interface doesn't implement the new driver output model + or the output scheduling model isn't IFNET_SCHED_MODEL_NORMAL, + or EAGAIN if there is currently no packet available to + be dequeued. + */ +extern errno_t ifnet_dequeue(ifnet_t interface, mbuf_t *packet); + +/* + @function ifnet_dequeue_service_class + @discussion Dequeue a packet of a particular service class from the + appropriate output queue of an interface which implements the + new driver output model, and that the output scheduling model + is set to IFNET_SCHED_MODEL_DRIVER_MANAGED. + @param interface The interface to dequeue the packet from. + @param tc The service class. + @param packet Pointer to the packet being dequeued. + @result May return EINVAL if the parameters are invalid, ENXIO if + the interface doesn't implement the new driver output model + or if the output scheduling model isn't configured to + IFNET_SCHED_MODEL_DRIVER_MANAGED, or EAGAIN if there + is currently no packet available to be dequeued. + */ +extern errno_t ifnet_dequeue_service_class(ifnet_t interface, + mbuf_svc_class_t tc, mbuf_t *packet); + +/* + @function ifnet_dequeue_multi + @discussion Dequeue one or more packets from the output queue of an + interface which implements the new driver output model, and that + the output scheduling model is set to IFNET_SCHED_MODEL_NORMAL. + The returned packet chain is traversable with mbuf_nextpkt(). + @param interface The interface to dequeue the packets from. + @param first_packet Pointer to the first packet being dequeued. + @param last_packet Pointer to the last packet being dequeued. Caller + may supply NULL if not interested in value. + @param cnt Pointer to a storage for the number of packets dequeued. + Caller may supply NULL if not interested in value. + @param len Pointer to a storage for the total length (in bytes) + of the dequeued packets. Caller may supply NULL if not + interested in value. + @result May return EINVAL if the parameters are invalid, ENXIO if + the interface doesn't implement the new driver output model + or the output scheduling model isn't IFNET_SCHED_MODEL_NORMAL, + or EAGAIN if there is currently no packet available to + be dequeued. + */ +extern errno_t ifnet_dequeue_multi(ifnet_t interface, u_int32_t max, + mbuf_t *first_packet, mbuf_t *last_packet, u_int32_t *cnt, u_int32_t *len); + +/* + @function ifnet_dequeue_service_class_multi + @discussion Dequeue one or more packets of a particular service class + from the appropriate output queue of an interface which + implements the new driver output model, and that the output + scheduling model is set to IFNET_SCHED_MODEL_DRIVER_MANAGED. + The returned packet chain is traversable with mbuf_nextpkt(). + @param interface The interface to dequeue the packets from. + @param tc The service class. + @param first_packet Pointer to the first packet being dequeued. + @param last_packet Pointer to the last packet being dequeued. Caller + may supply NULL if not interested in value. + @param cnt Pointer to a storage for the number of packets dequeued. + Caller may supply NULL if not interested in value. + @param len Pointer to a storage for the total length (in bytes) + of the dequeued packets. Caller may supply NULL if not + interested in value. + @result May return EINVAL if the parameters are invalid, ENXIO if + the interface doesn't implement the new driver output model + or if the output scheduling model isn't configured to + IFNET_SCHED_MODEL_DRIVER_MANAGED, or EAGAIN if there + is currently no packet available to be dequeued. + */ +extern errno_t ifnet_dequeue_service_class_multi(ifnet_t interface, + mbuf_svc_class_t tc, u_int32_t max, mbuf_t *first_packet, + mbuf_t *last_packet, u_int32_t *cnt, u_int32_t *len); + +/* + @function ifnet_set_output_sched_model + @discussion Set the output scheduling model of an interface which + implements the new driver output model. + @param interface The interface to set scheduling model on. + @param model The IFNET_SCHED_MODEL value as defined in net/if.h + @result May return EINVAL if the parameters are invalid or ENXIO if + the interface doesn't implement the new driver output model. + */ +extern errno_t ifnet_set_output_sched_model(ifnet_t interface, + u_int32_t model); + +/* + @function ifnet_set_sndq_maxlen + @discussion Set the maximum length of the output queue of an + interface which implements the new driver output model. + This call may be issued post ifnet_allocate_extended in + order to modify the maximum output queue length previously + set at registration time. + @param interface The interface to set the max queue length on. + @param maxqlen The maximum number of packets in the output queue. + @result May return EINVAL if the parameters are invalid or ENXIO if + the interface doesn't implement the new driver output model. + */ +extern errno_t ifnet_set_sndq_maxlen(ifnet_t interface, u_int32_t maxqlen); + +/* + @function ifnet_get_sndq_maxlen + @discussion Get the maximum length of the output queue of an + interface which implements the new driver output model. + @param interface The interface to get the max queue length on. + @param maxqlen Pointer to a storage for the maximum number of packets + in the output queue. + @result May return EINVAL if the parameters are invalid or ENXIO if + the interface doesn't implement the new driver output model. + */ +extern errno_t ifnet_get_sndq_maxlen(ifnet_t interface, u_int32_t *maxqlen); + +/* + @function ifnet_get_sndq_len + @discussion Get the current length of the output queue of an + interface which implements the new driver output model. + @param interface The interface to get the current queue length on. + @param qlen Pointer to a storage for the current number of packets + in the output queue. + @result May return EINVAL if the parameters are invalid or ENXIO if + the interface doesn't implement the new driver output model. + */ +extern errno_t ifnet_get_sndq_len(ifnet_t interface, u_int32_t *qlen); + +/* + @function ifnet_set_rcvq_maxlen + @discussion Set the maximum length of the input queue of an + interface which implements the new driver input model. + This call may be issued post ifnet_allocate_extended in + order to modify the maximum input queue length previously + set at registration time. + @param interface The interface to set the max queue length on. + @param maxqlen The maximum number of packets in the input queue. + Drivers typically set this to the size of the receive ring + or the total number of descriptors used for the input path. + @result May return EINVAL if the parameters are invalid or ENXIO if + the interface doesn't implement the new driver input model. + */ +extern errno_t ifnet_set_rcvq_maxlen(ifnet_t interface, u_int32_t maxqlen); + +/* + @function ifnet_get_rcvq_maxlen + @discussion Get the maximum length of the input queue of an + interface which implements the new driver input model. + @param interface The interface to get the max queue length on. + @param maxqlen Pointer to a storage for the maximum number of packets + in the input queue. + @result May return EINVAL if the parameters are invalid or ENXIO if + the interface doesn't implement the new driver input model. + */ +extern errno_t ifnet_get_rcvq_maxlen(ifnet_t interface, u_int32_t *maxqlen); + +/* + @function ifnet_start + @discussion Trigger the transmission at the driver layer on an + interface which implements the new driver output model. + @param interface The interface to start the transmission on. + */ +extern void ifnet_start(ifnet_t interface); + +/* + @function ifnet_transmit_burst_start + @discussion Inform the kernel about the beginning of transmission + of a burst. This function should be called when a burst of + packets are scheduled to get transmitted over the link. The + callback will be used by the system to start measuring + bandwidth available on that link. The driver may choose to + adopt this scheme for uplink bandwidth measurement, in case + the information can't be obtained from the hardware. Else + it may alternatively inform the network stack about the + information using ifnet_set_bandwidths. + @param interface The interface. + @param mbuf_t The first packet in a burst of packets that has been + scheduled to transmit. +*/ +extern void ifnet_transmit_burst_start(ifnet_t interface, mbuf_t pkt); + +/* + @function ifnet_transmit_burst_end + @discussion Inform the kernel about the end of transmission of a burst. + This function should be called when the transmission of a burst + of packets is done. This information will be used by the + system to estimate bandwidth available on that link. The + driver may choose to adopt this scheme for uplink bandwidth + measurement, in case the information can't be obtained from + the hardware. Else it may alternatively inform the network + stack about the information using ifnet_set_bandwidths. + @param interface The interface. + @param mbuf_t The last packet in the burst that has been successfully + transmitted. +*/ +extern void ifnet_transmit_burst_end(ifnet_t interface, mbuf_t pkt); +#endif /* KERNEL_PRIVATE */ /*! @function ifnet_reference @@ -674,7 +1265,7 @@ errno_t ifnet_allocate(const struct ifnet_init_params *init, ifnet_t *interface) @param interface The interface to increment the reference count of. @result May return EINVAL if the interface is not valid. */ -errno_t ifnet_reference(ifnet_t interface); +extern errno_t ifnet_reference(ifnet_t interface); /*! @function ifnet_release @@ -684,7 +1275,7 @@ errno_t ifnet_reference(ifnet_t interface); and possibly free. @result May return EINVAL if the interface is not valid. */ -errno_t ifnet_release(ifnet_t interface); +extern errno_t ifnet_release(ifnet_t interface); /*! @function ifnet_attach @@ -692,7 +1283,7 @@ errno_t ifnet_release(ifnet_t interface); interface must be setup properly before calling attach. The stack will take a reference on the interface and hold it until ifnet_detach is called. - + This function is intended to be called by the driver. A kext must not call this function on an interface the kext does not own. @@ -704,34 +1295,54 @@ errno_t ifnet_release(ifnet_t interface); @result Will return an error if there is anything wrong with the interface. */ -errno_t ifnet_attach(ifnet_t interface, const struct sockaddr_dl *ll_addr); +extern errno_t ifnet_attach(ifnet_t interface, + const struct sockaddr_dl *ll_addr); /*! @function ifnet_detach @discussion Detaches the interface. - + Call this to indicate this interface is no longer valid (i.e. PC Card was removed). This function will begin the process of removing knowledge of this interface from the stack. - + The function will return before the interface is detached. The functions you supplied in to the interface may continue to be called. When the detach has been completed, your detached function will be called. Your kext must not unload until the detached function has been called. The interface will be properly freed when the reference count reaches zero. - + An interface may not be attached again. You must call ifnet_allocate to create a new interface to attach. - + This function is intended to be called by the driver. A kext must not call this function on an interface the kext does not own. @param interface The interface to detach. @result 0 on success, otherwise errno error. */ -errno_t ifnet_detach(ifnet_t interface); - +extern errno_t ifnet_detach(ifnet_t interface); + +/*! + @function ifnet_interface_family_find + @discussion Look up the interface family identifier for a string. + If there is no interface family identifier assigned for this string + a new interface family identifier is created and assigned. + It is recommended to use the bundle id of the KEXT as the string + to avoid collisions with other KEXTs. + The lookup operation is not optimized so a module should call this + function once during startup and cache the interface family identifier. + The interface family identifier for a string will not be re-assigned until + the system reboots. + @param module_string A unique string identifying your interface family + @param family_id Upon return, a unique interface family identifier for use with + ifnet_* functions. This identifier is valid until the system + is rebooted. + @result 0 on success, otherwise errno error. +*/ +extern errno_t ifnet_interface_family_find(const char *module_string, ifnet_family_t *family_id); + /* * Interface manipulation. */ @@ -742,7 +1353,7 @@ errno_t ifnet_detach(ifnet_t interface); @param interface Interface to retrieve the storage from. @result Driver's private storage. */ -void* ifnet_softc(ifnet_t interface); +extern void *ifnet_softc(ifnet_t interface); /*! @function ifnet_name @@ -750,15 +1361,15 @@ void* ifnet_softc(ifnet_t interface); @param interface Interface to retrieve the name from. @result Pointer to the name. */ -const char* ifnet_name(ifnet_t interface); +extern const char *ifnet_name(ifnet_t interface); /*! @function ifnet_family @discussion Returns the family of the interface. @param interface Interface to retrieve the unit number from. - @result Unit number. + @result Interface family type. */ -ifnet_family_t ifnet_family(ifnet_t interface); +extern ifnet_family_t ifnet_family(ifnet_t interface); /*! @function ifnet_unit @@ -766,7 +1377,7 @@ ifnet_family_t ifnet_family(ifnet_t interface); @param interface Interface to retrieve the unit number from. @result Unit number. */ -u_int32_t ifnet_unit(ifnet_t interface); +extern u_int32_t ifnet_unit(ifnet_t interface); /*! @function ifnet_index @@ -778,7 +1389,7 @@ u_int32_t ifnet_unit(ifnet_t interface); @param interface Interface to retrieve the index of. @result Index. */ -u_int32_t ifnet_index(ifnet_t interface); +extern u_int32_t ifnet_index(ifnet_t interface); /*! @function ifnet_set_flags @@ -792,7 +1403,8 @@ u_int32_t ifnet_index(ifnet_t interface); flags are defined in net/if.h @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_flags(ifnet_t interface, u_int16_t new_flags, u_int16_t mask); +extern errno_t ifnet_set_flags(ifnet_t interface, u_int16_t new_flags, + u_int16_t mask); /*! @function ifnet_flags @@ -800,11 +1412,11 @@ errno_t ifnet_set_flags(ifnet_t interface, u_int16_t new_flags, u_int16_t mask); @param interface Interface to retrieve the flags from. @result Flags. These flags are defined in net/if.h */ -u_int16_t ifnet_flags(ifnet_t interface); +extern u_int16_t ifnet_flags(ifnet_t interface); #ifdef KERNEL_PRIVATE -/*! +/* @function ifnet_set_eflags @discussion Sets the extended interface flags to new_flags. This function lets you specify which flags you want to change using @@ -817,16 +1429,213 @@ u_int16_t ifnet_flags(ifnet_t interface); @param mask The mask of flags to be modified. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_eflags(ifnet_t interface, u_int32_t new_flags, u_int32_t mask); +extern errno_t ifnet_set_eflags(ifnet_t interface, u_int32_t new_flags, + u_int32_t mask); -/*! +/* @function ifnet_eflags @discussion Returns the extended interface flags that are set. @param interface Interface to retrieve the flags from. @result Extended flags. These flags are defined in net/if.h */ -u_int32_t ifnet_eflags(ifnet_t interface); -#endif +extern u_int32_t ifnet_eflags(ifnet_t interface); + +/* + @function ifnet_set_idle_flags + @discussion Sets the if_idle_flags to new_flags. This function + lets you specify which flags you want to change using the + mask. The kernel will effectively take the lock, then set + the interface's idle flags to: + (if_idle_flags & ~mask) | (new_flags & mask). + Setting the flags to any non-zero value will cause the + networking stack to aggressively purge expired objects, + such as route entries, etc. + @param interface The interface. + @param new_flags The new set of flags that should be set. These + flags are defined in net/if.h + @param mask The mask of flags to be modified. + @result 0 on success otherwise the errno error. ENOTSUP is returned + when this call is made on non-supporting platforms. +*/ +extern errno_t ifnet_set_idle_flags(ifnet_t interface, u_int32_t new_flags, + u_int32_t mask); + +/* + @function ifnet_idle_flags + @discussion Returns the value of if_idle_flags. + @param interface Interface to retrieve the flags from. + @result if_idle_flags. These flags are defined in net/if.h +*/ +extern u_int32_t ifnet_idle_flags(ifnet_t interface); + +/* + @function ifnet_set_link_quality + @discussion Sets the Link Quality Metric for the ifnet. + @param interface Interface for which the Link Quality Metric should + be associated to. + @param quality IFNET_LQM value as defined in net/if.h. + @result 0 on success otherwise the errno error. EINVAL if quality + is not a valid value. ENXIO if the interface is not attached. +*/ +extern errno_t ifnet_set_link_quality(ifnet_t interface, int quality); + +/* + @function ifnet_link_quality + @discussion Returns the Link Quality Metric for the ifnet. + @param interface Interface to retrieve the value from. + @result IFNET_LQM as defined in net/if.h +*/ +extern int ifnet_link_quality(ifnet_t interface); + +/* + @struct ifnet_llreach_info + @discussion This structure is used to describe the link-layer + reachability information of an on-link node. + @field iflri_refcnt The number of network-layer objects referring + to this link-layer reachability record. + @field iflri_probes The total number of outstanding probes. + @field iflri_snd_expire The send expiration time. This is calculated + based on the last time the system transmitted a packet to the + node. A zero value indicates that a packet has not been sent + to the node. A non-zero value indicates the time before the + record is determined to be invalid. When the record is no + longer valid, the system will send probe(s) to resolve the + node again. This value is relative to the current time + specified in iflri_curtime. + @field iflri_rcv_expire The receive expiriation time. This is + calculated based on the last time the system received a packet + from the node. A zero value indicates that a packet has not + been received from the node. A non-zero value indicates the + time before the record is determined to be invalid. When the + record is no longer valid, the system will send probe(s) to + resolve the node again. This value is relative to the current + time specified in iflri_curtime. + @field iflri_curtime The current time when this record was retrieved. + @field iflri_netproto The protocol number of the network-layer object. + @field iflri_addr The link-layer address of the node. + @field iflri_rssi The received signal strength indication (RSSI) of the + node in dBm. The special value IFNET_RSSI_UNKNOWN is used when + the RSSI is either unknown or inapplicable for the interface. + @field iflri_lqm The link quality metric (LQM) to the node. The + special value IFNET_LQM_UNKNOWN is used when the LQM is not + currently known. The special value IFNET_LQM_OFF is used when + the link quality metric is inapplicable to nodes at this + attached to the network at this interface. + @field iflri_npm The node proximity metric (NPM) to the node. The + special value IFNET_NPM_UNKNOWN is used when the NPM is not + currently known. + */ +#define IFNET_LLREACHINFO_ADDRLEN 64 /* max ll addr len */ + +struct ifnet_llreach_info { + u_int32_t iflri_refcnt; + u_int32_t iflri_probes; + u_int64_t iflri_snd_expire; + u_int64_t iflri_rcv_expire; + u_int64_t iflri_curtime; + u_int32_t iflri_netproto; + u_int8_t iflri_addr[IFNET_LLREACHINFO_ADDRLEN]; + int32_t iflri_rssi; + int32_t iflri_lqm; + int32_t iflri_npm; +}; + +/* + @function ifnet_inet_defrouter_llreachinfo + @discussion Retrieve link-layer reachability information of the + default IPv4 router specific to the interface. + @param interface The interface associated with the default IPv4 router. + @param pinfo Pointer to the ifnet_llreach_info structure where the + information will be returned to, upon success. + @result 0 upon success, otherwise errno error. + */ +extern errno_t ifnet_inet_defrouter_llreachinfo(ifnet_t interface, + struct ifnet_llreach_info *pinfo); + +/* + @function ifnet_inet6_defrouter_llreachinfo + @discussion Retrieve link-layer reachability information of the + default IPv6 router specific to the interface. + @param interface The interface associated with the default IPv6 router. + @param pinfo Pointer to the ifnet_llreach_info structure where the + information will be returned to, upon success. + @result 0 upon success, otherwise errno error. + */ +extern errno_t ifnet_inet6_defrouter_llreachinfo(ifnet_t interface, + struct ifnet_llreach_info *pinfo); +#endif /* KERNEL_PRIVATE */ + +/*! + @function ifnet_set_capabilities_supported + @discussion Specify the capabilities supported by the interface. + @discussion This function lets you specify which capabilities are supported + by the interface. Typically this function is called by the driver when + the interface gets attached to the system. + The mask allows to control which capability to set or unset. + The kernel will effectively take the lock, then set the + interface's flags to (if_capabilities & ~mask) | (new_caps & mask). + + This function is intended to be called by the driver. A kext + must not call this function on an interface the kext does not + own. + @param interface Interface to set the capabilities on. + @param new_caps The value of the capabilities that should be set or unset. These + flags are defined in net/if.h + @param mask Which capabilities that should be affected. These + flags are defined in net/if.h + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_set_capabilities_supported(ifnet_t interface, u_int32_t new_caps, + u_int32_t mask); + +/*! + @function ifnet_capabilities_supported + @discussion Retrieve the interface capabilities supported by the interface. + @param interface Interface to retrieve the capabilities from. + @result Flags. Capabilities flags are defined in net/if.h + */ +extern u_int32_t ifnet_capabilities_supported(ifnet_t interface); + +/*! + @function ifnet_set_capabilities_enabled + @discussion Enable and/or disable the interface capabilities to match new_caps. + @discussion Sets the interface capabilities to new_caps. This function + lets you specify which capabilities you want to change using the mask. + The kernel will effectively take the lock, then set the + interface's flags to (if_capenable & ~mask) | (new_caps & mask). + + This function is intended to be called by the driver. A kext + must not call this function on an interface the kext does not + own. + + Typically this function is called by the driver when the interface is + created to specify which of the supported capabilities are enabled by + default. This function is also meant to be called when the driver handles + the interface ioctl SIOCSIFCAP. + + The driver should call ifnet_set_offlad() to indicate the corresponding + hardware offload bits that will be used by the networking stack. + + It is an error to enable a capability that is not marked as + supported by the interface. + @param interface Interface to set the capabilities on. + @param new_caps The value of the capabilities that should be set or unset. These + flags are defined in net/if.h + @param mask Which capabilities that should be affected. These + flags are defined in net/if.h + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_set_capabilities_enabled(ifnet_t interface, u_int32_t new_caps, + u_int32_t mask); + +/*! + @function ifnet_capabilities_enabled + @discussion Retrieve the interface capabilities enabled on the interface. + @param interface Interface to retrieve the capabilities from. + @result Flags. Capabilities flags are defined in net/if.h + */ +extern u_int32_t ifnet_capabilities_enabled(ifnet_t interface); + /*! @function ifnet_set_offload @@ -834,13 +1643,17 @@ u_int32_t ifnet_eflags(ifnet_t interface); support provided by the interface such as hardware checksums and VLAN. This replaces the if_hwassist flags field. Any flags unrecognized by the stack will not be set. + + Note the system will automatically set the interface capabilities + that correspond to the offload flags modified -- i.e. the driver + does not have to call ifnet_set_capabilities_enabled() and + ifnet_set_capabilities_supported(). @param interface The interface. @param offload The new set of flags indicating which offload options the device supports. - @param mask The mask of flags to be modified. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_offload(ifnet_t interface, ifnet_offload_t offload); +extern errno_t ifnet_set_offload(ifnet_t interface, ifnet_offload_t offload); /*! @function ifnet_offload @@ -849,7 +1662,62 @@ errno_t ifnet_set_offload(ifnet_t interface, ifnet_offload_t offload); @param interface Interface to retrieve the offload from. @result Abilities flags, see ifnet_offload_t. */ -ifnet_offload_t ifnet_offload(ifnet_t interface); +extern ifnet_offload_t ifnet_offload(ifnet_t interface); + +/*! + @function ifnet_set_tso_mtu + @discussion Sets maximum TCP Segmentation Offload segment size for + the interface + @param interface The interface. + @param family The family for which the offload MTU is provided for + (AF_INET or AF_INET6) + @param mtuLen Maximum segment size supported by the interface + @result 0 on success otherwise the errno error. +*/ +extern errno_t ifnet_set_tso_mtu(ifnet_t interface, sa_family_t family, + u_int32_t mtuLen); + +/*! + @function ifnet_get_tso_mtu + @discussion Returns maximum TCP Segmentation Offload segment size for + the interface + @param interface The interface. + @param family The family for which the offload MTU is provided for + (AF_INET or AF_INET6) + @param mtuLen Value of the maximum MTU supported for the interface + and family provided. + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_get_tso_mtu(ifnet_t interface, sa_family_t family, + u_int32_t *mtuLen); + +/*! + @enum Interface wake properties + @abstract Constants defining Interface wake properties. + @constant IFNET_WAKE_ON_MAGIC_PACKET Wake on Magic Packet. +*/ +enum { + IFNET_WAKE_ON_MAGIC_PACKET = 0x01 +}; + +/*! + @function ifnet_set_wake_flags + @discussion Sets the wake properties of the underlying hardware. These are + typically set by the driver. + @param interface The interface. + @param properties Properties to set or unset. + @param mask Mask of the properties to set of unset. + @result 0 on success otherwise the errno error. +*/ +extern errno_t ifnet_set_wake_flags(ifnet_t interface, u_int32_t properties, u_int32_t mask); + +/*! + @function ifnet_get_wake_flags + @discussion Returns the wake properties set on the interface. + @param interface The interface. + @result The wake properties +*/ +extern u_int32_t ifnet_get_wake_flags(ifnet_t interface); /*! @function ifnet_set_link_mib_data @@ -858,7 +1726,7 @@ ifnet_offload_t ifnet_offload(ifnet_t interface); whenever the sysctl for getting interface specific MIB data is used. Since the ifnet_t stores a pointer to your data instead of a copy, you may update the data at the address at any time. - + This function is intended to be called by the driver. A kext must not call this function on an interface the kext does not own. @@ -866,8 +1734,9 @@ ifnet_offload_t ifnet_offload(ifnet_t interface); @param mibData A pointer to the data. @param mibLen Length of data pointed to. @result 0 on success otherwise the errno error. - */ -errno_t ifnet_set_link_mib_data(ifnet_t interface, void *mibData, u_int32_t mibLen); +*/ +extern errno_t ifnet_set_link_mib_data(ifnet_t interface, void *mibData, + u_int32_t mibLen); /*! @function ifnet_get_link_mib_data @@ -883,7 +1752,8 @@ errno_t ifnet_set_link_mib_data(ifnet_t interface, void *mibData, u_int32_t mibL @result Returns an error if the buffer size is too small or there is no data. */ -errno_t ifnet_get_link_mib_data(ifnet_t interface, void *mibData, u_int32_t *mibLen); +extern errno_t ifnet_get_link_mib_data(ifnet_t interface, void *mibData, + u_int32_t *mibLen); /*! @function ifnet_get_link_mib_data_length @@ -892,7 +1762,7 @@ errno_t ifnet_get_link_mib_data(ifnet_t interface, void *mibData, u_int32_t *mib @result Returns the number of bytes of mib data associated with the interface. */ -u_int32_t ifnet_get_link_mib_data_length(ifnet_t interface); +extern u_int32_t ifnet_get_link_mib_data_length(ifnet_t interface); /*! @function ifnet_attach_protocol @@ -903,8 +1773,24 @@ u_int32_t ifnet_get_link_mib_data_length(ifnet_t interface); @param proto_details Details of the protocol being attached. @result 0 on success otherwise the errno error. */ -errno_t ifnet_attach_protocol(ifnet_t interface, protocol_family_t protocol_family, - const struct ifnet_attach_proto_param *proto_details); +extern errno_t ifnet_attach_protocol(ifnet_t interface, + protocol_family_t protocol_family, + const struct ifnet_attach_proto_param *proto_details); + +/*! + @function ifnet_attach_protocol_v2 + @discussion Attaches a protocol to an interface using the newer + version 2 style interface. So far the only difference is support + for packet chains which improve performance. + @param interface The interface. + @param protocol_family The protocol family being attached + (PF_INET/PF_APPLETALK/etc...). + @param proto_details Details of the protocol being attached. + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_attach_protocol_v2(ifnet_t interface, + protocol_family_t protocol_family, + const struct ifnet_attach_proto_param_v2 *proto_details); /*! @function ifnet_detach_protocol @@ -914,7 +1800,8 @@ errno_t ifnet_attach_protocol(ifnet_t interface, protocol_family_t protocol_fami detach. @result 0 on success otherwise the errno error. */ -errno_t ifnet_detach_protocol(ifnet_t interface, protocol_family_t protocol_family); +extern errno_t ifnet_detach_protocol(ifnet_t interface, + protocol_family_t protocol_family); /*! @function ifnet_output @@ -925,8 +1812,7 @@ errno_t ifnet_detach_protocol(ifnet_t interface, protocol_family_t protocol_fami determine which preoutput function to call. The route and dest parameters will be passed to the preoutput function defined for the attachment of the specified protocol to the specified - interface. ifnet_output will free the mbuf chain in the event of - an error. + interface. ifnet_output will always free the mbuf chain. @param interface The interface. @param protocol_family The family of the protocol generating this packet (i.e. AF_INET). @@ -939,8 +1825,9 @@ errno_t ifnet_detach_protocol(ifnet_t interface, protocol_family_t protocol_fami function does not require this value, you may pass NULL. @result 0 on success otherwise the errno error. */ -errno_t ifnet_output(ifnet_t interface, protocol_family_t protocol_family, mbuf_t packet, - void* route, const struct sockaddr *dest); +extern errno_t ifnet_output(ifnet_t interface, + protocol_family_t protocol_family, mbuf_t packet, void *route, + const struct sockaddr *dest); /*! @function ifnet_output_raw @@ -952,15 +1839,15 @@ errno_t ifnet_output(ifnet_t interface, protocol_family_t protocol_family, mbuf_ packet. Processing, such as calling the protocol preoutput and interface framer functions will be bypassed. The packet will pass through the filters and be sent on the interface as is. - ifnet_output_raw will free the packet chain in the event of an - error. + ifnet_output_raw will always free the packet chain. @param interface The interface. @param protocol_family The family of the protocol generating this packet (i.e. AF_INET). @param packet The fully formed packet to be transmitted. @result 0 on success otherwise the errno error. */ -errno_t ifnet_output_raw(ifnet_t interface, protocol_family_t protocol_family, mbuf_t packet); +extern errno_t ifnet_output_raw(ifnet_t interface, + protocol_family_t protocol_family, mbuf_t packet); /*! @function ifnet_input @@ -976,13 +1863,39 @@ errno_t ifnet_output_raw(ifnet_t interface, protocol_family_t protocol_family, m stats. This parameter may be NULL. @result 0 on success otherwise the errno error. */ -errno_t ifnet_input(ifnet_t interface, mbuf_t first_packet, - const struct ifnet_stat_increment_param *stats); +extern errno_t ifnet_input(ifnet_t interface, mbuf_t first_packet, + const struct ifnet_stat_increment_param *stats); + +#ifdef KERNEL_PRIVATE +/* + @function ifnet_input_extended + @discussion Inputs packets from the interface. The interface's demux + will be called to determine the protocol. Once the protocol is + determined, the interface filters and protocol filters will be + called. From there, the packet will be passed to the registered + protocol. If there is an error, the mbuf chain will be freed. + @param interface The interface. + @param first_packet The first packet in a chain of packets. + @param last_packet The last packet in a chain of packets. This may be + set to NULL if the driver does not have the information. + @param stats Counts to be integrated in to the stats. The interface + statistics will be incremented by the amounts specified in + stats. Unlike ifnet_input(), this parameter is required by + this extended variant. + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_input_extended(ifnet_t interface, mbuf_t first_packet, + mbuf_t last_packet, const struct ifnet_stat_increment_param *stats); +#endif /* KERNEL_PRIVATE */ /*! @function ifnet_ioctl @discussion Calls the interface's ioctl function with the parameters passed. + + All undefined ioctls are reserved for future use by Apple. If + you need to communicate with your kext using an ioctl, please + use SIOCSIFKPI and SIOCGIFKPI. @param interface The interface. @param protocol The protocol family of the protocol to send the ioctl to (may be zero). Some ioctls apply to a protocol while @@ -991,8 +1904,8 @@ errno_t ifnet_input(ifnet_t interface, mbuf_t first_packet, @param ioctl_arg Any parameters to the ioctl. @result 0 on success otherwise the errno error. */ -errno_t ifnet_ioctl(ifnet_t interface, protocol_family_t protocol, - u_int32_t ioctl_code, void *ioctl_arg); +extern errno_t ifnet_ioctl(ifnet_t interface, protocol_family_t protocol, + unsigned long ioctl_code, void *ioctl_arg); /*! @function ifnet_event @@ -1002,14 +1915,14 @@ errno_t ifnet_ioctl(ifnet_t interface, protocol_family_t protocol, event. @result 0 on success otherwise the errno error. */ -errno_t ifnet_event(ifnet_t interface, struct kern_event_msg* event_ptr); +extern errno_t ifnet_event(ifnet_t interface, struct kern_event_msg *event_ptr); /*! @function ifnet_set_mtu @discussion Sets the value of the MTU in the interface structure. Calling this function will not notify the driver that the MTU should be changed. Use the appropriate ioctl. - + This function is intended to be called by the driver. A kext must not call this function on an interface the kext does not own. @@ -1017,21 +1930,21 @@ errno_t ifnet_event(ifnet_t interface, struct kern_event_msg* event_ptr); @param mtu The new MTU. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_mtu(ifnet_t interface, u_int32_t mtu); +extern errno_t ifnet_set_mtu(ifnet_t interface, u_int32_t mtu); /*! @function ifnet_mtu @param interface The interface. @result The MTU. */ -u_int32_t ifnet_mtu(ifnet_t interface); +extern u_int32_t ifnet_mtu(ifnet_t interface); /*! @function ifnet_type @param interface The interface. @result The type. See net/if_types.h. */ -u_int8_t ifnet_type(ifnet_t interface); +extern u_int8_t ifnet_type(ifnet_t interface); /*! @function ifnet_set_addrlen @@ -1043,14 +1956,14 @@ u_int8_t ifnet_type(ifnet_t interface); @param addrlen The new address length. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_addrlen(ifnet_t interface, u_int8_t addrlen); +extern errno_t ifnet_set_addrlen(ifnet_t interface, u_int8_t addrlen); /*! @function ifnet_addrlen @param interface The interface. @result The address length. */ -u_int8_t ifnet_addrlen(ifnet_t interface); +extern u_int8_t ifnet_addrlen(ifnet_t interface); /*! @function ifnet_set_hdrlen @@ -1062,14 +1975,14 @@ u_int8_t ifnet_addrlen(ifnet_t interface); @param hdrlen The new header length. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_hdrlen(ifnet_t interface, u_int8_t hdrlen); +extern errno_t ifnet_set_hdrlen(ifnet_t interface, u_int8_t hdrlen); /*! @function ifnet_hdrlen @param interface The interface. @result The header length. */ -u_int8_t ifnet_hdrlen(ifnet_t interface); +extern u_int8_t ifnet_hdrlen(ifnet_t interface); /*! @function ifnet_set_metric @@ -1081,14 +1994,14 @@ u_int8_t ifnet_hdrlen(ifnet_t interface); @param metric The new metric. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_metric(ifnet_t interface, u_int32_t metric); +extern errno_t ifnet_set_metric(ifnet_t interface, u_int32_t metric); /*! @function ifnet_metric @param interface The interface. @result The metric. */ -u_int32_t ifnet_metric(ifnet_t interface); +extern u_int32_t ifnet_metric(ifnet_t interface); /*! @function ifnet_set_baudrate @@ -1100,14 +2013,46 @@ u_int32_t ifnet_metric(ifnet_t interface); @param baudrate The new baudrate. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_baudrate(ifnet_t interface, u_int64_t baudrate); +extern errno_t ifnet_set_baudrate(ifnet_t interface, u_int64_t baudrate); /*! @function ifnet_baudrate @param interface The interface. @result The baudrate. */ -u_int64_t ifnet_baudrate(ifnet_t interface); +extern u_int64_t ifnet_baudrate(ifnet_t interface); + +#ifdef KERNEL_PRIVATE +typedef struct if_bandwidths if_bandwidths_t; + +/* + @function ifnet_set_bandwidths + @param interface The interface. + @param output_bw The output bandwidth values (in bits per second). + May be set to NULL if the caller does not want to alter the + existing output bandwidth values. + @param input_bw The input bandwidth values (in bits per second). + May be set to NULL if the caller does not want to alter the + existing input bandwidth values. + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_set_bandwidths(ifnet_t interface, + if_bandwidths_t *output_bw, if_bandwidths_t *input_bw); + +/* + @function ifnet_bandwidths + @param interface The interface. + @param output_bw The output bandwidth values (in bits per second). + May be set to NULL if the caller does not want to retrieve the + output bandwidth value. + @param input_bw The input bandwidth values (in bits per second). + May be set to NULL if the caller does not want to retrieve the + input bandwidth value. + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_bandwidths(ifnet_t interface, if_bandwidths_t *output_bw, + if_bandwidths_t *input_bw); +#endif /* KERNEL_PRIVATE */ /*! @function ifnet_stat_increment @@ -1121,8 +2066,8 @@ u_int64_t ifnet_baudrate(ifnet_t interface); ifnet_counter_increment structure are handled in the stack. @result 0 on success otherwise the errno error. */ -errno_t ifnet_stat_increment(ifnet_t interface, - const struct ifnet_stat_increment_param *counts); +extern errno_t ifnet_stat_increment(ifnet_t interface, + const struct ifnet_stat_increment_param *counts); /*! @function ifnet_stat_increment_in @@ -1131,7 +2076,7 @@ errno_t ifnet_stat_increment(ifnet_t interface, function allows a driver to update the inbound interface counts. The most efficient time to update these counts is when calling ifnet_input. - + A lock protects the counts, this makes the increment functions expensive. The increment function will update the lastchanged value. @@ -1141,16 +2086,16 @@ errno_t ifnet_stat_increment(ifnet_t interface, @param errors_in The number of additional receive errors. @result 0 on success otherwise the errno error. */ -errno_t ifnet_stat_increment_in(ifnet_t interface, - u_int32_t packets_in, u_int32_t bytes_in, - u_int32_t errors_in); +extern errno_t ifnet_stat_increment_in(ifnet_t interface, + u_int32_t packets_in, u_int32_t bytes_in, u_int32_t errors_in); /*! @function ifnet_stat_increment_out @discussion This function is intended to be called by the driver. This - function allows a driver to update the outbound interface counts. - + function allows a driver to update the outbound interface + counts. + A lock protects the counts, this makes the increment functions expensive. The increment function will update the lastchanged value. @@ -1160,9 +2105,8 @@ errno_t ifnet_stat_increment_in(ifnet_t interface, @param errors_out The number of additional send errors. @result 0 on success otherwise the errno error. */ -errno_t ifnet_stat_increment_out(ifnet_t interface, - u_int32_t packets_out, u_int32_t bytes_out, - u_int32_t errors_out); +extern errno_t ifnet_stat_increment_out(ifnet_t interface, +u_int32_t packets_out, u_int32_t bytes_out, u_int32_t errors_out); /*! @function ifnet_set_stat @@ -1170,15 +2114,15 @@ errno_t ifnet_stat_increment_out(ifnet_t interface, This function is intended to be called by the driver. A kext must not call this function on an interface the kext does not own. - + The one exception would be the case where a kext wants to zero all of the counters. @param interface The interface. @param counts The new stats values. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_stat(ifnet_t interface, - const struct ifnet_stats_param *stats); +extern errno_t ifnet_set_stat(ifnet_t interface, + const struct ifnet_stats_param *stats); /*! @function ifnet_stat @@ -1186,8 +2130,8 @@ errno_t ifnet_set_stat(ifnet_t interface, @param out_stats Storage for the values. @result 0 on success otherwise the errno error. */ -errno_t ifnet_stat(ifnet_t interface, - struct ifnet_stats_param *out_stats); +extern errno_t ifnet_stat(ifnet_t interface, + struct ifnet_stats_param *out_stats); /*! @function ifnet_set_promiscuous @@ -1204,7 +2148,7 @@ errno_t ifnet_stat(ifnet_t interface, zero, promiscuous mode will be disabled. @result 0 on success otherwise the errno error. */ -errno_t ifnet_set_promiscuous(ifnet_t interface, int on); +extern errno_t ifnet_set_promiscuous(ifnet_t interface, int on); /*! @function ifnet_touch_lastchange @@ -1212,7 +2156,7 @@ errno_t ifnet_set_promiscuous(ifnet_t interface, int on); @param interface The interface. @result 0 on success otherwise the errno error. */ -errno_t ifnet_touch_lastchange(ifnet_t interface); +extern errno_t ifnet_touch_lastchange(ifnet_t interface); /*! @function ifnet_lastchange @@ -1220,7 +2164,7 @@ errno_t ifnet_touch_lastchange(ifnet_t interface); @param last_change A timeval struct to copy the last time changed in to. */ -errno_t ifnet_lastchange(ifnet_t interface, struct timeval *last_change); +extern errno_t ifnet_lastchange(ifnet_t interface, struct timeval *last_change); /*! @function ifnet_get_address_list @@ -1235,7 +2179,7 @@ errno_t ifnet_lastchange(ifnet_t interface, struct timeval *last_change); @param addresses A pointer to a NULL terminated array of ifaddr_ts. @result 0 on success otherwise the errno error. */ -errno_t ifnet_get_address_list(ifnet_t interface, ifaddr_t **addresses); +extern errno_t ifnet_get_address_list(ifnet_t interface, ifaddr_t **addresses); /*! @function ifnet_get_address_list_family @@ -1252,7 +2196,13 @@ errno_t ifnet_get_address_list(ifnet_t interface, ifaddr_t **addresses); @param addresses A pointer to a NULL terminated array of ifaddr_ts. @result 0 on success otherwise the errno error. */ -errno_t ifnet_get_address_list_family(ifnet_t interface, ifaddr_t **addresses, sa_family_t family); +extern errno_t ifnet_get_address_list_family(ifnet_t interface, + ifaddr_t **addresses, sa_family_t family); + +#ifdef KERNEL_PRIVATE +__private_extern__ errno_t ifnet_get_address_list_family_internal(ifnet_t, + ifaddr_t **, sa_family_t, int, int); +#endif /* KERNEL_PRIVATE */ /*! @function ifnet_free_address_list @@ -1261,7 +2211,7 @@ errno_t ifnet_get_address_list_family(ifnet_t interface, ifaddr_t **addresses, s memory used for the array of references. @param addresses An array of ifaddr_ts. */ -void ifnet_free_address_list(ifaddr_t *addresses); +extern void ifnet_free_address_list(ifaddr_t *addresses); /*! @function ifnet_set_lladdr @@ -1272,7 +2222,8 @@ void ifnet_free_address_list(ifaddr_t *addresses); the 6 byte ethernet address for ethernet). @param lladdr_len The length, in bytes, of the link layer address. */ -errno_t ifnet_set_lladdr(ifnet_t interface, const void* lladdr, size_t lladdr_len); +extern errno_t ifnet_set_lladdr(ifnet_t interface, const void *lladdr, + size_t lladdr_len); /*! @function ifnet_lladdr_copy_bytes @@ -1283,7 +2234,8 @@ errno_t ifnet_set_lladdr(ifnet_t interface, const void* lladdr, size_t lladdr_le @param length The length of the buffer. This value must match the length of the link-layer address. */ -errno_t ifnet_lladdr_copy_bytes(ifnet_t interface, void* lladdr, size_t length); +extern errno_t ifnet_lladdr_copy_bytes(ifnet_t interface, void *lladdr, + size_t length); #ifdef KERNEL_PRIVATE /*! @@ -1291,8 +2243,8 @@ errno_t ifnet_lladdr_copy_bytes(ifnet_t interface, void* lladdr, size_t length); @discussion Returns a pointer to the link-layer address. @param interface The interface the link-layer address is on. */ -void* ifnet_lladdr(ifnet_t interface); -#endif KERNEL_PRIVATE +extern void *ifnet_lladdr(ifnet_t interface); +#endif /* KERNEL_PRIVATE */ /*! @function ifnet_llbroadcast_copy_bytes @@ -1304,8 +2256,8 @@ void* ifnet_lladdr(ifnet_t interface); @param addr_len On return, the length of the broadcast address. @param lladdr_len The length, in bytes, of the link layer address. */ -errno_t ifnet_llbroadcast_copy_bytes(ifnet_t interface, void* addr, - size_t bufferlen, size_t* addr_len); +extern errno_t ifnet_llbroadcast_copy_bytes(ifnet_t interface, void *addr, + size_t bufferlen, size_t *addr_len); #ifdef KERNEL_PRIVATE /*! @@ -1320,8 +2272,26 @@ errno_t ifnet_llbroadcast_copy_bytes(ifnet_t interface, void* addr, @param lladdr_len The length, in bytes, of the link layer address. @param type The link-layer address type. */ -errno_t ifnet_set_lladdr_and_type(ifnet_t interface, const void* lladdr, size_t length, u_char type); -#endif KERNEL_PRIVATE +extern errno_t ifnet_set_lladdr_and_type(ifnet_t interface, const void *lladdr, + size_t length, u_char type); +#endif /* KERNEL_PRIVATE */ + +/*! + @function ifnet_resolve_multicast + @discussion Resolves a multicast address for an attached protocol to + a link-layer address. If a link-layer address is passed in, the + interface will verify that it is a valid multicast address. + @param interface The interface. + @param proto_addr A protocol address to be converted to a link-layer + address. + @param ll_addr Storage for the resulting link-layer address. + @param ll_len Length of the storage for the link-layer address. + @result 0 on success. EOPNOTSUPP indicates the multicast address was + not supported or could not be translated. Other errors may + indicate other failures. + */ +extern errno_t ifnet_resolve_multicast(ifnet_t ifp, + const struct sockaddr *proto_addr, struct sockaddr *ll_addr, size_t ll_len); /*! @function ifnet_add_multicast @@ -1331,14 +2301,14 @@ errno_t ifnet_set_lladdr_and_type(ifnet_t interface, const void* lladdr, size_t ifnet_remove_multicast and making sure you no longer have any references to the multicast. @param interface The interface. - @param maddr The multicast address to join. Either a physical - address or logical address to be translated to a physical - address. + @param maddr The multicast address (AF_UNSPEC/AF_LINK) to join. Either + a physical address or logical address to be translated to a + physical address. @param multicast The resulting ifmultiaddr_t multicast address. @result 0 on success otherwise the errno error. */ -errno_t ifnet_add_multicast(ifnet_t interface, const struct sockaddr *maddr, - ifmultiaddr_t *multicast); +extern errno_t ifnet_add_multicast(ifnet_t interface, + const struct sockaddr *maddr, ifmultiaddr_t *multicast); /*! @function ifnet_remove_multicast @@ -1348,23 +2318,23 @@ errno_t ifnet_add_multicast(ifnet_t interface, const struct sockaddr *maddr, removed when the number of times ifnet_remove_multicast has been called matches the number of times ifnet_add_multicast has been called. - + The memory for the multicast address is not actually freed until the separate reference count has reached zero. Some parts of the stack may keep a pointer to the multicast even after that multicast has been removed from the interface. - + When an interface is detached, all of the multicasts are removed. If the interface of the multicast passed in is no longer attached, this function will gracefully return, performing no work. - + It is the callers responsibility to release the multicast address after calling this function. @param multicast The multicast to be removed. @result 0 on success otherwise the errno error. */ -errno_t ifnet_remove_multicast(ifmultiaddr_t multicast); +extern errno_t ifnet_remove_multicast(ifmultiaddr_t multicast); /*! @function ifnet_get_multicast_list @@ -1379,7 +2349,8 @@ errno_t ifnet_remove_multicast(ifmultiaddr_t multicast); to the multicast addresses. @result 0 on success otherwise the errno error. */ -errno_t ifnet_get_multicast_list(ifnet_t interface, ifmultiaddr_t **addresses); +extern errno_t ifnet_get_multicast_list(ifnet_t interface, + ifmultiaddr_t **addresses); /*! @function ifnet_free_multicast_list @@ -1389,7 +2360,7 @@ errno_t ifnet_get_multicast_list(ifnet_t interface, ifmultiaddr_t **addresses); @param multicasts An array of references to the multicast addresses. @result 0 on success otherwise the errno error. */ -void ifnet_free_multicast_list(ifmultiaddr_t *multicasts); +extern void ifnet_free_multicast_list(ifmultiaddr_t *multicasts); /*! @function ifnet_find_by_name @@ -1402,7 +2373,7 @@ void ifnet_free_multicast_list(ifmultiaddr_t *multicasts); filled in if a matching interface is found. @result 0 on success otherwise the errno error. */ -errno_t ifnet_find_by_name(const char *ifname, ifnet_t *interface); +extern errno_t ifnet_find_by_name(const char *ifname, ifnet_t *interface); /*! @function ifnet_list_get @@ -1418,7 +2389,28 @@ errno_t ifnet_find_by_name(const char *ifname, ifnet_t *interface); matching interfaces in the array. @result 0 on success otherwise the errno error. */ -errno_t ifnet_list_get(ifnet_family_t family, ifnet_t **interfaces, u_int32_t *count); +extern errno_t ifnet_list_get(ifnet_family_t family, ifnet_t **interfaces, + u_int32_t *count); + +#ifdef KERNEL_PRIVATE +/*! + @function ifnet_list_get_all + @discussion Get a list of attached interfaces. List will be set to + point to an array allocated by ifnet_list_get. The interfaces + are refcounted and the counts will be incremented before the + function returns. The list of interfaces must be freed using + ifnet_list_free. This is similar to ifnet_list_get, except + that it includes interfaces that are detaching. + @param family The interface family (i.e. IFNET_FAMILY_ETHERNET). To + find interfaces of all families, use IFNET_FAMILY_ANY. + @param interfaces A pointer to an array of interface references. + @param count A pointer that will be filled in with the number of + matching interfaces in the array. + @result 0 on success otherwise the errno error. + */ +extern errno_t ifnet_list_get_all(ifnet_family_t family, ifnet_t **interfaces, + u_int32_t *count); +#endif /* KERNEL_PRIVATE */ /*! @function ifnet_list_free @@ -1429,11 +2421,11 @@ errno_t ifnet_list_get(ifnet_family_t family, ifnet_t **interfaces, u_int32_t *c ifnet_list_free. @param interfaces An array of interface references from ifnet_list_get. */ -void ifnet_list_free(ifnet_t *interfaces); +extern void ifnet_list_free(ifnet_t *interfaces); -/********************************************************************************************/ -/* ifaddr_t accessors */ -/********************************************************************************************/ +/******************************************************************************/ +/* ifaddr_t accessors */ +/******************************************************************************/ /*! @function ifaddr_reference @@ -1442,7 +2434,7 @@ void ifnet_list_free(ifnet_t *interfaces); @param ifaddr The interface address. @result 0 upon success */ -errno_t ifaddr_reference(ifaddr_t ifaddr); +extern errno_t ifaddr_reference(ifaddr_t ifaddr); /*! @function ifaddr_release @@ -1451,7 +2443,7 @@ errno_t ifaddr_reference(ifaddr_t ifaddr); @param ifaddr The interface address. @result 0 upon success */ -errno_t ifaddr_release(ifaddr_t ifaddr); +extern errno_t ifaddr_release(ifaddr_t ifaddr); /*! @function ifaddr_address @@ -1461,7 +2453,8 @@ errno_t ifaddr_release(ifaddr_t ifaddr); @param addr_size The size of the storage for the address. @result 0 upon success */ -errno_t ifaddr_address(ifaddr_t ifaddr, struct sockaddr *out_addr, u_int32_t addr_size); +extern errno_t ifaddr_address(ifaddr_t ifaddr, struct sockaddr *out_addr, + u_int32_t addr_size); /*! @function ifaddr_address @@ -1469,7 +2462,7 @@ errno_t ifaddr_address(ifaddr_t ifaddr, struct sockaddr *out_addr, u_int32_t add @param ifaddr The interface address. @result 0 on failure, address family on success. */ -sa_family_t ifaddr_address_family(ifaddr_t ifaddr); +extern sa_family_t ifaddr_address_family(ifaddr_t ifaddr); /*! @function ifaddr_dstaddress @@ -1479,7 +2472,8 @@ sa_family_t ifaddr_address_family(ifaddr_t ifaddr); @param dstaddr_size The size of the storage for the destination address. @result 0 upon success */ -errno_t ifaddr_dstaddress(ifaddr_t ifaddr, struct sockaddr *out_dstaddr, u_int32_t dstaddr_size); +extern errno_t ifaddr_dstaddress(ifaddr_t ifaddr, struct sockaddr *out_dstaddr, + u_int32_t dstaddr_size); /*! @function ifaddr_netmask @@ -1489,7 +2483,8 @@ errno_t ifaddr_dstaddress(ifaddr_t ifaddr, struct sockaddr *out_dstaddr, u_int32 @param netmask_size The size of the storage for the netmask. @result 0 upon success */ -errno_t ifaddr_netmask(ifaddr_t ifaddr, struct sockaddr *out_netmask, u_int32_t netmask_size); +extern errno_t ifaddr_netmask(ifaddr_t ifaddr, struct sockaddr *out_netmask, + u_int32_t netmask_size); /*! @function ifaddr_ifnet @@ -1501,7 +2496,7 @@ errno_t ifaddr_netmask(ifaddr_t ifaddr, struct sockaddr *out_netmask, u_int32_t @param ifaddr The interface address. @result A reference to the interface the address is attached to. */ -ifnet_t ifaddr_ifnet(ifaddr_t ifaddr); +extern ifnet_t ifaddr_ifnet(ifaddr_t ifaddr); /*! @function ifaddr_withaddr @@ -1511,7 +2506,7 @@ ifnet_t ifaddr_ifnet(ifaddr_t ifaddr); @param address The address to search for. @result A reference to the interface address. */ -ifaddr_t ifaddr_withaddr(const struct sockaddr* address); +extern ifaddr_t ifaddr_withaddr(const struct sockaddr *address); /*! @function ifaddr_withdstaddr @@ -1522,7 +2517,7 @@ ifaddr_t ifaddr_withaddr(const struct sockaddr* address); @param destination The destination to search for. @result A reference to the interface address. */ -ifaddr_t ifaddr_withdstaddr(const struct sockaddr* destination); +extern ifaddr_t ifaddr_withdstaddr(const struct sockaddr *destination); /*! @function ifaddr_withnet @@ -1533,7 +2528,7 @@ ifaddr_t ifaddr_withdstaddr(const struct sockaddr* destination); @param net The network to search for. @result A reference to the interface address. */ -ifaddr_t ifaddr_withnet(const struct sockaddr* net); +extern ifaddr_t ifaddr_withnet(const struct sockaddr *net); /*! @function ifaddr_withroute @@ -1546,8 +2541,8 @@ ifaddr_t ifaddr_withnet(const struct sockaddr* net); @param gateway A gateway to search for. @result A reference to the interface address. */ -ifaddr_t ifaddr_withroute(int flags, const struct sockaddr* destination, - const struct sockaddr* gateway); +extern ifaddr_t ifaddr_withroute(int flags, const struct sockaddr *destination, + const struct sockaddr *gateway); /*! @function ifaddr_findbestforaddr @@ -1559,11 +2554,12 @@ ifaddr_t ifaddr_withroute(int flags, const struct sockaddr* destination, @param interface The local interface. @result A reference to the interface address. */ -ifaddr_t ifaddr_findbestforaddr(const struct sockaddr *addr, ifnet_t interface); +extern ifaddr_t ifaddr_findbestforaddr(const struct sockaddr *addr, + ifnet_t interface); -/********************************************************************************************/ -/* ifmultiaddr_t accessors */ -/********************************************************************************************/ +/******************************************************************************/ +/* ifmultiaddr_t accessors */ +/******************************************************************************/ /*! @function ifmaddr_reference @@ -1572,7 +2568,7 @@ ifaddr_t ifaddr_findbestforaddr(const struct sockaddr *addr, ifnet_t interface); @param ifmaddr The interface multicast address. @result 0 on success. Only error will be EINVAL if ifmaddr is not valid. */ -errno_t ifmaddr_reference(ifmultiaddr_t ifmaddr); +extern errno_t ifmaddr_reference(ifmultiaddr_t ifmaddr); /*! @function ifmaddr_release @@ -1583,7 +2579,7 @@ errno_t ifmaddr_reference(ifmultiaddr_t ifmaddr); @param ifmaddr The interface multicast address. @result 0 on success. Only error will be EINVAL if ifmaddr is not valid. */ -errno_t ifmaddr_release(ifmultiaddr_t ifmaddr); +extern errno_t ifmaddr_release(ifmultiaddr_t ifmaddr); /*! @function ifmaddr_address @@ -1592,7 +2588,8 @@ errno_t ifmaddr_release(ifmultiaddr_t ifmaddr); @param addr_size Size of the storage. @result 0 on success. */ -errno_t ifmaddr_address(ifmultiaddr_t ifmaddr, struct sockaddr *out_multicast, u_int32_t addr_size); +extern errno_t ifmaddr_address(ifmultiaddr_t ifmaddr, + struct sockaddr *out_multicast, u_int32_t addr_size); /*! @function ifmaddr_lladdress @@ -1602,8 +2599,8 @@ errno_t ifmaddr_address(ifmultiaddr_t ifmaddr, struct sockaddr *out_multicast, u @param addr_size Size of the storage. @result 0 on success. */ -errno_t ifmaddr_lladdress(ifmultiaddr_t ifmaddr, struct sockaddr *out_link_layer_multicast, - u_int32_t addr_size); +extern errno_t ifmaddr_lladdress(ifmultiaddr_t ifmaddr, + struct sockaddr *out_link_layer_multicast, u_int32_t addr_size); /*! @function ifmaddr_ifnet @@ -1616,8 +2613,133 @@ errno_t ifmaddr_lladdress(ifmultiaddr_t ifmaddr, struct sockaddr *out_link_layer @param ifmaddr The interface multicast address. @result A reference to the interface. */ -ifnet_t ifmaddr_ifnet(ifmultiaddr_t ifmaddr); +extern ifnet_t ifmaddr_ifnet(ifmultiaddr_t ifmaddr); + +#ifdef KERNEL_PRIVATE +/******************************************************************************/ +/* interface cloner */ +/******************************************************************************/ + +/* + @typedef ifnet_clone_create_func + @discussion ifnet_clone_create_func is called to create an interface. + @param ifcloner The interface cloner. + @param unit The interface unit number to create. + @param params Additional information specific to the interface cloner. + @result Return zero on success or an errno error value on failure. + */ +typedef errno_t (*ifnet_clone_create_func)(if_clone_t ifcloner, u_int32_t unit, void *params); + +/* + @typedef ifnet_clone_destroy_func + @discussion ifnet_clone_create_func is called to destroy an interface created + by an interface cloner. + @param interface The interface to destroy. + @result Return zero on success or an errno error value on failure. + */ +typedef errno_t (*ifnet_clone_destroy_func)(ifnet_t interface); + +/* + @struct ifnet_clone_params + @discussion This structure is used to represent an interface cloner. + @field ifc_name The interface name handled by this interface cloner. + @field ifc_create The function to create an interface. + @field ifc_destroy The function to destroy an interface. +*/ +struct ifnet_clone_params { + const char *ifc_name; + ifnet_clone_create_func ifc_create; + ifnet_clone_destroy_func ifc_destroy; +}; + +/* + @function ifnet_clone_attach + @discussion Attaches a new interface cloner. + @param cloner_params The structure that defines an interface cloner. + @param interface A pointer to an opaque handle that represent the interface cloner + that is attached upon success. + @result Returns 0 on success. + May return ENOBUFS if there is insufficient memory. + May return EEXIST if an interface cloner with the same name is already attached. + */ +extern errno_t ifnet_clone_attach(struct ifnet_clone_params *cloner_params, if_clone_t *ifcloner); + +/* + @function ifnet_clone_detach + @discussion Detaches a previously attached interface cloner. + @param ifcloner The opaque handle returned when the interface cloner was attached. + @result Returns 0 on success. + */ +extern errno_t ifnet_clone_detach(if_clone_t ifcloner); + +/******************************************************************************/ +/* misc */ +/******************************************************************************/ + +/* + @function ifnet_get_local_ports + @discussion Returns a bitfield indicating which ports have sockets + open. An interface that supports waking the host on unicast traffic may + use this information to discard incoming unicast packets that don't have + a corresponding bit set instead of waking up the host. For port 0x0001, + bit 1 of the first byte would be set. For port n, bit 1 << (n % 8) of + the (n / 8)'th byte would be set. + @param ifp The interface in question. + @param bitfield A pointer to 8192 bytes. + @result Returns 0 on success. + */ +extern errno_t ifnet_get_local_ports(ifnet_t ifp, uint8_t *bitfield); +/******************************************************************************/ +/* for interfaces that support dynamic node absence/presence events */ +/******************************************************************************/ + +/* + @function ifnet_notice_node_presence + @discussion Provided for network interface drivers to notify the + system of a change detected in the presence of the specified + node. + @param ifp The interface attached to the link where the specified node + is present. + @param sa The AF_LINK family address of the node whose presence is + changing. + @param rssi The received signal strength indication as measured in + dBm by a radio receiver. + @param lqm A link quality metric associated with the specified node. + @param npm A node proximity metric associated with the specified node. + @param srvinfo A fixed-size array of octets containing opaque service + information data used by the mDNS responder subsystem. + @result Returns 0 on success, or EINVAL if arguments are invalid. + */ +extern errno_t +ifnet_notice_node_presence(ifnet_t ifp, struct sockaddr* sa, int32_t rssi, + int lqm, int npm, u_int8_t srvinfo[48]); + +/* + @function ifnet_notice_node_absence + @discussion Provided for network interface drivers to notify the + system that the absence of the specified node has been detected. + @param ifp The interface attached to the link where the absence of the + specified node has been detected. + @param sa The AF_LINK family address of the node whose absence has been + detected. + @result Returns 0 on success, or EINVAL if arguments are invalid. + */ +extern errno_t ifnet_notice_node_absence(ifnet_t ifp, struct sockaddr* sa); + +/* + @function ifnet_notice_master_elected + @discussion Provided for network interface drivers to notify the system + that the nodes with a locally detected presence on the attached + link have elected a new master. + @param ifp The interface attached to the link where the new master has + been elected. + @result Returns 0 on success, or EINVAL if arguments are invalid. + */ +extern errno_t ifnet_notice_master_elected(ifnet_t ifp); + +#endif /* KERNEL_PRIVATE */ __END_DECLS -#endif +#endif /* __KPI_INTERFACE__ */ +