akmhoque | 298385a | 2014-02-13 14:13:09 -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 | |
| 8 | #include "nlsr_conf_param.hpp" |
| 9 | #include "nlsr_adl.hpp" |
| 10 | #include "nlsr_npl.hpp" |
| 11 | #include "nlsr_im.hpp" |
| 12 | #include "nlsr_dm.hpp" |
| 13 | #include "nlsr_lsdb.hpp" |
| 14 | #include "nlsr_sm.hpp" |
| 15 | #include "nlsr_rt.hpp" |
| 16 | #include "nlsr_npt.hpp" |
| 17 | #include "nlsr_fib.hpp" |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 18 | #include "nlsr_logger.hpp" |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame^] | 19 | #include "nlsr_km.hpp" |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 20 | //testing |
| 21 | #include "nlsr_test.hpp" |
| 22 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 23 | namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 24 | { |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 25 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 26 | using namespace ndn; |
| 27 | using namespace std; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 28 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 29 | class Nlsr |
| 30 | { |
| 31 | public: |
| 32 | Nlsr() |
| 33 | : io(ndn::make_shared<boost::asio::io_service>()) |
| 34 | , nlsrFace(io) |
| 35 | , scheduler(*io) |
| 36 | , configFileName() |
| 37 | , confParam() |
| 38 | , adl() |
| 39 | , npl() |
| 40 | , im() |
| 41 | , dm() |
| 42 | , sm() |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame^] | 43 | , km() |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 44 | , nlsrLsdb() |
| 45 | , adjBuildCount(0) |
| 46 | , isBuildAdjLsaSheduled(0) |
| 47 | , isRouteCalculationScheduled(0) |
| 48 | , isRoutingTableCalculating(0) |
| 49 | , routingTable() |
| 50 | , npt() |
| 51 | , fib() |
| 52 | , nlsrLogger() |
| 53 | , nlsrTesting() |
| 54 | { |
| 55 | isDaemonProcess=false; |
| 56 | configFileName="nlsr.conf"; |
| 57 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 58 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 59 | void nlsrRegistrationFailed(const ndn::Name& name); |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 60 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 61 | void setInterestFilterNlsr(const string& name); |
| 62 | void startEventLoop(); |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 63 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 64 | int usage(const string& progname); |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 65 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 66 | string getConfFileName() |
| 67 | { |
| 68 | return configFileName; |
| 69 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 70 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 71 | void setConfFileName(const string& fileName) |
| 72 | { |
| 73 | configFileName=fileName; |
| 74 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 75 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 76 | bool isSetDaemonProcess() |
| 77 | { |
| 78 | return isDaemonProcess; |
| 79 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 80 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 81 | void setIsDaemonProcess(bool value) |
| 82 | { |
| 83 | isDaemonProcess=value; |
| 84 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 85 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 86 | ConfParameter& getConfParameter() |
| 87 | { |
| 88 | return confParam; |
| 89 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 90 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 91 | Adl& getAdl() |
| 92 | { |
| 93 | return adl; |
| 94 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 95 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 96 | Npl& getNpl() |
| 97 | { |
| 98 | return npl; |
| 99 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 100 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 101 | ndn::shared_ptr<boost::asio::io_service>& getIo() |
| 102 | { |
| 103 | return io; |
| 104 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 105 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 106 | ndn::Scheduler& getScheduler() |
| 107 | { |
| 108 | return scheduler; |
| 109 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 110 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 111 | ndn::Face& getNlsrFace() |
| 112 | { |
| 113 | return nlsrFace; |
| 114 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 115 | |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame^] | 116 | KeyManager& getKeyManager() |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 117 | { |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame^] | 118 | return km; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 119 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 120 | |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame^] | 121 | // ndn::KeyChain& getKeyChain() |
| 122 | // { |
| 123 | // return kChain; |
| 124 | // } |
| 125 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 126 | interestManager& getIm() |
| 127 | { |
| 128 | return im; |
| 129 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 130 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 131 | DataManager& getDm() |
| 132 | { |
| 133 | return dm; |
| 134 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 135 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 136 | SequencingManager& getSm() |
| 137 | { |
| 138 | return sm; |
| 139 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 140 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 141 | Lsdb& getLsdb() |
| 142 | { |
| 143 | return nlsrLsdb; |
| 144 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 145 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 146 | RoutingTable& getRoutingTable() |
| 147 | { |
| 148 | return routingTable; |
| 149 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 150 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 151 | Npt& getNpt() |
| 152 | { |
| 153 | return npt; |
| 154 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 155 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 156 | Fib& getFib() |
| 157 | { |
| 158 | return fib; |
| 159 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 160 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 161 | long int getAdjBuildCount() |
| 162 | { |
| 163 | return adjBuildCount; |
| 164 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 165 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 166 | void incrementAdjBuildCount() |
| 167 | { |
| 168 | adjBuildCount++; |
| 169 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 170 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 171 | void setAdjBuildCount(long int abc) |
| 172 | { |
| 173 | adjBuildCount=abc; |
| 174 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 175 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 176 | int getIsBuildAdjLsaSheduled() |
| 177 | { |
| 178 | return isBuildAdjLsaSheduled; |
| 179 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 180 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 181 | void setIsBuildAdjLsaSheduled(int iabls) |
| 182 | { |
| 183 | isBuildAdjLsaSheduled=iabls; |
| 184 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 185 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 186 | NlsrTest& getNlsrTesting() |
| 187 | { |
| 188 | return nlsrTesting; |
| 189 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 190 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 191 | void setApiPort(int ap) |
| 192 | { |
| 193 | apiPort=ap; |
| 194 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 195 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 196 | int getApiPort() |
| 197 | { |
| 198 | return apiPort; |
| 199 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 200 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 201 | int getIsRoutingTableCalculating() |
| 202 | { |
| 203 | return isRoutingTableCalculating; |
| 204 | } |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 205 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 206 | void setIsRoutingTableCalculating(int irtc) |
| 207 | { |
| 208 | isRoutingTableCalculating=irtc; |
| 209 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 210 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 211 | int getIsRouteCalculationScheduled() |
| 212 | { |
| 213 | return isRouteCalculationScheduled; |
| 214 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 215 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 216 | void setIsRouteCalculationScheduled(int ircs) |
| 217 | { |
| 218 | isRouteCalculationScheduled=ircs; |
| 219 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 220 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 221 | NlsrLogger& getNlsrLogger() |
| 222 | { |
| 223 | return nlsrLogger; |
| 224 | } |
| 225 | |
| 226 | private: |
| 227 | ConfParameter confParam; |
| 228 | Adl adl; |
| 229 | Npl npl; |
| 230 | ndn::shared_ptr<boost::asio::io_service> io; |
| 231 | ndn::Scheduler scheduler; |
| 232 | ndn::Face nlsrFace; |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame^] | 233 | // ndn::KeyChain kChain; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 234 | interestManager im; |
| 235 | DataManager dm; |
| 236 | SequencingManager sm; |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame^] | 237 | KeyManager km; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 238 | bool isDaemonProcess; |
| 239 | string configFileName; |
| 240 | int apiPort; |
| 241 | |
| 242 | Lsdb nlsrLsdb; |
| 243 | RoutingTable routingTable; |
| 244 | Npt npt; |
| 245 | Fib fib; |
| 246 | NlsrLogger nlsrLogger; |
| 247 | |
| 248 | long int adjBuildCount; |
| 249 | int isBuildAdjLsaSheduled; |
| 250 | int isRouteCalculationScheduled; |
| 251 | int isRoutingTableCalculating; |
| 252 | |
| 253 | NlsrTest nlsrTesting; |
| 254 | |
| 255 | |
| 256 | }; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 257 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 258 | } //namespace nlsr |
| 259 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 260 | #endif |