#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. | |
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.
00041 { 00042 RealWorldTestMessage* msg = new RealWorldTestMessage; 00043 buf[length-1] = 0; 00044 msg->setMsg(buf); 00045 00046 return msg; 00047 }
| 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.
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 }
1.5.8