Re: Question about network partial checksums
Re: Question about network partial checksums
- Subject: Re: Question about network partial checksums
- From: Phil Jordan <email@hidden>
- Date: Tue, 19 Feb 2013 12:20:39 +0100
Hi Dave,
On Tue, Feb 19, 2013 at 8:13 AM, dave jones <email@hidden> wrote:
> How do I compute partial checksums on mbuf chains on OS X? Would you
> give me an exmaple? Thanks. It seems to me OS X doesn't have that API.
There are functions mbuf_inet_cksum() and mbuf_inet6_cksum() which
calculate the checksum for a range of data in an mbuf:
http://developer.apple.com/library/mac/documentation/Kernel/Reference/kpi_mbuf_header_reference/Reference/reference.html#//apple_ref/doc/uid/TP40011939-CHkpimbufhFunctions-DontLinkElementID_46
The documentation isn't fantastic, so you'll probably want to look at
the source code; mbuf_inet_cksum() calls inet_cksum() to do the actual
work, and that's defined in bsd/netinet/in_cksum.c in the xnu source
tree.
However, in my virtio-net driver I seem to have ended up implementing
the one's complement sum directly for the partial checksum on
fragmented packets. I wrote that code 18 months ago, and I can't for
the life of me remember why I didn't just use mbuf_inet_cksum().
Hope that (vaguely) helps.
phil
--
http://philjordan.eu/ - Phil Jordan, software development contractor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden