00001 // 00002 // (C) 2005 Vojtech Janota 00003 // 00004 // This library is free software, you can redistribute it 00005 // and/or modify 00006 // it under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation; 00008 // either version 2 of the License, or any later version. 00009 // The library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 // See the GNU Lesser General Public License for more details. 00013 // 00014 00015 #ifndef __INET_TED_H 00016 #define __INET_TED_H 00017 00018 #include <omnetpp.h> 00019 #include "TED_m.h" 00020 #include "IntServ.h" 00021 00022 class IRoutingTable; 00023 class IInterfaceTable; 00024 class InterfaceEntry; 00025 class NotificationBoard; 00026 00027 00034 class TED : public cSimpleModule 00035 { 00036 public: 00041 struct vertex_t 00042 { 00043 IPAddress node; // FIXME *** is this the routerID? *** 00044 int parent; // index into the same vertex_t vector 00045 double dist; // distance to root (???) 00046 }; 00047 00052 struct edge_t 00053 { 00054 int src; // index into the vertex_t[] vector 00055 int dest; // index into the vertex_t[] vector 00056 double metric; // link cost 00057 }; 00058 00062 TELinkStateInfoVector ted; 00063 00064 public: 00065 TED(); 00066 virtual ~TED(); 00067 00068 protected: 00069 virtual void initialize(int stage); 00070 virtual int numInitStages() const {return 5;} 00071 virtual void handleMessage(cMessage *msg); 00072 00073 virtual IPAddressVector calculateShortestPath(IPAddressVector dest, 00074 const TELinkStateInfoVector& topology, double req_bandwidth, int priority); 00075 00076 public: 00079 virtual IPAddress getInterfaceAddrByPeerAddress(IPAddress peerIP); 00080 virtual IPAddress peerRemoteInterface(IPAddress peerIP); 00081 virtual IPAddress getPeerByLocalAddress(IPAddress localInf); 00082 virtual IPAddress primaryAddress(IPAddress localInf); 00083 virtual bool isLocalPeer(IPAddress inetAddr); 00084 virtual bool isLocalAddress(IPAddress addr); 00085 virtual unsigned int linkIndex(IPAddress localInf); 00086 virtual unsigned int linkIndex(IPAddress advrouter, IPAddress linkid); 00087 virtual IPAddressVector getLocalAddress(); 00088 00089 virtual void rebuildRoutingTable(); 00091 00092 protected: 00093 IRoutingTable *rt; 00094 IInterfaceTable *ift; 00095 IPAddress routerId; 00096 NotificationBoard *nb; 00097 00098 IPAddressVector interfaceAddrs; // list of local interface addresses 00099 00100 protected: 00101 int maxMessageId; 00102 00103 virtual int assignIndex(std::vector<vertex_t>& vertices, IPAddress nodeAddr); 00104 00105 std::vector<vertex_t> calculateShortestPaths(const TELinkStateInfoVector& topology, 00106 double req_bandwidth, int priority); 00107 00108 public: //FIXME 00109 virtual bool checkLinkValidity(TELinkStateInfo link, TELinkStateInfo *&match); 00110 virtual void updateTimestamp(TELinkStateInfo *link); 00111 }; 00112 00113 std::ostream & operator<<(std::ostream & os, const TELinkStateInfo& info); 00114 00115 #endif 00116 00117