Introduce the m_length() function which will return the accumulated

length of an mbuf-chain and optionally a pointer to the last mbuf.
This commit is contained in:
Poul-Henning Kamp 2002-09-18 14:57:35 +00:00
parent 9f86067a9c
commit ac6e585d24
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103544
2 changed files with 21 additions and 7 deletions

View File

@ -714,13 +714,26 @@ m_print(const struct mbuf *m)
int
m_fixhdr(struct mbuf *m0)
{
struct mbuf *m = m0;
int len = 0;
int len;
while (m) {
len += m->m_len;
m = m->m_next;
}
len = m_length(m0, NULL);
m0->m_pkthdr.len = len;
return len;
return (len);
}
int
m_length(struct mbuf *m0, struct mbuf **last)
{
struct mbuf *m;
int len;
len = 0;
for (m = m0; m != NULL; m = m->m_next) {
len += m->m_len;
if (m->m_next == NULL)
break;
}
if (last != NULL)
*last = m;
return (len);
}

View File

@ -489,6 +489,7 @@ struct mbuf *m_getcl(int, short, int);
struct mbuf *m_gethdr(int, short);
struct mbuf *m_gethdr_clrd(int, short);
struct mbuf *m_getm(struct mbuf *, int, int, short);
int m_length(struct mbuf *m, struct mbuf **l);
struct mbuf *m_prepend(struct mbuf *, int, int);
void m_print(const struct mbuf *m);
struct mbuf *m_pulldown(struct mbuf *, int, int, int *);