akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | c6a8522 | 2017-01-03 16:54:34 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 21 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 22 | #ifndef NLSR_NLSR_HPP |
| 23 | #define NLSR_NLSR_HPP |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 24 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 25 | #include <boost/cstdint.hpp> |
| 26 | #include <stdexcept> |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 27 | #include <boost/throw_exception.hpp> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 28 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 29 | #include <ndn-cxx/face.hpp> |
| 30 | #include <ndn-cxx/security/key-chain.hpp> |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 31 | #include <ndn-cxx/security/certificate-cache-ttl.hpp> |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 32 | #include <ndn-cxx/util/scheduler.hpp> |
Junxiao Shi | 3e5120c | 2016-09-10 16:58:34 +0000 | [diff] [blame] | 33 | #include <ndn-cxx/mgmt/nfd/face-event-notification.hpp> |
| 34 | #include <ndn-cxx/mgmt/nfd/face-monitor.hpp> |
Nick Gordon | d1f4f33 | 2017-01-20 13:40:57 -0600 | [diff] [blame] | 35 | #include <ndn-cxx/mgmt/dispatcher.hpp> |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 36 | |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 37 | #include "adjacency-list.hpp" |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 38 | #include "common.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 39 | #include "conf-parameter.hpp" |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 40 | #include "hello-protocol.hpp" |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 41 | #include "lsdb.hpp" |
| 42 | #include "name-prefix-list.hpp" |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 43 | #include "test-access-control.hpp" |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 44 | #include "validator.hpp" |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 45 | #include "publisher/lsdb-dataset-interest-handler.hpp" |
| 46 | #include "route/fib.hpp" |
| 47 | #include "route/name-prefix-table.hpp" |
| 48 | #include "route/routing-table.hpp" |
| 49 | #include "security/certificate-store.hpp" |
| 50 | #include "update/prefix-update-processor.hpp" |
Nick Gordon | 4d2c6c0 | 2017-01-20 13:18:46 -0600 | [diff] [blame] | 51 | #include "update/nfd-rib-command-processor.hpp" |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 52 | #include "utility/name-helper.hpp" |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 53 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 54 | namespace nlsr { |
| 55 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 56 | static ndn::Name DEFAULT_BROADCAST_PREFIX("/ndn/broadcast"); |
| 57 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 58 | class Nlsr |
| 59 | { |
Nick Gordon | 9461afb | 2017-04-25 15:54:50 -0500 | [diff] [blame] | 60 | friend class NlsrRunner; |
| 61 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 62 | class Error : public std::runtime_error |
| 63 | { |
| 64 | public: |
| 65 | explicit |
| 66 | Error(const std::string& what) |
| 67 | : std::runtime_error(what) |
| 68 | { |
| 69 | } |
| 70 | }; |
| 71 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 72 | public: |
Laqin Fan | a4cf402 | 2017-01-03 18:57:35 +0000 | [diff] [blame] | 73 | Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face, ndn::KeyChain& keyChain); |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 74 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 75 | void |
| 76 | registrationFailed(const ndn::Name& name); |
| 77 | |
| 78 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 79 | onRegistrationSuccess(const ndn::Name& name); |
| 80 | |
| 81 | void |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 82 | onLocalhostRegistrationSuccess(const ndn::Name& name); |
| 83 | |
| 84 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 85 | setInfoInterestFilter(); |
| 86 | |
| 87 | void |
| 88 | setLsaInterestFilter(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 89 | |
| 90 | void |
| 91 | startEventLoop(); |
| 92 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 93 | std::string |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 94 | getConfFileName() const |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 95 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 96 | return m_configFileName; |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 97 | } |
| 98 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 99 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 100 | setConfFileName(const std::string& fileName) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 101 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 102 | m_configFileName = fileName; |
| 103 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 104 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 105 | bool |
| 106 | getIsSetDaemonProcess() |
| 107 | { |
| 108 | return m_isDaemonProcess; |
| 109 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 110 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 111 | void |
| 112 | setIsDaemonProcess(bool value) |
| 113 | { |
| 114 | m_isDaemonProcess = value; |
| 115 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 116 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 117 | ConfParameter& |
| 118 | getConfParameter() |
| 119 | { |
| 120 | return m_confParam; |
| 121 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 122 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 123 | AdjacencyList& |
| 124 | getAdjacencyList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 125 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 126 | return m_adjacencyList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 127 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 128 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 129 | NamePrefixList& |
| 130 | getNamePrefixList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 131 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 132 | return m_namePrefixList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 133 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 134 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 135 | ndn::Face& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 136 | getNlsrFace() |
| 137 | { |
| 138 | return m_nlsrFace; |
| 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 | Lsdb& |
| 142 | getLsdb() |
| 143 | { |
| 144 | return m_nlsrLsdb; |
| 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 | RoutingTable& |
| 148 | getRoutingTable() |
| 149 | { |
| 150 | return m_routingTable; |
| 151 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 152 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 153 | NamePrefixTable& |
| 154 | getNamePrefixTable() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 155 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 156 | return m_namePrefixTable; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 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 | Fib& |
| 160 | getFib() |
| 161 | { |
| 162 | return m_fib; |
| 163 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 164 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 165 | long int |
| 166 | getAdjBuildCount() |
| 167 | { |
| 168 | return m_adjBuildCount; |
| 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 | void |
| 172 | incrementAdjBuildCount() |
| 173 | { |
| 174 | m_adjBuildCount++; |
| 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 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 178 | setAdjBuildCount(int64_t abc) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 179 | { |
| 180 | m_adjBuildCount = abc; |
| 181 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 182 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 183 | bool |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 184 | getIsBuildAdjLsaSheduled() |
| 185 | { |
| 186 | return m_isBuildAdjLsaSheduled; |
| 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 |
| 190 | setIsBuildAdjLsaSheduled(bool iabls) |
| 191 | { |
| 192 | m_isBuildAdjLsaSheduled = iabls; |
| 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 | bool |
| 196 | getIsRoutingTableCalculating() |
| 197 | { |
| 198 | return m_isRoutingTableCalculating; |
| 199 | } |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 200 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 201 | void |
| 202 | setIsRoutingTableCalculating(bool irtc) |
| 203 | { |
| 204 | m_isRoutingTableCalculating = irtc; |
| 205 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 206 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 207 | bool |
| 208 | getIsRouteCalculationScheduled() |
| 209 | { |
| 210 | return m_isRouteCalculationScheduled; |
| 211 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 212 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 213 | void |
| 214 | setIsRouteCalculationScheduled(bool ircs) |
| 215 | { |
| 216 | m_isRouteCalculationScheduled = ircs; |
| 217 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 218 | |
Muktadir R Chowdhury | 3ac0728 | 2016-06-17 16:30:29 -0500 | [diff] [blame] | 219 | LsdbDatasetInterestHandler& |
| 220 | getLsdbDatasetHandler() |
| 221 | { |
| 222 | return m_lsdbDatasetHandler; |
| 223 | } |
| 224 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 225 | void |
| 226 | initialize(); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 227 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 228 | void |
akmhoque | 443ad81 | 2014-07-29 10:26:56 -0500 | [diff] [blame] | 229 | initializeKey(); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 230 | |
| 231 | void |
| 232 | loadValidator(boost::property_tree::ptree section, |
| 233 | const std::string& filename) |
| 234 | { |
| 235 | m_validator.load(section, filename); |
| 236 | } |
| 237 | |
| 238 | Validator& |
| 239 | getValidator() |
| 240 | { |
| 241 | return m_validator; |
| 242 | } |
| 243 | |
| 244 | void |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 245 | loadCertToPublish(std::shared_ptr<ndn::IdentityCertificate> certificate) |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 246 | { |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 247 | m_certStore.insert(certificate); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 248 | } |
| 249 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 250 | std::shared_ptr<const ndn::IdentityCertificate> |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 251 | getCertificate(const ndn::Name& certificateNameWithoutVersion) |
| 252 | { |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 253 | shared_ptr<const ndn::IdentityCertificate> cert = |
| 254 | m_certStore.find(certificateNameWithoutVersion); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 255 | |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 256 | if (cert != nullptr) { |
| 257 | return cert; |
| 258 | } |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 259 | |
| 260 | return m_certificateCache->getCertificate(certificateNameWithoutVersion); |
| 261 | } |
| 262 | |
| 263 | ndn::KeyChain& |
| 264 | getKeyChain() |
| 265 | { |
| 266 | return m_keyChain; |
| 267 | } |
| 268 | |
| 269 | const ndn::Name& |
| 270 | getDefaultCertName() |
| 271 | { |
| 272 | return m_defaultCertName; |
| 273 | } |
| 274 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 275 | update::PrefixUpdateProcessor& |
| 276 | getPrefixUpdateProcessor() |
| 277 | { |
| 278 | return m_prefixUpdateProcessor; |
| 279 | } |
| 280 | |
Nick Gordon | 4d2c6c0 | 2017-01-20 13:18:46 -0600 | [diff] [blame] | 281 | update::NfdRibCommandProcessor& |
| 282 | getNfdRibCommandProcessor() |
| 283 | { |
| 284 | return m_nfdRibCommandProcessor; |
| 285 | } |
| 286 | |
Nick Gordon | d1f4f33 | 2017-01-20 13:40:57 -0600 | [diff] [blame] | 287 | ndn::mgmt::Dispatcher& |
| 288 | getDispatcher() |
| 289 | { |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame^] | 290 | return m_localhostDispatcher; |
| 291 | } |
| 292 | |
| 293 | ndn::mgmt::Dispatcher& |
| 294 | getDispatcherRouterName() |
| 295 | { |
| 296 | return m_routerNameDispatcher; |
Nick Gordon | d1f4f33 | 2017-01-20 13:40:57 -0600 | [diff] [blame] | 297 | } |
| 298 | |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 299 | void |
| 300 | createFace(const std::string& faceUri, |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 301 | const CommandSucceedCallback& onSuccess, |
| 302 | const CommandFailCallback& onFailure); |
| 303 | |
| 304 | void |
| 305 | destroyFaces(); |
| 306 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 307 | void |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 308 | setStrategies(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 309 | |
akmhoque | 0494c25 | 2014-07-23 23:46:44 -0500 | [diff] [blame] | 310 | void |
| 311 | daemonize(); |
| 312 | |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 313 | uint32_t |
| 314 | getFirstHelloInterval() const |
| 315 | { |
| 316 | return m_firstHelloInterval; |
| 317 | } |
| 318 | |
Nick Gordon | 9461afb | 2017-04-25 15:54:50 -0500 | [diff] [blame] | 319 | /** |
| 320 | * \brief Canonize the URI for this and all proceeding neighbors in a list. |
| 321 | * |
| 322 | * This function canonizes the URI of the Adjacent object pointed to |
| 323 | * by currentNeighbor. It then executes the then callback, providing |
| 324 | * the next iterator in the list to the callback. A standard |
| 325 | * invocation would be to pass the begin() iterator of NLSR's |
| 326 | * adjacency list, and to provide Nlsr::canonizeContinuation as the |
| 327 | * callback. Because every URI must be canonical before we begin |
| 328 | * operations, the canonize function must call initialize itself. |
| 329 | * |
| 330 | * \sa Nlsr::canonizeContinuation |
| 331 | * \sa Nlsr::initialize |
| 332 | * \sa NlsrRunner::run |
| 333 | */ |
| 334 | void |
| 335 | canonizeNeighborUris(std::list<Adjacent>::iterator currentNeighbor, |
| 336 | std::function<void(std::list<Adjacent>::iterator)> then); |
| 337 | |
| 338 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 339 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 340 | void |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 341 | addCertificateToCache(std::shared_ptr<ndn::IdentityCertificate> certificate) |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 342 | { |
| 343 | if (certificate != nullptr) { |
| 344 | m_certificateCache->insertCertificate(certificate); |
| 345 | } |
| 346 | } |
| 347 | |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 348 | security::CertificateStore& |
| 349 | getCertificateStore() |
| 350 | { |
| 351 | return m_certStore; |
| 352 | } |
| 353 | |
akmhoque | 393d4ff | 2014-07-16 14:27:03 -0500 | [diff] [blame] | 354 | private: |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 355 | void |
| 356 | registerKeyPrefix(); |
| 357 | |
| 358 | void |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 359 | registerLocalhostPrefix(); |
| 360 | |
| 361 | void |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 362 | onKeyInterest(const ndn::Name& name, const ndn::Interest& interest); |
| 363 | |
| 364 | void |
| 365 | onKeyPrefixRegSuccess(const ndn::Name& name); |
| 366 | |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 367 | void |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 368 | onDestroyFaceSuccess(const ndn::nfd::ControlParameters& commandSuccessResult); |
| 369 | |
| 370 | void |
Junxiao Shi | 63bd034 | 2016-08-17 16:57:14 +0000 | [diff] [blame] | 371 | onDestroyFaceFailure(const ndn::nfd::ControlResponse& response); |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 372 | |
| 373 | void |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 374 | onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification); |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 375 | |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 376 | void |
| 377 | setFirstHelloInterval(uint32_t interval) |
| 378 | { |
| 379 | m_firstHelloInterval = interval; |
| 380 | } |
| 381 | |
Nick Gordon | 9461afb | 2017-04-25 15:54:50 -0500 | [diff] [blame] | 382 | /** |
| 383 | * \brief Continues canonizing neighbor URIs. |
| 384 | * |
| 385 | * For testability reasons, we want what each instance of |
| 386 | * canonization does after completion to be controllable. The best |
| 387 | * way to do this is to control that by simply passing a |
| 388 | * continuation function. |
| 389 | */ |
| 390 | void |
| 391 | canonizeContinuation(std::list<Adjacent>::iterator iterator); |
| 392 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 393 | public: |
| 394 | static const ndn::Name LOCALHOST_PREFIX; |
| 395 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 396 | private: |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 397 | ndn::Face& m_nlsrFace; |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 398 | ndn::Scheduler& m_scheduler; |
Laqin Fan | a4cf402 | 2017-01-03 18:57:35 +0000 | [diff] [blame] | 399 | ndn::KeyChain& m_keyChain; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 400 | ConfParameter m_confParam; |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 401 | AdjacencyList m_adjacencyList; |
| 402 | NamePrefixList m_namePrefixList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 403 | bool m_isDaemonProcess; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 404 | std::string m_configFileName; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 405 | Lsdb m_nlsrLsdb; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 406 | int64_t m_adjBuildCount; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 407 | bool m_isBuildAdjLsaSheduled; |
| 408 | bool m_isRouteCalculationScheduled; |
| 409 | bool m_isRoutingTableCalculating; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 410 | RoutingTable m_routingTable; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 411 | Fib m_fib; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 412 | NamePrefixTable m_namePrefixTable; |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame^] | 413 | ndn::mgmt::Dispatcher m_localhostDispatcher; |
| 414 | ndn::mgmt::Dispatcher m_routerNameDispatcher; |
| 415 | |
Vince Lehman | d6bb3fa | 2015-04-24 14:21:39 -0500 | [diff] [blame] | 416 | LsdbDatasetInterestHandler m_lsdbDatasetHandler; |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 417 | |
Vince Lehman | f7eec4f | 2015-05-08 19:02:31 -0500 | [diff] [blame] | 418 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 419 | HelloProtocol m_helloProtocol; |
| 420 | |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 421 | private: |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 422 | std::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache; |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 423 | security::CertificateStore m_certStore; |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 424 | Validator m_validator; |
Joao Pereira | 97473d4 | 2015-07-03 16:57:27 -0400 | [diff] [blame] | 425 | ndn::security::SigningInfo m_signingInfo; |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 426 | ndn::Name m_defaultCertName; |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 427 | update::PrefixUpdateProcessor m_prefixUpdateProcessor; |
Nick Gordon | 4d2c6c0 | 2017-01-20 13:18:46 -0600 | [diff] [blame] | 428 | update::NfdRibCommandProcessor m_nfdRibCommandProcessor; |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 429 | |
akmhoque | 060d302 | 2014-08-12 13:35:06 -0500 | [diff] [blame] | 430 | ndn::nfd::FaceMonitor m_faceMonitor; |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 431 | |
| 432 | uint32_t m_firstHelloInterval; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 433 | }; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 434 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 435 | } // namespace nlsr |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 436 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 437 | #endif // NLSR_NLSR_HPP |