Kernel/IPStack - Fix TCP node size being zero instead of -1
[tpg/acess2.git] / KernelLand / Modules / IPStack / icmp.c
index 1603719..fa9927e 100644 (file)
@@ -83,7 +83,10 @@ void ICMP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buff
                hdr->Checksum = 0;
                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);
+               
+               tIPStackBuffer  *buffer = IPStack_Buffer_CreateBuffer(1 + IPV4_BUFFERS);
+               IPStack_Buffer_AppendSubBuffer(buffer, Length, 0, hdr, NULL, NULL);
+               IPv4_SendPacket(Interface, *(tIPv4*)Address, 1, ntohs(hdr->Sequence), buffer);
                break;
        default:
                break;
@@ -117,16 +120,18 @@ int ICMP_Ping(tInterface *Interface, tIPv4 Addr)
        gICMP_PingSlots[i].bArrived = 0;
        hdr->ID = i;
        hdr->Sequence = ~i;
-       hdr->Checksum = htons( IPv4_Checksum((Uint16*)hdr, sizeof(buf)/2) );
+       hdr->Checksum = htons( IPv4_Checksum((Uint16*)buf, sizeof(buf)) );
        
        ts = now();
        
-       IPv4_SendPacket(Interface, Addr, 1, i, sizeof(buf), buf);
+       tIPStackBuffer  *buffer = IPStack_Buffer_CreateBuffer(1 + IPV4_BUFFERS);
+       IPStack_Buffer_AppendSubBuffer(buffer, sizeof(buf), 0, buf, NULL, NULL);
+       IPv4_SendPacket(Interface, Addr, 1, i, buffer);
        
        end = ts + Interface->TimeoutDelay;
        while( !gICMP_PingSlots[i].bArrived && now() < end)     Threads_Yield();
        
-       if(now() > end)
+       if( !gICMP_PingSlots[i].bArrived )
                return -1;
        
        return (int)( now() - ts );

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