From 9c3bb1aed4b9e8922bc33f4133f9936c992ef93d Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Wed, 27 Feb 2008 20:44:12 +0000 Subject: added routing table support --- routingTable.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'routingTable.h') diff --git a/routingTable.h b/routingTable.h index 9a4ffae..b406b65 100644 --- a/routingTable.h +++ b/routingTable.h @@ -36,27 +36,38 @@ #include "threadUtils.hpp" #include "datatypes.h" -#include "routingTableEntry.h" +//#include "routingTableEntry.h" #include "networkAddress.h" -typedef std::map RoutingMap; +#include "networkPrefix.h" +typedef std::map RoutingMap; class RoutingTable { public: + static RoutingTable& instance(); RoutingTable(); ~RoutingTable(); - void addRoute(const RoutingTableEntry &route); - const RoutingMap::iterator getRoute(); - const RoutingMap::iterator getEnd(); + void addRoute(const NetworkPrefix & ,u_int16_t); + u_int16_t getRoute(const NetworkAddress &); bool empty(); void clear(); Mutex& getMutex(); private: - RoutingTable(const RoutingTable &s); + static Mutex instMutex; + static RoutingTable* inst; + class instanceCleaner { + public: ~instanceCleaner() { + if(RoutingTable::inst != 0) + delete RoutingTable::inst; + } + }; + RoutingTable(const RoutingTable &s); void operator=(const RoutingTable &s); RoutingMap routes_; Mutex mutex_; }; +extern RoutingTable& gRoutingTable; + #endif -- cgit v1.2.3