akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 1 | #ifndef NLSR_HPP |
| 2 | #define NLSR_HPP |
| 3 | |
| 4 | #include <ndn-cpp-dev/face.hpp> |
| 5 | #include <ndn-cpp-dev/security/key-chain.hpp> |
| 6 | #include <ndn-cpp-dev/util/scheduler.hpp> |
| 7 | |
akmhoque | 204e754 | 2014-01-31 16:08:25 -0600 | [diff] [blame] | 8 | #include "nlsr_conf_param.hpp" |
| 9 | #include "nlsr_adl.hpp" |
| 10 | #include "nlsr_npl.hpp" |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 11 | #include "nlsr_im.hpp" |
| 12 | #include "nlsr_dm.hpp" |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 13 | #include "nlsr_lsdb.hpp" |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 14 | |
| 15 | |
| 16 | using namespace ndn; |
| 17 | using namespace std; |
| 18 | |
| 19 | class nlsr |
| 20 | { |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 21 | public: |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 22 | nlsr() |
| 23 | : io(ndn::make_shared<boost::asio::io_service>()) |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 24 | , nlsrFace(io) |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 25 | , scheduler(*io) |
| 26 | , configFileName() |
| 27 | , confParam() |
| 28 | , adl() |
| 29 | , npl() |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 30 | , im() |
| 31 | , dm() |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 32 | , nlsrLsdb() |
| 33 | , nameLsaSeq(0) |
| 34 | , adjLsaSeq(0) |
| 35 | , corLsaSeq(0) |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame^] | 36 | , adjBuildCount(0) |
| 37 | , isBuildAdjLsaSheduled(0) |
| 38 | , isRouteCalculationScheduled(0) |
| 39 | , isRoutingTableCalculating(0) |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 40 | { |
| 41 | isDaemonProcess=false; |
| 42 | configFileName="nlsr.conf"; |
| 43 | } |
| 44 | |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 45 | nlsr(string confFile, uint32_t nlsn, uint32_t alsn, uint32_t clsn) |
| 46 | : io(ndn::make_shared<boost::asio::io_service>()) |
| 47 | , nlsrFace(io) |
| 48 | , scheduler(*io) |
| 49 | , configFileName() |
| 50 | , confParam() |
| 51 | , adl() |
| 52 | , npl() |
| 53 | , im() |
| 54 | , dm() |
| 55 | , nlsrLsdb() |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame^] | 56 | , adjBuildCount(0) |
| 57 | , isBuildAdjLsaSheduled(0) |
| 58 | , isRouteCalculationScheduled(0) |
| 59 | , isRoutingTableCalculating(0) |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 60 | { |
| 61 | isDaemonProcess=false; |
| 62 | configFileName=confFile; |
| 63 | nameLsaSeq=nlsn; |
| 64 | adjLsaSeq=alsn; |
| 65 | corLsaSeq=clsn; |
| 66 | } |
| 67 | |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 68 | void nlsrRegistrationFailed(const ptr_lib::shared_ptr<const Name>&); |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 69 | |
| 70 | void setInterestFilterNlsr(const string& name); |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 71 | void startEventLoop(); |
| 72 | |
| 73 | int usage(const string& progname); |
| 74 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 75 | string getConfFileName() |
| 76 | { |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 77 | return configFileName; |
| 78 | } |
| 79 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 80 | void setConfFileName(const string& fileName) |
| 81 | { |
| 82 | configFileName=fileName; |
| 83 | } |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 84 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 85 | bool isSetDaemonProcess() |
| 86 | { |
| 87 | return isDaemonProcess; |
| 88 | } |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 89 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 90 | void setIsDaemonProcess(bool value) |
| 91 | { |
| 92 | isDaemonProcess=value; |
| 93 | } |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 94 | |
akmhoque | a8cd6b9 | 2014-01-31 20:13:26 -0600 | [diff] [blame] | 95 | ConfParameter& getConfParameter(){ |
| 96 | return confParam; |
| 97 | } |
| 98 | |
| 99 | Adl& getAdl(){ |
| 100 | return adl; |
| 101 | } |
| 102 | |
| 103 | Npl& getNpl(){ |
| 104 | return npl; |
| 105 | } |
| 106 | |
| 107 | ndn::shared_ptr<boost::asio::io_service>& getIo() |
| 108 | { |
| 109 | return io; |
| 110 | } |
| 111 | |
| 112 | ndn::Scheduler& getScheduler(){ |
| 113 | return scheduler; |
| 114 | } |
| 115 | |
| 116 | ndn::Face& getNlsrFace(){ |
| 117 | return nlsrFace; |
| 118 | } |
| 119 | |
| 120 | ndn::KeyChain& getKeyChain(){ |
| 121 | return kChain; |
| 122 | } |
| 123 | |
| 124 | interestManager& getIm(){ |
| 125 | return im; |
| 126 | } |
| 127 | |
| 128 | DataManager& getDm(){ |
| 129 | return dm; |
| 130 | } |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 131 | |
| 132 | Lsdb& getLsdb(){ |
| 133 | return nlsrLsdb; |
| 134 | } |
| 135 | |
| 136 | uint32_t getNameLsaSeq() |
| 137 | { |
| 138 | return nameLsaSeq; |
| 139 | } |
| 140 | |
| 141 | void setNameLsaSeq(uint32_t nlsn){ |
| 142 | nameLsaSeq=nlsn; |
| 143 | } |
| 144 | |
| 145 | uint32_t getAdjLsaSeq() |
| 146 | { |
| 147 | return adjLsaSeq; |
| 148 | } |
| 149 | |
| 150 | void setAdjLsaSeq(uint32_t alsn){ |
| 151 | adjLsaSeq=alsn; |
| 152 | } |
| 153 | |
| 154 | uint32_t getCorLsaSeq() |
| 155 | { |
| 156 | return corLsaSeq; |
| 157 | } |
| 158 | |
| 159 | void setCorLsaSeq(uint32_t clsn){ |
| 160 | corLsaSeq=clsn; |
| 161 | } |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame^] | 162 | |
| 163 | long int getAdjBuildCount() |
| 164 | { |
| 165 | return adjBuildCount; |
| 166 | } |
| 167 | |
| 168 | void incrementAdjBuildCount() |
| 169 | { |
| 170 | adjBuildCount++; |
| 171 | } |
| 172 | |
| 173 | void setAdjBuildCount(long int abc) |
| 174 | { |
| 175 | adjBuildCount=abc; |
| 176 | } |
| 177 | |
| 178 | int getIsBuildAdjLsaSheduled() |
| 179 | { |
| 180 | return isBuildAdjLsaSheduled; |
| 181 | } |
| 182 | |
| 183 | void setIsBuildAdjLsaSheduled(int iabls) |
| 184 | { |
| 185 | isBuildAdjLsaSheduled=iabls; |
| 186 | } |
| 187 | |
akmhoque | a8cd6b9 | 2014-01-31 20:13:26 -0600 | [diff] [blame] | 188 | private: |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 189 | ConfParameter confParam; |
| 190 | Adl adl; |
| 191 | Npl npl; |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 192 | ndn::shared_ptr<boost::asio::io_service> io; |
| 193 | ndn::Scheduler scheduler; |
| 194 | ndn::Face nlsrFace; |
| 195 | ndn::KeyChain kChain; |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 196 | interestManager im; |
| 197 | DataManager dm; |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 198 | bool isDaemonProcess; |
| 199 | string configFileName; |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 200 | Lsdb nlsrLsdb; |
| 201 | uint32_t nameLsaSeq; |
| 202 | uint32_t adjLsaSeq; |
| 203 | uint32_t corLsaSeq; |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame^] | 204 | |
| 205 | long int adjBuildCount; |
| 206 | int isBuildAdjLsaSheduled; |
| 207 | int isRouteCalculationScheduled; |
| 208 | int isRoutingTableCalculating; |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 209 | |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 210 | |
| 211 | }; |
| 212 | |
| 213 | #endif |