nlsr.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #include "nlsr.hpp"
23 #include "adjacent.hpp"
24 #include "logger.hpp"
25 
26 #include <cstdlib>
27 #include <string>
28 #include <sstream>
29 #include <cstdio>
30 #include <unistd.h>
31 #include <vector>
32 
33 #include <ndn-cxx/net/face-uri.hpp>
34 #include <ndn-cxx/signature.hpp>
35 
36 namespace nlsr {
37 
38 INIT_LOGGER(Nlsr);
39 
40 const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
41 
42 Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
43  : m_face(face)
44  , m_scheduler(face.getIoService())
45  , m_keyChain(keyChain)
46  , m_confParam(confParam)
47  , m_adjacencyList(confParam.getAdjacencyList())
48  , m_namePrefixList(confParam.getNamePrefixList())
49  , m_validator(m_confParam.getValidator())
50  , m_fib(m_face, m_scheduler, m_adjacencyList, m_confParam, m_keyChain)
51  , m_routingTable(m_scheduler, m_fib, m_lsdb, m_namePrefixTable, m_confParam)
52  , m_namePrefixTable(m_fib, m_routingTable, m_routingTable.afterRoutingChange)
53  , m_lsdb(m_face, m_keyChain, m_signingInfo,
54  m_confParam, m_namePrefixTable, m_routingTable)
55  , m_afterSegmentValidatedConnection(m_lsdb.afterSegmentValidatedSignal.connect(
56  std::bind(&Nlsr::afterFetcherSignalEmitted, this, _1)))
57  , m_dispatcher(m_face, m_keyChain)
58  , m_datasetHandler(m_dispatcher, m_lsdb, m_routingTable)
59  , m_helloProtocol(m_face, m_keyChain, m_signingInfo, confParam, m_routingTable, m_lsdb)
60  , m_certStore(m_confParam.getCertStore())
61  , m_controller(m_face, m_keyChain)
62  , m_faceDatasetController(m_face, m_keyChain)
63  , m_prefixUpdateProcessor(m_dispatcher,
64  m_confParam.getPrefixUpdateValidator(),
65  m_namePrefixList,
66  m_lsdb,
67  m_confParam.getConfFileNameDynamic())
68  , m_nfdRibCommandProcessor(m_dispatcher,
69  m_namePrefixList,
70  m_lsdb)
71  , m_statsCollector(m_lsdb, m_helloProtocol)
72  , m_faceMonitor(m_face)
73 {
74  m_faceMonitor.onNotification.connect(std::bind(&Nlsr::onFaceEventNotification, this, _1));
75  m_faceMonitor.start();
76 
77  setStrategies();
78 }
79 
80 void
81 Nlsr::registrationFailed(const ndn::Name& name)
82 {
83  NLSR_LOG_ERROR("ERROR: Failed to register prefix in local hub's daemon");
84  BOOST_THROW_EXCEPTION(Error("Error: Prefix registration failed"));
85 }
86 
87 void
88 Nlsr::onRegistrationSuccess(const ndn::Name& name)
89 {
90  NLSR_LOG_DEBUG("Successfully registered prefix: " << name);
91 }
92 
93 void
95 {
96  ndn::Name name(m_confParam.getRouterPrefix());
97  name.append("nlsr");
98  name.append("INFO");
99 
100  NLSR_LOG_DEBUG("Setting interest filter for Hello interest: " << name);
101 
102  m_face.setInterestFilter(ndn::InterestFilter(name).allowLoopback(false),
103  std::bind(&HelloProtocol::processInterest, &m_helloProtocol, _1, _2),
104  std::bind(&Nlsr::onRegistrationSuccess, this, _1),
105  std::bind(&Nlsr::registrationFailed, this, _1),
106  m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
107 }
108 
109 void
111 {
112  ndn::Name name = m_confParam.getLsaPrefix();
113 
114  NLSR_LOG_DEBUG("Setting interest filter for LsaPrefix: " << name);
115 
116  m_face.setInterestFilter(ndn::InterestFilter(name).allowLoopback(false),
117  std::bind(&Lsdb::processInterest, &m_lsdb, _1, _2),
118  std::bind(&Nlsr::onRegistrationSuccess, this, _1),
119  std::bind(&Nlsr::registrationFailed, this, _1),
120  m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
121 }
122 
123 void
124 Nlsr::addDispatcherTopPrefix(const ndn::Name& topPrefix)
125 {
126  try {
127  // false since we want to have control over the registration process
128  m_dispatcher.addTopPrefix(topPrefix, false, m_signingInfo);
129  }
130  catch (const std::exception& e) {
131  NLSR_LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
132  }
133 }
134 
135 void
137 {
138  const std::string strategy("ndn:/localhost/nfd/strategy/multicast");
139 
140  m_fib.setStrategy(m_confParam.getLsaPrefix(), strategy, 0);
141  m_fib.setStrategy(m_confParam.getSyncPrefix(), strategy, 0);
142 }
143 
144 void
145 Nlsr::loadCertToPublish(const ndn::security::v2::Certificate& certificate)
146 {
147  NLSR_LOG_TRACE("Loading cert to publish.");
148  m_certStore.insert(certificate);
149  m_validator.loadAnchor("Authoritative-Certificate",
150  ndn::security::v2::Certificate(certificate));
151  m_prefixUpdateProcessor.getValidator().
152  loadAnchor("Authoritative-Certificate",
153  ndn::security::v2::Certificate(certificate));
154 }
155 
156 void
157 Nlsr::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
158 {
159  NLSR_LOG_TRACE("SegmentFetcher fetched a data segment. Start inserting cert to own cert store.");
160  ndn::Name keyName = lsaSegment.getSignature().getKeyLocator().getName();
161  if (getCertificate(keyName) == nullptr) {
162  publishCertFromCache(keyName);
163  }
164  else {
165  NLSR_LOG_TRACE("Certificate is already in the store: " << keyName);
166  }
167 }
168 
169 void
170 Nlsr::publishCertFromCache(const ndn::Name& keyName)
171 {
172  const ndn::security::v2::Certificate* cert = m_validator.getUnverifiedCertCache()
173  .find(keyName);
174  if (cert != nullptr) {
175  m_certStore.insert(*cert);
176  NLSR_LOG_TRACE(*cert);
177  ndn::Name certName = ndn::security::v2::extractKeyNameFromCertName(cert->getName());
178  NLSR_LOG_TRACE("Setting interest filter for: " << certName);
179  m_face.setInterestFilter(ndn::InterestFilter(certName).allowLoopback(false),
180  std::bind(&Nlsr::onKeyInterest, this, _1, _2),
181  std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
182  std::bind(&Nlsr::registrationFailed, this, _1),
183  m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
184 
185  if (!cert->getKeyName().equals(cert->getSignature().getKeyLocator().getName())) {
186  publishCertFromCache(cert->getSignature().getKeyLocator().getName());
187  }
188  }
189  else {
190  NLSR_LOG_TRACE("Cert for " << keyName << " was not found in the Validator's cache. ");
191  }
192 }
193 
194 void
196 {
197  NLSR_LOG_DEBUG("Initializing Nlsr");
198 
199  // Logging start
200  m_adjacencyList.writeLog();
201  NLSR_LOG_DEBUG(m_namePrefixList);
202 
203  initializeKey();
204 
205  NLSR_LOG_DEBUG("Default NLSR identity: " << m_signingInfo.getSignerName());
206 
207  // Can be moved to HelloProtocol and Lsdb ctor if initializeKey is set
208  // earlier in the Nlsr constructor so as to set m_signingInfo
211 
212  // add top-level prefixes: router and localhost prefix
213  addDispatcherTopPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"));
215 
216  initializeFaces(std::bind(&Nlsr::processFaceDataset, this, _1),
217  std::bind(&Nlsr::onFaceDatasetFetchTimeout, this, _1, _2, 0));
218 
219  enableIncomingFaceIdIndication();
220 
221  m_lsdb.buildAndInstallOwnNameLsa();
222 
223  // Install coordinate LSAs if using HR or dry-run HR.
224  if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
226  }
227 
228  registerKeyPrefix();
229  registerLocalhostPrefix();
230  registerRouterPrefix();
231 
232  m_helloProtocol.scheduleInterest(m_confParam.getFirstHelloInterval());
233 
234  // Need to set direct neighbors' costs to 0 for hyperbolic routing
235  if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
236 
237  std::list<Adjacent>& neighbors = m_adjacencyList.getAdjList();
238 
239  for (std::list<Adjacent>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) {
240  it->setLinkCost(0);
241  }
242  }
243 }
244 
245 void
247 {
248  NLSR_LOG_DEBUG("Initializing Key ...");
249 
250  ndn::Name nlsrInstanceName = m_confParam.getRouterPrefix();
251  nlsrInstanceName.append("nlsr");
252 
253  try {
254  m_keyChain.deleteIdentity(m_keyChain.getPib().getIdentity(nlsrInstanceName));
255  } catch (const std::exception& e) {
256  NLSR_LOG_WARN(e.what());
257  }
258 
259  auto nlsrInstanceIdentity = m_keyChain.createIdentity(nlsrInstanceName);
260  auto nlsrInstanceKey = nlsrInstanceIdentity.getDefaultKey();
261 
262  ndn::security::v2::Certificate certificate;
263 
264  ndn::Name certificateName = nlsrInstanceKey.getName();
265  certificateName.append("NA");
266  certificateName.appendVersion();
267  certificate.setName(certificateName);
268 
269  // set metainfo
270  certificate.setContentType(ndn::tlv::ContentType_Key);
271  certificate.setFreshnessPeriod(ndn::time::days(365));
272 
273  // set content
274  certificate.setContent(nlsrInstanceKey.getPublicKey().data(), nlsrInstanceKey.getPublicKey().size());
275 
276  // set signature-info
277  ndn::SignatureInfo signatureInfo;
278  signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(ndn::time::system_clock::TimePoint(),
279  ndn::time::system_clock::now()
280  + ndn::time::days(365)));
281  try {
282  m_keyChain.sign(certificate,
283  ndn::security::SigningInfo(m_keyChain.getPib().getIdentity(m_confParam.getRouterPrefix()))
284  .setSignatureInfo(signatureInfo));
285  }
286  catch (const std::exception& e) {
287  NLSR_LOG_WARN("ERROR: Router's " << e.what()
288  << "NLSR is running without security."
289  << " If security is enabled NLSR will not converge.");
290 
291  std::cerr << "Router's " << e.what() << ". NLSR is running without security "
292  << "(Only for testing, should not be used in production.)"
293  << " If security is enabled NLSR will not converge." << std::endl;
294  }
295 
296  m_signingInfo = ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID,
297  nlsrInstanceName);
298 
299  loadCertToPublish(certificate);
300 }
301 
302 void
303 Nlsr::registerKeyPrefix()
304 {
305  // Start listening for the interest of this router's NLSR certificate
306  ndn::Name nlsrKeyPrefix = m_confParam.getRouterPrefix();
307  nlsrKeyPrefix.append("nlsr");
308  nlsrKeyPrefix.append("KEY");
309 
310  m_face.setInterestFilter(ndn::InterestFilter(nlsrKeyPrefix).allowLoopback(false),
311  std::bind(&Nlsr::onKeyInterest, this, _1, _2),
312  std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
313  std::bind(&Nlsr::registrationFailed, this, _1),
314  m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
315 
316  // Start listening for the interest of this router's certificate
317  ndn::Name routerKeyPrefix = m_confParam.getRouterPrefix();
318  routerKeyPrefix.append("KEY");
319 
320  m_face.setInterestFilter(ndn::InterestFilter(routerKeyPrefix).allowLoopback(false),
321  std::bind(&Nlsr::onKeyInterest, this, _1, _2),
322  std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
323  std::bind(&Nlsr::registrationFailed, this, _1),
324  m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
325 
326  // Start listening for the interest of this router's operator's certificate
327  ndn::Name operatorKeyPrefix = m_confParam.getNetwork();
328  operatorKeyPrefix.append(m_confParam.getSiteName());
329  operatorKeyPrefix.append(std::string("%C1.Operator"));
330 
331  m_face.setInterestFilter(ndn::InterestFilter(operatorKeyPrefix).allowLoopback(false),
332  std::bind(&Nlsr::onKeyInterest, this, _1, _2),
333  std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
334  std::bind(&Nlsr::registrationFailed, this, _1),
335  m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
336 
337  // Start listening for the interest of this router's site's certificate
338  ndn::Name siteKeyPrefix = m_confParam.getNetwork();
339  siteKeyPrefix.append(m_confParam.getSiteName());
340  siteKeyPrefix.append("KEY");
341 
342  m_face.setInterestFilter(ndn::InterestFilter(siteKeyPrefix).allowLoopback(false),
343  std::bind(&Nlsr::onKeyInterest, this, _1, _2),
344  std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
345  std::bind(&Nlsr::registrationFailed, this, _1),
346  m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
347 }
348 
349 void
350 Nlsr::registerLocalhostPrefix()
351 {
352  m_face.registerPrefix(LOCALHOST_PREFIX,
353  std::bind(&Nlsr::onRegistrationSuccess, this, _1),
354  std::bind(&Nlsr::registrationFailed, this, _1));
355 }
356 
357 void
358 Nlsr::registerRouterPrefix()
359 {
360  m_face.registerPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"),
361  std::bind(&Nlsr::onRegistrationSuccess, this, _1),
362  std::bind(&Nlsr::registrationFailed, this, _1));
363 }
364 
365 void
366 Nlsr::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
367 {
368  NLSR_LOG_DEBUG("Got interest for certificate. Interest: " << interest.getName());
369 
370  const ndn::Name& interestName = interest.getName();
371  const ndn::security::v2::Certificate* cert = getCertificate(interestName);
372 
373  if (cert == nullptr) {
374  NLSR_LOG_DEBUG("Certificate is not found for: " << interest);
375  return; // cert is not found
376  }
377 
378  m_face.put(*cert);
379 }
380 
381 void
382 Nlsr::onKeyPrefixRegSuccess(const ndn::Name& name)
383 {
384  NLSR_LOG_DEBUG("KEY prefix: " << name << " registration is successful.");
385 }
386 
387 void
388 Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification)
389 {
390  NLSR_LOG_TRACE("Nlsr::onFaceEventNotification called");
391 
392  switch (faceEventNotification.getKind()) {
393  case ndn::nfd::FACE_EVENT_DESTROYED: {
394  uint64_t faceId = faceEventNotification.getFaceId();
395 
396  auto adjacent = m_adjacencyList.findAdjacent(faceId);
397 
398  if (adjacent != m_adjacencyList.end()) {
399  NLSR_LOG_DEBUG("Face to " << adjacent->getName() << " with face id: " << faceId << " destroyed");
400 
401  adjacent->setFaceId(0);
402 
403  // Only trigger an Adjacency LSA build if this node is changing
404  // from ACTIVE to INACTIVE since this rebuild will effectively
405  // cancel the previous Adjacency LSA refresh event and schedule
406  // a new one further in the future.
407  //
408  // Continuously scheduling the refresh in the future will block
409  // the router from refreshing its Adjacency LSA. Since other
410  // routers' Name prefixes' expiration times are updated when
411  // this router refreshes its Adjacency LSA, the other routers'
412  // prefixes will expire and be removed from the RIB.
413  //
414  // This check is required to fix Bug #2733 for now. This check
415  // would be unnecessary to fix Bug #2733 when Issue #2732 is
416  // completed, but the check also helps with optimization so it
417  // can remain even when Issue #2732 is implemented.
418  if (adjacent->getStatus() == Adjacent::STATUS_ACTIVE) {
419  adjacent->setStatus(Adjacent::STATUS_INACTIVE);
420 
421  // A new adjacency LSA cannot be built until the neighbor is marked INACTIVE and
422  // has met the HELLO retry threshold
423  adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
424 
425  if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
426  m_routingTable.scheduleRoutingTableCalculation();
427  }
428  else {
429  m_lsdb.scheduleAdjLsaBuild();
430  }
431  }
432  }
433  break;
434  }
435  case ndn::nfd::FACE_EVENT_CREATED: {
436  // Find the neighbor in our adjacency list
437  ndn::FaceUri faceUri;
438  try {
439  faceUri = ndn::FaceUri(faceEventNotification.getRemoteUri());
440  }
441  catch (const std::exception& e) {
442  NLSR_LOG_WARN(e.what());
443  return;
444  }
445  auto adjacent = m_adjacencyList.findAdjacent(faceUri);
446 
447  // If we have a neighbor by that FaceUri and it has no FaceId, we
448  // have a match.
449  if (adjacent != m_adjacencyList.end()) {
450  NLSR_LOG_DEBUG("Face creation event matches neighbor: " << adjacent->getName()
451  << ". New Face ID: " << faceEventNotification.getFaceId()
452  << ". Registering prefixes.");
453  adjacent->setFaceId(faceEventNotification.getFaceId());
454 
455  registerAdjacencyPrefixes(*adjacent, ndn::time::milliseconds::max());
456 
457  if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
458  m_routingTable.scheduleRoutingTableCalculation();
459  }
460  else {
461  m_lsdb.scheduleAdjLsaBuild();
462  }
463  }
464  break;
465  }
466  default:
467  break;
468  }
469 }
470 
471 void
473  const FetchDatasetTimeoutCallback& onFetchFailure)
474 {
475  NLSR_LOG_TRACE("Initializing Faces...");
476 
477  m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(onFetchSuccess, onFetchFailure);
478 
479 }
480 
481 void
482 Nlsr::processFaceDataset(const std::vector<ndn::nfd::FaceStatus>& faces)
483 {
484  NLSR_LOG_DEBUG("Processing face dataset");
485 
486  // Iterate over each neighbor listed in nlsr.conf
487  for (auto& adjacent : m_adjacencyList.getAdjList()) {
488 
489  const std::string faceUriString = adjacent.getFaceUri().toString();
490  // Check the list of FaceStatus objects we got for a match
491  for (const ndn::nfd::FaceStatus& faceStatus : faces) {
492  // Set the adjacency FaceID if we find a URI match and it was
493  // previously unset. Change the boolean to true.
494  if (adjacent.getFaceId() == 0 && faceUriString == faceStatus.getRemoteUri()) {
495  NLSR_LOG_DEBUG("FaceUri: " << faceStatus.getRemoteUri() <<
496  " FaceId: "<< faceStatus.getFaceId());
497  adjacent.setFaceId(faceStatus.getFaceId());
498  // Register the prefixes for each neighbor
499  this->registerAdjacencyPrefixes(adjacent, ndn::time::milliseconds::max());
500  }
501  }
502  // If this adjacency has no information in this dataset, then one
503  // of two things is happening: 1. NFD is starting slowly and this
504  // Face wasn't ready yet, or 2. NFD is configured
505  // incorrectly and this Face isn't available.
506  if (adjacent.getFaceId() == 0) {
507  NLSR_LOG_WARN("The adjacency " << adjacent.getName() <<
508  " has no Face information in this dataset.");
509  }
510  }
511 
512  scheduleDatasetFetch();
513 }
514 
515 void
517  const ndn::time::milliseconds& timeout)
518 {
519  ndn::FaceUri faceUri = adj.getFaceUri();
520  double linkCost = adj.getLinkCost();
521  const ndn::Name& adjName = adj.getName();
522 
523  m_fib.registerPrefix(adjName, faceUri, linkCost,
524  timeout, ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
525 
526  m_fib.registerPrefix(m_confParam.getSyncPrefix(),
527  faceUri, linkCost, timeout,
528  ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
529 
530  m_fib.registerPrefix(m_confParam.getLsaPrefix(),
531  faceUri, linkCost, timeout,
532  ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
533 }
534 
535 void
537  const std::string& msg,
538  uint32_t nRetriesSoFar)
539 {
540  NLSR_LOG_DEBUG("onFaceDatasetFetchTimeout");
541  // If we have exceeded the maximum attempt count, do not try again.
542  if (nRetriesSoFar++ < m_confParam.getFaceDatasetFetchTries()) {
543  NLSR_LOG_DEBUG("Failed to fetch dataset: " << msg << ". Attempting retry #" << nRetriesSoFar);
544  m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(std::bind(&Nlsr::processFaceDataset,
545  this, _1),
547  this, _1, _2, nRetriesSoFar));
548  }
549  else {
550  NLSR_LOG_ERROR("Failed to fetch dataset: " << msg << ". Exceeded limit of " <<
551  m_confParam.getFaceDatasetFetchTries() << ", so not trying again this time.");
552  // If we fail to fetch it, just do nothing until the next
553  // interval. Since this is a backup mechanism, we aren't as
554  // concerned with retrying.
555  scheduleDatasetFetch();
556  }
557 }
558 
559 void
560 Nlsr::scheduleDatasetFetch()
561 {
562  NLSR_LOG_DEBUG("Scheduling Dataset Fetch in " << m_confParam.getFaceDatasetFetchInterval());
563 
564  m_scheduler.scheduleEvent(m_confParam.getFaceDatasetFetchInterval(),
565  [this] {
566  this->initializeFaces(
567  [this] (const std::vector<ndn::nfd::FaceStatus>& faces) {
568  this->processFaceDataset(faces);
569  },
570  [this] (uint32_t code, const std::string& msg) {
571  this->onFaceDatasetFetchTimeout(code, msg, 0);
572  });
573  });
574 }
575 
576 void
577 Nlsr::enableIncomingFaceIdIndication()
578 {
579  NLSR_LOG_DEBUG("Enabling incoming face id indication for local face.");
580 
581  m_controller.start<ndn::nfd::FaceUpdateCommand>(
582  ndn::nfd::ControlParameters()
583  .setFlagBit(ndn::nfd::FaceFlagBit::BIT_LOCAL_FIELDS_ENABLED, true),
584  bind(&Nlsr::onFaceIdIndicationSuccess, this, _1),
585  bind(&Nlsr::onFaceIdIndicationFailure, this, _1));
586 }
587 
588 void
589 Nlsr::onFaceIdIndicationSuccess(const ndn::nfd::ControlParameters& cp)
590 {
591  NLSR_LOG_DEBUG("Successfully enabled incoming face id indication"
592  << "for face id " << cp.getFaceId());
593 }
594 
595 void
596 Nlsr::onFaceIdIndicationFailure(const ndn::nfd::ControlResponse& cr)
597 {
598  std::ostringstream os;
599  os << "Failed to enable incoming face id indication feature: " <<
600  "(code: " << cr.getCode() << ", reason: " << cr.getText() << ")";
601 
602  NLSR_LOG_DEBUG(os.str());
603 }
604 
605 } // namespace nlsr
void initializeFaces(const FetchDatasetCallback &onFetchSuccess, const FetchDatasetTimeoutCallback &onFetchFailure)
Initializes neighbors&#39; Faces using information from NFD.
Definition: nlsr.cpp:472
void onFaceDatasetFetchTimeout(uint32_t code, const std::string &reason, uint32_t nRetriesSoFar)
Definition: nlsr.cpp:536
#define NLSR_LOG_WARN(x)
Definition: logger.hpp:40
A class to house all the configuration parameters for NLSR.
void initialize()
Definition: nlsr.cpp:195
void scheduleAdjLsaBuild()
Schedules a build of this router&#39;s LSA.
Definition: lsdb.cpp:581
std::function< void(uint32_t, const std::string &)> FetchDatasetTimeoutCallback
Definition: nlsr.hpp:71
const ndn::FaceUri & getFaceUri() const
Definition: adjacent.hpp:69
void setStrategies()
Definition: nlsr.cpp:136
void scheduleRoutingTableCalculation()
Schedules a calculation event in the event scheduler only if one isn&#39;t already scheduled.
#define NLSR_LOG_DEBUG(x)
Definition: logger.hpp:38
const ndn::Name & getRouterPrefix() const
STL namespace.
std::function< void(const std::vector< ndn::nfd::FaceStatus > &)> FetchDatasetCallback
Definition: nlsr.hpp:70
Nlsr(ndn::Face &face, ndn::KeyChain &keyChain, ConfParameter &confParam)
Definition: nlsr.cpp:42
void setStrategy(const ndn::Name &name, const std::string &strategy, uint32_t count)
Definition: fib.cpp:306
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
void setLsaInterestFilter()
Definition: nlsr.cpp:110
void addDispatcherTopPrefix(const ndn::Name &topPrefix)
Add top level prefixes for Dispatcher.
Definition: nlsr.cpp:124
static const ndn::Name LOCALHOST_PREFIX
Definition: nlsr.hpp:260
void scheduleInterest(uint32_t seconds)
Schedules a Hello Interest event.
void registerAdjacencyPrefixes(const Adjacent &adj, const ndn::time::milliseconds &timeout)
Registers NLSR-specific prefixes for a neighbor (Adjacent)
Definition: nlsr.cpp:516
#define INIT_LOGGER(name)
Definition: logger.hpp:35
const ndn::Name & getSyncPrefix() const
uint32_t getInterestRetryNumber() const
ndn::security::ValidatorConfig & getValidator()
const ndn::Name & getName() const
Definition: adjacent.hpp:57
void insert(const ndn::security::v2::Certificate &certificate)
const ndn::Name & getLsaPrefix() const
void onRegistrationSuccess(const ndn::Name &name)
Definition: nlsr.cpp:88
void loadCertToPublish(const ndn::security::v2::Certificate &certificate)
Add a certificate NLSR claims to be authoritative for to the certificate store.
Definition: nlsr.cpp:145
void publishCertFromCache(const ndn::Name &keyName)
Retrieves the chain of certificates from Validator&#39;s cache and store them in Nlsr&#39;s own CertificateSt...
Definition: nlsr.cpp:170
void processInterest(const ndn::Name &name, const ndn::Interest &interest)
Processes a Hello Interest from a neighbor.
void setInfoInterestFilter()
Definition: nlsr.cpp:94
void afterFetcherSignalEmitted(const ndn::Data &lsaSegment)
Callback when SegmentFetcher retrieves a segment.
Definition: nlsr.cpp:157
void processInterest(const ndn::Name &name, const ndn::Interest &interest)
Definition: lsdb.cpp:1032
A neighbor reachable over a Face.
Definition: adjacent.hpp:38
#define NLSR_LOG_ERROR(x)
Definition: logger.hpp:41
void registrationFailed(const ndn::Name &name)
Definition: nlsr.cpp:81
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
AdjacencyList::iterator findAdjacent(const ndn::Name &adjName)
uint32_t getFirstHelloInterval() const
uint32_t getFaceDatasetFetchTries() const
const ndn::Name & getNetwork() const
const ndn::security::v2::Certificate * getCertificate(const ndn::Name &certificateKeyName)
Find a certificate.
Definition: nlsr.hpp:190
bool buildAndInstallOwnNameLsa()
Builds a name LSA for this router and then installs it into the LSDB.
Definition: lsdb.cpp:153
bool buildAndInstallOwnCoordinateLsa()
Builds a cor. LSA for this router and installs it into the LSDB.
Definition: lsdb.cpp:381
int32_t getHyperbolicState() const
uint64_t getLinkCost() const
Definition: adjacent.hpp:81
const ndn::Name & getSiteName() const
void processFaceDataset(const std::vector< ndn::nfd::FaceStatus > &faces)
Consumes a Face StatusDataset to configure NLSR neighbors.
Definition: nlsr.cpp:482
const ndn::time::seconds getFaceDatasetFetchInterval() const
std::list< Adjacent > & getAdjList()
void initializeKey()
Definition: nlsr.cpp:246
#define NLSR_LOG_TRACE(x)
Definition: logger.hpp:37
const_iterator end() const
void registerPrefix(const ndn::Name &namePrefix, const ndn::FaceUri &faceUri, uint64_t faceCost, const ndn::time::milliseconds &timeout, uint64_t flags, uint8_t times)
Inform NFD of a next-hop.
Definition: fib.cpp:200