|
INET Framework for OMNeT++/OMNEST
|
00001 // Author: Matej Hrncirik 00002 // FIT VUT 2012 00003 // 00004 // 00005 // This program is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this program. If not, see http://www.gnu.org/licenses/. 00017 // 00018 00019 #ifndef ISISTYPES_H_ 00020 #define ISISTYPES_H_ 00021 00022 #include "MACAddress.h" 00023 #include "InterfaceEntry.h" 00024 #include "ISISTimer_m.h" 00025 #include "ISISMessage_m.h" 00026 //#include "ISIS.h" 00027 00028 00029 #define ISIS_DIS_PRIORITY 64 00030 #define ISIS_METRIC 10 00031 #define ISIS_HELLO_INTERVAL 10 00032 #define ISIS_HELLO_MULTIPLIER 3 00033 #define ISIS_SYSTEM_ID 6 00034 #define ISIS_MAX_AREAS 3 00035 #define ISIS_AREA_ID 3 00036 #define ISIS_LSP_INTERVAL 33 00037 #define ISIS_LSP_REFRESH_INTERVAL 150 00038 #define ISIS_LSP_MAX_LIFETIME 200 00039 #define ISIS_LSP_GEN_INTERVAL 5 00040 #define ISIS_LSP_INIT_WAIT 50 00041 #define ISIS_CSNP_INTERVAL 10 00042 #define ISIS_PSNP_INTERVAL 2 00043 #define ISIS_LSP_MAX_SIZE 1492 //TODO change to something smaller so we can test it 00044 #define ISIS_LSP_SEND_INTERVAL 5 00045 #define ISIS_SPF_FULL_INTERVAL 50 00046 //class InterfaceEntr; 00047 //class MACAddress; 00048 00052 struct ISISinterface 00053 { 00054 int intID; 00055 int gateIndex; 00056 bool network; 00057 //bool broadcast; /*!<broadcast enabled?*/ 00058 //bool loopback; /*!<is it loopback?*/ 00059 bool passive; 00060 bool ISISenabled; 00061 short circuitType; 00062 unsigned char priority; 00063 unsigned char L1DISpriority; 00064 unsigned char L2DISpriority; 00065 unsigned char L1DIS[7]; 00066 unsigned char L2DIS[7]; 00067 unsigned char metric; 00068 int L1HelloInterval; 00069 int L2HelloInterval; 00070 short L1HelloMultiplier; 00071 short L2HelloMultiplier; 00072 int lspInterval; 00073 int L1CsnpInterval; 00074 int L2CsnpInterval; 00075 int L1PsnpInterval; 00076 int L2PsnpInterval; 00078 InterfaceEntry *entry; 00079 }; 00080 00084 struct ISISadj 00085 { 00086 unsigned char sysID[6]; 00087 unsigned char areaID[3]; 00088 MACAddress mac; 00089 bool state; 00090 ISISTimer *timer; 00091 int gateIndex; 00092 bool network; 00094 //bool operator for sorting 00095 bool operator<(const ISISadj& adj2) const { 00096 00097 for (unsigned int j = 0; j < ISIS_AREA_ID; j++){ 00098 if(areaID[j] < adj2.areaID[j]){ 00099 return true; //first is smaller, so return true 00100 }else if(areaID[j] > adj2.areaID[j]){ 00101 return false; //first is bigger, so return false 00102 } 00103 //if it's equal then continue to next one 00104 } 00105 //AreaIDs match, so compare system IDs 00106 00107 for (unsigned int i = 0; i < ISIS_SYSTEM_ID; i++){ 00108 if(sysID[i] < adj2.sysID[i]){ 00109 return true; //first is smaller, so return true 00110 }else if(sysID[i] > adj2.sysID[i]){ 00111 return false; //first is bigger, so return false 00112 } 00113 //if it's equal then continue to next one 00114 } 00115 00116 //if the first MAC address is smaller, return true 00117 if(mac.compareTo(adj2.mac) < 0){ 00118 return true; 00119 } 00120 00121 //if they're equal, return false 00122 return false; 00123 } 00124 }; 00125 00129 struct metrics_t 00130 { 00131 unsigned char defaultMetric; 00132 unsigned char delayMetric; 00133 unsigned char expenseMetric; 00134 unsigned char errortMetric; 00135 }; 00136 00140 struct LSPneighbour 00141 { 00142 unsigned char LANid[7]; 00143 metrics_t metrics; 00145 }; 00146 00147 struct LSPrecord 00148 { 00149 std::vector<LSPneighbour> neighbours; //list of neighbours 00150 unsigned char LSPid[8]; //ID of LSP 00151 unsigned long seq; //sequence number 00152 ISISTimer *deadTimer; //dead timer - 1200s 00153 }; 00154 00155 struct LSPRecord 00156 { 00157 ISISLSPPacket* LSP; //link-state protocol data unit 00158 ISISTimer *deadTimer; //dead timer 00159 std::vector<bool> SRMflags; 00160 std::vector<bool> SSNflags; 00161 double simLifetime; 00163 /* LSPRecord(){ 00164 for (std::vector<ISISinterface>::iterator intIt = this->ISISIft.begin(); intIt != this->ISISIft.end(); ++intIt) 00165 { 00166 00167 this->SRMflags.push_back(false); 00168 this->SSNflags.push_back(false); 00169 00170 } 00171 }*/ 00172 00173 ~LSPRecord(){ 00174 00175 /* for (unsigned int i = 0; i < this->LSP->getTLVArraySize(); i++) 00176 { 00177 if(this->LSP->getTLV(i).value != NULL){ 00178 delete this->LSP->getTLV(i).value; 00179 } 00180 }*/ 00181 this->LSP->setTLVArraySize(0); 00182 if(this->LSP != NULL){ 00183 delete this->LSP; 00184 } 00185 // if(this->deadTimer != NULL){ 00186 // drop(this->deadTimer); 00187 // delete this->deadTimer; 00188 // } 00189 this->SRMflags.clear(); 00190 this->SSNflags.clear(); 00191 } 00192 00193 //bool operator for sorting 00194 bool operator<(const LSPRecord& lspRec2) const { 00195 00196 for (unsigned int i = 0; i < ISIS_SYSTEM_ID + 2; i++){ 00197 if(this->LSP->getLspID(i) < lspRec2.LSP->getLspID(i)){ 00198 return true; //first is smaller, so return true 00199 }else if(this->LSP->getLspID(i) > lspRec2.LSP->getLspID(i)){ 00200 return false; //first is bigger, so return false 00201 } 00202 //if it's equal then continue to next one 00203 } 00204 00205 //if they're equal, return false 00206 return false; 00207 } 00208 00209 }; 00210 typedef std::vector<LSPRecord *> LSPRecQ_t; 00211 00212 struct FlagRecord 00213 { 00214 LSPRecord *lspRec; 00215 int index; 00216 //destructor!! 00217 ~FlagRecord(){ 00218 00219 } 00220 }; 00221 typedef std::vector<FlagRecord*> FlagRecQ_t; 00222 typedef std::vector<std::vector<FlagRecord*> *> FlagRecQQ_t; 00223 struct ISISNeighbour 00224 { 00225 unsigned char *id; 00226 //uint32_t metric; 00227 bool type; //should represent whether it's a leaf node; true = leaf 00228 00229 00230 }; 00231 00232 typedef std::vector<ISISNeighbour*> ISISNeighbours_t; 00233 00234 struct ISISPath 00235 { 00236 unsigned char *to; 00237 uint32_t metric; 00238 ISISNeighbours_t from; 00239 //bool operator for sorting 00240 bool operator<(const ISISPath& path2) const { 00241 00242 for (unsigned int i = 0; i < ISIS_SYSTEM_ID + 2; i++){ 00243 if(this->metric < path2.metric){ 00244 return true; //first is smaller, so return true 00245 }else{ 00246 return false; //first is bigger, so return false 00247 } 00248 //if it's equal then continue to next one 00249 } 00250 00251 //if they're equal, return false 00252 return false; 00253 } 00254 }; 00255 00256 typedef std::vector<ISISPath*> ISISPaths_t; 00257 typedef std::vector<LSPRecord *> ISISLspDb_t; 00258 00259 struct ISISCon 00260 { 00261 unsigned char *from; 00262 unsigned char *to; 00263 uint32_t metric; 00264 bool type; 00265 }; 00266 typedef std::vector<ISISCon*> ISISCons_t; 00267 00268 /* 00269 * Adjacency states for 3-way handshake on point-to-point links 00270 */ 00271 enum PTP_HELLO_ADJ_STATE 00272 { 00273 PTP_UP = 1, 00274 PTP_INIT = 2, 00275 PTP_DOWN = 3 00276 }; 00277 00278 00279 00280 #endif /* ISISTYPES_H_ */