INET Framework for OMNeT++/OMNEST
inet::VirtualTunnel Class Reference

#include <VirtualTunnel.h>

Inheritance diagram for inet::VirtualTunnel:
inet::queueing::PassivePacketSinkBase inet::queueing::PacketSinkBase inet::queueing::IPassivePacketSink inet::queueing::PacketProcessorBase inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver

Public Member Functions

virtual ~VirtualTunnel ()
 
- Public Member Functions inherited from inet::queueing::PassivePacketSinkBase
virtual bool supportsPacketPushing (cGate *gate) const override
 Returns true if the processor supports pushing packets at the given gate. More...
 
virtual bool supportsPacketPulling (cGate *gate) const override
 Returns true if the processor supports pulling packets at the given gate. More...
 
virtual bool canPushSomePacket (cGate *gate) const override
 Returns false if the packet sink is full at the given gate and no more packets can be pushed into it without raising an error. More...
 
virtual bool canPushPacket (Packet *packet, cGate *gate) const override
 Returns true if the given packet can be pushed at the given gate into the packet sink without raising an error. More...
 
virtual void pushPacketStart (Packet *packet, cGate *gate, bps datarate) override
 Starts pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketEnd (Packet *packet, cGate *gate) override
 Ends pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength=b(0)) override
 Progresses pushing the packet into the packet sink at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::PacketProcessorBase
virtual bool supportsPacketSending (cGate *gate) const override
 Returns true if the processor supports sending packets at the given gate. More...
 
virtual bool supportsPacketPassing (cGate *gate) const override
 Returns true if the processor supports passing packets as a whole at the given gate. More...
 
virtual bool supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming packets at the given gate. More...
 
virtual const char * resolveDirective (char directive) const override
 
- Public Member Functions inherited from inet::queueing::IPacketProcessor
virtual ~IPacketProcessor ()
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSink
virtual ~IPassivePacketSink ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *message) override
 
virtual void pushPacket (Packet *packet, cGate *gate) override
 Pushes the packet into the packet sink at the given gate. More...
 
- Protected Member Functions inherited from inet::queueing::PacketProcessorBase
virtual void refreshDisplay () const override
 
virtual void handlePacketProcessed (Packet *packet)
 
virtual void checkPacketOperationSupport (cGate *gate) const
 
virtual void checkPacketOperationSupport (cGate *startGate, cGate *endGate) const
 
