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