|
INET Framework for OMNeT++/OMNEST
|
#include <TunLoopbackApp.h>
◆ finish()
| void inet::TunLoopbackApp::finish |
( |
| ) |
|
|
overrideprotected |
◆ handleMessage()
| void inet::TunLoopbackApp::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotected |
43 if (message->arrivedOn(
"socketIn")) {
44 EV_INFO <<
"Message " << message->getName() <<
" arrived from tun. " <<
packetsReceived + 1 <<
" packets received so far\n";
47 Packet *packet = check_and_cast<Packet *>(message);
50 if (packetProtocol != networkProtocol)
51 throw cRuntimeError(
"Cannot handle packet");
54 const auto& transportProtocol = *networkHeader->getProtocol();
57 unsigned int destPort = transportHeader->getDestinationPort();
58 transportHeader->setDestinationPort(transportHeader->getSourcePort());
59 transportHeader->setSourcePort(destPort);
60 L3Address destAddr = networkHeader->getDestinationAddress();
61 networkHeader->setDestinationAddress(networkHeader->getSourceAddress());
62 networkHeader->setSourceAddress(destAddr);
67 delete message->removeControlInfo();
73 throw cRuntimeError(
"Unknown message: %s", message->getName());
◆ initialize()
| void inet::TunLoopbackApp::initialize |
( |
int |
stage | ) |
|
|
overrideprotected |
25 cSimpleModule::initialize(stage);
32 IInterfaceTable *interfaceTable = getModuleFromPar<IInterfaceTable>(par(
"interfaceTableModule"),
this);
33 NetworkInterface *networkInterface = interfaceTable->findInterfaceByName(
tunInterface);
34 if (networkInterface ==
nullptr)
35 throw cRuntimeError(
"TUN interface not found: %s",
tunInterface);
◆ numInitStages()
| virtual int inet::TunLoopbackApp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ packetsReceived
| unsigned int inet::TunLoopbackApp::packetsReceived = 0 |
|
protected |
◆ packetsSent
| unsigned int inet::TunLoopbackApp::packetsSent = 0 |
|
protected |
◆ tunInterface
| const char* inet::TunLoopbackApp::tunInterface = nullptr |
|
protected |
◆ tunSocket
The documentation for this class was generated from the following files:
void open(int interfaceId)
Definition: TunSocket.cc:56
unsigned int packetsReceived
Definition: TunLoopbackApp.h:21
const Protocol & getPacketProtocol(Packet *packet)
Definition: ProtocolTools.cc:18
void insertNetworkProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< NetworkHeaderBase > &header)
Definition: L3Tools.cc:70
const char * tunInterface
Definition: TunLoopbackApp.h:18
void insertTransportProtocolHeader(Packet *packet, const Protocol &protocol, const Ptr< TransportHeaderBase > &header)
Definition: L4Tools.cc:77
const Ptr< TransportHeaderBase > removeTransportProtocolHeader(Packet *packet, const Protocol &protocol)
Definition: L4Tools.cc:85
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
TunSocket tunSocket
Definition: TunLoopbackApp.h:23
unsigned int packetsSent
Definition: TunLoopbackApp.h:20
void setOutputGate(cGate *outputGate)
Sets the gate on which to send raw packets.
Definition: TunSocket.h:45
INET_API InitStage INITSTAGE_APPLICATION_LAYER
Initialization of applications.
const Ptr< NetworkHeaderBase > removeNetworkProtocolHeader(Packet *packet, const Protocol &protocol)
Definition: L3Tools.cc:78
const Protocol & getNetworkProtocol(Packet *packet)
Definition: L3Tools.cc:28
virtual void send(Packet *packet) override
Definition: TunSocket.cc:66