+ * @function mbuf_get_traffic_class
+ * @discussion Get the traffic class of an mbuf packet
+ * @param mbuf The mbuf to get the traffic class of.
+ * @result The traffic class
+ */
+extern mbuf_traffic_class_t mbuf_get_traffic_class(mbuf_t mbuf)
+__NKE_API_DEPRECATED;
+
+/*!
+ * @function mbuf_set_traffic_class
+ * @discussion Set the traffic class of an mbuf packet.
+ * @param mbuf The mbuf to set the traffic class on.
+ * @param tc The traffic class
+ * @result 0 on success, EINVAL if bad parameter is passed
+ */
+extern errno_t mbuf_set_traffic_class(mbuf_t mbuf, mbuf_traffic_class_t tc)
+__NKE_API_DEPRECATED;
+
+/*!
+ * @function mbuf_is_traffic_class_privileged
+ * @discussion Returns the privileged status of the traffic class
+ * of the packet specified by the mbuf.
+ * @param mbuf The mbuf to retrieve the status from.
+ * @result Non-zero if privileged, 0 otherwise.
+ */
+extern int mbuf_is_traffic_class_privileged(mbuf_t mbuf)
+__NKE_API_DEPRECATED;
+
+#ifdef KERNEL_PRIVATE
+
+/*!
+ * @function mbuf_get_traffic_class_max_count
+ * @discussion Returns the maximum number of mbuf traffic class types
+ * @result The total count of mbuf traffic classes
+ */
+extern u_int32_t mbuf_get_traffic_class_max_count(void);
+
+/*!
+ * @function mbuf_get_traffic_class_index
+ * @discussion Returns the zero-based index of an mbuf traffic class value
+ * @param tc The traffic class
+ * @param index Pointer to the index value
+ * @result 0 on success, EINVAL if bad parameter is passed
+ */
+extern errno_t mbuf_get_traffic_class_index(mbuf_traffic_class_t tc,
+ u_int32_t *index);
+
+/*!
+ * @enum mbuf_svc_class_t
+ * @abstract Service class of a packet
+ * @discussion Property that represents the category of service
+ * of a packet. This information may be used by the driver
+ * and at the link level.
+ * @constant MBUF_SC_BK_SYS "Background System-Initiated", high delay
+ * tolerant, high loss tolerant, elastic flow, variable size &
+ * long-lived.
+ * @constant MBUF_SC_BK "Background", user-initiated, high delay tolerant,
+ * high loss tolerant, elastic flow, variable size. This level
+ * corresponds to WMM access class "BG", or MBUF_TC_BK.
+ * @constant MBUF_SC_BE "Best Effort", unclassified/standard. This is
+ * the default service class; pretty much a mix of everything.
+ * This level corresponds to WMM access class "BE" or MBUF_TC_BE.
+ * @constant MBUF_SC_RD
+ * "Responsive Data", a notch higher than "Best Effort", medium
+ * delay tolerant, medium loss tolerant, elastic flow, bursty,
+ * long-lived.
+ * @constant MBUF_SC_OAM "Operations, Administration, and Management",
+ * medium delay tolerant, low-medium loss tolerant, elastic &
+ * inelastic flows, variable size.
+ * @constant MBUF_SC_AV "Multimedia Audio/Video Streaming", medium delay
+ * tolerant, low-medium loss tolerant, elastic flow, constant
+ * packet interval, variable rate & size.
+ * @constant MBUF_SC_RV "Responsive Multimedia Audio/Video", low delay
+ * tolerant, low-medium loss tolerant, elastic flow, variable
+ * packet interval, rate and size.
+ * @constant MBUF_SC_VI "Interactive Video", low delay tolerant, low-
+ * medium loss tolerant, elastic flow, constant packet interval,
+ * variable rate & size. This level corresponds to WMM access
+ * class "VI" or MBUF_TC_VI.
+ * @constant MBUF_SC_SIG "Signaling", low delay tolerant, low loss
+ * tolerant, inelastic flow, jitter tolerant, rate is bursty but
+ * short, variable size. e.g. SIP. This level corresponds to WMM
+ * access class "VI" or MBUF_TC_VI.
+ * @constant MBUF_SC_VO "Interactive Voice", low delay tolerant, low loss
+ * tolerant, inelastic flow, constant packet rate, somewhat fixed
+ * size. This level corresponds to WMM access class "VO" or
+ * MBUF_TC_VO.
+ * @constant MBUF_SC_CTL "Network Control", low delay tolerant, low loss
+ * tolerant, inelastic flow, rate is short & burst, variable size.
+ */
+typedef enum {
+#ifdef XNU_KERNEL_PRIVATE
+ MBUF_SC_UNSPEC = -1, /* Internal: not specified */
+#endif
+ MBUF_SC_BK_SYS = 0x00080090, /* lowest class */
+ MBUF_SC_BK = 0x00100080,
+
+ MBUF_SC_BE = 0x00000000,
+ MBUF_SC_RD = 0x00180010,
+ MBUF_SC_OAM = 0x00200020,
+
+ MBUF_SC_AV = 0x00280120,
+ MBUF_SC_RV = 0x00300110,
+ MBUF_SC_VI = 0x00380100,
+ MBUF_SC_SIG = 0x00380130,
+
+ MBUF_SC_VO = 0x00400180,
+ MBUF_SC_CTL = 0x00480190, /* highest class */
+} mbuf_svc_class_t;
+
+/*!
+ * @function mbuf_get_service_class_max_count
+ * @discussion Returns the maximum number of mbuf service class types.
+ * @result The total count of mbuf service classes.
+ */
+extern u_int32_t mbuf_get_service_class_max_count(void);
+
+/*!
+ * @function mbuf_get_service_class_index
+ * @discussion Returns the zero-based index of an mbuf service class value
+ * @param sc The service class
+ * @param index Pointer to the index value
+ * @result 0 on success, EINVAL if bad parameter is passed
+ */
+extern errno_t mbuf_get_service_class_index(mbuf_svc_class_t sc,
+ u_int32_t *index);
+
+/*!
+ * @function mbuf_get_service_class
+ * @discussion Get the service class of an mbuf packet
+ * @param mbuf The mbuf to get the service class of.
+ * @result The service class
+ */
+extern mbuf_svc_class_t mbuf_get_service_class(mbuf_t mbuf);
+
+/*!
+ * @function mbuf_set_servicec_class
+ * @discussion Set the service class of an mbuf packet.
+ * @param mbuf The mbuf to set the service class on.
+ * @param sc The service class
+ * @result 0 on success, EINVAL if bad parameter is passed
+ */
+extern errno_t mbuf_set_service_class(mbuf_t mbuf, mbuf_svc_class_t sc);
+
+/*!
+ * @function mbuf_is_service_class_privileged
+ * @discussion Returns the privileged status of the service class
+ * of the packet specified by the mbuf.
+ * @param mbuf The mbuf to retrieve the status from.
+ * @result Non-zero if privileged, 0 otherwise.
+ */
+extern int mbuf_is_service_class_privileged(mbuf_t mbuf);
+
+/*!
+ * @enum mbuf_pkthdr_aux_flags_t
+ * @abstract Constants defining mbuf auxiliary flags. Only the flags
+ * listed below can be retrieved.
+ * @constant MBUF_PKTAUXF_INET_RESOLVE_RTR Indicates this is an ARP
+ * request packet, whose target is the address of the default
+ * IPv4 router.
+ * @constant MBUF_PKTAUXF_INET6_RESOLVE_RTR Indicates this is an ICMPv6
+ * Neighbor Solicitation packet, whose target is the address of
+ * the default IPv6 router.
+ */
+enum {
+ MBUF_PKTAUXF_INET_RESOLVE_RTR = 0x0004,
+ MBUF_PKTAUXF_INET6_RESOLVE_RTR = 0x0008,
+};
+typedef u_int32_t mbuf_pkthdr_aux_flags_t;
+
+/*!
+ * @function mbuf_pkthdr_aux_flags
+ * @discussion Returns the auxiliary flags of a packet.
+ * @param mbuf The mbuf containing the packet header.
+ * @param paux_flags Pointer to mbuf_pkthdr_aux_flags_t variable.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_pkthdr_aux_flags(mbuf_t mbuf,
+ mbuf_pkthdr_aux_flags_t *paux_flags);
+
+/*!
+ * @function mbuf_get_driver_scratch
+ * @discussion Returns a pointer to a driver specific area in the mbuf
+ * @param m The mbuf whose driver scratch space is to be returned
+ * @param area A pointer to a location to store the address of the
+ * driver scratch space. This value is guaranteed to be 32-bit
+ * aligned.
+ * @param area_ln A pointer to a location to store the total length of
+ * the memory location.
+ */
+extern errno_t mbuf_get_driver_scratch(mbuf_t m, u_int8_t **area,
+ size_t *area_ln);
+
+/*!
+ * @function mbuf_get_unsent_data_bytes
+ * @discussion Returns the amount of data that is waiting to be sent
+ * on this interface. This is a private SPI used by cellular
+ * interface as an indication of future activity on that
+ * interface.
+ * @param m The mbuf containing the packet header
+ * @param unsent_data A pointer to an integer where the value of
+ * unsent data will be set.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_get_unsent_data_bytes(const mbuf_t m,
+ u_int32_t *unsent_data);
+
+typedef struct {
+ int32_t buf_interface; /* data to send at interface */
+ int32_t buf_sndbuf; /* data to send at socket buffer */
+} mbuf_buffer_status_t;
+
+/*!
+ * @function mbuf_get_buffer_status
+ * @discussion Returns the amount of data that is waiting to be sent
+ * on this interface. This is a private SPI used by cellular
+ * interface as an indication of future activity on that
+ * interface.
+ * @param m The mbuf containing the packet header
+ * @param buf_status A pointer to the structure where the value of
+ * unsent data will be set.
+ * @result 0 upon success. If any of the arguments is NULL or if the
+ * mbuf packet header does not have valid data bytes,
+ * EINVAL will be returned
+ */
+extern errno_t mbuf_get_buffer_status(const mbuf_t m,
+ mbuf_buffer_status_t *buf_status);
+
+/*!
+ * @function mbuf_pkt_new_flow
+ * @discussion This function is used to check if the packet is from a
+ * new flow that can be treated with higher priority. This is
+ * a private SPI.
+ * @param m The mbuf containing the packet header
+ * @param retval A pointer to an integer used as an out argument. The
+ * value is set to 1 if the packet is from a new flow,
+ * otherwise it is set to 0.
+ * @result 0 upon success otherwise the errno error. If any of the
+ * arguments is NULL or if the mbuf does not have valid packet
+ * header, the error code will be EINVAL
+ */
+extern errno_t mbuf_pkt_new_flow(const mbuf_t m, u_int32_t *retval);
+
+/*!
+ * @function mbuf_last_pkt
+ * @discussion This function is used to check if the packet is the
+ * last one sent on a TCP socket. This is an advisory
+ * for the underlying layers.
+ * @param m The mbuf containing the packet header
+ * @param retval A pointer to an integer whose value will be set to
+ * 1 if the packet is the last packet, otherwise it will
+ * be set to 0.
+ * @result 0 upon success otherwise the errno error. If any of the
+ * arguments is NULL or if the mbuf does not have valid
+ * packet header, the error code will be EINVAL
+ */
+extern errno_t mbuf_last_pkt(const mbuf_t m, u_int32_t *retval);
+
+#endif /* KERNEL_PRIVATE */
+
+#ifdef XNU_KERNEL_PRIVATE
+/*!
+ * @function mbuf_pkt_list_len
+ * @discussion Retrieves the length of the list of mbuf packets.
+ * @param mbuf The mbuf.
+ * @result The length of the mbuf packet list.
+ */
+extern size_t mbuf_pkt_list_len(const mbuf_t mbuf);
+
+/*!
+ * @function mbuf_pkt_list_maxlen
+ * @discussion Retrieves the maximum length of data that may be stored
+ * in the list of mbuf packet. This value assumes that the data pointer
+ * was set to the start of the possible range for that pointer
+ * for each mbuf in the packet chain
+ * @param mbuf The mbuf.
+ * @result The maximum length of data for this mbuf.
+ */
+extern size_t mbuf_pkt_list_maxlen(const mbuf_t mbuf);
+#endif /* XNU_KERNEL_PRIVATE */
+
+#ifdef KERNEL_PRIVATE
+/*!
+ * @function mbuf_get_timestamp
+ * @discussion Retrieves the timestamp of the packet.
+ * @param mbuf The mbuf representing the packet.
+ * @param ts A pointer where the value of the timestamp will be copied
+ * to.
+ * @param valid A pointer to a boolean value that indicate if the
+ * timestamp is valid (i.e. the packet timestamp has been set).
+ * If "false" the value of "ts" is undetermined.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_get_timestamp(mbuf_t mbuf, u_int64_t *ts, boolean_t *valid);
+
+/*!
+ * @function mbuf_set_timestamp
+ * @discussion Set the timestamp of the packet.
+ * @param mbuf The mbuf representing the packet.
+ * @param ts The value of the timestamp to be stored in the mbuf packet
+ * header
+ * @param valid A boolean value that indicate if the timestamp is valid.
+ * Passing false clears any previous timestamp value.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_set_timestamp(mbuf_t mbuf, u_int64_t ts, boolean_t valid);
+
+/*!
+ * @typedef mbuf_tx_compl_func
+ * @discussion This callback is used to indicate when a driver has
+ * transmitted a packet.
+ * @param pktid The packet indentifier that was returned by
+ * mbuf_set_timestamp_requested()
+ * @param ifp The outgoing interface or NULL if the packet was dropped
+ * before reaching the driver
+ * @param ts The timestamp in nanoseconds when the packet was transmitted
+ * @param tx_compl_arg An argument set by the driver
+ * @param tx_compl_data Additional data set by the driver
+ * @param tx_compl_val The transmission status is expected to be an
+ * IOReturn value -- see <IOKit/IOReturn.h>
+ */
+
+typedef void (*mbuf_tx_compl_func)(uintptr_t pktid, ifnet_t ifp, u_int64_t ts,
+ uintptr_t tx_compl_arg, uintptr_t tx_compl_data, kern_return_t tx_compl_val);
+
+/*!
+ * @function mbuf_register_tx_compl_callback
+ * @discussion Register a transmit completion callback function. The
+ * callback function must be unregistered before the calling
+ * module unloads.
+ * @param callback The completion callback function to register
+ * @result 0 upon success otherwise the errno error. ENOSPC is returned
+ * if too many callbacks are registered. EINVAL is returned when
+ * the function pointer is invalid. EEXIST is returned when
+ * the function pointer is already registered.
+ */
+extern errno_t mbuf_register_tx_compl_callback(
+ mbuf_tx_compl_func callback);
+
+/*!
+ * @function mbuf_unregister_tx_compl_callback
+ * @discussion Unregister a transmit completion callback function. The
+ * callback function must be unregistered before the calling
+ * module unloads.
+ * @param callback The completion callback function to unregister
+ * @result 0 upon success otherwise the errno error. EINVAL is returned
+ * when the function pointer is invalid. ENOENT is returned when
+ * the function pointer is not registered.
+ */
+extern errno_t mbuf_unregister_tx_compl_callback(
+ mbuf_tx_compl_func callback);
+
+/*!
+ * @function mbuf_get_timestamp_requested
+ * @discussion Tell if the packet timestamp needs to be set. This is meant
+ * to be used by a driver on egress packets.
+ * @param mbuf The mbuf representing the packet.
+ * @param requested A pointer to a boolean value that indicate if the
+ * timestamp was requested to be set.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_get_timestamp_requested(mbuf_t mbuf, boolean_t *requested);
+
+/*!
+ * @function mbuf_set_timestamp_requested
+ * @discussion Indicate the callback is expected to be called with the
+ * transmission complete timestamp. This is meant to be used
+ * on egress packet by the driver.
+ * @param mbuf The mbuf representing the packet.
+ * @param callback A previously registered completion callback function.
+ * @param pktid An output parameter with an opaque value that can be used
+ * to identify the packet.
+ * @result 0 upon success otherwise the errno error. EINVAL is retuned
+ * if the mbuf is not a valid packet or if one of the parameter
+ * is NULL. ENOENT if the callback is not registred.
+ */
+extern errno_t mbuf_set_timestamp_requested(mbuf_t mbuf,
+ uintptr_t *pktid, mbuf_tx_compl_func callback);
+
+/*!
+ * @function mbuf_get_status
+ * @discussion Retrieves the packet completion status.
+ * @param mbuf The mbuf representing the packet.
+ * @param status A pointer where the value of the completion status will
+ * be copied to.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_get_status(mbuf_t mbuf, kern_return_t *status);
+
+/*!
+ * @function mbuf_set_status
+ * @discussion Store the packet completion status in the mbuf packet
+ * header.
+ * @param mbuf The mbuf representing the packet.
+ * @param status The value of the completion status.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_set_status(mbuf_t mbuf, kern_return_t status);
+
+/*!
+ * @function mbuf_get_tx_compl_data
+ * @discussion Retrieves the packet completion status.
+ * @param m The mbuf representing the packet.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_get_tx_compl_data(mbuf_t m, uintptr_t *arg,
+ uintptr_t *data);
+
+/*!
+ * @function mbuf_set_tx_compl_data
+ * @discussion Retrieves the packet completion status.
+ * @param m The mbuf representing the packet.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_set_tx_compl_data(mbuf_t m, uintptr_t arg,
+ uintptr_t data);
+
+/*!
+ * @function mbuf_get_flowid
+ * @discussion Retrieve the flow ID of the packet .
+ * @param mbuf The mbuf representing the packet.
+ * @param flowid The flow ID of the packet.
+ * @result 0 upon success otherwise the errno error. If the mbuf
+ * packet header does not have valid data bytes, the error
+ * code will be EINVAL
+ */
+extern errno_t mbuf_get_flowid(mbuf_t mbuf, u_int16_t *flowid);