Moved m_copyback into uipc_mbuf.c
This commit is contained in:
parent
71d20391bf
commit
c5789ba376
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3352
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
|
||||
* $Id: uipc_mbuf.c,v 1.3 1994/08/02 07:43:02 davidg Exp $
|
||||
* $Id: uipc_mbuf.c,v 1.4 1994/10/02 17:35:31 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -661,3 +661,56 @@ m_devget(buf, totlen, off0, ifp, copy)
|
||||
}
|
||||
return (top);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy data from a buffer back into the indicated mbuf chain,
|
||||
* starting "off" bytes from the beginning, extending the mbuf
|
||||
* chain if necessary.
|
||||
*/
|
||||
void
|
||||
m_copyback(m0, off, len, cp)
|
||||
struct mbuf *m0;
|
||||
register int off;
|
||||
register int len;
|
||||
caddr_t cp;
|
||||
{
|
||||
register int mlen;
|
||||
register struct mbuf *m = m0, *n;
|
||||
int totlen = 0;
|
||||
|
||||
if (m0 == 0)
|
||||
return;
|
||||
while (off > (mlen = m->m_len)) {
|
||||
off -= mlen;
|
||||
totlen += mlen;
|
||||
if (m->m_next == 0) {
|
||||
n = m_getclr(M_DONTWAIT, m->m_type);
|
||||
if (n == 0)
|
||||
goto out;
|
||||
n->m_len = min(MLEN, len + off);
|
||||
m->m_next = n;
|
||||
}
|
||||
m = m->m_next;
|
||||
}
|
||||
while (len > 0) {
|
||||
mlen = min (m->m_len - off, len);
|
||||
bcopy(cp, off + mtod(m, caddr_t), (unsigned)mlen);
|
||||
cp += mlen;
|
||||
len -= mlen;
|
||||
mlen += off;
|
||||
off = 0;
|
||||
totlen += mlen;
|
||||
if (len == 0)
|
||||
break;
|
||||
if (m->m_next == 0) {
|
||||
n = m_get(M_DONTWAIT, m->m_type);
|
||||
if (n == 0)
|
||||
break;
|
||||
n->m_len = min(MLEN, len);
|
||||
m->m_next = n;
|
||||
}
|
||||
m = m->m_next;
|
||||
}
|
||||
out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))
|
||||
m->m_pkthdr.len = totlen;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)rtsock.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id$
|
||||
* $Id: rtsock.c,v 1.3 1994/08/02 07:46:44 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -372,59 +372,6 @@ rt_xaddrs(cp, cplim, rtinfo)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy data from a buffer back into the indicated mbuf chain,
|
||||
* starting "off" bytes from the beginning, extending the mbuf
|
||||
* chain if necessary.
|
||||
*/
|
||||
void
|
||||
m_copyback(m0, off, len, cp)
|
||||
struct mbuf *m0;
|
||||
register int off;
|
||||
register int len;
|
||||
caddr_t cp;
|
||||
{
|
||||
register int mlen;
|
||||
register struct mbuf *m = m0, *n;
|
||||
int totlen = 0;
|
||||
|
||||
if (m0 == 0)
|
||||
return;
|
||||
while (off > (mlen = m->m_len)) {
|
||||
off -= mlen;
|
||||
totlen += mlen;
|
||||
if (m->m_next == 0) {
|
||||
n = m_getclr(M_DONTWAIT, m->m_type);
|
||||
if (n == 0)
|
||||
goto out;
|
||||
n->m_len = min(MLEN, len + off);
|
||||
m->m_next = n;
|
||||
}
|
||||
m = m->m_next;
|
||||
}
|
||||
while (len > 0) {
|
||||
mlen = min (m->m_len - off, len);
|
||||
bcopy(cp, off + mtod(m, caddr_t), (unsigned)mlen);
|
||||
cp += mlen;
|
||||
len -= mlen;
|
||||
mlen += off;
|
||||
off = 0;
|
||||
totlen += mlen;
|
||||
if (len == 0)
|
||||
break;
|
||||
if (m->m_next == 0) {
|
||||
n = m_get(M_DONTWAIT, m->m_type);
|
||||
if (n == 0)
|
||||
break;
|
||||
n->m_len = min(MLEN, len);
|
||||
m->m_next = n;
|
||||
}
|
||||
m = m->m_next;
|
||||
}
|
||||
out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))
|
||||
m->m_pkthdr.len = totlen;
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
rt_msg1(type, rtinfo)
|
||||
int type;
|
||||
|
Loading…
Reference in New Issue
Block a user