- 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

svn path=/trunk/; revision=43638
This commit is contained in:
Cameron Gutman 2009-10-20 06:07:34 +00:00
parent 31ba6d7556
commit 13c453792d
2 changed files with 3 additions and 5 deletions

View file

@ -69,16 +69,14 @@ UDPv4ChecksumCalculate(
/* Pad the data if needed */ /* Pad the data if needed */
Pad = (DataLength & 1); Pad = (DataLength & 1);
if (Pad) { if (Pad)
DbgPrint("Odd\n");
DataLength++; DataLength++;
} else DbgPrint("Even\n");
/* Add from the UDP header and data */ /* Add from the UDP header and data */
for (i = 0; i < DataLength; i += 2) for (i = 0; i < DataLength; i += 2)
{ {
TmpSum = ((PacketBuffer[i] << 8) & 0xFF00) + 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; Sum += TmpSum;
} }

View file

@ -267,7 +267,7 @@ VOID UDPReceive(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
i = UDPv4ChecksumCalculate(IPv4Header, i = UDPv4ChecksumCalculate(IPv4Header,
(PUCHAR)UDPHeader, (PUCHAR)UDPHeader,
WH2N(UDPHeader->Length)); WH2N(UDPHeader->Length));
if (i != DH2N(0x0000FFFF)) if (i != DH2N(0x0000FFFF) && UDPHeader->Checksum != 0)
{ {
TI_DbgPrint(MIN_TRACE, ("Bad checksum on packet received.\n")); TI_DbgPrint(MIN_TRACE, ("Bad checksum on packet received.\n"));
return; return;