![]() |
CalculatePseudoChecksum() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: SpoofSocket.h |
Declaration
unsigned short CalculatePseudoChecksum(
const char* pBuffer,
int iBufferLength,
IP aDestinationAddress,
int iPacketLength) const;
DescriptionCalculate the checksum for TCP and UDP
Function Body
try
{
//Calculate the checksum
LPPseudoHeader lpPseudo;
lpPseudo=new PseudoHeader;
//Protect it
std::auto_ptr<PseudoHeader> pProtection(lpPseudo);
//Set the values
lpPseudo->ulDestinationAddress=aDestinationAddress;
lpPseudo->ulSourceAddress=m_ulSourceAddress;
lpPseudo->ucZeros=0;
lpPseudo->ucPTCL=m_ucProtocol;
lpPseudo->usLength=htons(iPacketLength);
//Calculate checksum of all
int iTotalLength;
iTotalLength=PseudoHeaderLength+iBufferLength;
//Allocate the buffer
char* pNewBuffer;
pNewBuffer=new char[iTotalLength];
//Protect the new buffer
CArray_ptr<char> pBufferProtection(pNewBuffer);
//Copy pseudo
memcpy(pNewBuffer,lpPseudo,PseudoHeaderLength);
//Copy header
memcpy(pNewBuffer+PseudoHeaderLength,
pBuffer,
iBufferLength);
//Calculate the checksum
unsigned short usChecksum;
usChecksum=CalculateChecksum((unsigned short*)pNewBuffer,iTotalLength);
//Return checksum
return usChecksum;
}
ERROR_HANDLER_RETURN("CalculatePseudoChecksum",0)
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |