akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 1 | #ifndef NLSR_LSDB_HPP |
| 2 | #define NLSR_LSDB_HPP |
| 3 | |
| 4 | #include <utility> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 5 | #include <boost/cstdint.hpp> |
| 6 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 7 | #include "lsa.hpp" |
| 8 | |
| 9 | namespace nlsr { |
| 10 | class Nlsr; |
| 11 | |
| 12 | class Lsdb |
| 13 | { |
| 14 | public: |
| 15 | Lsdb() |
| 16 | : m_lsaRefreshTime(0) |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | |
| 21 | bool |
| 22 | doesLsaExist(std::string key, int lsType); |
| 23 | // function related to Name LSDB |
| 24 | |
| 25 | bool |
| 26 | buildAndInstallOwnNameLsa(Nlsr& pnlsr); |
| 27 | |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 28 | NameLsa* |
| 29 | findNameLsa(const std::string key); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 30 | |
| 31 | bool |
| 32 | installNameLsa(Nlsr& pnlsr, NameLsa& nlsa); |
| 33 | |
| 34 | bool |
| 35 | removeNameLsa(Nlsr& pnlsr, std::string& key); |
| 36 | |
| 37 | bool |
| 38 | isNameLsaNew(std::string key, uint64_t seqNo); |
| 39 | |
| 40 | void |
| 41 | printNameLsdb(); //debugging |
| 42 | |
| 43 | //function related to Cor LSDB |
| 44 | bool |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 45 | buildAndInstallOwnCoordinateLsa(Nlsr& pnlsr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 46 | |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 47 | CoordinateLsa* |
| 48 | findCoordinateLsa(const std::string& key); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 49 | |
| 50 | bool |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 51 | installCoordinateLsa(Nlsr& pnlsr, CoordinateLsa& clsa); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 52 | |
| 53 | bool |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 54 | removeCoordinateLsa(Nlsr& pnlsr, const std::string& key); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 55 | |
| 56 | bool |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 57 | isCoordinateLsaNew(const std::string& key, uint64_t seqNo); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 58 | |
| 59 | void |
| 60 | printCorLsdb(); //debugging |
| 61 | |
| 62 | //function related to Adj LSDB |
| 63 | void |
| 64 | scheduledAdjLsaBuild(Nlsr& pnlsr); |
| 65 | |
| 66 | bool |
| 67 | buildAndInstallOwnAdjLsa(Nlsr& pnlsr); |
| 68 | |
| 69 | bool |
| 70 | removeAdjLsa(Nlsr& pnlsr, std::string& key); |
| 71 | |
| 72 | bool |
| 73 | isAdjLsaNew(std::string key, uint64_t seqNo); |
| 74 | bool |
| 75 | installAdjLsa(Nlsr& pnlsr, AdjLsa& alsa); |
| 76 | |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 77 | AdjLsa* |
| 78 | findAdjLsa(std::string key); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 79 | |
| 80 | std::list<AdjLsa>& |
| 81 | getAdjLsdb(); |
| 82 | |
| 83 | void |
| 84 | printAdjLsdb(); |
| 85 | |
| 86 | //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval); |
| 87 | void |
| 88 | setLsaRefreshTime(int lrt); |
| 89 | |
| 90 | void |
| 91 | setThisRouterPrefix(std::string trp); |
| 92 | |
| 93 | private: |
| 94 | bool |
| 95 | addNameLsa(NameLsa& nlsa); |
| 96 | |
| 97 | bool |
| 98 | doesNameLsaExist(std::string key); |
| 99 | |
| 100 | |
| 101 | bool |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 102 | addCoordinateLsa(CoordinateLsa& clsa); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 103 | |
| 104 | bool |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 105 | doesCoordinateLsaExist(const std::string& key); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 106 | |
| 107 | bool |
| 108 | addAdjLsa(AdjLsa& alsa); |
| 109 | |
| 110 | bool |
| 111 | doesAdjLsaExist(std::string key); |
| 112 | |
| 113 | ndn::EventId |
| 114 | scheduleNameLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime); |
| 115 | |
| 116 | void |
| 117 | exprireOrRefreshNameLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo); |
| 118 | |
| 119 | ndn::EventId |
| 120 | scheduleAdjLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime); |
| 121 | |
| 122 | void |
| 123 | exprireOrRefreshAdjLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo); |
| 124 | |
| 125 | ndn::EventId |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 126 | scheduleCoordinateLsaExpiration(Nlsr& pnlsr, const std::string& key, int seqNo, |
| 127 | int expTime); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 128 | |
| 129 | void |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 130 | exprireOrRefreshCoordinateLsa(Nlsr& pnlsr, const std::string& lsaKey, |
| 131 | uint64_t seqNo); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 132 | |
| 133 | |
| 134 | private: |
| 135 | void |
| 136 | cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, ndn::EventId eid); |
| 137 | |
| 138 | std::list<NameLsa> m_nameLsdb; |
| 139 | std::list<AdjLsa> m_adjLsdb; |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 140 | std::list<CoordinateLsa> m_corLsdb; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 141 | |
| 142 | int m_lsaRefreshTime; |
| 143 | std::string m_thisRouterPrefix; |
| 144 | |
| 145 | }; |
| 146 | |
| 147 | }//namespace nlsr |
| 148 | |
| 149 | #endif //NLSR_LSDB_HPP |