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