|
INET Framework for OMNeT++/OMNEST
|
#include <InterfaceStateManager.h>
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 | |
| IInterfaceTable * | ift |
| Provides access to the interface table. | |
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.
| void InterfaceStateManager::changeInterfaceState | ( | InterfaceEntry * | targetInt, |
| bool | toDown | ||
| ) |
Definition at line 72 of file InterfaceStateManager.cc.
Referenced by processCommand(), AnsaPPP::receiveChangeNotification(), and AnsaEtherMACBase::receiveChangeNotification().
| 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.
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);
}
IInterfaceTable* InterfaceStateManager::ift [private] |
Provides access to the interface table.
Definition at line 42 of file InterfaceStateManager.h.
Referenced by initialize(), and processCommand().