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

#include <EthernetMacLayer.h>

Inheritance diagram for inet::EthernetMacLayer:

Public Member Functions

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

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 

Member Function Documentation

◆ initialize()

void inet::EthernetMacLayer::initialize ( int  stage)
overrideprotectedvirtual
20 {
21  cModule::initialize(stage);
22  if (stage == INITSTAGE_LINK_LAYER) {
23  auto networkInterface = getContainingNicModule(this);
24  auto interfaceTable = check_and_cast<cModule *>(networkInterface->getInterfaceTable());
25  interfaceTable->subscribe(interfaceStateChangedSignal, this);
26  }
27 }

◆ numInitStages()

virtual int inet::EthernetMacLayer::numInitStages ( ) const
inlineoverrideprotectedvirtual
18 { return NUM_INIT_STAGES; }

◆ receiveSignal()

void inet::EthernetMacLayer::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
30 {
31  if (signal == interfaceStateChangedSignal) {
32  auto networkInterface = getContainingNicModule(this);
33  auto networkInterfaceChangeDetails = check_and_cast<const NetworkInterfaceChangeDetails *>(object);
34  if (networkInterfaceChangeDetails->getNetworkInterface() == networkInterface && networkInterfaceChangeDetails->getFieldId() == NetworkInterface::F_CARRIER) {
35  if (!networkInterface->hasCarrier()) {
36  auto queue = check_and_cast<IPacketQueue *>(getSubmodule("queue"));
37  if (queue != nullptr)
38  queue->removeAllPackets();
39  }
40  }
41  }
42  else
43  throw cRuntimeError("Unknown signal");
44 }

The documentation for this class was generated from the following files:
inet::getContainingNicModule
NetworkInterface * getContainingNicModule(const cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: NetworkInterface.cc:691
inet::NetworkInterface::F_CARRIER
@ F_CARRIER
Definition: NetworkInterface.h:146
inet::interfaceStateChangedSignal
simsignal_t interfaceStateChangedSignal
Definition: Simsignals.cc:32
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.