#include <RealWorldTestPacketParser.h>
Inheritance diagram for RealWorldTestPacketParser:
Public Member Functions | |
char * | encapsulatePayload (cMessage *msg, unsigned int *length) |
Convert a cMessage to a data block for sending it to the tun device. | |
cMessage * | decapsulatePayload (char *buf, unsigned int length) |
Parses a block of data received from the tun device. |
cMessage * RealWorldTestPacketParser::decapsulatePayload | ( | char * | buf, | |
unsigned int | length | |||
) | [virtual] |
Parses a block of data received from the tun device.
Pure virtual function, has to be implemented by inherited classes.
buf | The data to be parsed | |
length | The length of the data |
Implements PacketParser.
00041 { 00042 RealWorldTestMessage* msg = new RealWorldTestMessage; 00043 buf[length-1] = 0; 00044 msg->setMsg(buf); 00045 00046 return msg; 00047 }
char * RealWorldTestPacketParser::encapsulatePayload | ( | cMessage * | msg, | |
unsigned int * | length | |||
) | [virtual] |
Convert a cMessage to a data block for sending it to the tun device.
Pure virtual function, has to be implemented by inherited classes.
msg | A pointer to the message to be converted | |
length | A pointer to an integer that will hold the length of the data |
Implements PacketParser.
00031 { 00032 const char* data = dynamic_cast<RealWorldTestMessage*> (msg)->getMsg(); 00033 *length = strlen(data)+1; 00034 char* buf = new char[*length]; 00035 strncpy(buf, data, *length); 00036 buf[*length-1] = '\n'; 00037 return buf; 00038 }