Deleted Added
full compact
uipc_mbuf.c (123557) uipc_mbuf.c (123564)
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

--- 20 unchanged lines hidden (view full) ---

29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
34 */
35
36#include <sys/cdefs.h>
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

--- 20 unchanged lines hidden (view full) ---

29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf.c 123557 2003-12-15 21:49:41Z bms $");
37__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf.c 123564 2003-12-16 14:13:47Z bms $");
38
39#include "opt_mac.h"
40#include "opt_param.h"
41#include "opt_mbuf_stress_test.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/kernel.h>

--- 710 unchanged lines hidden (view full) ---

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,
38
39#include "opt_mac.h"
40#include "opt_param.h"
41#include "opt_mbuf_stress_test.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/kernel.h>

--- 710 unchanged lines hidden (view full) ---

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)
764 int (*f)(void *, void *, u_int), void *arg)
765{
765{
766 unsigned int count;
766 u_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));
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);
771 while (off > 0) {
772 KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
773 if (off < m->m_len)
774 break;
775 off -= m->m_len;
776 m = m->m_next;
777 }
778 while (len > 0) {
779 KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
780 count = min(m->m_len - off, len);
782
783 rval = (*f)(arg, mtod(m, caddr_t) + off, count);
784 if (rval)
785 return (rval);
781 rval = (*f)(arg, mtod(m, caddr_t) + off, count);
782 if (rval)
783 return (rval);
786
787 len -= count;
788 off = 0;
789 m = m->m_next;
790 }
784 len -= count;
785 off = 0;
786 m = m->m_next;
787 }
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) {
788 return (0);
789}
790
791/*
792 * Return a pointer to mbuf/offset of location in mbuf chain.
793 */
794struct mbuf *
795m_getptr(struct mbuf *m, int loc, int *off)
796{
797
798 while (loc >= 0) {
803 /* Normal end of search */
799 /* Normal end of search. */
804 if (m->m_len > loc) {
805 *off = loc;
806 return (m);
807 } else {
808 loc -= m->m_len;
800 if (m->m_len > loc) {
801 *off = loc;
802 return (m);
803 } else {
804 loc -= m->m_len;
809
810 if (m->m_next == NULL) {
811 if (loc == 0) {
805 if (m->m_next == NULL) {
806 if (loc == 0) {
812 /* Point at the end of valid data */
807 /* Point at the end of valid data. */
813 *off = m->m_len;
814 return (m);
808 *off = m->m_len;
809 return (m);
815 } else
816 return (NULL);
817 } else
818 m = m->m_next;
810 }
811 return (NULL);
812 }
813 m = m->m_next;
819 }
820 }
814 }
815 }
821
822 return (NULL);
823}
824
825void
826m_print(const struct mbuf *m)
827{
828 int len;
829 const struct mbuf *m2;

--- 207 unchanged lines hidden ---
816 return (NULL);
817}
818
819void
820m_print(const struct mbuf *m)
821{
822 int len;
823 const struct mbuf *m2;

--- 207 unchanged lines hidden ---