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