Public Member Functions

RealWorldTestPacketParser Class Reference

A message parser for RealWorldTestMessages. More...

#include <RealWorldTestPacketParser.h>

Inheritance diagram for RealWorldTestPacketParser:
PacketParser

List of all members.

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.

Detailed Description

A message parser for RealWorldTestMessages.

Author:
Stephan Krause

Definition at line 40 of file RealWorldTestPacketParser.h.


Member Function Documentation

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.

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

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.

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;
}


The documentation for this class was generated from the following files: