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

#include <CarrierBasedLifeTimer.h>

Inheritance diagram for inet::CarrierBasedLifeTimer:

Public Member Functions

virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *obj, cObject *details) override
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void clearCollection ()
 

Protected Attributes

opp_component_ptr< NetworkInterfacenetworkInterface
 
ModuleRefByPar< IPacketCollectionpacketCollection
 

Member Function Documentation

◆ clearCollection()

void inet::CarrierBasedLifeTimer::clearCollection ( )
protectedvirtual
31 {
32  while (!packetCollection->isEmpty()) {
33  auto packet = packetCollection->getPacket(0);
34  packetCollection->removePacket(packet);
35  EV_WARN << "Dropping packet because interface has no carrier" << EV_FIELD(packet) << EV_ENDL;
36  PacketDropDetails details;
37  details.setReason(INTERFACE_DOWN);
38  emit(packetDroppedSignal, packet, &details);
39  delete packet;
40  }
41 }

Referenced by receiveSignal().

◆ initialize()

void inet::CarrierBasedLifeTimer::initialize ( int  stage)
overrideprotectedvirtual
20 {
21  if (stage == INITSTAGE_LOCAL) {
24  packetCollection.reference(this, "collectionModule", true);
25  auto packetCollectionModule = check_and_cast<cModule *>(packetCollection.get());
26  packetCollectionModule->subscribe(packetPushedSignal, this);
27  }
28 }

◆ receiveSignal()

void inet::CarrierBasedLifeTimer::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  obj,
cObject *  details 
)
overridevirtual
44 {
45  Enter_Method("%s", cComponent::getSignalName(signal));
46 
47  if (signal == interfaceStateChangedSignal) {
48  auto interfaceChangeDetails = check_and_cast<NetworkInterfaceChangeDetails *>(details);
49  if (interfaceChangeDetails->getFieldId() == NetworkInterface::F_CARRIER && !networkInterface->hasCarrier())
51  }
52  else if (signal == packetPushedSignal) {
53  if (!networkInterface->hasCarrier())
55  }
56  else
57  throw cRuntimeError("Unknown signal");
58 }

Member Data Documentation

◆ networkInterface

opp_component_ptr<NetworkInterface> inet::CarrierBasedLifeTimer::networkInterface
protected

Referenced by initialize(), and receiveSignal().

◆ packetCollection

ModuleRefByPar<IPacketCollection> inet::CarrierBasedLifeTimer::packetCollection
protected

Referenced by clearCollection(), and initialize().


The documentation for this class was generated from the following files:
inet::CarrierBasedLifeTimer::networkInterface
opp_component_ptr< NetworkInterface > networkInterface
Definition: CarrierBasedLifeTimer.h:21
inet::CarrierBasedLifeTimer::packetCollection
ModuleRefByPar< IPacketCollection > packetCollection
Definition: CarrierBasedLifeTimer.h:22
inet::getContainingNicModule
NetworkInterface * getContainingNicModule(const cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: NetworkInterface.cc:691
inet::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
inet::CarrierBasedLifeTimer::clearCollection
virtual void clearCollection()
Definition: CarrierBasedLifeTimer.cc:30
inet::NetworkInterface::F_CARRIER
@ F_CARRIER
Definition: NetworkInterface.h:146
inet::packetPushedSignal
simsignal_t packetPushedSignal
Definition: Simsignals.cc:99
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::interfaceStateChangedSignal
simsignal_t interfaceStateChangedSignal
Definition: Simsignals.cc:32
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::INTERFACE_DOWN
@ INTERFACE_DOWN
Definition: Simsignals_m.h:72
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114