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

Base class for lifecycle operations that manipulate a network interface. More...

#include <InterfaceOperations.h>

Inheritance diagram for inet::InterfaceOperationBase:
inet::LifecycleOperation inet::InterfaceDownOperation inet::InterfaceUpOperation

Public Types

enum  Stage { STAGE_LOCAL, STAGE_LAST }
 
- Public Types inherited from inet::LifecycleOperation
typedef std::map< std::string, std::string > StringMap
 

Public Member Functions

 InterfaceOperationBase ()
 
virtual void initialize (cModule *module, StringMap &params)
 Initialize the operation using the parameters provided in the string map. More...
 
virtual int getNumStages () const
 Returns the number of stages required by this operation. More...
 
NetworkInterfacegetInterface () const
 
- Public Member Functions inherited from inet::LifecycleOperation
 LifecycleOperation ()
 
cModule * getRootModule () const
 Returns the module the operation is initiated on. More...
 
int getCurrentStage () const
 Returns the current stage, an integer in 0..numStages-1. More...
 

Private Attributes

NetworkInterfaceie
 

Detailed Description

Base class for lifecycle operations that manipulate a network interface.

Member Enumeration Documentation

◆ Stage

Enumerator
STAGE_LOCAL 
STAGE_LAST 

Constructor & Destructor Documentation

◆ InterfaceOperationBase()

inet::InterfaceOperationBase::InterfaceOperationBase ( )
inline
29 : ie(nullptr) {}

Member Function Documentation

◆ getInterface()

NetworkInterface* inet::InterfaceOperationBase::getInterface ( ) const
inline
32 { return ie; }

◆ getNumStages()

virtual int inet::InterfaceOperationBase::getNumStages ( ) const
inlinevirtual

Returns the number of stages required by this operation.

Implements inet::LifecycleOperation.

31 { return STAGE_LAST + 1; }

◆ initialize()

void inet::InterfaceOperationBase::initialize ( cModule *  module,
StringMap params 
)
virtual

Initialize the operation using the parameters provided in the string map.

The implementation should destructively modify the map, removing from it the parameters it understands. Ideally, the map should be empty when this method returns; if it is not, the caller should treat that as an error, and report the remaining parameters as unrecognized by the operation.

Reimplemented from inet::LifecycleOperation.

20 {
21  if (!isNetworkNode(module))
22  throw cRuntimeError("Interface operations may only be applied to network nodes (host, router, etc.)");
23 
24  LifecycleOperation::initialize(module, params);
25 
26  // note: these operations cannot be generic, because their ctor requires NetworkInterface as parameter
27  IInterfaceTable *ift = L3AddressResolver().findInterfaceTableOf(module);
28  if (!ift)
29  throw cRuntimeError("Interface table of network node '%s' not found, required for operation %s", module->getFullPath().c_str(), getClassName());
30  std::string interfaceName = params["interfacename"];
31  params.erase("interfacename"); // TODO implement "towards=..."
32  if (interfaceName.empty())
33  throw cRuntimeError("interfacename attribute missing, required for operation %s", getClassName());
34  NetworkInterface *ie = ift->findInterfaceByName(interfaceName.c_str());
35  if (!ie)
36  throw cRuntimeError("No interface named '%s', required for operation %s", interfaceName.c_str(), getClassName());
37 }

Member Data Documentation

◆ ie

NetworkInterface* inet::InterfaceOperationBase::ie
private

Referenced by initialize().


The documentation for this class was generated from the following files:
inet::InterfaceOperationBase::STAGE_LOCAL
@ STAGE_LOCAL
Definition: InterfaceOperations.h:23
inet::InterfaceOperationBase::ie
NetworkInterface * ie
Definition: InterfaceOperations.h:26
inet::isNetworkNode
bool isNetworkNode(const cModule *mod)
Returns true if the given module is a network node, i.e.
Definition: ModuleAccess.cc:18
inet::InterfaceOperationBase::STAGE_LAST
@ STAGE_LAST
Definition: InterfaceOperations.h:23
inet::LifecycleOperation::initialize
virtual void initialize(cModule *module, StringMap &params)
Initialize the operation using the parameters provided in the string map.
Definition: LifecycleOperation.h:49