Author: cgutman
Date: Tue Oct 20 08:07:34 2009
New Revision: 43638
URL:
http://svn.reactos.org/svn/reactos?rev=43638&view=rev
Log:
- Fix a typo in checksum calculation for datagrams with an odd number of octets
- Allow packets with no checksum
- Remove debug prints that got left behind
Modified:
trunk/reactos/lib/drivers/ip/network/checksum.c
trunk/reactos/lib/drivers/ip/transport/udp/udp.c
Modified: trunk/reactos/lib/drivers/ip/network/checksum.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/che…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/checksum.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/checksum.c [iso-8859-1] Tue Oct 20 08:07:34 2009
@@ -69,16 +69,14 @@
/* Pad the data if needed */
Pad = (DataLength & 1);
- if (Pad) {
- DbgPrint("Odd\n");
+ if (Pad)
DataLength++;
- } else DbgPrint("Even\n");
/* Add from the UDP header and data */
for (i = 0; i < DataLength; i += 2)
{
TmpSum = ((PacketBuffer[i] << 8) & 0xFF00) +
- ((Pad && i == DataLength - 1) ? 0 : (PacketBuffer[i+1] &
0x00FF));
+ ((Pad && i == DataLength - 2) ? 0 : (PacketBuffer[i+1] &
0x00FF));
Sum += TmpSum;
}
Modified: trunk/reactos/lib/drivers/ip/transport/udp/udp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/u…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] Tue Oct 20 08:07:34
2009
@@ -267,7 +267,7 @@
i = UDPv4ChecksumCalculate(IPv4Header,
(PUCHAR)UDPHeader,
WH2N(UDPHeader->Length));
- if (i != DH2N(0x0000FFFF))
+ if (i != DH2N(0x0000FFFF) && UDPHeader->Checksum != 0)
{
TI_DbgPrint(MIN_TRACE, ("Bad checksum on packet received.\n"));
return;