|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // This program is free software: you can redistribute it and/or modify 00003 // it under the terms of the GNU Lesser General Public License as published by 00004 // the Free Software Foundation, either version 3 of the License, or 00005 // (at your option) any later version. 00006 // 00007 // This program is distributed in the hope that it will be useful, 00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 // GNU Lesser General Public License for more details. 00011 // 00012 // You should have received a copy of the GNU Lesser General Public License 00013 // along with this program. If not, see http://www.gnu.org/licenses/. 00014 // 00015 00016 #ifndef __ANSAINET_STP_H_ 00017 #define __ANSAINET_STP_H_ 00018 00019 #include <string> 00020 #include <vector> 00021 00022 #include <omnetpp.h> 00023 //#include "MACAddress.h" 00024 #include "stpi.h" 00025 #include "MACAddress.h" 00026 #include "macTable.h" 00027 #include "STPBPDU_m.h" 00028 #include "STPTCN_m.h" 00029 00030 class Stp : public cSimpleModule 00031 { 00032 public: 00033 00034 bool learning(unsigned int, unsigned int); 00035 bool forwarding(unsigned int, unsigned int); 00036 00037 void dispatchALL(); 00038 void dispatch(unsigned int); 00039 00040 00041 /* FOR XML CONFIGURATOR*/ 00042 int getInstanceIndex(unsigned int); 00043 void setBridgePriority(unsigned int, unsigned int); 00044 00045 void setPortPriority(unsigned int, std::vector<unsigned int>&, std::vector<unsigned int>&); 00046 void setLinkCost(unsigned int, std::vector<unsigned int>&, std::vector<unsigned int>&); 00047 void setForwardDelay(unsigned int, unsigned int); 00048 void setMaxAge(unsigned int, unsigned int); 00049 void setHelloTime(unsigned int, unsigned int); 00050 00051 00052 00053 00054 protected: 00055 virtual void initialize(int stage); 00056 virtual int numInitStages() const {return 2;} 00057 virtual void handleMessage(cMessage * msg); 00058 virtual void finish(); 00059 void handleSelfMessage(cMessage * msg); 00060 void handleBPDU(STPBPDU * bpdu); 00061 void handleTCN(STPTCN * tcn); 00062 00063 /* internal for XML config */ 00064 void setPortPriority(unsigned int, unsigned int, unsigned int); 00065 void setLinkCost(unsigned int, unsigned int, unsigned int); 00066 00067 unsigned int portCount; 00068 MACAddress bridgeAddress; 00069 00070 00071 std::vector<unsigned int> instReg; // search vector of existing instances 00072 std::vector<stpi> inst; // actual instances 00073 00074 /* timers */ 00075 cMessage * tick; 00076 00077 MACTable * addrTable; 00078 00079 }; 00080 00081 00082 00083 00084 00085 00086 #endif