#include <RealworldApp.h>
Inheritance diagram for RealworldApp:
Public Member Functions | |
Module_Class_Members (RealworldApp, RealworldConnector, 0) | |
Protected Member Functions | |
virtual char * | encapsulate (cMessage *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 cMessage * | 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". |
char * RealworldApp::encapsulate | ( | cMessage * | msg, | |
unsigned int * | length, | |||
sockaddr ** | addr, | |||
socklen_t * | addrlen | |||
) | [protected, virtual] |
Converts an IP datagram to a data block for sending it to the (realworld) network.
msg | A pointer to the message to be converted | |
length | A pointer to an int that will hold the length of the converted data | |
addr | Ignored (set to 0) | |
addrlen | Ignored (set to 0) |
Implements RealworldConnector.
00034 { 00035 unsigned int payloadLen; 00036 *addr = 0; 00037 *addrlen = 0; 00038 00039 // parse payload 00040 char* payload = parser->encapsulatePayload(msg, &payloadLen); 00041 if (!payload ) 00042 return NULL; 00043 00044 if(payloadLen > 0xffff) { 00045 opp_error("RealworldApp: Encapsulating packet failed: packet too long"); 00046 } 00047 *length = payloadLen; 00048 00049 return payload; 00050 }
cMessage * RealworldApp::decapsulate | ( | char * | buf, | |
uint32_t | length, | |||
sockaddr * | addr, | |||
socklen_t | addrlen | |||
) | [protected, virtual] |
Parses data received from the (realworld) network and converts it into a cMessage.
buf | A pointer to the data to be parsed | |
length | The lenght of the buffer in bytes | |
addr | Ignored (deleted) | |
addrlen | Ignored |
Implements RealworldConnector.
00056 { 00057 cMessage* payload = 0; 00058 // "Decode" packet: 16bit payload length|payload 00059 payload = parser->decapsulatePayload( buf, length ); 00060 if (!payload) { 00061 ev << "RealworldApp: Parsing of Payload failed, dropping packet.\n"; 00062 } 00063 00064 delete buf; 00065 return payload; 00066 delete addr; 00067 }
virtual bool RealworldApp::isApp | ( | ) | [inline, protected, virtual] |
The Connector connects to an application, so this method to returns "true".
Reimplemented from RealworldConnector.
RealworldApp::Module_Class_Members | ( | RealworldApp | , | |
RealworldConnector | , | |||
0 | ||||
) |