OverSim
RealworldApp Class Reference

Applicaton that communicates with a realword application via a socket. More...

#include <RealworldApp.h>

Inheritance diagram for RealworldApp:
RealworldConnector

Protected Member Functions

virtual char * encapsulate (cPacket *msg, unsigned int *length, sockaddr **addr, socklen_t *addrlen)
 Converts an IP datagram to a data block for sending it to the (realworld) network.
virtual cPacket * decapsulate (char *buf, uint32_t length, sockaddr *addr, socklen_t addrlen)
 Parses data received from the (realworld) network and converts it into a cMessage.
virtual bool isApp ()
 The Connector connects to an application, so this method to returns "true".
- Protected Member Functions inherited from RealworldConnector
virtual void transmitToNetwork (cPacket *msg)
 Send a message to the (realworld) network.
virtual void updateDisplayString ()

Additional Inherited Members

- Public Member Functions inherited from RealworldConnector
 RealworldConnector ()
virtual ~RealworldConnector ()
virtual int numInitStages () const
virtual void initialize (int stage)
 Initialization of the module.
virtual void handleMessage (cMessage *msg)
 The "main loop".
- Protected Attributes inherited from RealworldConnector
int gateIndexNetwOut
unsigned int mtu
long numSent
long numSendError
long numRcvdOK
long numRcvError
cMessage * packetNotification
PacketBuffer packetBuffer
RealtimeSchedulerscheduler
PacketParserparser

Detailed Description

Applicaton that communicates with a realword application via a socket.

Definition at line 33 of file RealworldApp.h.

Member Function Documentation

cPacket * RealworldApp::decapsulate ( char *  buf,
uint32_t  length,
sockaddr *  addr,
socklen_t  addrlen 
)
protectedvirtual

Parses data received from the (realworld) network and converts it into a cMessage.

Parameters
bufA pointer to the data to be parsed
lengthThe lenght of the buffer in bytes
addrIgnored (deleted)
addrlenIgnored
Returns
The parsed message

Implements RealworldConnector.

Definition at line 52 of file RealworldApp.cc.

{
cPacket* payload = 0;
// "Decode" packet: 16bit payload length|payload
payload = parser->decapsulatePayload( buf, length );
if (!payload) {
EV << "[RealworldApp::decapsulate()]\n"
<< " Parsing of Payload failed, dropping packet"
<< endl;
}
delete buf;
return payload;
delete addr; // FIXME: unreachable
}
char * RealworldApp::encapsulate ( cPacket *  msg,
unsigned int *  length,
sockaddr **  addr,
socklen_t *  addrlen 
)
protectedvirtual

Converts an IP datagram to a data block for sending it to the (realworld) network.

Parameters
msgA pointer to the message to be converted
lengthA pointer to an int that will hold the length of the converted data
addrIgnored (set to 0)
addrlenIgnored (set to 0)
Returns
A pointer to the converted data

Implements RealworldConnector.

Definition at line 30 of file RealworldApp.cc.

{
unsigned int payloadLen;
*addr = 0;
*addrlen = 0;
// parse payload
char* payload = parser->encapsulatePayload(msg, &payloadLen);
if (!payload )
return NULL;
if(payloadLen > 0xffff) {
opp_error("RealworldApp: Encapsulating packet failed: packet too long");
}
*length = payloadLen;
return payload;
}
virtual bool RealworldApp::isApp ( )
inlineprotectedvirtual

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

Returns
true

Reimplemented from RealworldConnector.

Definition at line 69 of file RealworldApp.h.

{return true;}

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