+/*
+ * Exported (private)
+ */
+
+extern struct mbstat mbstat; /* statistics */
+
+__END_DECLS
+#endif /* KERNEL_PRIVATE */
+
+#ifdef XNU_KERNEL_PRIVATE
+__BEGIN_DECLS
+
+/*
+ * Not exported (xnu private)
+ */
+
+/* flags to m_get/MGET */
+/* Need to include malloc.h to get right options for malloc */
+#include <sys/malloc.h>
+
+struct mbuf;
+
+/* length to m_copy to copy all */
+#define M_COPYALL 1000000000
+
+#define M_DONTWAIT M_NOWAIT
+#define M_WAIT M_WAITOK
+
+/*
+ * These macros are mapped to the appropriate KPIs, so that private code
+ * can be simply recompiled in order to be forward-compatible with future
+ * changes toward the struture sizes.
+ */
+#define MLEN mbuf_get_mlen() /* normal data len */
+#define MHLEN mbuf_get_mhlen() /* data len w/pkthdr */
+
+#define MINCLSIZE mbuf_get_minclsize() /* cluster usage threshold */
+
+extern void m_freem(struct mbuf *);
+extern char *mcl_to_paddr(char *);
+extern void m_adj(struct mbuf *, int);
+extern void m_cat(struct mbuf *, struct mbuf *);
+extern void m_copydata(struct mbuf *, int, int, void *);
+extern struct mbuf *m_copym(struct mbuf *, int, int, int);
+extern struct mbuf *m_get(int, int);
+extern struct mbuf *m_gethdr(int, int);
+extern struct mbuf *m_getpacket(void);
+extern struct mbuf *m_getpackets(int, int, int);
+extern struct mbuf *m_mclget(struct mbuf *, int);
+extern void *m_mtod(struct mbuf *);
+extern struct mbuf *m_prepend_2(struct mbuf *, int, int);
+extern struct mbuf *m_pullup(struct mbuf *, int);
+extern struct mbuf *m_split(struct mbuf *, int, int);
+extern void m_mclfree(caddr_t p);
+
+__private_extern__ union mbigcluster *mbutl; /* start VA of mbuf pool */
+__private_extern__ union mbigcluster *embutl; /* end VA of mbuf pool */
+__private_extern__ unsigned int nmbclusters; /* number of mapped clusters */
+__private_extern__ int njcl; /* # of jumbo clusters */
+__private_extern__ int njclbytes; /* size of a jumbo cluster */
+__private_extern__ int max_linkhdr; /* largest link-level header */
+__private_extern__ int max_protohdr; /* largest protocol header */
+__private_extern__ int max_hdr; /* largest link+protocol header */
+__private_extern__ int max_datalen; /* MHLEN - max_hdr */
+
+__private_extern__ unsigned int mbuf_default_ncl(int, u_int64_t);
+__private_extern__ void mbinit(void);
+__private_extern__ struct mbuf *m_clattach(struct mbuf *, int, caddr_t,
+ void (*)(caddr_t, u_int, caddr_t), u_int, caddr_t, int);
+__private_extern__ caddr_t m_bigalloc(int);
+__private_extern__ void m_bigfree(caddr_t, u_int, caddr_t);
+__private_extern__ struct mbuf *m_mbigget(struct mbuf *, int);
+__private_extern__ caddr_t m_16kalloc(int);
+__private_extern__ void m_16kfree(caddr_t, u_int, caddr_t);
+__private_extern__ struct mbuf *m_m16kget(struct mbuf *, int);
+
+__private_extern__ struct mbuf *m_free(struct mbuf *);
+__private_extern__ struct mbuf *m_getclr(int, int);
+__private_extern__ struct mbuf *m_getptr(struct mbuf *, int, int *);
+__private_extern__ unsigned int m_length(struct mbuf *);
+__private_extern__ struct mbuf *m_prepend(struct mbuf *, int, int);
+__private_extern__ struct mbuf *m_copyup(struct mbuf *, int, int);
+__private_extern__ struct mbuf *m_retry(int, int);
+__private_extern__ struct mbuf *m_retryhdr(int, int);
+__private_extern__ int m_freem_list(struct mbuf *);
+__private_extern__ int m_append(struct mbuf *, int, caddr_t);
+__private_extern__ struct mbuf *m_last(struct mbuf *);
+__private_extern__ struct mbuf *m_devget(char *, int, int, struct ifnet *,
+ void (*)(const void *, void *, size_t));
+__private_extern__ struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
+
+__private_extern__ struct mbuf *m_getcl(int, int, int);
+__private_extern__ caddr_t m_mclalloc(int);
+__private_extern__ int m_mclhasreference(struct mbuf *);
+__private_extern__ void m_copy_pkthdr(struct mbuf *, struct mbuf *);
+
+__private_extern__ struct mbuf *m_dtom(void *);
+__private_extern__ int m_mtocl(void *);
+__private_extern__ union mcluster *m_cltom(int);
+
+__private_extern__ int m_trailingspace(struct mbuf *);
+__private_extern__ int m_leadingspace(struct mbuf *);
+
+__private_extern__ struct mbuf *m_normalize(struct mbuf *m);
+__private_extern__ void m_mchtype(struct mbuf *m, int t);
+__private_extern__ void m_mcheck(struct mbuf *);
+
+__private_extern__ void m_copyback(struct mbuf *, int, int, const void *);
+__private_extern__ struct mbuf *m_copyback_cow(struct mbuf *, int, int,
+ const void *, int);
+__private_extern__ int m_makewritable(struct mbuf **, int, int, int);
+__private_extern__ struct mbuf *m_dup(struct mbuf *m, int how);
+__private_extern__ struct mbuf *m_copym_with_hdrs(struct mbuf *, int, int, int,
+ struct mbuf **, int *);
+__private_extern__ struct mbuf *m_getpackethdrs(int, int);
+__private_extern__ struct mbuf *m_getpacket_how(int);
+__private_extern__ struct mbuf *m_getpackets_internal(unsigned int *, int,
+ int, int, size_t);
+__private_extern__ struct mbuf *m_allocpacket_internal(unsigned int *, size_t,
+ unsigned int *, int, int, size_t);
+
+/*
+ * Packets may have annotations attached by affixing a list of "packet
+ * tags" to the pkthdr structure. Packet tags are dynamically allocated
+ * semi-opaque data structures that have a fixed header (struct m_tag)
+ * that specifies the size of the memory block and an <id,type> pair that
+ * identifies it. The id identifies the module and the type identifies the
+ * type of data for that module. The id of zero is reserved for the kernel.
+ *
+ * Note that the packet tag returned by m_tag_allocate has the default
+ * memory alignment implemented by malloc. To reference private data one
+ * can use a construct like:
+ *
+ * struct m_tag *mtag = m_tag_allocate(...);
+ * struct foo *p = (struct foo *)(mtag+1);
+ *
+ * if the alignment of struct m_tag is sufficient for referencing members
+ * of struct foo. Otherwise it is necessary to embed struct m_tag within
+ * the private data structure to insure proper alignment; e.g.
+ *
+ * struct foo {
+ * struct m_tag tag;
+ * ...
+ * };
+ * struct foo *p = (struct foo *) m_tag_allocate(...);
+ * struct m_tag *mtag = &p->tag;
+ */
+
+#define KERNEL_MODULE_TAG_ID 0
+
+enum {
+ KERNEL_TAG_TYPE_NONE = 0,
+ KERNEL_TAG_TYPE_DUMMYNET = 1,
+ KERNEL_TAG_TYPE_DIVERT = 2,
+ KERNEL_TAG_TYPE_IPFORWARD = 3,
+ KERNEL_TAG_TYPE_IPFILT = 4,
+ KERNEL_TAG_TYPE_MACLABEL = 5,
+ KERNEL_TAG_TYPE_MAC_POLICY_LABEL = 6,
+ KERNEL_TAG_TYPE_ENCAP = 8,
+ KERNEL_TAG_TYPE_INET6 = 9,
+ KERNEL_TAG_TYPE_IPSEC = 10,
+ KERNEL_TAG_TYPE_PF = 11
+};
+
+/* Packet tag routines */
+__private_extern__ struct m_tag *m_tag_alloc(u_int32_t, u_int16_t, int, int);
+__private_extern__ struct m_tag *m_tag_create(u_int32_t, u_int16_t, int, int,
+ struct mbuf *);
+__private_extern__ void m_tag_free(struct m_tag *);
+__private_extern__ void m_tag_prepend(struct mbuf *, struct m_tag *);
+__private_extern__ void m_tag_unlink(struct mbuf *, struct m_tag *);
+__private_extern__ void m_tag_delete(struct mbuf *, struct m_tag *);
+__private_extern__ void m_tag_delete_chain(struct mbuf *, struct m_tag *);
+__private_extern__ struct m_tag *m_tag_locate(struct mbuf *, u_int32_t,
+ u_int16_t, struct m_tag *);
+__private_extern__ struct m_tag *m_tag_copy(struct m_tag *, int);
+__private_extern__ int m_tag_copy_chain(struct mbuf *, struct mbuf *, int);
+__private_extern__ void m_tag_init(struct mbuf *);
+__private_extern__ struct m_tag *m_tag_first(struct mbuf *);
+__private_extern__ struct m_tag *m_tag_next(struct mbuf *, struct m_tag *);
+
+__private_extern__ void m_prio_init(struct mbuf *);
+
+__END_DECLS
+#endif /* XNU_KERNEL_PRIVATE */
+#ifdef KERNEL
+#include <sys/kpi_mbuf.h>
+#endif /* KERNEL */