akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | #ifndef NLSR_LSDB_HPP |
| 2 | #define NLSR_LSDB_HPP |
| 3 | |
| 4 | #include <utility> |
| 5 | #include "nlsr_lsa.hpp" |
| 6 | |
| 7 | using namespace std; |
| 8 | |
| 9 | class nlsr; |
| 10 | |
| 11 | class Lsdb{ |
| 12 | public: |
| 13 | Lsdb() |
| 14 | : lsaRefreshTime(0) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | |
| 19 | bool doesLsaExist(string key, int lsType); |
| 20 | // function related to Name LSDB |
| 21 | bool buildAndInstallOwnNameLsa(nlsr& pnlsr); |
| 22 | std::pair<NameLsa&, bool> getNameLsa(string key); |
| 23 | bool installNameLsa(nlsr& pnlsr, NameLsa &nlsa); |
| 24 | bool removeNameLsa(nlsr& pnlsr, string& key); |
| 25 | void printNameLsdb(); //debugging |
| 26 | |
| 27 | //function related to Cor LSDB |
| 28 | bool buildAndInstallOwnCorLsa(nlsr& pnlsr); |
| 29 | std::pair<CorLsa&, bool> getCorLsa(string key); |
| 30 | bool installCorLsa(nlsr& pnlsr, CorLsa &clsa); |
| 31 | bool removeCorLsa(nlsr& pnlsr, string& key); |
| 32 | void printCorLsdb(); //debugging |
| 33 | |
| 34 | //function related to Adj LSDB |
| 35 | void scheduledAdjLsaBuild(nlsr& pnlsr); |
| 36 | bool buildAndInstallOwnAdjLsa(nlsr& pnlsr); |
| 37 | bool removeAdjLsa(nlsr& pnlsr, string& key); |
| 38 | bool installAdjLsa(nlsr& pnlsr, AdjLsa &alsa); |
| 39 | std::pair<AdjLsa& , bool> getAdjLsa(string key); |
| 40 | std::list<AdjLsa>& getAdjLsdb(); |
| 41 | void printAdjLsdb(); |
| 42 | |
| 43 | //void scheduleRefreshLsdb(nlsr& pnlsr, int interval); |
| 44 | void setLsaRefreshTime(int lrt); |
| 45 | void setThisRouterPrefix(string trp); |
| 46 | |
| 47 | private: |
| 48 | bool addNameLsa(NameLsa &nlsa); |
| 49 | bool doesNameLsaExist(string key); |
| 50 | |
| 51 | |
| 52 | bool addCorLsa(CorLsa& clsa); |
| 53 | bool doesCorLsaExist(string key); |
| 54 | |
| 55 | bool addAdjLsa(AdjLsa &alsa); |
| 56 | bool doesAdjLsaExist(string key); |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 57 | |
| 58 | ndn::EventId |
| 59 | scheduleNameLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime); |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 60 | void exprireOrRefreshNameLsa(nlsr& pnlsr, string lsaKey, int seqNo); |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 61 | ndn::EventId |
| 62 | scheduleAdjLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime); |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 63 | void exprireOrRefreshAdjLsa(nlsr& pnlsr, string lsaKey, int seqNo); |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 64 | ndn::EventId |
| 65 | scheduleCorLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime); |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 66 | void exprireOrRefreshCorLsa(nlsr& pnlsr, string lsaKey, int seqNo); |
| 67 | |
| 68 | |
| 69 | private: |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 70 | void cancelScheduleLsaExpiringEvent(nlsr& pnlsr, EventId eid); |
| 71 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 72 | std::list<NameLsa> nameLsdb; |
| 73 | std::list<AdjLsa> adjLsdb; |
| 74 | std::list<CorLsa> corLsdb; |
| 75 | |
| 76 | int lsaRefreshTime; |
| 77 | string thisRouterPrefix; |
| 78 | |
| 79 | }; |
| 80 | |
| 81 | #endif |