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, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual void prepareNode ()
 
virtual void prepareInterface (InterfaceEntry *interfaceEntry)
 
virtual void configureNode ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 

Protected Attributes

NodeStatusnodeStatus
 
IInterfaceTableinterfaceTable
 
L2NetworkConfiguratornetworkConfigurator
 

Detailed Description

Configures L2 data of a node.

See the NED definition for details.

Constructor & Destructor Documentation

inet::L2NodeConfigurator::L2NodeConfigurator ( )
26 {
27  nodeStatus = nullptr;
28  interfaceTable = nullptr;
29  networkConfigurator = nullptr;
30 }
IInterfaceTable * interfaceTable
Definition: L2NodeConfigurator.h:34
L2NetworkConfigurator * networkConfigurator
Definition: L2NodeConfigurator.h:35
NodeStatus * nodeStatus
Definition: L2NodeConfigurator.h:33

Member Function Documentation

void inet::L2NodeConfigurator::configureNode ( )
protectedvirtual

Referenced by handleOperationStage().

75 {
76  ASSERT(networkConfigurator);
77  // std::cout << "configureNode(): " << interfaceTable->getNumInterfaces() << endl;
78  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++)
80 }
IInterfaceTable * interfaceTable
Definition: L2NodeConfigurator.h:34
void configureInterface(InterfaceInfo *interfaceInfo)
Definition: L2NetworkConfigurator.cc:278
L2NetworkConfigurator * networkConfigurator
Definition: L2NodeConfigurator.h:35
virtual int getNumInterfaces() const =0
Returns the number of interfaces.
virtual InterfaceEntry * getInterface(int pos) const =0
Returns the InterfaceEntry specified by an index 0..numInterfaces-1.
virtual void inet::L2NodeConfigurator::handleMessage ( cMessage *  msg)
inlineoverrideprotectedvirtual
42 { throw cRuntimeError("this module doesn't handle messages, it runs only in initialize()"); }
bool inet::L2NodeConfigurator::handleOperationStage ( LifecycleOperation operation,
int  stage,
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.

44 {
45  Enter_Method_Silent();
46  if (dynamic_cast<NodeStartOperation *>(operation)) {
48  prepareNode();
49  configureNode();
50  }
51  }
52  else if (dynamic_cast<NodeShutdownOperation *>(operation))
53  /*nothing to do*/;
54  else if (dynamic_cast<NodeCrashOperation *>(operation))
55  /*nothing to do*/;
56  else
57  throw cRuntimeError("Unsupported lifecycle operation '%s'", operation->getClassName());
58  return true;
59 }
Definition: NodeOperations.h:49
virtual void configureNode()
Definition: L2NodeConfigurator.cc:74
virtual void prepareNode()
Definition: L2NodeConfigurator.cc:61
Stage
Definition: NodeOperations.h:46
void inet::L2NodeConfigurator::initialize ( int  stage)
overrideprotectedvirtual
33 {
34  if (stage == INITSTAGE_LOCAL) {
35  cModule *host = getContainingNode(this);
36  nodeStatus = dynamic_cast<NodeStatus *>(host->getSubmodule("status"));
37  interfaceTable = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
38  networkConfigurator = findModuleFromPar<L2NetworkConfigurator>(par("l2ConfiguratorModule"), this);
39  host->subscribe(NF_INTERFACE_CREATED, this);
40  }
41 }
IInterfaceTable * interfaceTable
Definition: L2NodeConfigurator.h:34
L2NetworkConfigurator * networkConfigurator
Definition: L2NodeConfigurator.h:35
Local initializations.
Definition: InitStages.h:35
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
simsignal_t NF_INTERFACE_CREATED
Definition: NotifierConsts.cc:48
NodeStatus * nodeStatus
Definition: L2NodeConfigurator.h:33
virtual int inet::L2NodeConfigurator::numInitStages ( ) const
inlineoverrideprotectedvirtual
41 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::L2NodeConfigurator::prepareInterface ( InterfaceEntry interfaceEntry)
protectedvirtual

Referenced by prepareNode(), and receiveSignal().

68 {
69  ASSERT(!interfaceEntry->ieee8021dData());
70  Ieee8021dInterfaceData *ieee8021dInterfaceData = new Ieee8021dInterfaceData();
71  interfaceEntry->setIeee8021dInterfaceData(ieee8021dInterfaceData);
72 }
void inet::L2NodeConfigurator::prepareNode ( )
protectedvirtual

Referenced by handleOperationStage().

62 {
63  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++)
65 }
IInterfaceTable * interfaceTable
Definition: L2NodeConfigurator.h:34
virtual int getNumInterfaces() const =0
Returns the number of interfaces.
virtual InterfaceEntry * getInterface(int pos) const =0
Returns the InterfaceEntry specified by an index 0..numInterfaces-1.
virtual void prepareInterface(InterfaceEntry *interfaceEntry)
Definition: L2NodeConfigurator.cc:67
void inet::L2NodeConfigurator::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
cObject *  obj,
cObject *  details 
)
overrideprotectedvirtual
83 {
85  return;
86 
87  if (signalID == NF_INTERFACE_CREATED) {
88  InterfaceEntry *ie = check_and_cast<InterfaceEntry *>(obj);
89  prepareInterface(ie);
92  }
93 }
void configureInterface(InterfaceInfo *interfaceInfo)
Definition: L2NetworkConfigurator.cc:278
L2NetworkConfigurator * networkConfigurator
Definition: L2NodeConfigurator.h:35
simsignal_t NF_INTERFACE_CREATED
Definition: NotifierConsts.cc:48
NodeStatus * nodeStatus
Definition: L2NodeConfigurator.h:33
virtual void prepareInterface(InterfaceEntry *interfaceEntry)
Definition: L2NodeConfigurator.cc:67
virtual State getState() const
Definition: NodeStatus.h:48
Definition: NodeStatus.h:40

Member Data Documentation

IInterfaceTable* inet::L2NodeConfigurator::interfaceTable
protected
L2NetworkConfigurator* inet::L2NodeConfigurator::networkConfigurator
protected
NodeStatus* inet::L2NodeConfigurator::nodeStatus
protected

The documentation for this class was generated from the following files: