Class CTCPCrafter::
GetCraftedPacket()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: FinalTCPHeaderNext page: operator =    Show member index
Public Function Declared in:
TCPCrafter.h

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

char * GetCraftedPacket(
    unsigned short usSourcePort,
    unsigned long ulDestinationAddress,
    const char* pBuffer,
    unsigned long ulBufferSize,
    unsigned short usDestinationPort,
    unsigned short& usTotalSize) const;

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

Get the memory of a crafted packet (returns an allocated packet)

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

try
{
    //Let's try our first attack
    LPTCPHeader lpHead;

    //Header length
    int iHeaderLength;
    iHeaderLength=TCPHeaderLength;

    //Create the header
    lpHead=ConstructTCPHeader(usSourcePort,
                              usDestinationPort,
                              iHeaderLength);

    //Protect it
    std::auto_ptr<TCPHeader> pProtection(lpHead);

    //Our total length
    int iTotalLength;
    iTotalLength=iHeaderLength+ulBufferSize;

    //Allocate the buffer
    char* pNewBuffer;
    pNewBuffer=new char[iTotalLength];

    //Protect it
    CArray_ptr<char> pBufferProtection(pNewBuffer);

    //Copy the header
    memcpy(pNewBuffer,
           lpHead,
           iHeaderLength);

    //Copy the data
    if (ulBufferSize)
        //Copy the data
        memcpy(pNewBuffer+iHeaderLength,
               pBuffer,
               ulBufferSize);

    //Calculate the checksum
    lpHead->usChecksum=CalculatePseudoChecksum(pNewBuffer,
                                               iTotalLength,
                                               ulDestinationAddress,
                                               iTotalLength);

    //Last change to the header
    FinalTCPHeader(lpHead);

    //Copy the header
    memcpy(pNewBuffer,
           lpHead,
           iHeaderLength);

    //Send the data
    char* pNewData;
    pNewData=CIPCrafter::GetCraftedPacket(this,
                                          ulDestinationAddress,
                                          pNewBuffer,
                                          iTotalLength,
                                          usTotalSize);

    //Exit
    return pNewData;
}
ERROR_HANDLER_RETURN("GetCraftedPacket",NULL)

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

Class Overview Class Overview  |  Public base class CTCPSocket  |  Public base class CIPCrafter  |  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 © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.