uipc_mbuf.c (135904) | uipc_mbuf.c (138541) |
---|---|
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 --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94 30 */ 31 32#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 --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf.c 135904 2004-09-28 18:40:18Z jmg $"); | 33__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf.c 138541 2004-12-08 05:42:02Z sam $"); |
34 35#include "opt_mac.h" 36#include "opt_param.h" 37#include "opt_mbuf_stress_test.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> --- 887 unchanged lines hidden (view full) --- 929 } 930 m = m->m_next; 931 } 932out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen)) 933 m->m_pkthdr.len = totlen; 934} 935 936/* | 34 35#include "opt_mac.h" 36#include "opt_param.h" 37#include "opt_mbuf_stress_test.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> --- 887 unchanged lines hidden (view full) --- 929 } 930 m = m->m_next; 931 } 932out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen)) 933 m->m_pkthdr.len = totlen; 934} 935 936/* |
937 * Append the specified data to the indicated mbuf chain, 938 * Extend the mbuf chain if the new data does not fit in 939 * existing space. 940 * 941 * Return 1 if able to complete the job; otherwise 0. 942 */ 943int 944m_append(struct mbuf *m0, int len, c_caddr_t cp) 945{ 946 struct mbuf *m, *n; 947 int remainder, space; 948 949 for (m = m0; m->m_next != NULL; m = m->m_next) 950 ; 951 remainder = len; 952 space = M_TRAILINGSPACE(m); 953 if (space > 0) { 954 /* 955 * Copy into available space. 956 */ 957 if (space > remainder) 958 space = remainder; 959 bcopy(cp, mtod(m, caddr_t) + m->m_len, space); 960 m->m_len += space; 961 cp += space, remainder -= space; 962 } 963 while (remainder > 0) { 964 /* 965 * Allocate a new mbuf; could check space 966 * and allocate a cluster instead. 967 */ 968 n = m_get(M_DONTWAIT, m->m_type); 969 if (n == NULL) 970 break; 971 n->m_len = min(MLEN, remainder); 972 bcopy(cp, mtod(m, caddr_t), m->m_len); 973 cp += m->m_len, remainder -= m->m_len; 974 m->m_next = n; 975 m = n; 976 } 977 if (m0->m_flags & M_PKTHDR) 978 m0->m_pkthdr.len += len - remainder; 979 return (remainder == 0); 980} 981 982/* |
|
937 * Apply function f to the data in an mbuf chain starting "off" bytes from 938 * the beginning, continuing for "len" bytes. 939 */ 940int 941m_apply(struct mbuf *m, int off, int len, 942 int (*f)(void *, void *, u_int), void *arg) 943{ 944 u_int count; --- 328 unchanged lines hidden --- | 983 * Apply function f to the data in an mbuf chain starting "off" bytes from 984 * the beginning, continuing for "len" bytes. 985 */ 986int 987m_apply(struct mbuf *m, int off, int len, 988 int (*f)(void *, void *, u_int), void *arg) 989{ 990 u_int count; --- 328 unchanged lines hidden --- |