X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FIPStack%2Ficmp.c;h=fa9927ee1adba1af8de758e15bb3df32d2335c4a;hb=43ed567babb1a9084d732519dc2f6d4214310115;hp=16037199173abb974df8cae419ab4b5b41f0c917;hpb=48743e39650eb1ef988380e9d95f27fd40d3a9ce;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/IPStack/icmp.c b/KernelLand/Modules/IPStack/icmp.c index 16037199..fa9927ee 100644 --- a/KernelLand/Modules/IPStack/icmp.c +++ b/KernelLand/Modules/IPStack/icmp.c @@ -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 );