INET Framework for OMNeT++/OMNEST
InterfaceStateManager Class Reference

#include <InterfaceStateManager.h>

Inheritance diagram for InterfaceStateManager:
IScriptable

List of all members.

Public Member Functions

void changeInterfaceState (InterfaceEntry *targetInt, bool toDown)

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)
virtual void processCommand (const cXMLElement &node)

Private Attributes

IInterfaceTableift
 Provides access to the interface table.

Detailed Description

This module allows managing changes of interface states in AnsaRouter. It can receive XML command from ScenarioManger and accomplish all necessary steps. Now, it supports 2 command: 1. Change of interface state to UP <interfaceup module="R1.interfaceStateManager" int="eth0"> 2. Change of interface state to DOWN <interfacedown module="R1.interfaceStateManager" int="eth0">

Definition at line 38 of file InterfaceStateManager.h.


Member Function Documentation

void InterfaceStateManager::changeInterfaceState ( InterfaceEntry targetInt,
bool  toDown 
)

Definition at line 72 of file InterfaceStateManager.cc.

Referenced by processCommand(), AnsaPPP::receiveChangeNotification(), and AnsaEtherMACBase::receiveChangeNotification().

{
  Enter_Method_Silent();
  
  if(targetInt != NULL)
  {
    bool isDown = targetInt->isDown();
    if(!isDown && toDown)
      targetInt->setDown(true);
    else
      if(isDown && !toDown)
        targetInt->setDown(false);
  }
  else
    EV << "Interface NOT found\n";
}
void InterfaceStateManager::handleMessage ( cMessage *  msg) [protected, virtual]

Definition at line 32 of file InterfaceStateManager.cc.

{
    ASSERT(false);
}
void InterfaceStateManager::initialize ( ) [protected, virtual]

Definition at line 24 of file InterfaceStateManager.cc.

{
    ift = InterfaceTableAccess().get();
    if (ift == NULL){
       throw cRuntimeError("AnsaInterfaceTable not found");
    }
}
void InterfaceStateManager::processCommand ( const cXMLElement &  node) [protected, virtual]

Called by ScenarioManager whenever a script command needs to be carried out by the module.

The command is represented by the XML element or element tree. The command name can be obtained as:

 const char *command = node->getTagName()
 

Parameters are XML attributes, e.g. a "neighbour" parameter can be retrieved as:

 const char *attr = node->getAttribute("neighbour")
 

More complex input can be passed in child elements.

See also:
cXMLElement

Implements IScriptable.

Definition at line 42 of file InterfaceStateManager.cc.

{
   if (!strcmp(node.getTagName(), "interfacedown"))
    {
      InterfaceEntry *targetInt = ift->getInterfaceByName(node.getAttribute("int"));
      EV << "interface " << node.getAttribute("int") << " is going DOWN" << endl;
      if (targetInt == NULL){
         throw cRuntimeError("Interface %s not found", node.getAttribute("int"));
      }
      changeInterfaceState(targetInt, true);
    }
    else if(!strcmp(node.getTagName(), "interfaceup"))
    {
      InterfaceEntry *targetInt = ift->getInterfaceByName(node.getAttribute("int"));
      EV << "interface " << node.getAttribute("int") << " is going UP" << endl;
      if (targetInt == NULL){
         throw cRuntimeError("Interface %s not found", node.getAttribute("int"));
      }
      changeInterfaceState(targetInt, false);
    }
    else
        ASSERT(false);

}

Member Data Documentation

Provides access to the interface table.

Definition at line 42 of file InterfaceStateManager.h.

Referenced by initialize(), and processCommand().


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