![]() |
ProccessICMP() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Protected Function |
Declared in: ICMPSocket.h |
Declaration
virtual BOOL ProccessICMP(
const char* buf);
DescriptionProccess incoming ICMP data
Function Body
try
{
//Here we proccess the input we received
//Initialize members
if (!m_IPHeader)
m_IPHeader=new IpHeader;
if (!m_ICMPHeader)
m_ICMPHeader=new ICMPHeader;
//Create an IP header
LPIpHeader lpHead;
lpHead=m_IPHeader;
//Copy to buffer
memcpy(lpHead,buf,IpHeaderLength);
//Let's check for options
unsigned char ucHeaderSize;
ucHeaderSize=lpHead->HeaderLength_Version & 15;
ucHeaderSize*=4;
//Now check for total packet size
unsigned short ucPacketSize;
ucPacketSize=htons(lpHead->TotalLength);
//Copy data to icmp
memset(m_ICMPHeader,0,ICMPHeaderLength);
//How much to copy ?
unsigned short ucCopy;
ucCopy=ucPacketSize-ucHeaderSize;
//Save the datasize
m_DataSize=ucCopy;
if (ucCopy>ICMPHeaderLength)
ucCopy=ICMPHeaderLength;
memcpy(m_ICMPHeader,buf+ucHeaderSize,ucCopy);
//Now save the original IP
if (m_ICMPHeader->ICMPType!=ICMP_Echo &&
m_ICMPHeader->ICMPType!=ICMP_Echo_Reply &&
m_ICMPHeader->ICMPType!=ICMP_Timestamp &&
m_ICMPHeader->ICMPType!=ICMP_Timestamp_Reply &&
m_ICMPHeader->ICMPType!=ICMP_Information &&
m_ICMPHeader->ICMPType!=ICMP_Information_Reply)
{
if (!m_ICMPIPHeader)
m_ICMPIPHeader=new IpHeader;
memcpy(m_ICMPIPHeader,buf+ucHeaderSize+ICMP_Unreachable_SIZE,IpHeaderLength);
//Copy rest of data
if (!m_Data)
m_Data=new char[ICMP_DATA_SIZE];
memcpy(m_Data,buf+ucPacketSize-ICMP_DATA_SIZE,ICMP_DATA_SIZE);
}
//Now I need to reverse the header
ReverseHeader();
return TRUE;
}
ERROR_HANDLER_RETURN("ProccessICMP",FALSE)
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2001 Barak Weichselbaum. See the About page for additional notices. This page last updated: 27 Jun 2001. |