From: dw6 Date: Wed, 25 Jun 2008 15:56:00 +0000 (+0000) Subject: fix for checksum bug X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=eb5940657b289a192f3bbd2660e8ecf421eb624d;p=senf.git fix for checksum bug git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@882 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/DefaultBundle/UDPPacket.cc b/Packets/DefaultBundle/UDPPacket.cc index 892487f..f3cfc56 100644 --- a/Packets/DefaultBundle/UDPPacket.cc +++ b/Packets/DefaultBundle/UDPPacket.cc @@ -50,10 +50,7 @@ prefix_ boost::uint16_t senf::UDPPacketParser::calcChecksum() const { IpChecksum summer; - summer.feed( i(), i()+checksum_offset ); - summer.feed( i()+checksum_offset+2, data().end() ); - - // Now on to the awkward part: the IP pseudo header + // first on to the awkward part: the IP pseudo header IPv4Packet ipv4 (packet().rfind(nothrow)); if (ipv4) { // Pseudo header defined in RFC768 @@ -88,6 +85,11 @@ prefix_ boost::uint16_t senf::UDPPacketParser::calcChecksum() } } + // since header are 16 / even 32bit aligned we don't have to care for padding. since IpChecksum + // cares for padding at the final summing we don't have to care is the payload is 16nbit-aligned, too. + summer.feed( i(), i()+checksum_offset ); + summer.feed( i()+checksum_offset+2, data().end() ); + boost::uint16_t rv (summer.sum()); return rv ? rv : 0xffffu; }