X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FIPStack%2Ficmp.c;h=16037199173abb974df8cae419ab4b5b41f0c917;hb=58c7107eb0a5ae254c135f2eaa6263751f1ebe67;hp=de3a9db5ab606bf49fb5fe9a65957d27121389b8;hpb=23096bbffa94688e90db5045d124dcdfe83a132e;p=tpg%2Facess2.git diff --git a/Modules/IPStack/icmp.c b/Modules/IPStack/icmp.c index de3a9db5..16037199 100644 --- a/Modules/IPStack/icmp.c +++ b/Modules/IPStack/icmp.c @@ -81,7 +81,7 @@ void ICMP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buff //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; @@ -117,15 +117,17 @@ int ICMP_Ping(tInterface *Interface, tIPv4 Addr) 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 ); }