INET Framework for OMNeT++/OMNEST
stpXMLparser Class Reference

#include <stpXMLparser.h>

List of all members.

Public Member Functions

 stpXMLparser (Stp *)
virtual ~stpXMLparser ()
bool parse (const char *, const char *)
void parseSTP (cXMLElement *node)

Private Attributes

Stpstp

Detailed Description

Definition at line 16 of file stpXMLparser.h.


Constructor & Destructor Documentation

Definition at line 10 of file stpXMLparser.cc.

                                     {
        stp = _stp;
}

Definition at line 14 of file stpXMLparser.cc.

                            {

}

Member Function Documentation

bool stpXMLparser::parse ( const char *  filename,
const char *  switchID 
)

Definition at line 19 of file stpXMLparser.cc.

Referenced by Stp::initialize().

                                                                     {

        cXMLElement* switchConfig = ev.getXMLDocument(filename);
        if (switchConfig == NULL) {
                return false;
        }

        std::string switchXPath("Switch[@id='");
        switchXPath += switchID;
        switchXPath += "']";

        /* FIND root of current switch's configuration subtree */
        cXMLElement* switchNode = switchConfig->getElementByPath(switchXPath.c_str());
        if (switchNode == NULL) {
                return false;
                //opp_error("No configuration for Switch ID: %s", switchID);
        }


        /* FIND section Interfaces */
        cXMLElement* stpNode = switchNode->getFirstChildWithTag("STP");
        if (stpNode != NULL) {
                parseSTP(stpNode);
        }

        return true;

}
void stpXMLparser::parseSTP ( cXMLElement *  node)

Definition at line 48 of file stpXMLparser.cc.

Referenced by parse().

                                              {
        std::string tmp, instance, bridgePriority, fwDelay, helloTime,
                                maxAge, portPriority, linkCost,subNodeName;

        std::vector<unsigned int> portPriList, priPortList; // list of port priorities, list of ports for adressing
        std::vector<unsigned int> portCostList, costPortList;// list of link costs, list of links for adressing

        unsigned int inst=0;

        cXMLElementList instConfig = node->getChildren();
        cXMLElementList::iterator it;

        for(it = instConfig.begin(); it != instConfig.end(); it++) {
                subNodeName  = (*it)->getTagName();

                tmp.clear();
                instance.clear();
                bridgePriority.clear();
                fwDelay.clear();
                helloTime.clear();
                maxAge.clear();
                portPriority.clear();
                linkCost.clear();

                portPriList.clear();
                priPortList.clear();
                portCostList.clear();
                costPortList.clear();

                if (subNodeName == "Instance" && (*it)->getAttribute("id")) {
                        instance = (*it)->getAttribute("id");

                        cXMLElementList instDetails = (*it)->getChildren();
                        cXMLElementList::iterator instElemIt;
                        for (instElemIt = instDetails.begin(); instElemIt != instDetails.end(); instElemIt++) {
                          std::string nodeName = (*instElemIt)->getTagName();

                          if (nodeName=="BridgePriority") {
                                bridgePriority = (*instElemIt)->getNodeValue();
                          }

                          if (nodeName=="PortPriority") {
                                priPortList.push_back(atoi((*instElemIt)->getAttribute("id")));
                                portPriList.push_back(atoi((*instElemIt)->getNodeValue()));
                          }
                          if (nodeName=="LinkCost") {
                                costPortList.push_back(atoi((*instElemIt)->getAttribute("id")));
                                portCostList.push_back(atoi((*instElemIt)->getNodeValue()));
                          }
                          if (nodeName=="ForwardDelay") {
                                  fwDelay = (*instElemIt)->getNodeValue();
                          }
                          if (nodeName=="HelloTimer") {
                                  helloTime = (*instElemIt)->getNodeValue();
                          }
                          if (nodeName=="MaxAge") {
                                  maxAge = (*instElemIt)->getNodeValue();
                          }


                        } // instDetail for

                } // instConfig for

                if (instance.empty() == true) {
                        continue;
                }

                inst = atoi(instance.c_str());

                if (bridgePriority.empty() == false) {
                        stp->setBridgePriority(inst, atoi(bridgePriority.c_str()));
                }
                if (fwDelay.empty() == false) {
                        stp->setForwardDelay(inst, atoi(fwDelay.c_str()));
                }
                if (maxAge.empty() == false) {
                        stp->setMaxAge(inst, atoi(maxAge.c_str()));
                }
                if (helloTime.empty() == false) {
                        stp->setHelloTime(inst, atoi(helloTime.c_str()));
                }

                if (portPriList.empty() == false) {
                        stp->setPortPriority(inst, priPortList, portPriList);
                }

                if (portPriList.empty() == false) {
                        stp->setPortPriority(inst, costPortList, portCostList);
                }


        }



}

Member Data Documentation

Stp* stpXMLparser::stp [private]

Definition at line 26 of file stpXMLparser.h.

Referenced by parseSTP(), and stpXMLparser().


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