Suggested patch for IdIcmpClient unit

Giganews Newsgroups
Subject: Suggested patch for IdIcmpClient unit
Posted by:  Pibì
Date: Wed, 25 Apr 2007

Problem solved:
1) PacketSize support all values, original version don't support size < 44
2) ReplyStatus.BytesReceived is correct, tcp header size is ignored

Example: ping 127.0.0.1 with PacketSize = 0
Rx from 127.0.0.1: bytes=0 time=<10ms TTL=128

Warning: tested only with IpV4, BDS2006 & Win32

procedure TIdCustomIcmpClient.PrepareEchoRequestIPv4:

  // {original} FillBytes(FbufIcmp, iDataSize, 0);
  FillBytes(FbufIcmp, Length(FbufIcmp), 0);

procedure TIdCustomIcmpClient.InternalPing:

  // {original} SetLength(FbufIcmp, FPacketSize);
  SetLength(FbufIcmp, 12 + FPacketSize);        //is Id_ICMP_MASK_HSIZE?
  if IPVersion = Id_IPv4 then begin
    // {original} SetLength(FbufReceive, FPacketSize+Id_IP_HSIZE);
    SetLength(FbufReceive, FPacketSize + 32);  // need constant
  end else begin
    SetLength(FbufReceive, FPacketSize+(Id_IPv6_HSIZE*2));
  end;

function TIdCustomIcmpClient.DecodeIPv4Packet:

        // {original} BytesReceived := BytesRead;
        BytesReceived := BytesRead - 32;        // need constant

ciao  Paolo

Replies