virtual void animate (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacket (Packet *packet, cGate *gate, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, long transmissionId, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions, Action action) const
 
virtual void pushOrSendPacket (Packet *packet, cGate *gate, IPassivePacketSink *consumer)
 
virtual void pushOrSendPacketStart (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
 
virtual void pushOrSendPacketEnd (Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
 
virtual void pushOrSendPacketProgress (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, b position, b extraProcessableLength, int transmissionId)
 
virtual void animatePush (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacket (Packet *packet, cGate *gate) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void animatePull (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacket (Packet *packet, cGate *gate) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void dropPacket (Packet *packet, PacketDropReason reason, int limit=-1)
 
virtual void updateDisplayString () const
 

Protected Attributes

NetworkInterfacerealNetworkInterface = nullptr
 
NetworkInterfacenetworkInterface = nullptr
 
const Protocolprotocol = nullptr
 
int vlanId = -1
 
ISocketsocket = nullptr
 
- Protected Attributes inherited from inet::queueing::PassivePacketSinkBase
cGate * inputGate = nullptr
 
IActivePacketSourceproducer = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Additional Inherited Members

- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Constructor & Destructor Documentation

◆ ~VirtualTunnel()

virtual inet::VirtualTunnel::~VirtualTunnel ( )
inlinevirtual
63 { delete socket; }

Member Function Documentation

◆ handleMessage()

void inet::VirtualTunnel::handleMessage ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::queueing::PassivePacketSinkBase.

80 {
81  if (socket->belongsToSocket(message))
82  socket->processMessage(message);
83  else {
84  auto packet = check_and_cast<Packet *>(message);
85  if (vlanId != -1)
86  packet->addTagIfAbsent<VlanReq>()->setVlanId(vlanId);
87  packet->addTagIfAbsent<MacAddressReq>()->setSrcAddress(networkInterface->getMacAddress());
88  socket->send(packet);
89  }
90 }

Referenced by pushPacket().

◆ initialize()

void inet::VirtualTunnel::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::queueing::PassivePacketSinkBase.

23 {
24  if (stage == INITSTAGE_LOCAL) {
25  vlanId = par("vlanId");
27  const char *protocolAsString = par("protocol");
28  if (*protocolAsString != '\0')
29  protocol = Protocol::findProtocol(protocolAsString);
30  }
32  auto interfaceTable = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
33  realNetworkInterface = CHK(interfaceTable->findInterfaceByName(par("realInterface")));
34  const char *addressString = par("address");
35  MacAddress address;
36  if (!strcmp(addressString, "auto"))
38  else if (!strcmp(addressString, "copy"))
40  else
41  address = MacAddress(addressString);
43  networkInterface->setInterfaceToken(address.formInterfaceIdentifier());
47  }
48  else if (stage == INITSTAGE_LINK_LAYER) {
49  // KLUDGE depends on other interface
50  if (!strcmp(par("address"), "copy"))
52  if (false) ;
53 #ifdef INET_WITH_ETHERNET
54  else if (protocol == &Protocol::ethernetMac) {
55  auto ethernetSocket = new EthernetSocket();
56  ethernetSocket->setCallback(this);
57  ethernetSocket->setOutputGate(gate("upperLayerOut"));
58  ethernetSocket->setNetworkInterface(realNetworkInterface);
59  ethernetSocket->bind(networkInterface->getMacAddress(), MacAddress(), nullptr, par("steal"));
60  socket = ethernetSocket;
61  }
62 #endif
63 #ifdef INET_WITH_IEEE8021Q
65  auto ieee8021qSocket = new Ieee8021qSocket();
66  ieee8021qSocket->setCallback(this);
67  ieee8021qSocket->setOutputGate(gate("upperLayerOut"));
68  ieee8021qSocket->setNetworkInterface(realNetworkInterface);
69  ieee8021qSocket->setProtocol(protocol);
70  ieee8021qSocket->bind(nullptr, vlanId, par("steal"));
71  socket = ieee8021qSocket;
72  }
73 #endif
74  else
75  throw cRuntimeError("Unknown protocol");
76  }
77 }

◆ numInitStages()

virtual int inet::VirtualTunnel::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::queueing::PacketProcessorBase.

45 { return NUM_INIT_STAGES; }

◆ pushPacket()

void inet::VirtualTunnel::pushPacket ( Packet packet,
cGate *  gate 
)
overrideprotectedvirtual

Pushes the packet into the packet sink at the given gate.

This operation pushes the packet as a whole. The onwership of the packet is transferred to the sink.

This method is called, for example, when a packet source module pushes a packet into a queue module.

The sink must not be full at the gate. The packet must not be nullptr. The gate must be a valid gate of this module and it must support pushing and passing packets.

Implements inet::queueing::IPassivePacketSink.

93 {
94  Enter_Method("pushPacket");
95  take(packet);
96  handleMessage(packet);
97 }

Member Data Documentation

◆ networkInterface

NetworkInterface* inet::VirtualTunnel::networkInterface = nullptr
protected

Referenced by handleMessage(), and initialize().

◆ protocol

const Protocol* inet::VirtualTunnel::protocol = nullptr
protected

Referenced by initialize().

◆ realNetworkInterface

NetworkInterface* inet::VirtualTunnel::realNetworkInterface = nullptr
protected

Referenced by initialize().

◆ socket

ISocket* inet::VirtualTunnel::socket = nullptr
protected

◆ vlanId

int inet::VirtualTunnel::vlanId = -1
protected

Referenced by handleMessage(), and initialize().


The documentation for this class was generated from the following files:
inet::VirtualTunnel::realNetworkInterface
NetworkInterface * realNetworkInterface
Definition: VirtualTunnel.h:37
CHK
#define CHK(x)
Definition: INETDefs.h:87
inet::ISocket::processMessage
virtual void processMessage(cMessage *msg)=0
Examines the message, takes ownership, and updates socket state.
inet::VirtualTunnel::protocol
const Protocol * protocol
Definition: VirtualTunnel.h:39
inet::NetworkInterface::getMacAddress
const MacAddress & getMacAddress() const
Definition: NetworkInterface.h:245
inet::NetworkInterface::setMulticast
virtual void setMulticast(bool b)
Definition: NetworkInterface.h:259
inet::NetworkInterface::isBroadcast
bool isBroadcast() const
Definition: NetworkInterface.h:238
inet::NetworkInterface::setBroadcast
virtual void setBroadcast(bool b)
Definition: NetworkInterface.h:258
inet::getContainingNicModule
NetworkInterface * getContainingNicModule(const cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: NetworkInterface.cc:691
inet::ISocket::send
virtual void send(Packet *packet)=0
inet::NetworkInterface::setMacAddress
virtual void setMacAddress(const MacAddress &addr)
Definition: NetworkInterface.h:263
inet::INITSTAGE_NETWORK_INTERFACE_CONFIGURATION
INET_API InitStage INITSTAGE_NETWORK_INTERFACE_CONFIGURATION
Initialization of network interfaces includes:
inet::MacAddress::generateAutoAddress
static MacAddress generateAutoAddress()
Generates a unique address which begins with 0a:aa and ends in a unique suffix.
Definition: MacAddress.cc:133
inet::NetworkInterface::setInterfaceToken
virtual void setInterfaceToken(const InterfaceToken &t)
Definition: NetworkInterface.h:264
inet::Protocol::ethernetMac
static const Protocol ethernetMac
Definition: Protocol.h:65
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::VirtualTunnel::handleMessage
virtual void handleMessage(cMessage *message) override
Definition: VirtualTunnel.cc:79
inet::Protocol::ieee8021qSTag
static const Protocol ieee8021qSTag
Definition: Protocol.h:86
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::NetworkInterface::isMulticast
bool isMulticast() const
Definition: NetworkInterface.h:239
inet::NetworkInterface::isPointToPoint
bool isPointToPoint() const
Definition: NetworkInterface.h:240
inet::NetworkInterface::setPointToPoint
virtual void setPointToPoint(bool b)
Definition: NetworkInterface.h:260
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::VirtualTunnel::networkInterface
NetworkInterface * networkInterface
Definition: VirtualTunnel.h:38
inet::VirtualTunnel::socket
ISocket * socket
Definition: VirtualTunnel.h:42
inet::ISocket::belongsToSocket
virtual bool belongsToSocket(cMessage *msg) const =0
Returns true if the message belongs to this socket.
inet::VirtualTunnel::vlanId
int vlanId
Definition: VirtualTunnel.h:40
inet::Protocol::ieee8021qCTag
static const Protocol ieee8021qCTag
Definition: Protocol.h:85
inet::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
inet::Protocol::findProtocol
static const Protocol * findProtocol(int id)
Definition: Protocol.cc:44