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