From owner-freebsd-net Wed Sep 5 13:28: 3 2001 Delivered-To: freebsd-net@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id A50CE37B403 for ; Wed, 5 Sep 2001 13:27:59 -0700 (PDT) Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id NAA25092; Wed, 5 Sep 2001 13:59:59 -0700 (PDT) Date: Wed, 5 Sep 2001 13:59:58 -0700 (PDT) From: Julian Elischer To: "Ramasubramanian Ramamoorthy (EXT-NRC/Boston)" Cc: freebsd-net@freebsd.org Subject: RE: Reg. mbuf structure In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Wed, 5 Sep 2001, Ramasubramanian Ramamoorthy (EXT-NRC/Boston) wrote: > Hi, > I had mailed regarding extracting the same data from the skbuff > structure in Linux and the mbuf structure in BSD. I am calculating the > checksum in two machines, one running BSD and the other running Red Hat. > I need to calculate the checksum at both the machines, for which I > should be extracting the same data from these structures and send that > to the algorithm, which calculates the checksum. > > Can you tell me how we can confirm that we are extracting the same data > from both these structures. It would be of great help, if anybody could > help me in this regard soon. > Do you know how much data you are supposed to be extracting? Do you have an IP header or something on the front you want to ignore? I assume this is a kernel module. Here is a data extraction function from kern/uipc_mbuf.c You can modify this function to checksum intead of copying.. or since this is always in the kernel, you could just call it. /* * Copy data from an mbuf chain starting "off" bytes from the beginning, * continuing for "len" bytes, into the indicated buffer. */ void m_copydata(m, off, len, cp) register struct mbuf *m; register int off; register int len; caddr_t cp; { register unsigned count; while (off > 0) { if (off < m->m_len) break; off -= m->m_len; m = m->m_next; } while (len > 0) { count = min(m->m_len - off, len); bcopy(mtod(m, caddr_t) + off, cp, count); len -= count; cp += count; off = 0; m = m->m_next; } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message