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

Configures L2 data of a node. More...

#include <L2NodeConfigurator.h>

Inheritance diagram for inet::L2NodeConfigurator:
inet::ILifecycle

Public Member Functions

 L2NodeConfigurator ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void initialize (int stage) override
 
virtual bool handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual void prepareNode ()
 
virtual void prepareInterface (NetworkInterface *networkInterface)
 
virtual void configureNode ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 

Protected Attributes

opp_component_ptr< NodeStatusnodeStatus
 
ModuleRefByPar< IInterfaceTableinterfaceTable
 
ModuleRefByPar< L2NetworkConfiguratornetworkConfigurator
 

Detailed Description

Configures L2 data of a node.

See the NED definition for details.

Constructor & Destructor Documentation

◆ L2NodeConfigurator()

inet::L2NodeConfigurator::L2NodeConfigurator ( )
19 {
20 }

Member Function Documentation

◆ configureNode()

void inet::L2NodeConfigurator::configureNode ( )
protectedvirtual
64 {
65 // std::cout << "configureNode(): " << interfaceTable->getNumInterfaces() << endl;
66  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++)
67  networkConfigurator->configureInterface(interfaceTable->getInterface(i));
68 }

Referenced by handleOperationStage().

◆ handleMessage()

virtual void inet::L2NodeConfigurator::handleMessage ( cMessage *  msg)
inlineoverrideprotectedvirtual
33 { throw cRuntimeError("this module doesn't handle messages, it runs only in initialize()"); }

◆ handleOperationStage()

bool inet::L2NodeConfigurator::handleOperationStage ( LifecycleOperation operation,
IDoneCallback doneCallback 
)
overrideprotectedvirtual

Perform one stage of a lifecycle operation.

Processing may be done entirely within this method, or may be a longer process that involves nonzero simulation time or several events, and is triggered by this method call.

Return value: true = "done"; false = "not yet done, will invoke doneCallback when done"

Implements inet::ILifecycle.

34 {
35  Enter_Method("handleOperationStage");
36  if (dynamic_cast<ModuleStartOperation *>(operation)) {
37  if (static_cast<ModuleStartOperation::Stage>(operation->getCurrentStage()) == ModuleStartOperation::STAGE_LINK_LAYER) {
38  prepareNode();
39  configureNode();
40  }
41  }
42  else if (dynamic_cast<ModuleStopOperation *>(operation))
43  /*nothing to do*/;
44  else if (dynamic_cast<ModuleCrashOperation *>(operation))
45  /*nothing to do*/;
46  else
47  throw cRuntimeError("Unsupported lifecycle operation '%s'", operation->getClassName());
48  return true;
49 }

◆ initialize()

void inet::L2NodeConfigurator::initialize ( int  stage)
overrideprotectedvirtual
23 {
24  if (stage == INITSTAGE_LOCAL) {
25  cModule *host = getContainingNode(this);
26  nodeStatus = dynamic_cast<NodeStatus *>(host->getSubmodule("status"));
27  interfaceTable.reference(this, "interfaceTableModule", true);
28  networkConfigurator.reference(this, "l2ConfiguratorModule", false);
29  host->subscribe(interfaceCreatedSignal, this);
30  }
31 }

◆ numInitStages()

virtual int inet::L2NodeConfigurator::numInitStages ( ) const
inlineoverrideprotectedvirtual
32 { return NUM_INIT_STAGES; }

◆ prepareInterface()

void inet::L2NodeConfigurator::prepareInterface ( NetworkInterface networkInterface)
protectedvirtual
58 {
59 // ASSERT(!networkInterface->getProtocolData<Ieee8021dInterfaceData>());
60  networkInterface->addProtocolData<Ieee8021dInterfaceData>();
61 }

Referenced by prepareNode(), and receiveSignal().

◆ prepareNode()

void inet::L2NodeConfigurator::prepareNode ( )
protectedvirtual
52 {
53  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++)
54  prepareInterface(interfaceTable->getInterface(i));
55 }

Referenced by handleOperationStage().

◆ receiveSignal()

void inet::L2NodeConfigurator::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
cObject *  obj,
cObject *  details 
)
overrideprotectedvirtual
71 {
72  Enter_Method("%s", cComponent::getSignalName(signalID));
73 
74  if (nodeStatus && nodeStatus->getState() != NodeStatus::UP)
75  return;
76 
77  if (signalID == interfaceCreatedSignal) {
78  NetworkInterface *ie = check_and_cast<NetworkInterface *>(obj);
79  prepareInterface(ie);
81  networkConfigurator->configureInterface(ie);
82  }
83 }

Member Data Documentation

◆ interfaceTable

ModuleRefByPar<IInterfaceTable> inet::L2NodeConfigurator::interfaceTable
protected

◆ networkConfigurator

ModuleRefByPar<L2NetworkConfigurator> inet::L2NodeConfigurator::networkConfigurator
protected

◆ nodeStatus

opp_component_ptr<NodeStatus> inet::L2NodeConfigurator::nodeStatus
protected

Referenced by initialize(), and receiveSignal().


The documentation for this class was generated from the following files:
inet::getContainingNode
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
inet::L2NodeConfigurator::nodeStatus
opp_component_ptr< NodeStatus > nodeStatus
Definition: L2NodeConfigurator.h:24
inet::ModuleStartOperation::Stage
Stage
Definition: ModuleOperations.h:25
inet::L2NodeConfigurator::configureNode
virtual void configureNode()
Definition: L2NodeConfigurator.cc:63
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::L2NodeConfigurator::networkConfigurator
ModuleRefByPar< L2NetworkConfigurator > networkConfigurator
Definition: L2NodeConfigurator.h:26
inet::NodeStatus::UP
@ UP
Definition: NodeStatus.h:28
inet::L2NodeConfigurator::interfaceTable
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: L2NodeConfigurator.h:25
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::L2NodeConfigurator::prepareNode
virtual void prepareNode()
Definition: L2NodeConfigurator.cc:51
inet::L2NodeConfigurator::prepareInterface
virtual void prepareInterface(NetworkInterface *networkInterface)
Definition: L2NodeConfigurator.cc:57
inet::ModuleStartOperation::STAGE_LINK_LAYER
@ STAGE_LINK_LAYER
Definition: ModuleOperations.h:28
inet::interfaceCreatedSignal
simsignal_t interfaceCreatedSignal
Definition: Simsignals.cc:30