A message parser for RealWorldTestMessages. More...
#include <RealWorldTestPacketParser.h>
Public Member Functions | |
| char * | encapsulatePayload (cPacket *msg, unsigned int *length) |
| Convert a cMessage to a data block for sending it to the tun device. | |
| cPacket * | decapsulatePayload (char *buf, unsigned int length) |
| Parses a block of data received from the tun device. | |
A message parser for RealWorldTestMessages.
Definition at line 40 of file RealWorldTestPacketParser.h.
| cPacket * 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.
Definition at line 40 of file RealWorldTestPacketParser.cc.
{
RealWorldTestMessage* msg = new RealWorldTestMessage;
buf[length-1] = 0;
msg->setMsg(buf);
return msg;
}
| char * RealWorldTestPacketParser::encapsulatePayload | ( | cPacket * | 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.
Definition at line 30 of file RealWorldTestPacketParser.cc.
{
const char* data = dynamic_cast<RealWorldTestMessage*> (msg)->getMsg();
*length = strlen(data)+1;
char* buf = new char[*length];
strncpy(buf, data, *length);
buf[*length-1] = '\n';
return buf;
}
1.7.1