uipc_mbuf.c (3390d47670b18dbdd6f618cc7df61a233cb1e914) | uipc_mbuf.c (37621fd5d93015b59e08fc1278cbabfbf393fa7b) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 741 unchanged lines hidden (view full) --- 750 m->m_next = n; 751 } 752 m = m->m_next; 753 } 754out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen)) 755 m->m_pkthdr.len = totlen; 756} 757 | 1/* 2 * Copyright (c) 1982, 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 741 unchanged lines hidden (view full) --- 750 m->m_next = n; 751 } 752 m = m->m_next; 753 } 754out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen)) 755 m->m_pkthdr.len = totlen; 756} 757 |
758/* 759 * Apply function f to the data in an mbuf chain starting "off" bytes from 760 * the beginning, continuing for "len" bytes. 761 */ 762int 763m_apply(struct mbuf *m, int off, int len, 764 int (*f)(void *, caddr_t, unsigned int), void *arg) 765{ 766 unsigned int count; 767 int rval; 768 769 KASSERT(off >= 0, ("m_apply, negative off %d", off)); 770 KASSERT(len >= 0, ("m_apply, negative len %d", len)); 771 772 while (off > 0) { 773 KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain")); 774 if (off < m->m_len) 775 break; 776 off -= m->m_len; 777 m = m->m_next; 778 } 779 while (len > 0) { 780 KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain")); 781 count = min(m->m_len - off, len); 782 783 rval = (*f)(arg, mtod(m, caddr_t) + off, count); 784 if (rval) 785 return (rval); 786 787 len -= count; 788 off = 0; 789 m = m->m_next; 790 } 791 792 return (0); 793} 794 795/* 796 * Return a pointer to mbuf/offset of location in mbuf chain. 797 */ 798struct mbuf * 799m_getptr(struct mbuf *m, int loc, int *off) 800{ 801 802 while (loc >= 0) { 803 /* Normal end of search */ 804 if (m->m_len > loc) { 805 *off = loc; 806 return (m); 807 } else { 808 loc -= m->m_len; 809 810 if (m->m_next == NULL) { 811 if (loc == 0) { 812 /* Point at the end of valid data */ 813 *off = m->m_len; 814 return (m); 815 } else 816 return (NULL); 817 } else 818 m = m->m_next; 819 } 820 } 821 822 return (NULL); 823} 824 |
|
758void 759m_print(const struct mbuf *m) 760{ 761 int len; 762 const struct mbuf *m2; 763 764 len = m->m_pkthdr.len; 765 m2 = m; --- 204 unchanged lines hidden --- | 825void 826m_print(const struct mbuf *m) 827{ 828 int len; 829 const struct mbuf *m2; 830 831 len = m->m_pkthdr.len; 832 m2 = m; --- 204 unchanged lines hidden --- |