![]() |
GetCraftedPacket() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Public Function |
Declared in: UDPCrafter.h |
char * GetCraftedPacket( unsigned short usSourcePort, unsigned long ulDestinationAddress, const char* pBuffer, unsigned long ulBufferSizeBufferSize, unsigned short usDestinationPort, unsigned short& usTotalSize) const;
Get a crafted packet
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)
![]() |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |