X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FIPStack%2Ficmp.c;h=80974ef15f780482f95df563ce5cf1a574352e48;hb=dfe6387e68caf8ffd75f7814131ca2af3be53eb1;hp=16037199173abb974df8cae419ab4b5b41f0c917;hpb=51ab5f489bc356940c95cc936fd0508e8f07ea97;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/IPStack/icmp.c b/KernelLand/Modules/IPStack/icmp.c index 16037199..80974ef1 100644 --- a/KernelLand/Modules/IPStack/icmp.c +++ b/KernelLand/Modules/IPStack/icmp.c @@ -83,7 +83,11 @@ 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); + IPStack_Buffer_DestroyBuffer(buffer); break; default: break; @@ -117,16 +121,19 @@ 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); + IPStack_Buffer_DestroyBuffer(buffer); end = ts + Interface->TimeoutDelay; while( !gICMP_PingSlots[i].bArrived && now() < end) Threads_Yield(); - if(now() > end) + if(now() >= end) return -1; return (int)( now() - ts );