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

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

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

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

Get a crafted packet

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

try
{
    //Create the header
    UDPHeader aHeader;

    //Set the ports
    aHeader.usSourcePort=htons(usSourcePort);
    aHeader.usDestinationPort=htons(usDestinationPort);

    //Check sum
    aHeader.usChecksum=0;

    //Set the total size
    unsigned long ulTotalLength;
    ulTotalLength=UDPHeaderLength+ulBufferSizeBufferSize;

    //Set the length
    aHeader.usLength=htons(ulTotalLength);

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

    //Protect the data
    CArray_ptr<char> pProtection(pNewBuffer);

    //Copy original header
    memcpy(pNewBuffer,
           &aHeader,
           UDPHeaderLength);

    //Do we have data ?
    if (ulBufferSizeBufferSize)
        memcpy(pNewBuffer+UDPHeaderLength,
               pBuffer,
               ulBufferSizeBufferSize);

    //Get the checksum
    aHeader.usChecksum=CalculatePseudoChecksum(pNewBuffer,
                                               ulTotalLength,
                                               ulDestinationAddress,
                                               ulTotalLength);

    //Recopy it
    memcpy(pNewBuffer,
           &aHeader,
           UDPHeaderLength);

    //Set the new checksum (if applicateable)
    FinalUDPHeader((LPUDPHeader)pNewBuffer);

    //And return what we have from the IP
    return CIPCrafter::GetCraftedPacket(this,
                                        ulDestinationAddress,
                                        pNewBuffer,
                                        ulTotalLength,
                                        usTotalSize);
}
ERROR_HANDLER_RETURN("GetCraftedPacket",NULL)

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

Class Overview Class Overview  |  Public base class CUDPSocket  |  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.