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