|
INET Framework for OMNeT++/OMNEST
|
#include <stp.h>
Public Member Functions | |
| bool | learning (unsigned int, unsigned int) |
| bool | forwarding (unsigned int, unsigned int) |
| void | dispatchALL () |
| void | dispatch (unsigned int) |
| int | getInstanceIndex (unsigned int) |
| void | setBridgePriority (unsigned int, unsigned int) |
| void | setPortPriority (unsigned int, std::vector< unsigned int > &, std::vector< unsigned int > &) |
| void | setLinkCost (unsigned int, std::vector< unsigned int > &, std::vector< unsigned int > &) |
| void | setForwardDelay (unsigned int, unsigned int) |
| void | setMaxAge (unsigned int, unsigned int) |
| void | setHelloTime (unsigned int, unsigned int) |
Protected Member Functions | |
| virtual void | initialize (int stage) |
| virtual int | numInitStages () const |
| virtual void | handleMessage (cMessage *msg) |
| virtual void | finish () |
| void | handleSelfMessage (cMessage *msg) |
| void | handleBPDU (STPBPDU *bpdu) |
| void | handleTCN (STPTCN *tcn) |
| void | setPortPriority (unsigned int, unsigned int, unsigned int) |
| void | setLinkCost (unsigned int, unsigned int, unsigned int) |
Protected Attributes | |
| unsigned int | portCount |
| MACAddress | bridgeAddress |
| std::vector< unsigned int > | instReg |
| std::vector< stpi > | inst |
| cMessage * | tick |
| MACTable * | addrTable |
| void Stp::dispatch | ( | unsigned int | idx | ) |
Definition at line 49 of file stp.cc.
Referenced by dispatchALL(), handleBPDU(), and handleTCN().
| void Stp::dispatchALL | ( | ) |
| void Stp::finish | ( | ) | [protected, virtual] |
| bool Stp::forwarding | ( | unsigned int | port, |
| unsigned int | vlan | ||
| ) |
| int Stp::getInstanceIndex | ( | unsigned int | _inst | ) |
Definition at line 57 of file stp.cc.
Referenced by setBridgePriority(), setForwardDelay(), setHelloTime(), setLinkCost(), setMaxAge(), and setPortPriority().
| void Stp::handleBPDU | ( | STPBPDU * | bpdu | ) | [protected] |
| void Stp::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Definition at line 196 of file stp.cc.
{
cMessage * tmp = msg;
if (!msg->isSelfMessage()) {
if (dynamic_cast<STPBPDU *>(tmp)){ // Configuration BPDU
STPBPDU * bpdu = (STPBPDU *) tmp;
handleBPDU(bpdu);
} else if (dynamic_cast<STPTCN *>(tmp)){ // Topology Change Notification
STPTCN * tcn = (STPTCN *) tmp;
handleTCN(tcn);
} else { // Rubbish
delete msg;
}
} else {
handleSelfMessage(msg);
}
}
| void Stp::handleSelfMessage | ( | cMessage * | msg | ) | [protected] |
| void Stp::handleTCN | ( | STPTCN * | tcn | ) | [protected] |
| void Stp::initialize | ( | int | stage | ) | [protected, virtual] |
Definition at line 145 of file stp.cc.
{
if (stage == 0) {
portCount = gateSize("out");
tick = new cMessage("STP_TICK", 0);
/* connection to MAC Table for faster aging */
cModule * tmp_macTable = getParentModule()->getSubmodule("MACTable");
addrTable = check_and_cast<MACTable *>(tmp_macTable);
WATCH(bridgeAddress);
}
else if (stage == 1) {
/* obtain a Bridge Address from Core and initialize instances*/
cModule * tmp_core = getParentModule()->getSubmodule("core");
ANSASwitchCore * core = check_and_cast<ANSASwitchCore *>(tmp_core);
bridgeAddress = core->getBridgeAddress();
/* obtain a VLAN list for STP instances creation */
cModule * tmp_vlantable = getParentModule()->getSubmodule("VLANTable");
VLANTable * vlantable = check_and_cast<VLANTable *>(tmp_vlantable);
instReg = vlantable->getVLANList();
/* call init on all instances */
for (unsigned int i = 0; i < instReg.size(); i++) {
stpi tmp(instReg.at(i), portCount, bridgeAddress, addrTable);
inst.push_back(tmp);
}
const char *filename = par("configFile");
const char *switchID = par("switchID");
if (*filename == '\0' || *switchID == '\0') {
EV << "Warning: " << this->getParentModule()->getName() << ": Could not config, config filename or switchID is not set, using Default." << std::endl;
} else {
stpXMLparser config(this);
config.parse(filename, switchID);
}
WATCH_VECTOR(inst);
WATCH_VECTOR(instReg);
scheduleAt(simTime()+1, tick);
}
}
| bool Stp::learning | ( | unsigned int | port, |
| unsigned int | vlan | ||
| ) |
| virtual int Stp::numInitStages | ( | ) | const [inline, protected, virtual] |
| void Stp::setBridgePriority | ( | unsigned int | _inst, |
| unsigned int | _bridgePriority | ||
| ) |
Definition at line 66 of file stp.cc.
Referenced by stpXMLparser::parseSTP().
{
int idx = getInstanceIndex(_inst);
if (idx == -1) {
return;
}
inst.at(idx).bridgePriority = _bridgePriority;
}
| void Stp::setForwardDelay | ( | unsigned int | _inst, |
| unsigned int | _fwdDelay | ||
| ) |
Definition at line 117 of file stp.cc.
Referenced by stpXMLparser::parseSTP().
{
int idx = getInstanceIndex(_inst);
if (idx == -1) {
return;
}
inst.at(idx).fwdDelay = _fwdDelay;
}
| void Stp::setHelloTime | ( | unsigned int | _inst, |
| unsigned int | _helloTime | ||
| ) |
Definition at line 134 of file stp.cc.
Referenced by stpXMLparser::parseSTP().
{
int idx = getInstanceIndex(_inst);
if (idx == -1) {
return;
}
inst.at(idx).helloTime = _helloTime;
}
| void Stp::setLinkCost | ( | unsigned int | _inst, |
| std::vector< unsigned int > & | _portList, | ||
| std::vector< unsigned int > & | _costList | ||
| ) |
Definition at line 101 of file stp.cc.
{
int idx = getInstanceIndex(_inst);
if (idx == -1) {
return;
}
if (_portList.size() != _costList.size()) {
return;
}
for (unsigned int i = 0; i < _portList.size(); i++) {
setLinkCost(idx, _portList.at(i), _costList.at(i));
}
}
| void Stp::setLinkCost | ( | unsigned int | _idx, |
| unsigned int | _port, | ||
| unsigned int | _cost | ||
| ) | [protected] |
| void Stp::setMaxAge | ( | unsigned int | _inst, |
| unsigned int | _maxAge | ||
| ) |
Definition at line 126 of file stp.cc.
Referenced by stpXMLparser::parseSTP().
{
int idx = getInstanceIndex(_inst);
if (idx == -1) {
return;
}
inst.at(idx).maxAge = _maxAge;
}
| void Stp::setPortPriority | ( | unsigned int | _inst, |
| std::vector< unsigned int > & | _portList, | ||
| std::vector< unsigned int > & | _priList | ||
| ) |
Definition at line 85 of file stp.cc.
Referenced by stpXMLparser::parseSTP().
{
int idx = getInstanceIndex(_inst);
if (idx == -1) {
return;
}
if (_portList.size() != _priList.size()) {
return;
}
for (unsigned int i = 0; i < _portList.size(); i++) {
setPortPriority(idx, _portList.at(i), _priList.at(i));
}
}
| void Stp::setPortPriority | ( | unsigned int | _idx, |
| unsigned int | _port, | ||
| unsigned int | _priority | ||
| ) | [protected] |
MACTable* Stp::addrTable [protected] |
Definition at line 77 of file stp.h.
Referenced by initialize().
MACAddress Stp::bridgeAddress [protected] |
Definition at line 68 of file stp.h.
Referenced by initialize().
Definition at line 72 of file stp.h.
Referenced by dispatch(), dispatchALL(), forwarding(), handleBPDU(), handleSelfMessage(), handleTCN(), initialize(), learning(), setBridgePriority(), setForwardDelay(), setHelloTime(), setLinkCost(), setMaxAge(), and setPortPriority().
std::vector<unsigned int> Stp::instReg [protected] |
Definition at line 71 of file stp.h.
Referenced by forwarding(), getInstanceIndex(), handleBPDU(), handleTCN(), initialize(), and learning().
unsigned int Stp::portCount [protected] |
Definition at line 67 of file stp.h.
Referenced by initialize().
cMessage* Stp::tick [protected] |
Definition at line 75 of file stp.h.
Referenced by finish(), handleSelfMessage(), and initialize().