/*
- * Copyright (c) 2004-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2017 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <sys/kernel_types.h>
#ifdef KERNEL_PRIVATE
+struct if_interface_state;
#include <sys/kpi_mbuf.h>
#endif /* KERNEL_PRIVATE */
#include <sys/_types/_sa_family_t.h>
#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;
/*!
@enum Interface Families
@abstract Constants defining interface families.
- @discussion
@constant IFNET_FAMILY_ANY Match interface of any family type.
@constant IFNET_FAMILY_LOOPBACK A software loopback interface.
@constant IFNET_FAMILY_ETHERNET An Ethernet interface.
IFNET_SUBFAMILY_WIFI = 3,
IFNET_SUBFAMILY_THUNDERBOLT = 4,
IFNET_SUBFAMILY_RESERVED = 5,
+ IFNET_SUBFAMILY_INTCOPROC = 6,
+ IFNET_SUBFAMILY_UTUN = 7,
+ IFNET_SUBFAMILY_IPSEC = 8,
};
/*
/*!
@enum BPF tap mode
@abstract Constants defining interface families.
- @discussion
@constant BPF_MODE_DISABLED Disable bpf.
@constant BPF_MODE_INPUT Enable input only.
@constant BPF_MODE_OUTPUT Enable output only.
/*!
@enum Interface Abilities
@abstract Constants defining interface offload support.
- @discussion
@constant IFNET_CSUM_IP Hardware will calculate IPv4 checksums.
@constant IFNET_CSUM_TCP Hardware will calculate TCP checksums.
@constant IFNET_CSUM_UDP Hardware will calculate UDP checksums.
#ifdef KERNEL_PRIVATE
IFNET_CSUM_PARTIAL = 0x00001000,
IFNET_CSUM_SUM16 = IFNET_CSUM_PARTIAL,
+ IFNET_CSUM_ZERO_INVERT = 0x00002000,
#endif /* KERNEL_PRIVATE */
IFNET_VLAN_TAGGING = 0x00010000,
IFNET_VLAN_MTU = 0x00020000,
IFNET_MULTIPAGES = 0x00100000,
IFNET_TSO_IPV4 = 0x00200000,
IFNET_TSO_IPV6 = 0x00400000,
- IFNET_TX_STATUS = 0x00800000
+ IFNET_TX_STATUS = 0x00800000,
+ IFNET_HW_TIMESTAMP = 0x01000000,
+ IFNET_SW_TIMESTAMP = 0x02000000
};
/*!
@typedef ifnet_offload_t
#ifdef KERNEL_PRIVATE
#define IFNET_OFFLOADF_BITS \
"\020\1CSUM_IP\2CSUM_TCP\3CSUM_UDP\4CSUM_IP_FRAGS\5IP_FRAGMENT" \
- "\6CSUM_TCPIPV6\7CSUM_UDPIPV6\10IPV6_FRAGMENT\15CSUM_PARTIAL" \
- "\20VLAN_TAGGING\21VLAN_MTU\25MULTIPAGES\26TSO_IPV4\27TSO_IPV6" \
- "\30TXSTATUS"
+ "\6CSUM_TCPIPV6\7CSUM_UDPIPV6\10IPV6_FRAGMENT\15CSUM_PARTIAL" \
+ "\16CSUM_ZERO_INVERT\20VLAN_TAGGING\21VLAN_MTU\25MULTIPAGES" \
+ "\26TSO_IPV4\27TSO_IPV6\30TXSTATUS\31HW_TIMESTAMP\32SW_TIMESTAMP"
+
+#define IFNET_CHECKSUMF \
+ (IFNET_CSUM_IP | IFNET_CSUM_TCP | IFNET_CSUM_UDP | \
+ IFNET_CSUM_FRAGMENT | IFNET_CSUM_TCPIPV6 | IFNET_CSUM_UDPIPV6 | \
+ IFNET_CSUM_PARTIAL | IFNET_CSUM_ZERO_INVERT)
+
+#define IFNET_TSOF \
+ (IFNET_TSO_IPV4 | IFNET_TSO_IPV6)
#endif /* KERNEL_PRIVATE */
/*
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.
*/
@discussion ifnet_event_func is called when an event occurs on a
specific interface.
@param interface The interface the event occurred on.
- @param event_ptr Pointer to a kern_event structure describing the
- event.
*/
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.
+ @discussion 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.
+ @discussion 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.
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.
- @param The interface.
+ @param interface The interface.
@param mcast The multicast address.
@result
Zero upon success, EADDRNOTAVAIL on invalid multicast,
a specific protocol on a specific interface. This function is
registered on an interface using ifnet_attach_protocol.
@param ifp The interface the packet was received on.
- @param protocol_family The protocol of the packet received.
+ @param protocol The protocol of the packet received.
@param packet The packet being input.
@param header The frame header.
@result
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 protocol 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
opportunity to specify the media specific frame type and
destination.
@param ifp The interface the packet will be sent on.
- @param protocol_family The protocol of the packet being sent
+ @param protocol The protocol of the packet being sent
(PF_INET/etc...).
@param packet The packet being sent.
@param dest The protocol level destination address.
@discussion proto_media_event is called to notify this layer of
interface specific events.
@param ifp The interface.
- @param protocol_family The protocol family.
- @param kev_msg The event.
+ @param protocol The protocol family.
+ @param event The event.
*/
typedef void (*proto_media_event)(ifnet_t ifp, protocol_family_t protocol,
const struct kev_msg *event);
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 protocol The protocol family.
@param command The ioctl command.
@param argument The argument to the ioctl.
@result
@discussion proto_media_detached notifies you that your protocol
has been detached.
@param ifp The interface.
- @param protocol_family The protocol family.
+ @param protocol The protocol family.
@result
See the discussion.
*/
function should inspect the parameters and transmit an arp
packet using the information passed in.
@param ifp The interface the arp packet should be sent on.
- @param protocol_family The protocol family of the addresses
- (PF_INET).
@param arpop The arp operation (usually ARPOP_REQUEST or
ARPOP_REPLY).
@param sender_hw The value to use for the sender hardware
/* Valid values for flags */
#define IFNET_INIT_LEGACY 0x1 /* legacy network interface model */
#define IFNET_INIT_INPUT_POLL 0x2 /* opportunistic input polling model */
+#define IFNET_INIT_NX_NOAUTO 0x4 /* do not auto config nexus */
+#define IFNET_INIT_ALLOC_KPI 0x8 /* allocated via the ifnet_alloc() KPI */
/*
@typedef ifnet_pre_enqueue_func
@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.
+ or ifnet_dequeue_multi() or ifnet_dequeue_multi_bytes().
+ 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);
@field output_lt The effective output latency (in nanosecond.)
@field output_lt_max The maximum theoretical output latency
(in nanosecond.)
+ @field start_delay_qlen The maximum length of output queue for
+ delaying start callback to the driver. This is an
+ optimization for coalescing output packets.
+ @field start_delay_timeout The timeout in microseconds to delay
+ start callback. If start_delay_qlen number of packets are
+ not in the output queue when the timer fires, the start
+ callback will be invoked. Maximum allowed value is
+ 20ms (in microseconds).
@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 broadcast_addr The link-layer broadcast address for this
interface.
@field broadcast_len The length of the link-layer broadcast address.
+ @field tx_headroom The amount of headroom space to be reserved in the
+ packet being transmitted on the interface, specified in bytes.
+ Must be a multiple of 8 bytes.
+ @field tx_trailer The amount of trailer space to be reserved in the
+ packet being transmitted on the interface, specified in bytes.
+ @field rx_mit_ival mitigation interval for the rx mitigation logic,
+ specified in microseconds.
*/
struct ifnet_init_eparams {
u_int32_t ver; /* required */
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 output_target_qdelay; /* optional, only for new model */
+ u_int32_t output_target_qdelay; /* optional, only for new model, value in ms */
u_int64_t output_bw; /* optional */
u_int64_t output_bw_max; /* optional */
u_int64_t output_lt; /* optional */
u_int64_t output_lt_max; /* optional */
- u_int64_t _reserved[2]; /* for future use */
+ u_int16_t start_delay_qlen; /* optional */
+ u_int16_t start_delay_timeout; /* optional */
+ u_int32_t _reserved[3]; /* 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 broadcast_len; /* required for non point-to-point interfaces */
ifnet_framer_extended_func framer_extended; /* optional */
ifnet_subfamily_t subfamily; /* optional */
+ u_int16_t tx_headroom; /* optional */
+ u_int16_t tx_trailer; /* optional */
+ u_int32_t rx_mit_ival; /* optional */
#if !defined(__LP64__)
- u_int64_t _____reserved[3]; /* for future use */
+ u_int64_t ____reserved[2]; /* for future use */
#else
- u_int32_t ____reserved; /* pad */
- u_int64_t _____reserved[2]; /* for future use */
+ u_int32_t ____reserved; /* for future use */
+ u_int64_t _____reserved[1]; /* for future use */
#endif /* __LP64__ */
};
#endif /* KERNEL_PRIVATE */
if an interface with the same uniqueid and family has already
been allocated and is in use.
*/
+#ifdef KERNEL_PRIVATE
+extern errno_t ifnet_allocate_internal(const struct ifnet_init_params *init,
+ ifnet_t *interface);
+
+#define ifnet_allocate(init, interface) \
+ ifnet_allocate_internal((init), (interface))
+#else
extern errno_t ifnet_allocate(const struct ifnet_init_params *init,
ifnet_t *interface);
+#endif /* KERNEL_PRIVATE */
#ifdef KERNEL_PRIVATE
/*
@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
+ @result May return ENOMEM if there is insufficient memory or EBUSY
+ if an interface with the same uniqueid/(name + unit) and family has already
been allocated and is in use.
*/
extern errno_t ifnet_allocate_extended(const struct ifnet_init_eparams *init,
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_multi_bytes
+ @discussion Dequeue one or more packets from the output queue of
+ an interface which implements the new driver output model,
+ where the scheduling model is set to
+ IFNET_SCHED_MODEL_NORMAL. The limit is specified in terms
+ of maximum number of bytes to return. The number of bytes
+ returned can be slightly higher than the limit so that
+ packet boundaries can be preserved.
+ @param interface The interface to dequeue the packets from
+ @param max_bytes The maximum number of bytes in the packet chain
+ that may be returned to the caller; this needs to be a
+ non-zero value for any packet to be returned.
+ @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 bytes dequeued.
+ Caller may supply NULL if not interested in this 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 this 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_bytes(ifnet_t interface,
+ u_int32_t max_bytes, 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
*/
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);
-
/*
@function ifnet_flowid
@discussion Returns the interface flow ID value, which can be used
*/
extern int ifnet_link_quality(ifnet_t interface);
+/*
+ @function ifnet_set_interface_state
+ @discussion Sets the interface state for the ifnet.
+ @param interface Interface for which the interface state should
+ be set to.
+ @param if_interface_state as defined in net/if_var.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_interface_state(ifnet_t interface,
+ struct if_interface_state *if_interface_state);
+
+/*
+ @function ifnet_get_interface_state
+ @discussion Returns the interface state for the ifnet.
+ @param if_interface_state to ret.
+ @result 0 on success, errno otherwise
+*/
+extern int ifnet_get_interface_state(ifnet_t interface,
+ struct if_interface_state *if_interface_state);
+
/*
@struct ifnet_llreach_info
@discussion This structure is used to describe the link-layer
/*!
@enum Interface wake properties
@abstract Constants defining Interface wake properties.
- @discussion
@constant IFNET_WAKE_ON_MAGIC_PACKET Wake on Magic Packet.
*/
enum {
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.
+ @param stats The new stats values.
@result 0 on success otherwise the errno error.
*/
extern errno_t ifnet_set_stat(ifnet_t interface,
@param interface The interface.
@param addr A buffer to copy the broadcast address in to.
@param bufferlen The length of the buffer at addr.
- @param addr_len On return, the length of the broadcast address.
- @param lladdr_len The length, in bytes, of the link layer address.
+ @param out_len On return, the length of the broadcast address.
*/
extern errno_t ifnet_llbroadcast_copy_bytes(ifnet_t interface, void *addr,
- size_t bufferlen, size_t *addr_len);
+ size_t bufferlen, size_t *out_len);
#ifdef KERNEL_PRIVATE
/*!
changed on.
@param lladdr A pointer to the raw link layer address (pointer to
the 6 byte ethernet address for ethernet).
- @param lladdr_len The length, in bytes, of the link layer address.
+ @param length The length, in bytes, of the link layer address.
@param type The link-layer address type.
*/
extern errno_t ifnet_set_lladdr_and_type(ifnet_t interface, const void *lladdr,
@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 ifp 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.
ifnet_free_multicast_list will decrement the reference counts
and free the array.
@param interface The interface.
- @param multicasts A pointer to a NULL terminated array of references
+ @param addresses A pointer to a NULL terminated array of references
to the multicast addresses.
@result 0 on success otherwise the errno error.
*/
ifnet_get_multicast_list. Decrements the refcount on each
multicast address and frees the array.
@param multicasts An array of references to the multicast addresses.
- @result 0 on success otherwise the errno error.
*/
extern void ifnet_free_multicast_list(ifmultiaddr_t *multicasts);
@discussion Find an interface by the name including the unit number.
Caller must call ifnet_release on any non-null interface return
value.
- @param name The name of the interface, including any unit number
+ @param ifname The name of the interface, including any unit number
(i.e. "en0").
@param interface A pointer to an interface reference. This will be
filled in if a matching interface is found.
*/
extern errno_t ifnet_get_local_ports(ifnet_t ifp, u_int8_t *bitfield);
-#define IFNET_GET_LOCAL_PORTS_WILDCARDOK 0x1
-#define IFNET_GET_LOCAL_PORTS_NOWAKEUPOK 0x2
-#define IFNET_GET_LOCAL_PORTS_TCPONLY 0x4
-#define IFNET_GET_LOCAL_PORTS_UDPONLY 0x8
+#define IFNET_GET_LOCAL_PORTS_WILDCARDOK 0x01
+#define IFNET_GET_LOCAL_PORTS_NOWAKEUPOK 0x02
+#define IFNET_GET_LOCAL_PORTS_TCPONLY 0x04
+#define IFNET_GET_LOCAL_PORTS_UDPONLY 0x08
+#define IFNET_GET_LOCAL_PORTS_RECVANYIFONLY 0x10
+#define IFNET_GET_LOCAL_PORTS_EXTBGIDLEONLY 0x20
+#define IFNET_GET_LOCAL_PORTS_ACTIVEONLY 0x40
/*
@function ifnet_get_local_ports_extended
@discussion Returns a bitfield indicating which local ports of the
@param protocol The protocol family of the sockets. PF_UNSPEC (0)
means all protocols, otherwise PF_INET or PF_INET6.
@param flags A bitwise of the following flags:
- IFNET_GET_LOCAL_PORTS_EXTENDED_WILDCARDOK: When bit is set,
- the list of local ports should include those that are
+ IFNET_GET_LOCAL_PORTS_WILDCARDOK: When bit is set,
+ the list of local ports should include those that are
used by sockets that aren't bound to any local address.
- IFNET_GET_LOCAL_PORTS_EXTENDED_NOWAKEUPOK: When bit is
- set, the list of local ports should return all sockets
- including the ones that do not need a wakeup from sleep.
- Sockets that do not want to wake from sleep are marked
+ IFNET_GET_LOCAL_PORTS_NOWAKEUPOK: When bit is
+ set, the list of local ports should return all sockets
+ including the ones that do not need a wakeup from sleep.
+ Sockets that do not want to wake from sleep are marked
with a socket option.
- IFNET_GET_LOCAL_PORTS_TCPONLY: When bit is set, the list
+ IFNET_GET_LOCAL_PORTS_TCPONLY: When bit is set, the list
of local ports should return the ports used by TCP sockets.
- IFNET_GET_LOCAL_PORTS_UDPONLY: When bit is set, the list
+ IFNET_GET_LOCAL_PORTS_UDPONLY: When bit is set, the list
of local ports should return the ports used by UDP sockets.
only.
+ IFNET_GET_LOCAL_PORTS_RECVANYIFONLY: When bit is set, the
+ port is in the list only if the socket has the option
+ SO_RECV_ANYIF set
+ IFNET_GET_LOCAL_PORTS_EXTBGIDLEONLY: When bit is set, the
+ port is in the list only if the socket has the option
+ SO_EXTENDED_BK_IDLE set
+ IFNET_GET_LOCAL_PORTS_ACTIVEONLY: When bit is set, the
+ port is in the list only if the socket is not in a final TCP
+ state or the connection is not idle in a final TCP state
@param bitfield A pointer to 8192 bytes.
@result Returns 0 on success.
*/
*/
extern errno_t ifnet_tx_compl_status(ifnet_t ifp, mbuf_t m, tx_compl_val_t val);
+/*
+ @function ifnet_tx_compl
+ @discussion Used to indicates the packet has been transmitted.
+ @param ifp The interface to which the mbuf was sent
+ @param m The mbuf that was transmitted
+*/
+extern errno_t ifnet_tx_compl(ifnet_t ifp, mbuf_t m);
+
/******************************************************************************/
/* for interfaces that support dynamic node absence/presence events */
/******************************************************************************/
extern errno_t
ifnet_get_delegate(ifnet_t ifp, ifnet_t *pdelegated_ifp);
-/******************************************************************************/
-/* for interface IPSec keepalive offload */
-/******************************************************************************/
+/*************************************************************************/
+/* for interface keep alive offload support */
+/*************************************************************************/
-#define IPSEC_OFFLOAD_FRAME_DATA_SIZE 128
-struct ipsec_offload_frame {
- u_int8_t data[IPSEC_OFFLOAD_FRAME_DATA_SIZE]; /* Frame bytes */
- u_int16_t length; /* Number of valid bytes in data, including offset */
- u_int16_t interval; /* Interval in seconds */
+/*
+ @struct ifnet_keepalive_offload_frame
+ @discussion This structure is used to define various opportunistic
+ polling parameters for an interface.
+ For IPSec and AirPlay UDP keep alive only a subset of the
+ fields are relevant.
+ An incoming TCP keep alive probe has the sequence number
+ in the TCP header equal to "remote_seq" and the
+ acknowledgment number field is equal to "local_seq".
+ An incoming TCP keep alive probe has the sequence number
+ equlal to "remote_seq" minus 1 and the acknowledgment number
+ field is equal to "local_seq".
+ Note that remote_seq is in network byte order so the value to
+ match may have to be converted to host byte order when
+ subtracting 1.
+ For TCP, the field "interval" corresponds to the socket option
+ TCP_KEEPALIVE, the field "keep_cnt" to TCP_KEEPINTVL and
+ the field "keep_cnt" to TCP_KEEPCNT.
+ @field data Keep alive probe to be sent.
+ @field type The type of keep alive frame
+ @field length The length of the frame in the data field
+ @field interval Keep alive interval between probes in seconds
+ @field ether_type Tell if it's the protocol is IPv4 or IPv6
+ @field keep_cnt Maximum number of time to retry probes (TCP only)
+ @field keep_retry Interval before retrying if previous probe was not answered (TCP only)
+ @field reply_length The length of the frame in the reply_data field (TCP only)
+ @field addr_length Length in bytes of local_addr and remote_addr (TCP only)
+ @field reply_data Keep alive reply to be sent to incoming probe (TCP only)
+ @field local_addr Local address: 4 bytes IPv4 or 16 bytes IPv6 address (TCP only)
+ @field remote_addr Remote address: 4 bytes IPv4 or 16 bytes IPv6 address (TCP only)
+ @field local_port Local port (TCP only)
+ @field remote_port Remote port (TCP only)
+ @field local_seq Local sequence number for matching incoming replies (TCP only)
+ @field remote_seq Remote sequence number for matching incoming probes or replies (TCP only)
+*/
+
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_DATA_SIZE 128
+#define IFNET_KEEPALIVE_OFFLOAD_MAX_ADDR_SIZE 16
+
+struct ifnet_keepalive_offload_frame {
+ u_int8_t data[IFNET_KEEPALIVE_OFFLOAD_FRAME_DATA_SIZE]; /* data bytes */
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_IPSEC 0x0
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_AIRPLAY 0x1
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_TCP 0x2
+ u_int8_t type; /* type of application */
+ u_int8_t length; /* Number of valid data bytes including offset */
+ u_int16_t interval; /* Keep alive interval in seconds */
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_ETHERTYPE_IPV4 0x0
+#define IFNET_KEEPALIVE_OFFLOAD_FRAME_ETHERTYPE_IPV6 0x1
+ u_int8_t ether_type; /* Ether type IPv4 or IPv6 */
+ u_int8_t keep_cnt; /* max number of time to retry probes */
+ u_int16_t keep_retry; /* interval before retrying if previous probe was not answered */
+ u_int8_t reply_length; /* Length of valid reply_data bytes including offset */
+ u_int8_t addr_length; /* Length of valid bytes in local_addr and remote_addr */
+ u_int8_t reserved[2];
+ u_int8_t reply_data[IFNET_KEEPALIVE_OFFLOAD_FRAME_DATA_SIZE]; /* Response packet */
+ u_int8_t local_addr[IFNET_KEEPALIVE_OFFLOAD_MAX_ADDR_SIZE]; /* in network byte order */
+ u_int8_t remote_addr[IFNET_KEEPALIVE_OFFLOAD_MAX_ADDR_SIZE]; /* in network byte order */
+ u_int16_t local_port; /* in host byte order */
+ u_int16_t remote_port; /* in host byte order */
+ u_int32_t local_seq; /* in host byte order */
+ u_int32_t remote_seq; /* in host byte order */
};
/*
- @function ifnet_get_ipsec_offload_frames
- @discussion Fills out frames_array with IP packets to send at periodic
- intervals on behalf of IPSec.
- @param ifp The interface to send the frames out on. This is used to
- select which IPSec SAs should generate the packets.
- @param frames_array An array of ipsec_offload_frame structs. This is
- allocated by the caller, and has frames_array_count frames of valid
- memory.
- @param frames_array_count The number of valid frames allocated in
- frames_array.
- @param frame_data_offset The offset in bytes into each frame data at
- which IPSec should write the IP header and payload.
- @param used_frames_count The returned number of frames that were filled
- out with valid information.
+ @function ifnet_get_keepalive_offload_frames
+ @discussion Fills out frames_array with IP packets to send at
+ periodic intervals as Keep-alive or heartbeat messages.
+ This can be used to offload keep alives for UDP or TCP.
+ Note: The frames are returned in this order: first the IPSec
+ frames, then the AirPlay frames and finally the TCP frames.
+ If a device does not support one kind of keep alive frames_array
+ it should provide a frames_array large enough to accomodate
+ the other frames
+ @param ifp The interface to send frames out on. This is used to
+ select which sockets or IPSec SAs should generate the
+ packets.
+ @param frames_array An array of ifnet_keepalive_offload_frame
+ structs. This is allocated by the caller, and has
+ frames_array_count frames of valid memory.
+ @param frames_array_count The number of valid frames allocated
+ by the caller in frames_array
+ @param frame_data_offset The offset in bytes into each frame data
+ at which the IPv4/IPv6 packet and payload should be written
+ @param used_frames_count The returned number of frames that were
+ filled out with valid information.
+ @result Returns 0 on success, error number otherwise.
+*/
+extern errno_t ifnet_get_keepalive_offload_frames(ifnet_t ifp,
+ struct ifnet_keepalive_offload_frame *frames_array,
+ u_int32_t frames_array_count, size_t frame_data_offset,
+ u_int32_t *used_frames_count);
+
+/*************************************************************************/
+/* Link level notifications */
+/*************************************************************************/
+/*
+ @function ifnet_link_status_report
+ @discussion A KPI to let the driver provide link specific
+ status information to the protocol stack. The KPI will
+ copy contents from the buffer based on the version and
+ length provided by the driver. The contents of the buffer
+ will be read but will not be modified.
+ @param ifp The interface that is generating the report
+ @param buffer Buffer containing the link specific information
+ for this interface. It is the caller's responsibility
+ to free this buffer.
+ @param buffer_len Valid length of the buffer provided by the caller
+ @result Returns 0 on success, error number otherwise.
+*/
+extern errno_t ifnet_link_status_report(ifnet_t ifp, const void *buffer,
+ size_t buffer_len);
+
+/*************************************************************************/
+/* QoS Fastlane */
+/*************************************************************************/
+/*!
+ @function ifnet_set_fastlane_capable
+ @param interface The interface.
+ @param capable Set the truth value that the interface is attached to
+ a network that is capable of Fastlane QoS marking.
+ @result Returns 0 on success, error number otherwise.
+ */
+extern errno_t ifnet_set_fastlane_capable(ifnet_t interface, boolean_t capable);
+
+/*!
+ @function ifnet_get_fastlane_capable
+ @param interface The interface.
+ @param capable On output contains the truth value that the interface
+ is attached ta network that is capable of Fastlane QoS marking.
@result Returns 0 on success, error number otherwise.
*/
-extern errno_t ifnet_get_ipsec_offload_frames(ifnet_t ifp,
- struct ipsec_offload_frame *frames_array, u_int32_t frames_array_count,
- size_t frame_data_offset, u_int32_t *used_frames_count);
+extern errno_t ifnet_get_fastlane_capable(ifnet_t interface, boolean_t *capable);
+
+/*!
+ @function ifnet_get_unsent_bytes
+ @param interface The interface
+ @param unsent_bytes An out parameter that contains unsent bytes for
+ an interface
+ @result Returns 0 on success, error otherwise.
+ */
+extern errno_t ifnet_get_unsent_bytes(ifnet_t interface, int64_t *unsent_bytes);
+
+typedef struct {
+ int32_t buf_interface; /* data to send at interface */
+ int32_t buf_sndbuf; /* data to send at socket buffer */
+} ifnet_buffer_status_t;
+
+/*!
+ @function ifnet_get_buffer_status
+ @param interface The interface
+ @param buf_status An out parameter that contains unsent bytes
+ for an interface
+ @result Returns 0 on success, EINVAL if any of the arguments is
+ NULL, ENXIO if the interface pointer is invalid
+ */
+extern errno_t ifnet_get_buffer_status(const ifnet_t interface,
+ ifnet_buffer_status_t *buf_status);
+
+/*!
+ @function ifnet_normalise_unsent_data
+ @discussion
+ Gathers the unsent bytes on all the interfaces.
+ This data will be reported to NetworkStatistics.
+
+ */
+extern void ifnet_normalise_unsent_data(void);
+
+/*!
+ @function ifnet_touch_lastupdown
+ @discussion Updates the lastupdown value to now.
+ @param interface The interface.
+ @result 0 on success otherwise the errno error.
+ */
+extern errno_t ifnet_touch_lastupdown(ifnet_t interface);
+
+/*!
+ @function ifnet_updown_delta
+ @discussion Retrieves the difference between lastupdown and now.
+ @param interface The interface.
+ @param updown_delta A timeval struct to copy the delta between lastupdown and now.
+ to.
+ */
+extern errno_t ifnet_updown_delta(ifnet_t interface, struct timeval *updown_delta);
+
#endif /* KERNEL_PRIVATE */
__END_DECLS
#endif /* __KPI_INTERFACE__ */
-