Kernel/x86_64 - Debugging iret->CPL3 crash
[tpg/acess2.git] / Modules / IPStack / icmp.c
index de3a9db..1603719 100644 (file)
@@ -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 );
 }

UCC git Repository :: git.ucc.asn.au