+/******************************************************************************/
+/* for interface delegation */
+/******************************************************************************/
+
+/*
+ * @function ifnet_set_delegate
+ * @discussion Indicate that an interface is delegating another interface
+ * for accounting/restriction purposes. This could be used by a
+ * virtual interface that is going over another interface, where
+ * the virtual interface is to be treated as if it's the underlying
+ * interface for certain operations/checks.
+ * @param ifp The delegating interface.
+ * @param delegated_ifp The delegated interface. If NULL or equal to
+ * the delegating interface itself, any previously-established
+ * delegation is removed. If non-NULL, a reference to the
+ * delegated interface is held by the delegating interface;
+ * this reference is released via a subsequent call to remove
+ * the established association, or when the delegating interface
+ * is detached.
+ * @param Returns 0 on success, EINVAL if arguments are invalid, or
+ * ENXIO if the delegating interface isn't currently attached.
+ */
+extern errno_t
+ifnet_set_delegate(ifnet_t ifp, ifnet_t delegated_ifp);
+
+/*
+ * @function ifnet_get_delegate
+ * @discussion Retrieve delegated interface information on an interface.
+ * @param ifp The delegating interface.
+ * @param pdelegated_ifp Pointer to the delegated interface. Upon
+ * success, this will contain the delegated interface or
+ * NULL if there is no delegation in place. If non-NULL,
+ * the delegated interface will be returned with a reference
+ * held for caller, and the caller is responsible for releasing
+ * it via ifnet_release();
+ * @param Returns 0 on success, EINVAL if arguments are invalid, or
+ * ENXIO if the delegating interface isn't currently attached.
+ */
+extern errno_t
+ifnet_get_delegate(ifnet_t ifp, ifnet_t *pdelegated_ifp);
+
+/*************************************************************************/
+/* for interface keep alive offload support */
+/*************************************************************************/
+
+/*
+ * @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 flags Flags (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 */
+#define IFNET_KEEPALIVE_OFFLOAD_FLAG_NOWAKEFROMSLEEP 0x01
+ u_int8_t flags;
+ u_int8_t reserved[1];
+ 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_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);
+
+
+/*
+ * @function ifnet_notify_tcp_keepalive_offload_timeout
+ * @discussion Used by an interface to notify a TCP connection whose
+ * keep alive was offloaded did experience a timeout.
+ * @param ifp The interface for which the TCP keep alive offload timed out
+ * @param frame The ifnet_keepalive_offload_frame structure that identifies
+ * the TCP connection that experienced the timeout.
+ * All the fields must be zeroed by the caller except for:
+ * - type: must be IFNET_KEEPALIVE_OFFLOAD_FRAME_TCP
+ * and for the fields identifying the 5-tup;e of the
+ * TCP connection:
+ * - ether_type
+ * - local_addr
+ * - remote_addr
+ * - local_port
+ * - remote_port
+ * @result Returns 0 on success, error number otherwise.
+ */
+extern errno_t ifnet_notify_tcp_keepalive_offload_timeout(ifnet_t ifp,
+ struct ifnet_keepalive_offload_frame *frame);
+
+/*************************************************************************/
+/* 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_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);
+
+/*************************************************************************/
+/* Low Power Mode */
+/*************************************************************************/
+
+/*!
+ * @function ifnet_set_low_power_mode
+ * @param interface The interface.
+ * @param on Set the truth value that the interface is in low power mode.
+ * @result Returns 0 on success, error number otherwise.
+ */
+extern errno_t ifnet_set_low_power_mode(ifnet_t interface, boolean_t on);
+
+/*!
+ * @function ifnet_get_low_power_mode
+ * @param interface The interface.
+ * @param on On output contains the truth value that the interface
+ * is in low power mode.
+ * @result Returns 0 on success, error number otherwise.
+ */
+extern errno_t ifnet_get_low_power_mode(ifnet_t interface, boolean_t *on);
+
+/*!
+ * @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);
+
+/*************************************************************************/
+/* Interface advisory notifications */
+/*************************************************************************/
+/*!
+ * @function ifnet_interface_advisory_report
+ * @discussion KPI to let the driver provide interface advisory
+ * notifications to the user space.
+ * @param ifp The interface that is generating the advisory report.
+ * @param advisory structure containing the advisory notification
+ * information.
+ * @result Returns 0 on success, error number otherwise.
+ */
+extern errno_t ifnet_interface_advisory_report(ifnet_t ifp,
+ const struct ifnet_interface_advisory *advisory);
+