//Log_Debug("ICMPv4", "Replying");
hdr->Type = ICMP_ECHOREPLY;
hdr->Checksum = 0;
- hdr->Checksum = htons( IPv4_Checksum(hdr, Length) );
+ hdr->Checksum = htons( IPv4_Checksum( (Uint16*)hdr, Length/2 ) );
//Log_Debug("ICMPv4", "Checksum = 0x%04x", hdr->Checksum);
IPv4_SendPacket(Interface, *(tIPv4*)Address, 1, ntohs(hdr->Sequence), Length, hdr);
break;
gICMP_PingSlots[i].bArrived = 0;
hdr->ID = i;
hdr->Sequence = ~i;
- hdr->Checksum = htons( IPv4_Checksum(hdr, sizeof(buf)) );
- IPv4_SendPacket(Interface, Addr, 1, i, sizeof(buf), buf);
+ hdr->Checksum = htons( IPv4_Checksum((Uint16*)hdr, sizeof(buf)/2) );
ts = now();
+
+ IPv4_SendPacket(Interface, Addr, 1, i, sizeof(buf), buf);
+
end = ts + Interface->TimeoutDelay;
while( !gICMP_PingSlots[i].bArrived && now() < end) Threads_Yield();
if(now() > end)
return -1;
- return (int)ts;
+ return (int)( now() - ts );
}