udp checksum on raw sockets

Ruslan Ermilov ru at freebsd.org
Wed Apr 28 00:05:59 PDT 2004


On Tue, Apr 27, 2004 at 11:16:39PM +0200, Mark Santcroos wrote:
> Hi,
> 
> On Tue, Apr 27, 2004 at 10:05:43PM +0300, Ruslan Ermilov wrote:
> > Have the raw IP code set csum_flags |= CSUM_UDP (and set csum_data
> > correctly) in m->m_pkthdr, if ip_p == IPPROTO_UDP && uh_csum == 0.
> > Do the same thing for IPPROTO_TCP.
> 
> Like I said, I'm willing to tackle this in the kernel, but for now I also 
> need a userland-only solution.
> 
OK.

> I guess I can fetch the IP address from the first ethernet iface and use
> that as the src address for the IP packet.
> 
getifaddrs(3).

> Then I have enough information to calculate the UDP checksum in userland,
> don't I?
> 
Yes, you do.  Another possibility would be to emit UDP datagrams
unchecksummed, by leaving the checksum field as zero.


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20040428/88cbe59f/attachment.bin


More information about the freebsd-net mailing list