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