From owner-freebsd-net Wed Sep 5 13:32:58 2001 Delivered-To: freebsd-net@freebsd.org Received: from mgw-dax1.ext.nokia.com (mgw-dax1.ext.nokia.com [63.78.179.216]) by hub.freebsd.org (Postfix) with ESMTP id DC14537B417 for ; Wed, 5 Sep 2001 13:32:42 -0700 (PDT) Received: from davir01nok.americas.nokia.com (davir01nok.americas.nokia.com [172.18.242.84]) by mgw-dax1.ext.nokia.com (Switch-2.1.0/Switch-2.1.0) with ESMTP id f85KWfo11627 for ; Wed, 5 Sep 2001 15:32:41 -0500 (CDT) Received: from daebh001.NOE.Nokia.com (unverified) by davir01nok.americas.nokia.com (Content Technologies SMTPRS 4.2.5) with ESMTP id ; Wed, 5 Sep 2001 15:32:41 -0500 content-class: urn:content-classes:message Subject: RE: Reg. mbuf structure Date: Wed, 5 Sep 2001 15:32:40 -0500 Message-ID: X-MS-Has-Attach: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MS-TNEF-Correlator: Thread-Topic: Reg. mbuf structure Thread-Index: AcE2SUJnu+Hza6I6EdWBSQBQi2X+DwAAC8iw X-MimeOLE: Produced By Microsoft Exchange V6.0.4712.0 From: "Ramasubramanian Ramamoorthy (EXT-NRC/Boston)" To: "'ext Julian Elischer'" Cc: 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 Yes, I used this copydata function, to extract some data to calculate my checksum. But, how do I send the same extracted data which is contained in skbuff structure in the linux machine? I need to check that the packet what I am sending from the Linux machine to the BSD machine using the checksum that I am generating.=20 I am able to extract data using m_copydata() in BSD. But, I need the same data in Linux for calculating the same checksum, as the algorithms are same at both ends. Thanks, Ram. -----Original Message----- From: ext Julian Elischer [mailto:julian@elischer.org] Sent: Wednesday, September 05, 2001 5:00 PM To: Ramasubramanian Ramamoorthy (EXT-NRC/Boston) Cc: freebsd-net@freebsd.org Subject: RE: Reg. mbuf structure 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. >=20 > 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. >=20 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=20 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 -=3D m->m_len; m =3D m->m_next; } while (len > 0) { count =3D min(m->m_len - off, len); bcopy(mtod(m, caddr_t) + off, cp, count); len -=3D count; cp +=3D count; off =3D 0; m =3D m->m_next; } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message