+ * @function mbuf_get_csum_performed
+ * @discussion This is used by the stack to determine which checksums
+ * were calculated in hardware on the inbound path.
+ * @param mbuf The mbuf containing the packet.
+ * @param flags Flags indicating which hardware checksum operations
+ * were performed.
+ * @param value If the MBUF_CSUM_DID_DATA flag is set, value will be
+ * set to the value of the TCP or UDP header as calculated by the
+ * hardware.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_get_csum_performed(mbuf_t mbuf,
+ mbuf_csum_performed_flags_t *flags, u_int32_t *value);
+#endif /* KERNEL_PRIVATE */
+
+/*!
+ * @function mbuf_get_mlen
+ * @discussion This routine returns the number of data bytes in a normal
+ * mbuf, i.e. an mbuf that is not a packet header, nor one with
+ * an external cluster attached to it. This is equivalent to the
+ * legacy MLEN macro.
+ * @result The number of bytes of available data.
+ */
+extern u_int32_t mbuf_get_mlen(void);
+
+/*!
+ * @function mbuf_get_mhlen
+ * @discussion This routine returns the number of data bytes in a packet
+ * header mbuf. This is equivalent to the legacy MHLEN macro.
+ * @result The number of bytes of available data.
+ */
+extern u_int32_t mbuf_get_mhlen(void);
+
+/*!
+ * @function mbuf_get_minclsize
+ * @discussion This routine returns the minimum number of data bytes
+ * before an external cluster is used. This is equivalent to the
+ * legacy MINCLSIZE macro.
+ * @result The minimum number of bytes before a cluster will be used.
+ */
+extern u_int32_t mbuf_get_minclsize(void);
+
+/*!
+ * @function mbuf_clear_csum_performed
+ * @discussion Clears the hardware checksum flags and values.
+ * @param mbuf The mbuf containing the packet.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_clear_csum_performed(mbuf_t mbuf);
+
+/*!
+ * @function mbuf_inet_cksum
+ * @discussion Calculates 16-bit 1's complement Internet checksum of the
+ * transport segment with or without the pseudo header checksum
+ * of a given IPv4 packet. If the caller specifies a non-zero
+ * transport protocol, the checksum returned will also include
+ * the pseudo header checksum for the corresponding transport
+ * header. Otherwise, no header parsing will be done and the
+ * caller may use this to calculate the Internet checksum of
+ * an arbitrary span of data.
+ *
+ * This routine does not modify the contents of the packet. If
+ * the caller specifies a non-zero protocol and/or offset, the
+ * routine expects the complete protocol header to be present
+ * at the beginning of the first mbuf.
+ * @param mbuf The mbuf (or chain of mbufs) containing the packet.
+ * @param protocol A zero or non-zero value. A non-zero value specifies
+ * the transport protocol used for pseudo header checksum.
+ * @param offset A zero or non-zero value; if the latter, it specifies
+ * the offset of the transport header from the beginning of mbuf.
+ * @param length The total (non-zero) length of the transport segment.
+ * @param csum Pointer to the checksum variable; upon success, this
+ * routine will return the calculated Internet checksum through
+ * this variable. The caller must set it to a non-NULL value.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_inet_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
+ u_int32_t length, u_int16_t *csum);
+
+/*!
+ * @function mbuf_inet6_cksum
+ * @discussion Calculates 16-bit 1's complement Internet checksum of the
+ * transport segment with or without the pseudo header checksum
+ * of a given IPv6 packet. If the caller specifies a non-zero
+ * transport protocol, the checksum returned will also include
+ * the pseudo header checksum for the corresponding transport
+ * header. Otherwise, no header parsing will be done and the
+ * caller may use this to calculate the Internet checksum of
+ * an arbitrary span of data.
+ *
+ * This routine does not modify the contents of the packet. If
+ * the caller specifies a non-zero protocol and/or offset, the
+ * routine expects the complete protocol header(s) to be present
+ * at the beginning of the first mbuf.
+ * @param mbuf The mbuf (or chain of mbufs) containing the packet.
+ * @param protocol A zero or non-zero value. A non-zero value specifies
+ * the transport protocol used for pseudo header checksum.
+ * @param offset A zero or non-zero value; if the latter, it specifies
+ * the offset of the transport header from the beginning of mbuf.
+ * @param length The total (non-zero) length of the transport segment.
+ * @param csum Pointer to the checksum variable; upon success, this
+ * routine will return the calculated Internet checksum through
+ * this variable. The caller must set it to a non-NULL value.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
+ u_int32_t length, u_int16_t *csum);
+
+/* mbuf tags */
+
+/*!
+ * @function mbuf_tag_id_find
+ * @discussion Lookup the module id for a string. If there is no module
+ * id assigned to this string, a new module id will be assigned.
+ * The string should be the bundle id of the kext. In the case of a
+ * tag that will be shared across multiple kexts, a common bundle
+ * id style string should be used.
+ *
+ * The lookup operation is not optimized. A module should call this
+ * function once during startup and chache the module id. The
+ * module id will not be resassigned until the machine reboots.
+ * @param module_string A unique string identifying your module.
+ * Example: com.apple.nke.SharedIP.
+ * @param module_id Upon return, a unique identifier for use with
+ * mbuf_tag_* functions. This identifier is valid until the machine
+ * is rebooted.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_tag_id_find(const char *module_string,
+ mbuf_tag_id_t *module_id);
+
+/*!
+ * @function mbuf_tag_allocate
+ * @discussion Allocate an mbuf tag. Mbuf tags allow various portions
+ * of the stack to tag mbufs with data that will travel with the
+ * mbuf through the stack.
+ *
+ * Tags may only be added to mbufs with packet headers
+ * (MBUF_PKTHDR flag is set). Mbuf tags are freed when the mbuf is
+ * freed or when mbuf_tag_free is called.
+ * @param mbuf The mbuf to attach this tag to.
+ * @param module_id A module identifier returned by mbuf_tag_id_find.
+ * @param type A 16 bit type value. For a given module_id, you can use
+ * a number of different tag types.
+ * @param length The length, in bytes, to allocate for storage that
+ * will be associated with this tag on this mbuf.
+ * @param how Indicate whether you want to block and wait for memory if
+ * memory is not immediately available.
+ * @param data_p Upon successful return, *data_p will point to the
+ * buffer allocated for the mtag.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_tag_allocate(mbuf_t mbuf, mbuf_tag_id_t module_id,
+ mbuf_tag_type_t type, size_t length, mbuf_how_t how, void **data_p);
+
+/*!
+ * @function mbuf_tag_find
+ * @discussion Find the data associated with an mbuf tag.
+ * @param mbuf The mbuf the tag is attached to.
+ * @param module_id A module identifier returned by mbuf_tag_id_find.
+ * @param type The 16 bit type of the tag to find.
+ * @param length Upon success, the length of data will be store in
+ * length.
+ * @param data_p Upon successful return, *data_p will point to the
+ * buffer allocated for the mtag.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_tag_find(mbuf_t mbuf, mbuf_tag_id_t module_id,
+ mbuf_tag_type_t type, size_t *length, void **data_p);
+
+/*!
+ * @function mbuf_tag_free
+ * @discussion Frees a previously allocated mbuf tag.
+ * @param mbuf The mbuf the tag was allocated on.
+ * @param module_id The ID of the tag to free.
+ * @param type The type of the tag to free.
+ */
+extern void mbuf_tag_free(mbuf_t mbuf, mbuf_tag_id_t module_id,
+ mbuf_tag_type_t type);
+
+#ifdef KERNEL_PRIVATE
+/*!
+ * @function mbuf_add_drvaux
+ * @discussion Allocate space for driver auxiliary data and attach it
+ * to the packet (MBUF_PKTHDR is required.) This space is freed
+ * when the mbuf is freed or when mbuf_del_drvaux is called.
+ * Only one instance of driver auxiliary data may be attached to
+ * a packet. Any attempt to add it to a packet already associated
+ * with one will yield an error, and the existing one must first
+ * be removed via mbuf_del_drvaux. The format and length of the
+ * data depend largely on the family and sub-family. The system
+ * makes no attempt to define and/or interpret the contents of
+ * the data, and simply acts as a conduit between its producer
+ * and consumer.
+ * @param mbuf The mbuf to attach the auxiliary data to.
+ * @param how Indicate whether you are willing to block and wait for
+ * memory, if memory is not immediately available.
+ * @param family The interface family as defined in net/kpi_interface.h.
+ * @param subfamily The interface sub-family as defined in
+ * net/kpi_interface.h.
+ * @param length The length of the auxiliary data, must be greater than 0.
+ * @param data_p Upon successful return, *data_p will point to the
+ * space allocated for the data. Caller may set this to NULL.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_add_drvaux(mbuf_t mbuf, mbuf_how_t how,
+ u_int32_t family, u_int32_t subfamily, size_t length, void **data_p);
+
+/*!
+ * @function mbuf_find_drvaux
+ * @discussion Find the driver auxiliary data associated with a packet.
+ * @param mbuf The mbuf the auxiliary data is attached to.
+ * @param family_p Upon successful return, *family_p will contain
+ * the interface family associated with the data, as defined
+ * in net/kpi_interface.h. Caller may set this to NULL.
+ * @param subfamily_p Upon successful return, *subfamily_p will contain
+ * the interface family associated with the data, as defined
+ * in net/kpi_interface.h. Caller may set this to NULL.
+ * @param length_p Upon successful return, *length_p will contain
+ * the length of the driver auxiliary data. Caller may
+ * set this to NULL.
+ * @param data_p Upon successful return, *data_p will point to the
+ * space allocated for the data.
+ * @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_find_drvaux(mbuf_t mbuf, u_int32_t *family_p,
+ u_int32_t *subfamily_p, u_int32_t *length_p, void **data_p);
+
+/*!
+ * @function mbuf_del_drvaux
+ * @discussion Remove and free any driver auxility data associated
+ * with the packet.
+ * @param mbuf The mbuf the auxiliary data is attached to.
+ */
+extern void mbuf_del_drvaux(mbuf_t mbuf);
+#endif /* KERNEL_PRIVATE */
+
+/* mbuf stats */
+
+/*!
+ * @function mbuf_stats
+ * @discussion Get the mbuf statistics.
+ * @param stats Storage to copy the stats in to.
+ */
+extern void mbuf_stats(struct mbuf_stat *stats);
+
+
+/*!
+ * @enum mbuf_traffic_class_t
+ * @abstract Traffic class of a packet
+ * @discussion Property that represent the category of traffic of a packet.
+ * This information may be used by the driver and at the link level.
+ * @constant MBUF_TC_BE Best effort, normal class.
+ * @constant MBUF_TC_BK Background, low priority or bulk traffic.
+ * @constant MBUF_TC_VI Interactive video, constant bit rate, low latency.
+ * @constant MBUF_TC_VO Interactive voice, constant bit rate, lowest latency.
+ */
+typedef enum {
+#ifdef XNU_KERNEL_PRIVATE
+ MBUF_TC_UNSPEC = -1, /* Internal: not specified */
+#endif
+ MBUF_TC_BE = 0,
+ MBUF_TC_BK = 1,
+ MBUF_TC_VI = 2,
+ MBUF_TC_VO = 3
+#ifdef XNU_KERNEL_PRIVATE
+ ,
+ MBUF_TC_MAX = 4 /* Internal: traffic class count */