RealworldApp Class Reference

#include <RealworldApp.h>

Inheritance diagram for RealworldApp:

RealworldConnector List of all members.

Detailed Description

Applicaton that communicates with a realword application via a socket.


Public Member Functions

 Module_Class_Members (RealworldApp, RealworldConnector, 0)

Protected Member Functions

virtual char * encapsulate (cMessage *msg, unsigned int *length)
 Converts an IP datagram to a data block for sending it to the tun device.
virtual cMessage * decapsulate (char *buf, uint32_t length)
 Parses data received from the tun device and converts it into a cMessage.
virtual bool isApp ()
 The Connector connects to an application, so this method to returns "true".


Member Function Documentation

cMessage * RealworldApp::decapsulate ( char *  buf,
uint32_t  length 
) [protected, virtual]

Parses data received from the tun device and converts it into a cMessage.

Parameters:
buf A pointer to the data to be parsed
length The length of the buffer in bytes
Returns:
The parsed message

Implements RealworldConnector.

00024 {
00025     cMessage* payload = 0; 
00026     // "Decode" packet: 16bit payload length|payload
00027     payload = parser->decapsulatePayload( buf, length );
00028     if (!payload) {
00029         ev << "RealworldApp: Parsing of Payload failed, dropping packet.\n";
00030     }
00031 
00032     delete buf;
00033     return payload;
00034 }

char * RealworldApp::encapsulate ( cMessage *  msg,
unsigned int *  length 
) [protected, virtual]

Converts an IP datagram to a data block for sending it to the tun device.

Parameters:
msg A pointer to the message to be converted
length A pointer to an int that will hold the length of the converted data
Returns:
A pointer to the converted data

Implements RealworldConnector.

00008 {
00009     unsigned int payloadLen;
00010     // parse payload
00011     char* payload = parser->encapsulatePayload(msg, &payloadLen);
00012     if (!payload )
00013         return NULL;
00014 
00015     if(payloadLen > 0xffff) {
00016         opp_error("RealworldApp: Encapsulating packet failed: packet too long");
00017     }
00018     *length = payloadLen;
00019 
00020     return payload;
00021 }

virtual bool RealworldApp::isApp (  )  [inline, protected, virtual]

The Connector connects to an application, so this method to returns "true".

Returns:
true

Reimplemented from RealworldConnector.

00036 {return true;}

RealworldApp::Module_Class_Members ( RealworldApp  ,
RealworldConnector  ,
 
)


The documentation for this class was generated from the following files:
Generated on Fri May 11 14:52:40 2007 for ITM OverSim by  doxygen 1.4.7