Class CSpoofSocket::
CalculatePseudoChecksum()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: CalculateChecksumNext page: CanRead    Show member index
Public Function Declared in:
SpoofSocket.h

'Declaration' icon -- Shortcut to top of page. Declaration

unsigned short CalculatePseudoChecksum(
    const char *buf,
    int BufLength,
    LPCSTR lpDestinationAddress,
    int iPacketLength) const;

'Description' icon -- Shortcut to top of page. Description

Calculate the checksum for TCP and UDP

'Function Body' icon -- Shortcut to top of page. Function Body

try
{
    //Calculate the checksum
    LPPseudoHeader lpPseudo;
    lpPseudo=new PseudoHeader;

    lpPseudo->DestinationAddress=inet_addr(lpDestinationAddress);
    lpPseudo->SourceAddress=inet_addr(m_SourceAddress);
    lpPseudo->Zeros=0;
    lpPseudo->PTCL=m_Protocol;
    lpPseudo->Length=htons(iPacketLength);

    //Calculate checksum of all
    int iTotalLength;
    iTotalLength=PseudoHeaderLength+BufLength;

    char* tmpBuf;
    tmpBuf=new char[iTotalLength];

    //Copy pseudo
    memcpy(tmpBuf,lpPseudo,PseudoHeaderLength);

    //Copy header
    memcpy(tmpBuf+PseudoHeaderLength,buf,BufLength);

    //Calculate the checksum
    unsigned short usChecksum;
    usChecksum=CalculateChecksum((unsigned short*)tmpBuf,iTotalLength);

    //Delete all
    delete tmpBuf;
    delete lpPseudo;

    //Return checksum
    return usChecksum;
}
ERROR_HANDLER_RETURN("CalculatePseudoChecksum",0)

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Public base class CSpoofBase  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!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.