MCPcopy Create free account
hub / github.com/F-Stack/f-stack / m_apply

Function m_apply

freebsd/kern/uipc_mbuf.c:1223–1250  ·  view source on GitHub ↗

* Apply function f to the data in an mbuf chain starting "off" bytes from * the beginning, continuing for "len" bytes. */

Source from the content-addressed store, hash-verified

1221 * the beginning, continuing for "len" bytes.
1222 */
1223int
1224m_apply(struct mbuf *m, int off, int len,
1225 int (*f)(void *, void *, u_int), void *arg)
1226{
1227 u_int count;
1228 int rval;
1229
1230 KASSERT(off >= 0, ("m_apply, negative off %d", off));
1231 KASSERT(len >= 0, ("m_apply, negative len %d", len));
1232 while (off > 0) {
1233 KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
1234 if (off < m->m_len)
1235 break;
1236 off -= m->m_len;
1237 m = m->m_next;
1238 }
1239 while (len > 0) {
1240 KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
1241 count = min(m->m_len - off, len);
1242 rval = (*f)(arg, mtod(m, caddr_t) + off, count);
1243 if (rval)
1244 return (rval);
1245 len -= count;
1246 off = 0;
1247 m = m->m_next;
1248 }
1249 return (0);
1250}
1251
1252/*
1253 * Return a pointer to mbuf/offset of location in mbuf chain.

Callers 2

crypto_apply_bufFunction · 0.85
tcp_signature_computeFunction · 0.85

Calls 1

minFunction · 0.85

Tested by

no test coverage detected