Module Name:    src
Committed By:   christos
Date:           Thu Jun 27 17:47:18 UTC 2013

Modified Files:
        src/sys/kern: uipc_mbuf.c
        src/sys/net80211: ieee80211_netbsd.c ieee80211_netbsd.h
        src/sys/sys: mbuf.h

Log Message:
- add m_add() that puts an mbuf to end of a chain
- m_append() and m_align() with their family
- remove parameters from prototypes


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.23 -r1.24 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.17 -r1.18 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.151 -r1.152 src/sys/sys/mbuf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.149 src/sys/kern/uipc_mbuf.c:1.150
--- src/sys/kern/uipc_mbuf.c:1.149	Wed May  8 07:08:45 2013
+++ src/sys/kern/uipc_mbuf.c	Thu Jun 27 13:47:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.149 2013/05/08 11:08:45 pooka Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.150 2013/06/27 17:47:18 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.149 2013/05/08 11:08:45 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.150 2013/06/27 17:47:18 christos Exp $");
 
 #include "opt_mbuftrace.h"
 #include "opt_nmbclusters.h"
@@ -458,6 +458,88 @@ mb_ctor(void *arg, void *object, int fla
 	return (0);
 }
 
+/*
+ * Add mbuf to the end of a chain
+ */
+struct mbuf *
+m_add(struct mbuf *c, struct mbuf *m) {
+	struct mbuf *n;
+
+	if (c == NULL)
+		return m;
+
+	for (n = c; n->m_next != NULL; n = n->m_next)
+		continue;
+	n->m_next = m;
+	return c;
+}
+
+/*
+ * Set the m_data pointer of a newly-allocated mbuf
+ * to place an object of the specified size at the
+ * end of the mbuf, longword aligned.
+ */
+void
+m_align(struct mbuf *m, int len)
+{
+       int adjust;
+
+       if (m->m_flags & M_EXT)
+	       adjust = m->m_ext.ext_size - len;
+       else if (m->m_flags & M_PKTHDR)
+	       adjust = MHLEN - len;
+       else
+	       adjust = MLEN - len;
+       m->m_data += adjust &~ (sizeof(long)-1);
+}
+
+/*
+ * Append the specified data to the indicated mbuf chain,
+ * Extend the mbuf chain if the new data does not fit in
+ * existing space.
+ *
+ * Return 1 if able to complete the job; otherwise 0.
+ */
+int
+m_append(struct mbuf *m0, int len, const void *cpv)
+{
+	struct mbuf *m, *n;
+	int remainder, space;
+	const char *cp = cpv;
+
+	for (m = m0; m->m_next != NULL; m = m->m_next)
+		continue;
+	remainder = len;
+	space = M_TRAILINGSPACE(m);
+	if (space > 0) {
+		/*
+		 * Copy into available space.
+		 */
+		if (space > remainder)
+			space = remainder;
+		memmove(mtod(m, char *) + m->m_len, cp, space);
+		m->m_len += space;
+		cp = cp + space, remainder -= space;
+	}
+	while (remainder > 0) {
+		/*
+		 * Allocate a new mbuf; could check space
+		 * and allocate a cluster instead.
+		 */
+		n = m_get(M_DONTWAIT, m->m_type);
+		if (n == NULL)
+			break;
+		n->m_len = min(MLEN, remainder);
+		memmove(mtod(n, void *), cp, n->m_len);
+		cp += n->m_len, remainder -= n->m_len;
+		m->m_next = n;
+		m = n;
+	}
+	if (m0->m_flags & M_PKTHDR)
+		m0->m_pkthdr.len += len - remainder;
+	return (remainder == 0);
+}
+
 void
 m_reclaim(void *arg, int flags)
 {

Index: src/sys/net80211/ieee80211_netbsd.c
diff -u src/sys/net80211/ieee80211_netbsd.c:1.23 src/sys/net80211/ieee80211_netbsd.c:1.24
--- src/sys/net80211/ieee80211_netbsd.c:1.23	Mon Feb  4 10:44:45 2013
+++ src/sys/net80211/ieee80211_netbsd.c	Thu Jun 27 13:47:18 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.23 2013/02/04 15:44:45 christos Exp $ */
+/* $NetBSD: ieee80211_netbsd.c,v 1.24 2013/06/27 17:47:18 christos Exp $ */
 /*-
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -30,7 +30,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
 #else
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.23 2013/02/04 15:44:45 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.24 2013/06/27 17:47:18 christos Exp $");
 #endif
 
 /*
@@ -535,71 +535,6 @@ if_printf(struct ifnet *ifp, const char 
 	return;
 }
 
-/*
- * Set the m_data pointer of a newly-allocated mbuf
- * to place an object of the specified size at the
- * end of the mbuf, longword aligned.
- */
-void
-m_align(struct mbuf *m, int len)
-{
-       int adjust;
-
-       if (m->m_flags & M_EXT)
-	       adjust = m->m_ext.ext_size - len;
-       else if (m->m_flags & M_PKTHDR)
-	       adjust = MHLEN - len;
-       else
-	       adjust = MLEN - len;
-       m->m_data += adjust &~ (sizeof(long)-1);
-}
-
-/*
- * Append the specified data to the indicated mbuf chain,
- * Extend the mbuf chain if the new data does not fit in
- * existing space.
- *
- * Return 1 if able to complete the job; otherwise 0.
- */
-int
-m_append(struct mbuf *m0, int len, const void *cpv)
-{
-	struct mbuf *m, *n;
-	int remainder, space;
-	const char *cp = cpv;
-
-	for (m = m0; m->m_next != NULL; m = m->m_next)
-		continue;
-	remainder = len;
-	space = M_TRAILINGSPACE(m);
-	if (space > 0) {
-		/*
-		 * Copy into available space.
-		 */
-		if (space > remainder)
-			space = remainder;
-		memmove(mtod(m, char *) + m->m_len, cp, space);
-		m->m_len += space;
-		cp = cp + space, remainder -= space;
-	}
-	while (remainder > 0) {
-		/*
-		 * Allocate a new mbuf; could check space
-		 * and allocate a cluster instead.
-		 */
-		n = m_get(M_DONTWAIT, m->m_type);
-		if (n == NULL)
-			break;
-		n->m_len = min(MLEN, remainder);
-		memmove(mtod(n, void *), cp, n->m_len);
-		cp += n->m_len, remainder -= n->m_len;
-		m->m_next = n;
-		m = n;
-	}
-	if (m0->m_flags & M_PKTHDR)
-		m0->m_pkthdr.len += len - remainder;
-	return (remainder == 0);
-}
 
 /*
  * Allocate and setup a management frame of the specified

Index: src/sys/net80211/ieee80211_netbsd.h
diff -u src/sys/net80211/ieee80211_netbsd.h:1.17 src/sys/net80211/ieee80211_netbsd.h:1.18
--- src/sys/net80211/ieee80211_netbsd.h:1.17	Sat Dec 31 15:41:58 2011
+++ src/sys/net80211/ieee80211_netbsd.h	Thu Jun 27 13:47:18 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.h,v 1.17 2011/12/31 20:41:58 christos Exp $ */
+/* $NetBSD: ieee80211_netbsd.h,v 1.18 2013/06/27 17:47:18 christos Exp $ */
 /*-
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -234,8 +234,6 @@ struct ieee80211_michael_event {
 #define	ovbcopy(__src, __dst, __n)	((void)memmove(__dst, __src, __n))
 
 void	if_printf(struct ifnet *, const char *, ...);
-void	m_align(struct mbuf *, int);
-int	m_append(struct mbuf *, int, const void *);
 void	get_random_bytes(void *, size_t);
 
 void	ieee80211_sysctl_attach(struct ieee80211com *);

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.151 src/sys/sys/mbuf.h:1.152
--- src/sys/sys/mbuf.h:1.151	Fri Jan 18 19:51:52 2013
+++ src/sys/sys/mbuf.h	Thu Jun 27 13:47:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.151 2013/01/19 00:51:52 rmind Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.152 2013/06/27 17:47:18 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -852,9 +852,12 @@ void	m_reclaim(void *, int);
 void	mbinit(void);
 void	m_ext_free(struct mbuf *);
 char *	m_mapin(struct mbuf *);
-void	m_move_pkthdr(struct mbuf *to, struct mbuf *from);
+void	m_move_pkthdr(struct mbuf *, struct mbuf *);
 
 bool	m_ensure_contig(struct mbuf **, int);
+struct mbuf *m_add(struct mbuf *, struct mbuf *);
+void	m_align(struct mbuf *, int);
+int	m_append(struct mbuf *, int, const void *);
 
 /* Inline routines. */
 static __inline u_int m_length(const struct mbuf *) __unused;

Reply via email to