RealWorldTestPacketParser Class Reference

#include <RealWorldTestPacketParser.h>

Inheritance diagram for RealWorldTestPacketParser:

PacketParser List of all members.

Detailed Description

A message parser for RealWorldTestMessages.

Author:
Stephan Krause


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.


Member Function Documentation

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.

Parameters:
buf The data to be parsed
length The length of the data
Returns:
A cMessage containing the parsed 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.

Parameters:
msg A pointer to the message to be converted
length A pointer to an integer that will hold the length of the data
Returns:
A pointer to the converted 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 }


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:06 2007 for ITM OverSim by  doxygen 1.4.7