aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2002-07-30 18:28:58 +0000
committerRobert Watson <rwatson@FreeBSD.org>2002-07-30 18:28:58 +0000
commite37b1fcdeef8f6dc069f08cc3ca7b50cb199cb79 (patch)
tree91ad33cffc9e42a558c99f2a5af6abe2628bfb89 /sys
parentca095220db8fbf69d201d739aa0090f1ab958a56 (diff)
downloadsrc-e37b1fcdeef8f6dc069f08cc3ca7b50cb199cb79.tar.gz
src-e37b1fcdeef8f6dc069f08cc3ca7b50cb199cb79.zip
Make M_COPY_PKTHDR() macro into a wrapper for a m_copy_pkthdr()
function. This permits conditionally compiled extensions to the packet header copying semantic, such as extensions to copy MAC labels. Reviewed by: bmilekic Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
Notes
Notes: svn path=/head/; revision=100960
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf.c19
-rw-r--r--sys/sys/mbuf.h17
2 files changed, 21 insertions, 15 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 2c74a4c04fda..e8a679ed8d86 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -63,6 +63,25 @@ SYSCTL_INT(_kern_ipc, KIPC_MAX_DATALEN, max_datalen, CTLFLAG_RW,
&max_datalen, 0, "");
/*
+ * Copy mbuf pkthdr from "from" to "to".
+ * "from" must have M_PKTHDR set, and "to" must be empty.
+ * aux pointer will be moved to "to".
+ */
+void
+m_copy_pkthdr(struct mbuf *to, struct mbuf *from)
+{
+
+#if 0
+ KASSERT(to->m_flags & M_PKTHDR,
+ ("m_copy_pkthdr() called on non-header"));
+#endif
+ to->m_data = to->m_pktdat;
+ to->m_flags = from->m_flags & M_COPYFLAGS;
+ to->m_pkthdr = from->m_pkthdr;
+ from->m_pkthdr.aux = NULL;
+}
+
+/*
* Lesser-used path for M_PREPEND:
* allocate new mbuf to prepend to chain,
* copy junk along.
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 0f3669476b9c..437a19220c40 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -280,6 +280,7 @@ struct mbstat {
* mbuf, cluster, and external object allocation macros
* (for compatibility purposes).
*/
+#define M_COPY_PKTHDR(to, from) m_copy_pkthdr(to, from)
#define m_getclr m_get_clrd
#define MGET(m, how, type) (m) = m_get((how), (type))
#define MGETHDR(m, how, type) (m) = m_gethdr((how), (type))
@@ -312,21 +313,6 @@ struct mbstat {
#define M_WRITABLE(m) (!((m)->m_flags & M_RDONLY) && (!((m)->m_flags \
& M_EXT) || !MEXT_IS_REF(m)))
-/*-
- * Copy mbuf pkthdr from "from" to "to".
- * "from" must have M_PKTHDR set, and "to" must be empty.
- * aux pointer will be moved to "to".
- */
-#define M_COPY_PKTHDR(to, from) do { \
- struct mbuf *_mfrom = (from); \
- struct mbuf *_mto = (to); \
- \
- _mto->m_data = _mto->m_pktdat; \
- _mto->m_flags = _mfrom->m_flags & M_COPYFLAGS; \
- _mto->m_pkthdr = _mfrom->m_pkthdr; \
- _mfrom->m_pkthdr.aux = NULL; \
-} while (0)
-
/*
* Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
* an object of the specified size at the end of the mbuf, longword aligned.
@@ -487,6 +473,7 @@ void m_copyback(struct mbuf *, int, int, caddr_t);
void m_copydata(const struct mbuf *, int, int, caddr_t);
struct mbuf *m_copym(struct mbuf *, int, int, int);
struct mbuf *m_copypacket(struct mbuf *, int);
+void m_copy_pkthdr(struct mbuf *to, struct mbuf *from);
struct mbuf *m_devget(char *, int, int, struct ifnet *,
void (*copy)(char *, caddr_t, u_int));
struct mbuf *m_dup(struct mbuf *, int);