Lines Matching refs:len
310 if (pktlen && pktlen != m->m_pkthdr.len) {
312 m->m_pkthdr.len = 0;
314 M_SANITY_ACTION("m_pkthdr.len != mbuf chain length");
412 m_prepend(struct mbuf *m, int len, int how)
428 if (len < M_SIZE(m))
429 M_ALIGN(m, len);
430 m->m_len = len;
436 * continuing for "len" bytes. If len is M_COPYALL, copy to end of mbuf.
442 m_copym(struct mbuf *m, int off0, int len, int wait)
450 KASSERT(len >= 0, ("m_copym, negative len %d", len));
463 while (len > 0) {
465 KASSERT(len == M_COPYALL,
479 if (len == M_COPYALL)
480 n->m_pkthdr.len -= off0;
482 n->m_pkthdr.len = len;
485 n->m_len = min(len, m->m_len - off);
492 if (len != M_COPYALL)
493 len -= n->m_len;
563 * continuing for "len" bytes, into the indicated buffer.
566 m_copydata(const struct mbuf *m, int off, int len, caddr_t cp)
571 KASSERT(len >= 0, ("m_copydata, negative len %d", len));
579 while (len > 0) {
581 count = min(m->m_len - off, len);
583 len -= count;
608 remain = m->m_pkthdr.len;
611 while (remain > 0 || top == NULL) { /* allow m->m_pkthdr.len == 0 */
656 ("%s: bogus m_pkthdr.len", __func__));
700 m->m_pkthdr.len += n->m_pkthdr.len;
709 int len = req_len;
715 if (len >= 0) {
719 while (m != NULL && len > 0) {
720 if (m->m_len <= len) {
721 len -= m->m_len;
725 m->m_len -= len;
726 m->m_data += len;
727 len = 0;
731 mp->m_pkthdr.len -= (req_len - len);
740 len = -len;
748 if (m->m_len >= len) {
749 m->m_len -= len;
751 mp->m_pkthdr.len -= len;
754 count -= len;
764 m->m_pkthdr.len = count;
780 * Rearange an mbuf chain so that len bytes are contiguous
782 * for a structure of size len). Returns the resulting
784 * If there is room, it will add up to max_protohdr-len extra bytes to the
788 m_pullup(struct mbuf *n, int len)
795 * If first mbuf has no cluster, and has room for len bytes
800 n->m_data + len < &n->m_dat[MLEN] && n->m_next) {
801 if (n->m_len >= len)
805 len -= m->m_len;
807 if (len > MHLEN)
817 count = min(min(max(len, max_protohdr), space), n->m_len);
820 len -= count;
828 } while (len > 0 && n);
829 if (len > 0) {
846 m_copyup(struct mbuf *n, int len, int dstoff)
851 if (len > (MHLEN - dstoff))
861 count = min(min(max(len, max_protohdr), space), n->m_len);
864 len -= count;
872 } while (len > 0 && n);
873 if (len > 0) {
898 u_int len = len0, remain;
901 for (m = m0; m && len > m->m_len; m = m->m_next)
902 len -= m->m_len;
905 remain = m->m_len - len;
913 n->m_pkthdr.len = m0->m_pkthdr.len - len0;
914 m0->m_pkthdr.len = len0;
921 n->m_pkthdr.len = m0->m_pkthdr.len - len0;
922 m0->m_pkthdr.len = len0;
928 n->m_next = m_split(m, len, wait);
950 n->m_data = m->m_data + len;
953 bcopy(mtod(m, caddr_t) + len, mtod(n, caddr_t), remain);
956 m->m_len = len;
968 void (*copy)(char *from, caddr_t to, u_int len))
972 int len;
981 len = MCLBYTES;
984 len = MHLEN;
989 len -= max_linkhdr;
995 m->m_pkthdr.len = totlen;
999 len = MCLBYTES;
1002 len = MLEN;
1011 len -= off;
1014 m->m_len = len = min(totlen, len);
1016 copy(buf, mtod(m, caddr_t), (u_int)len);
1018 bcopy(buf, mtod(m, caddr_t), (u_int)len);
1019 buf += len;
1022 totlen -= len;
1033 m_copyback(struct mbuf *m0, int off, int len, c_caddr_t cp)
1049 n->m_len = min(MLEN, len + off);
1054 while (len > 0) {
1055 if (m->m_next == NULL && (len > m->m_len - off)) {
1056 m->m_len += min(len - (m->m_len - off),
1059 mlen = min (m->m_len - off, len);
1062 len -= mlen;
1066 if (len == 0)
1072 n->m_len = min(MLEN, len);
1077 out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))
1078 m->m_pkthdr.len = totlen;
1089 m_append(struct mbuf *m0, int len, c_caddr_t cp)
1096 remainder = len;
1123 m0->m_pkthdr.len += len - remainder;
1129 * the beginning, continuing for "len" bytes.
1132 m_apply(struct mbuf *m, int off, int len,
1139 KASSERT(len >= 0, ("m_apply, negative len %d", len));
1147 while (len > 0) {
1149 count = min(m->m_len - off, len);
1153 len -= count;
1191 int len;
1201 len = m->m_pkthdr.len;
1203 len = -1;
1205 while (m2 != NULL && (len == -1 || len)) {
1209 printf("mbuf: %p len: %d, next: %p, %b%s", m2, m2->m_len,
1215 if (len != -1)
1216 len -= m2->m_len;
1219 if (len > 0)
1220 printf("%d bytes unaccounted for.\n", len);
1227 u_int len;
1229 len = m_length(m0, NULL);
1230 m0->m_pkthdr.len = len;
1231 return (len);
1238 u_int len;
1240 len = 0;
1242 len += m->m_len;
1248 return (len);
1282 if (m0->m_pkthdr.len > MHLEN)
1295 while (progress < m0->m_pkthdr.len) {
1296 length = m0->m_pkthdr.len - progress;
1324 m_defragbytes += m0->m_pkthdr.len;
1466 while (progress < m0->m_pkthdr.len) {
1473 if (fraglen > m0->m_pkthdr.len - progress)
1474 fraglen = m0->m_pkthdr.len - progress;
1508 m_uiotombuf(struct uio *uio, int how, int len, int align, int flags)
1516 * len can be zero or an arbitrary large value bound by
1519 if (len > 0)
1520 total = min(uio->uio_resid, len);
1533 * If len is zero return the smallest empty mbuf.
1553 m->m_pkthdr.len += length;
1561 * Copy an mbuf chain into a uio limited by len if set.
1564 m_mbuftouio(struct uio *uio, struct mbuf *m, int len)
1569 if (len > 0)
1570 total = min(uio->uio_resid, len);
1602 int len, off;
1683 len = m->m_len;
1688 int cc = min(len, MCLBYTES);
1698 len -= cc;
1699 if (len <= 0)