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 | |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 25 | #include "adjacency-list.hpp" |
Vince Lehman | 0a7da61 | 2014-10-29 14:39:29 -0500 | [diff] [blame] | 26 | #include "common.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 27 | #include "conf-parameter.hpp" |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 28 | #include "hello-protocol.hpp" |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 29 | #include "lsdb.hpp" |
| 30 | #include "name-prefix-list.hpp" |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 31 | #include "test-access-control.hpp" |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 32 | #include "validator.hpp" |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 33 | #include "publisher/lsdb-dataset-interest-handler.hpp" |
| 34 | #include "route/fib.hpp" |
| 35 | #include "route/name-prefix-table.hpp" |
| 36 | #include "route/routing-table.hpp" |
| 37 | #include "security/certificate-store.hpp" |
| 38 | #include "update/prefix-update-processor.hpp" |
Nick Gordon | 4d2c6c0 | 2017-01-20 13:18:46 -0600 | [diff] [blame] | 39 | #include "update/nfd-rib-command-processor.hpp" |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 40 | #include "utility/name-helper.hpp" |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 41 | |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame^] | 42 | #include <stdexcept> |
| 43 | |
| 44 | #include <ndn-cxx/face.hpp> |
| 45 | #include <ndn-cxx/security/key-chain.hpp> |
| 46 | #include <ndn-cxx/security/certificate-cache-ttl.hpp> |
| 47 | #include <ndn-cxx/util/scheduler.hpp> |
| 48 | #include <ndn-cxx/mgmt/nfd/face-event-notification.hpp> |
| 49 | #include <ndn-cxx/mgmt/nfd/face-monitor.hpp> |
| 50 | #include <ndn-cxx/mgmt/dispatcher.hpp> |
| 51 | #include <ndn-cxx/mgmt/nfd/face-status.hpp> |
| 52 | #include <ndn-cxx/data.hpp> |
| 53 | #include <ndn-cxx/encoding/block.hpp> |
| 54 | |
| 55 | #include <boost/cstdint.hpp> |
| 56 | #include <boost/throw_exception.hpp> |
| 57 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 58 | namespace nlsr { |
| 59 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 60 | static ndn::Name DEFAULT_BROADCAST_PREFIX("/ndn/broadcast"); |
| 61 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 62 | class Nlsr |
| 63 | { |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 64 | public: |
| 65 | using FetchDatasetCallback = std::function<void(const std::vector<ndn::nfd::FaceStatus>&)>; |
| 66 | using FetchDatasetTimeoutCallback = std::function<void(uint32_t, const std::string&)>; |
Nick Gordon | 9461afb | 2017-04-25 15:54:50 -0500 | [diff] [blame] | 67 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 68 | class Error : public std::runtime_error |
| 69 | { |
| 70 | public: |
| 71 | explicit |
| 72 | Error(const std::string& what) |
| 73 | : std::runtime_error(what) |
| 74 | { |
| 75 | } |
| 76 | }; |
| 77 | |
Laqin Fan | a4cf402 | 2017-01-03 18:57:35 +0000 | [diff] [blame] | 78 | 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] | 79 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 80 | void |
| 81 | registrationFailed(const ndn::Name& name); |
| 82 | |
| 83 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 84 | onRegistrationSuccess(const ndn::Name& name); |
| 85 | |
| 86 | void |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 87 | onLocalhostRegistrationSuccess(const ndn::Name& name); |
| 88 | |
| 89 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 90 | setInfoInterestFilter(); |
| 91 | |
| 92 | void |
| 93 | setLsaInterestFilter(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 94 | |
| 95 | void |
| 96 | startEventLoop(); |
| 97 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 98 | std::string |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 99 | getConfFileName() const |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 100 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 101 | return m_configFileName; |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 102 | } |
| 103 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 104 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 105 | setConfFileName(const std::string& fileName) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 106 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 107 | m_configFileName = fileName; |
| 108 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 109 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 110 | bool |
| 111 | getIsSetDaemonProcess() |
| 112 | { |
| 113 | return m_isDaemonProcess; |
| 114 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 115 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 116 | void |
| 117 | setIsDaemonProcess(bool value) |
| 118 | { |
| 119 | m_isDaemonProcess = value; |
| 120 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 121 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 122 | ConfParameter& |
| 123 | getConfParameter() |
| 124 | { |
| 125 | return m_confParam; |
| 126 | } |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 127 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 128 | AdjacencyList& |
| 129 | getAdjacencyList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 130 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 131 | return m_adjacencyList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 132 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 133 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 134 | NamePrefixList& |
| 135 | getNamePrefixList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 136 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 137 | return m_namePrefixList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 138 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 139 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 140 | ndn::Face& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 141 | getNlsrFace() |
| 142 | { |
| 143 | return m_nlsrFace; |
| 144 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 145 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 146 | Lsdb& |
| 147 | getLsdb() |
| 148 | { |
| 149 | return m_nlsrLsdb; |
| 150 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 151 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 152 | RoutingTable& |
| 153 | getRoutingTable() |
| 154 | { |
| 155 | return m_routingTable; |
| 156 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 157 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 158 | NamePrefixTable& |
| 159 | getNamePrefixTable() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 160 | { |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 161 | return m_namePrefixTable; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 162 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 163 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 164 | Fib& |
| 165 | getFib() |
| 166 | { |
| 167 | return m_fib; |
| 168 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 169 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 170 | long int |
| 171 | getAdjBuildCount() |
| 172 | { |
| 173 | return m_adjBuildCount; |
| 174 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 175 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 176 | void |
| 177 | incrementAdjBuildCount() |
| 178 | { |
| 179 | m_adjBuildCount++; |
| 180 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 181 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 182 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 183 | setAdjBuildCount(int64_t abc) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 184 | { |
| 185 | m_adjBuildCount = abc; |
| 186 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 187 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 188 | bool |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 189 | getIsBuildAdjLsaSheduled() |
| 190 | { |
| 191 | return m_isBuildAdjLsaSheduled; |
| 192 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 193 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 194 | void |
| 195 | setIsBuildAdjLsaSheduled(bool iabls) |
| 196 | { |
| 197 | m_isBuildAdjLsaSheduled = iabls; |
| 198 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 199 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 200 | bool |
| 201 | getIsRoutingTableCalculating() |
| 202 | { |
| 203 | return m_isRoutingTableCalculating; |
| 204 | } |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 205 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 206 | void |
| 207 | setIsRoutingTableCalculating(bool irtc) |
| 208 | { |
| 209 | m_isRoutingTableCalculating = irtc; |
| 210 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 211 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 212 | bool |
| 213 | getIsRouteCalculationScheduled() |
| 214 | { |
| 215 | return m_isRouteCalculationScheduled; |
| 216 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 217 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 218 | void |
| 219 | setIsRouteCalculationScheduled(bool ircs) |
| 220 | { |
| 221 | m_isRouteCalculationScheduled = ircs; |
| 222 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 223 | |
Muktadir R Chowdhury | 3ac0728 | 2016-06-17 16:30:29 -0500 | [diff] [blame] | 224 | LsdbDatasetInterestHandler& |
| 225 | getLsdbDatasetHandler() |
| 226 | { |
| 227 | return m_lsdbDatasetHandler; |
| 228 | } |
| 229 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 230 | void |
| 231 | initialize(); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 232 | |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 233 | /*! \brief Initializes neighbors' Faces using information from NFD. |
| 234 | * \sa Nlsr::initialize() |
| 235 | * \sa Nlsr::processFaceDataset() |
| 236 | * |
| 237 | * This function serves as the entry-point for initializing the |
| 238 | * neighbors listed in nlsr.conf during Nlsr::initialize(). NLSR |
| 239 | * will attempt to fetch a dataset of Faces from NFD, and configure |
| 240 | * each of its neighbors using information from that dataset. The |
| 241 | * explicit callbacks allow for better testability. |
| 242 | */ |
| 243 | void |
| 244 | initializeFaces(const FetchDatasetCallback& onFetchSuccess, |
| 245 | const FetchDatasetTimeoutCallback& onFetchFailure); |
| 246 | |
| 247 | void |
| 248 | onFaceDatasetFetchTimeout(uint32_t code, |
| 249 | const std::string& reason, |
| 250 | uint32_t nRetriesSoFar); |
| 251 | |
| 252 | /*! \brief Consumes a Face StatusDataset to configure NLSR neighbors. |
| 253 | * \sa Nlsr::initializeFaces |
| 254 | * \param faces A Face Dataset that should conform to FaceMgmt specifications. |
| 255 | * |
| 256 | * This function processes a Face StatusDataset that should conform |
| 257 | * to the FaceMgmt specifications listed |
| 258 | * [here](https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset). |
| 259 | * Any newly configured neighbors will have prefixes registered with NFD |
| 260 | * and be sent Hello Interests as well. |
| 261 | */ |
| 262 | void |
| 263 | processFaceDataset(const std::vector<ndn::nfd::FaceStatus>& faces); |
| 264 | |
| 265 | /*! \brief Registers NLSR-specific prefixes for a neighbor (Adjacent) |
| 266 | * \sa Nlsr::initializeFaces |
| 267 | * \param adj A reference to the neighbor to register prefixes for |
| 268 | * \param timeout The amount of time to give NFD to respond to *each* registration request. |
| 269 | * |
| 270 | * Registers the prefixes in NFD that NLSR needs to route with a |
| 271 | * neighbor. The timeout given is how long to set the timeout for |
| 272 | * *each* registration request that is made. |
| 273 | */ |
| 274 | void |
| 275 | registerAdjacencyPrefixes(const Adjacent& adj, |
| 276 | const ndn::time::milliseconds& timeout); |
| 277 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 278 | void |
akmhoque | 443ad81 | 2014-07-29 10:26:56 -0500 | [diff] [blame] | 279 | initializeKey(); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 280 | |
| 281 | void |
| 282 | loadValidator(boost::property_tree::ptree section, |
| 283 | const std::string& filename) |
| 284 | { |
| 285 | m_validator.load(section, filename); |
| 286 | } |
| 287 | |
| 288 | Validator& |
| 289 | getValidator() |
| 290 | { |
| 291 | return m_validator; |
| 292 | } |
| 293 | |
| 294 | void |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 295 | loadCertToPublish(std::shared_ptr<ndn::IdentityCertificate> certificate) |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 296 | { |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 297 | m_certStore.insert(certificate); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 298 | } |
| 299 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 300 | std::shared_ptr<const ndn::IdentityCertificate> |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 301 | getCertificate(const ndn::Name& certificateNameWithoutVersion) |
| 302 | { |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 303 | shared_ptr<const ndn::IdentityCertificate> cert = |
| 304 | m_certStore.find(certificateNameWithoutVersion); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 305 | |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 306 | if (cert != nullptr) { |
| 307 | return cert; |
| 308 | } |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 309 | |
| 310 | return m_certificateCache->getCertificate(certificateNameWithoutVersion); |
| 311 | } |
| 312 | |
| 313 | ndn::KeyChain& |
| 314 | getKeyChain() |
| 315 | { |
| 316 | return m_keyChain; |
| 317 | } |
| 318 | |
| 319 | const ndn::Name& |
| 320 | getDefaultCertName() |
| 321 | { |
| 322 | return m_defaultCertName; |
| 323 | } |
| 324 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 325 | update::PrefixUpdateProcessor& |
| 326 | getPrefixUpdateProcessor() |
| 327 | { |
| 328 | return m_prefixUpdateProcessor; |
| 329 | } |
| 330 | |
Nick Gordon | 4d2c6c0 | 2017-01-20 13:18:46 -0600 | [diff] [blame] | 331 | update::NfdRibCommandProcessor& |
| 332 | getNfdRibCommandProcessor() |
| 333 | { |
| 334 | return m_nfdRibCommandProcessor; |
| 335 | } |
| 336 | |
Nick Gordon | d1f4f33 | 2017-01-20 13:40:57 -0600 | [diff] [blame] | 337 | ndn::mgmt::Dispatcher& |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame^] | 338 | getLocalhostDispatcher() |
Nick Gordon | d1f4f33 | 2017-01-20 13:40:57 -0600 | [diff] [blame] | 339 | { |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 340 | return m_localhostDispatcher; |
| 341 | } |
| 342 | |
| 343 | ndn::mgmt::Dispatcher& |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame^] | 344 | getRouterNameDispatcher() |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 345 | { |
| 346 | return m_routerNameDispatcher; |
Nick Gordon | d1f4f33 | 2017-01-20 13:40:57 -0600 | [diff] [blame] | 347 | } |
| 348 | |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 349 | void |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 350 | setStrategies(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 351 | |
akmhoque | 0494c25 | 2014-07-23 23:46:44 -0500 | [diff] [blame] | 352 | void |
| 353 | daemonize(); |
| 354 | |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 355 | uint32_t |
| 356 | getFirstHelloInterval() const |
| 357 | { |
| 358 | return m_firstHelloInterval; |
| 359 | } |
| 360 | |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 361 | /*! \brief Canonize the URI for this and all proceeding neighbors in a list. |
Nick Gordon | 9461afb | 2017-04-25 15:54:50 -0500 | [diff] [blame] | 362 | * |
| 363 | * This function canonizes the URI of the Adjacent object pointed to |
| 364 | * by currentNeighbor. It then executes the then callback, providing |
| 365 | * the next iterator in the list to the callback. A standard |
| 366 | * invocation would be to pass the begin() iterator of NLSR's |
| 367 | * adjacency list, and to provide Nlsr::canonizeContinuation as the |
| 368 | * callback. Because every URI must be canonical before we begin |
| 369 | * operations, the canonize function must call initialize itself. |
| 370 | * |
| 371 | * \sa Nlsr::canonizeContinuation |
| 372 | * \sa Nlsr::initialize |
| 373 | * \sa NlsrRunner::run |
| 374 | */ |
| 375 | void |
| 376 | canonizeNeighborUris(std::list<Adjacent>::iterator currentNeighbor, |
| 377 | std::function<void(std::list<Adjacent>::iterator)> then); |
| 378 | |
| 379 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 380 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 381 | void |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 382 | addCertificateToCache(std::shared_ptr<ndn::IdentityCertificate> certificate) |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 383 | { |
| 384 | if (certificate != nullptr) { |
| 385 | m_certificateCache->insertCertificate(certificate); |
| 386 | } |
| 387 | } |
| 388 | |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 389 | security::CertificateStore& |
| 390 | getCertificateStore() |
| 391 | { |
| 392 | return m_certStore; |
| 393 | } |
| 394 | |
akmhoque | 393d4ff | 2014-07-16 14:27:03 -0500 | [diff] [blame] | 395 | private: |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 396 | void |
| 397 | registerKeyPrefix(); |
| 398 | |
| 399 | void |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 400 | registerLocalhostPrefix(); |
| 401 | |
| 402 | void |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 403 | onKeyInterest(const ndn::Name& name, const ndn::Interest& interest); |
| 404 | |
| 405 | void |
| 406 | onKeyPrefixRegSuccess(const ndn::Name& name); |
| 407 | |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 408 | void |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 409 | onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification); |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 410 | |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 411 | void |
| 412 | setFirstHelloInterval(uint32_t interval) |
| 413 | { |
| 414 | m_firstHelloInterval = interval; |
| 415 | } |
| 416 | |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 417 | /*! \brief Continues canonizing neighbor URIs. |
Nick Gordon | 9461afb | 2017-04-25 15:54:50 -0500 | [diff] [blame] | 418 | * |
| 419 | * For testability reasons, we want what each instance of |
| 420 | * canonization does after completion to be controllable. The best |
| 421 | * way to do this is to control that by simply passing a |
| 422 | * continuation function. |
| 423 | */ |
| 424 | void |
| 425 | canonizeContinuation(std::list<Adjacent>::iterator iterator); |
| 426 | |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 427 | void |
| 428 | scheduleDatasetFetch(); |
| 429 | |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 430 | public: |
| 431 | static const ndn::Name LOCALHOST_PREFIX; |
| 432 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 433 | private: |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 434 | ndn::Face& m_nlsrFace; |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 435 | ndn::Scheduler& m_scheduler; |
Laqin Fan | a4cf402 | 2017-01-03 18:57:35 +0000 | [diff] [blame] | 436 | ndn::KeyChain& m_keyChain; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 437 | ConfParameter m_confParam; |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 438 | AdjacencyList m_adjacencyList; |
| 439 | NamePrefixList m_namePrefixList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 440 | bool m_isDaemonProcess; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 441 | std::string m_configFileName; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 442 | Lsdb m_nlsrLsdb; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 443 | int64_t m_adjBuildCount; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 444 | bool m_isBuildAdjLsaSheduled; |
| 445 | bool m_isRouteCalculationScheduled; |
| 446 | bool m_isRoutingTableCalculating; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 447 | RoutingTable m_routingTable; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 448 | Fib m_fib; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 449 | NamePrefixTable m_namePrefixTable; |
Laqin Fan | 54a43f0 | 2017-03-08 12:31:30 -0600 | [diff] [blame^] | 450 | |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 451 | ndn::mgmt::Dispatcher m_localhostDispatcher; |
| 452 | ndn::mgmt::Dispatcher m_routerNameDispatcher; |
| 453 | |
Vince Lehman | d6bb3fa | 2015-04-24 14:21:39 -0500 | [diff] [blame] | 454 | LsdbDatasetInterestHandler m_lsdbDatasetHandler; |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 455 | |
Vince Lehman | f7eec4f | 2015-05-08 19:02:31 -0500 | [diff] [blame] | 456 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 457 | HelloProtocol m_helloProtocol; |
| 458 | |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 459 | private: |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 460 | std::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache; |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 461 | security::CertificateStore m_certStore; |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 462 | |
| 463 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 464 | Validator m_validator; |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 465 | |
| 466 | private: |
| 467 | ndn::nfd::Controller m_controller; |
| 468 | ndn::nfd::Controller m_faceDatasetController; |
Joao Pereira | 97473d4 | 2015-07-03 16:57:27 -0400 | [diff] [blame] | 469 | ndn::security::SigningInfo m_signingInfo; |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 470 | ndn::Name m_defaultCertName; |
alvy | 297f416 | 2015-03-03 17:15:33 -0600 | [diff] [blame] | 471 | update::PrefixUpdateProcessor m_prefixUpdateProcessor; |
Nick Gordon | 4d2c6c0 | 2017-01-20 13:18:46 -0600 | [diff] [blame] | 472 | update::NfdRibCommandProcessor m_nfdRibCommandProcessor; |
akmhoque | e176515 | 2014-06-30 11:32:01 -0500 | [diff] [blame] | 473 | |
akmhoque | 060d302 | 2014-08-12 13:35:06 -0500 | [diff] [blame] | 474 | ndn::nfd::FaceMonitor m_faceMonitor; |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 475 | |
| 476 | uint32_t m_firstHelloInterval; |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 477 | |
| 478 | friend class NlsrRunner; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 479 | }; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 480 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 481 | } // namespace nlsr |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 482 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 483 | #endif // NLSR_NLSR_HPP |