![]() |
CalculatePseudoChecksum() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Public Function |
Declared in: SpoofSocket.h |
unsigned short CalculatePseudoChecksum( const char* pBuffer, int iBufferLength, IP aDestinationAddress, int iPacketLength) const;
Calculate the checksum for TCP and UDP
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)
![]() |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |