try
{
LPICMPHeader lpHead;
lpHead=ConstructICMP();
if (!lpHead)
{
ReportError("SendEcho","Failed to construct ICMP header!");
return FALSE;
}
//Check if echo or reply
if (bReply)
lpHead->ICMPType=ICMP_Echo_Reply;
else
lpHead->ICMPType=ICMP_Echo;
lpHead->ICMPCode=0;
lpHead->sICMP.sUS.us1=htons(usIdentifier);
lpHead->sICMP.sUS.us2=htons(usSequence);
lpHead->ICMP_Originate_Timestamp=htonl(ulData);
//And the checksum
lpHead->ICMPChecksum=CalculateChecksum((unsigned short*)lpHead,ICMPHeaderLength);
//Send it
BOOL bSend;
bSend=CSpoofSocket::Send(lpDestinationAddress,(char*)lpHead,ICMPHeaderLength);
//Clear up
delete lpHead;
return bSend;
}
ERROR_HANDLER_RETURN("SendEcho",FALSE)