// Borland C++ Builder
// Copyright (c) 1995, 2005 by Borland Software Corporation
// All rights reserved

// (DO NOT EDIT: machine generated header) 'Inicmpclient.pas' rev: 10.00

#ifndef InicmpclientHPP
#define InicmpclientHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp>	// Pascal unit
#include <Sysinit.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <Inglobal.hpp>	// Pascal unit
#include <Inrawbase.hpp>	// Pascal unit
#include <Inrawclient.hpp>	// Pascal unit
#include <Instackbsdbase.hpp>	// Pascal unit
#include <Instackconsts.hpp>	// Pascal unit
#include <Sysutils.hpp>	// Pascal unit
#include <Incomponent.hpp>	// Pascal unit
#include <Inbasecomponent.hpp>	// Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Inicmpclient
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TReplyStatusTypes { rsEcho, rsError, rsTimeOut, rsErrorUnreachable, rsErrorTTLExceeded };
#pragma option pop

struct TReplyStatus
{
	
public:
	int BytesReceived;
	AnsiString FromIpAddress;
	Byte MsgType;
	Word SequenceId;
	unsigned MsRoundTripTime;
	Byte TimeToLive;
	TReplyStatusTypes ReplyStatusType;
} ;

typedef char TCharBuf[1024];

typedef Byte TICMPDataBuffer[128];

typedef void __fastcall (__closure *TOnReplyEvent)(Classes::TComponent* ASender, const TReplyStatus &AReplyStatus);

class DELPHICLASS TInIcmpClient;
class PASCALIMPLEMENTATION TInIcmpClient : public Inrawclient::TInRawClient 
{
	typedef Inrawclient::TInRawClient inherited;
	
protected:
	char bufReceive[1024];
	char bufIcmp[1024];
	Word wSeqNo;
	int iDataSize;
	TReplyStatus FReplyStatus;
	TOnReplyEvent FOnReply;
	AnsiString FReplydata;
	Word __fastcall CalcCheckSum(void);
	bool __fastcall DecodeResponse(unsigned BytesRead, TReplyStatus &AReplyStatus);
	void __fastcall DoReply(const TReplyStatus &AReplyStatus);
	void __fastcall GetEchoReply(void);
	virtual void __fastcall InitComponent(void);
	void __fastcall PrepareEchoRequest(AnsiString Buffer = "");
	void __fastcall SendEchoRequest(void);
	
public:
	void __fastcall Ping(AnsiString ABuffer = "", Word SequenceID = (Word)(0x0));
	TReplyStatus __fastcall Receive(int ATimeOut);
	__property TReplyStatus ReplyStatus = {read=FReplyStatus};
	__property AnsiString ReplyData = {read=FReplydata};
	
__published:
	__property ReceiveTimeout  = {default=5000};
	__property Host ;
	__property Port  = {default=0};
	__property Protocol  = {default=1};
	__property TOnReplyEvent OnReply = {read=FOnReply, write=FOnReply};
public:
	#pragma option push -w-inl
	/* TInRawBase.Destroy */ inline __fastcall virtual ~TInIcmpClient(void) { }
	#pragma option pop
	
public:
	#pragma option push -w-inl
	/* TInBaseComponent.Create */ inline __fastcall TInIcmpClient(Classes::TComponent* AOwner)/* overload */ : Inrawclient::TInRawClient(AOwner) { }
	#pragma option pop
	
};


//-- var, const, procedure ---------------------------------------------------
static const Shortint DEF_PACKET_SIZE = 0x20;
static const Word MAX_PACKET_SIZE = 0x400;
static const Byte iDEFAULTPACKETSIZE = 0x80;
static const Word iDEFAULTREPLYBUFSIZE = 0x400;
static const Word Id_TIDICMP_ReceiveTimeout = 0x1388;

}	/* namespace Inicmpclient */
using namespace Inicmpclient;
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// Inicmpclient
