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 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 8 | #include "conf-parameter.hpp" |
| 9 | #include "adl.hpp" |
| 10 | #include "npl.hpp" |
| 11 | #include "communication/interest-manager.hpp" |
| 12 | #include "communication/data-manager.hpp" |
| 13 | #include "lsdb.hpp" |
| 14 | #include "sequencing-manager.hpp" |
| 15 | #include "route/routing-table.hpp" |
| 16 | #include "route/npt.hpp" |
| 17 | #include "route/fib.hpp" |
| 18 | #include "security/key-manager.hpp" |
| 19 | #include "communication/sync-logic-handler.hpp" |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 20 | |
| 21 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 22 | namespace nlsr { |
| 23 | |
| 24 | inline static void |
| 25 | NullDeleter(boost::asio::io_service* variable) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 26 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 27 | // do nothing |
| 28 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 29 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 30 | class Nlsr |
| 31 | { |
| 32 | public: |
| 33 | Nlsr() |
| 34 | : m_io(new boost::asio::io_service) |
| 35 | , m_nlsrFace(new Face(ndn::shared_ptr<boost::asio::io_service>(&*m_io, |
| 36 | &NullDeleter))) |
| 37 | , m_scheduler(*m_io) |
| 38 | , m_confParam() |
| 39 | , m_adl() |
| 40 | , m_npl() |
| 41 | , m_im() |
| 42 | , m_dm() |
| 43 | , m_sm() |
| 44 | , m_km() |
| 45 | , m_isDaemonProcess(false) |
| 46 | , m_configFileName("nlsr.conf") |
| 47 | , m_nlsrLsdb() |
| 48 | , m_adjBuildCount(0) |
| 49 | , m_isBuildAdjLsaSheduled(false) |
| 50 | , m_isRouteCalculationScheduled(false) |
| 51 | , m_isRoutingTableCalculating(false) |
| 52 | , m_routingTable() |
| 53 | , m_npt() |
| 54 | , m_fib() |
| 55 | , m_slh(m_io) |
| 56 | {} |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 57 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 58 | void |
| 59 | registrationFailed(const ndn::Name& name); |
| 60 | |
| 61 | void |
| 62 | setInterestFilterNlsr(const string& name); |
| 63 | |
| 64 | void |
| 65 | startEventLoop(); |
| 66 | |
| 67 | int |
| 68 | usage(const string& progname); |
| 69 | |
| 70 | std::string |
| 71 | getConfFileName() |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 72 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 73 | return m_configFileName; |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 74 | } |
| 75 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 76 | void |
| 77 | setConfFileName(const string& fileName) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 78 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 79 | m_configFileName = fileName; |
| 80 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 81 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 82 | bool |
| 83 | getIsSetDaemonProcess() |
| 84 | { |
| 85 | return m_isDaemonProcess; |
| 86 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 87 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 88 | void |
| 89 | setIsDaemonProcess(bool value) |
| 90 | { |
| 91 | m_isDaemonProcess = value; |
| 92 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 93 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 94 | ConfParameter& |
| 95 | getConfParameter() |
| 96 | { |
| 97 | return m_confParam; |
| 98 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 99 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 100 | Adl& |
| 101 | getAdl() |
| 102 | { |
| 103 | return m_adl; |
| 104 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 105 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 106 | Npl& |
| 107 | getNpl() |
| 108 | { |
| 109 | return m_npl; |
| 110 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 111 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 112 | ndn::shared_ptr<boost::asio::io_service>& |
| 113 | getIo() |
| 114 | { |
| 115 | return m_io; |
| 116 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 117 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 118 | ndn::Scheduler& |
| 119 | getScheduler() |
| 120 | { |
| 121 | return m_scheduler; |
| 122 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 123 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 124 | ndn::shared_ptr<ndn::Face> |
| 125 | getNlsrFace() |
| 126 | { |
| 127 | return m_nlsrFace; |
| 128 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 129 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 130 | KeyManager& |
| 131 | getKeyManager() |
| 132 | { |
| 133 | return m_km; |
| 134 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 135 | |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame] | 136 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 137 | InterestManager& |
| 138 | getIm() |
| 139 | { |
| 140 | return m_im; |
| 141 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 142 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 143 | DataManager& |
| 144 | getDm() |
| 145 | { |
| 146 | return m_dm; |
| 147 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 148 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 149 | SequencingManager& |
| 150 | getSm() |
| 151 | { |
| 152 | return m_sm; |
| 153 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 154 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 155 | Lsdb& |
| 156 | getLsdb() |
| 157 | { |
| 158 | return m_nlsrLsdb; |
| 159 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 160 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 161 | RoutingTable& |
| 162 | getRoutingTable() |
| 163 | { |
| 164 | return m_routingTable; |
| 165 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 166 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 167 | Npt& |
| 168 | getNpt() |
| 169 | { |
| 170 | return m_npt; |
| 171 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 172 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 173 | Fib& |
| 174 | getFib() |
| 175 | { |
| 176 | return m_fib; |
| 177 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 178 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 179 | long int |
| 180 | getAdjBuildCount() |
| 181 | { |
| 182 | return m_adjBuildCount; |
| 183 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 184 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 185 | void |
| 186 | incrementAdjBuildCount() |
| 187 | { |
| 188 | m_adjBuildCount++; |
| 189 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 190 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 191 | void |
| 192 | setAdjBuildCount(long int abc) |
| 193 | { |
| 194 | m_adjBuildCount = abc; |
| 195 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 196 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 197 | int |
| 198 | getIsBuildAdjLsaSheduled() |
| 199 | { |
| 200 | return m_isBuildAdjLsaSheduled; |
| 201 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 202 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 203 | void |
| 204 | setIsBuildAdjLsaSheduled(bool iabls) |
| 205 | { |
| 206 | m_isBuildAdjLsaSheduled = iabls; |
| 207 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 208 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 209 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 210 | void |
| 211 | setApiPort(int ap) |
| 212 | { |
| 213 | m_apiPort = ap; |
| 214 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 215 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 216 | int |
| 217 | getApiPort() |
| 218 | { |
| 219 | return m_apiPort; |
| 220 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 221 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 222 | bool |
| 223 | getIsRoutingTableCalculating() |
| 224 | { |
| 225 | return m_isRoutingTableCalculating; |
| 226 | } |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 227 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 228 | void |
| 229 | setIsRoutingTableCalculating(bool irtc) |
| 230 | { |
| 231 | m_isRoutingTableCalculating = irtc; |
| 232 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 233 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 234 | bool |
| 235 | getIsRouteCalculationScheduled() |
| 236 | { |
| 237 | return m_isRouteCalculationScheduled; |
| 238 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 239 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 240 | void |
| 241 | setIsRouteCalculationScheduled(bool ircs) |
| 242 | { |
| 243 | m_isRouteCalculationScheduled = ircs; |
| 244 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 245 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 246 | SyncLogicHandler& |
| 247 | getSlh() |
| 248 | { |
| 249 | return m_slh; |
| 250 | } |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 251 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 252 | void |
| 253 | initialize(); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 254 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 255 | private: |
| 256 | ndn::shared_ptr<boost::asio::io_service> m_io; |
| 257 | ndn::shared_ptr<ndn::Face> m_nlsrFace; |
| 258 | ndn::Scheduler m_scheduler; |
| 259 | ConfParameter m_confParam; |
| 260 | Adl m_adl; |
| 261 | Npl m_npl; |
| 262 | InterestManager m_im; |
| 263 | DataManager m_dm; |
| 264 | SequencingManager m_sm; |
| 265 | KeyManager m_km; |
| 266 | bool m_isDaemonProcess; |
| 267 | string m_configFileName; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 268 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 269 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 270 | Lsdb m_nlsrLsdb; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 271 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 272 | |
| 273 | long int m_adjBuildCount; |
| 274 | bool m_isBuildAdjLsaSheduled; |
| 275 | bool m_isRouteCalculationScheduled; |
| 276 | bool m_isRoutingTableCalculating; |
| 277 | |
| 278 | RoutingTable m_routingTable; |
| 279 | Npt m_npt; |
| 280 | Fib m_fib; |
| 281 | SyncLogicHandler m_slh; |
| 282 | |
| 283 | int m_apiPort; |
| 284 | |
| 285 | |
| 286 | }; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 287 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 288 | } //namespace nlsr |
| 289 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame^] | 290 | #endif //NLSR_HPP |