summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/mbuf.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-03-29 08:21:28 +0000
committerbrian <brian@FreeBSD.org>1999-03-29 08:21:28 +0000
commit539d220871d789543afc7e3744e712d33128ca1b (patch)
tree22cddce0f60f9ee116dd5d869726e4f1b301b5ee /usr.sbin/ppp/mbuf.c
parent1d23653385b701e6ef13bbbe4fb216bab202b990 (diff)
downloadFreeBSD-src-539d220871d789543afc7e3744e712d33128ca1b.zip
FreeBSD-src-539d220871d789543afc7e3744e712d33128ca1b.tar.gz
Ensure that the thing we're casting to struct ip
is aligned for non-i386 architectures.
Diffstat (limited to 'usr.sbin/ppp/mbuf.c')
-rw-r--r--usr.sbin/ppp/mbuf.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c
index fa94406..0e29c81 100644
--- a/usr.sbin/ppp/mbuf.c
+++ b/usr.sbin/ppp/mbuf.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: mbuf.c,v 1.22 1998/08/25 17:48:42 brian Exp $
+ * $Id: mbuf.c,v 1.23 1999/02/06 02:54:47 brian Exp $
*
*/
#include <sys/types.h>
@@ -72,8 +72,7 @@ mbuf_Alloc(int cnt, int type)
totalalloced += cnt;
bp->size = bp->cnt = cnt;
bp->type = type;
- bp->pnext = NULL;
- return (bp);
+ return bp;
}
struct mbuf *
@@ -87,9 +86,10 @@ mbuf_FreeSeg(struct mbuf * bp)
MemMap[bp->type].octets -= bp->size;
totalalloced -= bp->size;
free(bp);
- return (nbp);
+ bp = nbp;
}
- return (bp);
+
+ return bp;
}
void
@@ -192,7 +192,6 @@ mbuf_Dequeue(struct mqueue *q)
return bp;
}
-
void
mbuf_Enqueue(struct mqueue *queue, struct mbuf *bp)
{
@@ -204,3 +203,30 @@ mbuf_Enqueue(struct mqueue *queue, struct mbuf *bp)
queue->qlen++;
log_Printf(LogDEBUG, "mbuf_Enqueue: len = %d\n", queue->qlen);
}
+
+struct mbuf *
+mbuf_Contiguous(struct mbuf *bp)
+{
+ /* Put it all in one contigous (aligned) mbuf */
+
+ if (bp->next != NULL) {
+ struct mbuf *nbp;
+ u_char *cp;
+
+ nbp = mbuf_Alloc(mbuf_Length(bp), bp->type);
+
+ for (cp = MBUF_CTOP(nbp); bp; bp = mbuf_FreeSeg(bp)) {
+ memcpy(cp, MBUF_CTOP(bp), bp->cnt);
+ cp += bp->cnt;
+ }
+ bp = nbp;
+ }
+#ifndef __i386__ /* Do any other archs not care about alignment ? */
+ else if ((bp->offset & 0x03) != 0) {
+ bcopy(MBUF_CTOP(bp), bp + 1, bp->cnt);
+ bp->offset = 0;
+ }
+#endif
+
+ return bp;
+}
OpenPOWER on IntegriCloud