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