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