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