NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
rib-manager.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, Regents of the University of California,
4  * Arizona Board of Regents,
5  * Colorado State University,
6  * University Pierre & Marie Curie, Sorbonne University,
7  * Washington University in St. Louis,
8  * Beijing Institute of Technology,
9  * The University of Memphis.
10  *
11  * This file is part of NFD (Named Data Networking Forwarding Daemon).
12  * See AUTHORS.md for complete list of NFD authors and contributors.
13  *
14  * NFD is free software: you can redistribute it and/or modify it under the terms
15  * of the GNU General Public License as published by the Free Software Foundation,
16  * either version 3 of the License, or (at your option) any later version.
17  *
18  * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  * PURPOSE. See the GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along with
23  * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #include "rib-manager.hpp"
27 
28 #include "common/global.hpp"
29 #include "common/logger.hpp"
30 #include "rib/rib.hpp"
31 #include "table/fib.hpp"
32 
33 #include <ndn-cxx/lp/tags.hpp>
37 
38 namespace nfd {
39 
40 using rib::RibUpdate;
41 using rib::Route;
42 
44 
45 static const std::string MGMT_MODULE_NAME = "rib";
46 static const Name LOCALHOST_TOP_PREFIX = "/localhost/nfd";
47 static const time::seconds ACTIVE_FACE_FETCH_INTERVAL = 5_min;
48 
49 const Name RibManager::LOCALHOP_TOP_PREFIX = "/localhop/nfd";
50 
52  ndn::nfd::Controller& nfdController, Dispatcher& dispatcher)
53  : ManagerBase(MGMT_MODULE_NAME, dispatcher)
54  , m_rib(rib)
55  , m_keyChain(keyChain)
56  , m_nfdController(nfdController)
57  , m_dispatcher(dispatcher)
58  , m_faceMonitor(face)
59  , m_localhostValidator(face)
60  , m_localhopValidator(make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
61  , m_paValidator(make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
62  , m_isLocalhopEnabled(false)
63 {
64  registerCommandHandler<ndn::nfd::RibRegisterCommand>("register",
65  bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
66  registerCommandHandler<ndn::nfd::RibUnregisterCommand>("unregister",
67  bind(&RibManager::unregisterEntry, this, _2, _3, _4, _5));
68 
69  registerStatusDatasetHandler("list", bind(&RibManager::listEntries, this, _1, _2, _3));
70 }
71 
72 void
73 RibManager::applyLocalhostConfig(const ConfigSection& section, const std::string& filename)
74 {
75  m_localhostValidator.load(section, filename);
76 }
77 
78 void
79 RibManager::enableLocalhop(const ConfigSection& section, const std::string& filename)
80 {
81  m_localhopValidator.load(section, filename);
82  m_isLocalhopEnabled = true;
83 }
84 
85 void
87 {
88  m_isLocalhopEnabled = false;
89 }
90 
91 void
92 RibManager::applyPaConfig(const ConfigSection& section, const std::string& filename)
93 {
94  m_paValidator.load(section, filename);
95 }
96 
97 void
99 {
100  registerTopPrefix(LOCALHOST_TOP_PREFIX);
101 
102  if (m_isLocalhopEnabled) {
103  registerTopPrefix(LOCALHOP_TOP_PREFIX);
104  }
105 
106  NFD_LOG_INFO("Start monitoring face create/destroy events");
107  m_faceMonitor.onNotification.connect(bind(&RibManager::onNotification, this, _1));
108  m_faceMonitor.start();
109 
110  scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
111 }
112 
113 void
115 {
116  m_nfdController.start<ndn::nfd::FaceUpdateCommand>(
118  [] (const ControlParameters&) {
119  NFD_LOG_DEBUG("Local fields enabled");
120  },
121  [] (const ControlResponse& res) {
122  NDN_THROW(Error("Couldn't enable local fields (" + to_string(res.getCode()) +
123  " " + res.getText() + ")"));
124  });
125 }
126 
127 void
128 RibManager::beginAddRoute(const Name& name, Route route, optional<time::nanoseconds> expires,
129  const std::function<void(RibUpdateResult)>& done)
130 {
131  if (expires) {
132  route.expires = time::steady_clock::now() + *expires;
133  }
134  else if (route.expires) {
135  expires = *route.expires - time::steady_clock::now();
136  }
137 
138  if (expires && *expires <= 0_s) {
139  m_rib.onRouteExpiration(name, route);
140  return done(RibUpdateResult::EXPIRED);
141  }
142 
143  NFD_LOG_INFO("Adding route " << name << " nexthop=" << route.faceId <<
144  " origin=" << route.origin << " cost=" << route.cost);
145 
146  if (expires) {
147  auto event = getScheduler().schedule(*expires, [=] { m_rib.onRouteExpiration(name, route); });
148  route.setExpirationEvent(event);
149  NFD_LOG_TRACE("Scheduled unregistration at: " << *route.expires);
150  }
151 
152  RibUpdate update;
153  update.setAction(RibUpdate::REGISTER)
154  .setName(name)
155  .setRoute(route);
156  beginRibUpdate(update, done);
157 }
158 
159 void
160 RibManager::beginRemoveRoute(const Name& name, const Route& route,
161  const std::function<void(RibUpdateResult)>& done)
162 {
163  NFD_LOG_INFO("Removing route " << name << " nexthop=" << route.faceId <<
164  " origin=" << route.origin);
165 
166  RibUpdate update;
167  update.setAction(RibUpdate::UNREGISTER)
168  .setName(name)
169  .setRoute(route);
170  beginRibUpdate(update, done);
171 }
172 
173 void
174 RibManager::beginRibUpdate(const RibUpdate& update,
175  const std::function<void(RibUpdateResult)>& done)
176 {
177  m_rib.beginApplyUpdate(update,
178  [=] {
179  NFD_LOG_DEBUG("RIB update succeeded for " << update);
180  done(RibUpdateResult::OK);
181  },
182  [=] (uint32_t code, const std::string& error) {
183  NFD_LOG_DEBUG("RIB update failed for " << update << " (" << code << " " << error << ")");
184 
185  // Since the FIB rejected the update, clean up invalid routes
186  scheduleActiveFaceFetch(1_s);
187 
188  done(RibUpdateResult::ERROR);
189  });
190 }
191 
192 void
193 RibManager::registerTopPrefix(const Name& topPrefix)
194 {
195  // add FIB nexthop
196  m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
197  ControlParameters().setName(Name(topPrefix).append(MGMT_MODULE_NAME))
198  .setFaceId(0),
199  [=] (const ControlParameters& res) {
200  NFD_LOG_DEBUG("Successfully registered " << topPrefix << " with NFD");
201 
202  // Routes must be inserted into the RIB so route flags can be applied
203  Route route;
204  route.faceId = res.getFaceId();
205  route.origin = ndn::nfd::ROUTE_ORIGIN_APP;
207 
208  m_rib.insert(topPrefix, route);
209  },
210  [=] (const ControlResponse& res) {
211  NDN_THROW(Error("Cannot add FIB entry " + topPrefix.toUri() + " (" +
212  to_string(res.getCode()) + " " + res.getText() + ")"));
213  });
214 
215  // add top prefix to the dispatcher without prefix registration
216  m_dispatcher.addTopPrefix(topPrefix, false);
217 }
218 
219 void
220 RibManager::registerEntry(const Name& topPrefix, const Interest& interest,
221  ControlParameters parameters,
222  const ndn::mgmt::CommandContinuation& done)
223 {
224  if (parameters.getName().size() > Fib::getMaxDepth()) {
225  done(ControlResponse(414, "Route prefix cannot exceed " + to_string(Fib::getMaxDepth()) +
226  " components"));
227  return;
228  }
229 
230  setFaceForSelfRegistration(interest, parameters);
231 
232  // Respond since command is valid and authorized
233  done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
234 
235  Route route;
236  route.faceId = parameters.getFaceId();
237  route.origin = parameters.getOrigin();
238  route.cost = parameters.getCost();
239  route.flags = parameters.getFlags();
240 
241  optional<time::nanoseconds> expires;
242  if (parameters.hasExpirationPeriod() &&
243  parameters.getExpirationPeriod() != time::milliseconds::max()) {
244  expires = time::duration_cast<time::nanoseconds>(parameters.getExpirationPeriod());
245  }
246 
247  beginAddRoute(parameters.getName(), std::move(route), expires, [] (RibUpdateResult) {});
248 }
249 
250 void
251 RibManager::unregisterEntry(const Name& topPrefix, const Interest& interest,
252  ControlParameters parameters,
253  const ndn::mgmt::CommandContinuation& done)
254 {
255  setFaceForSelfRegistration(interest, parameters);
256 
257  // Respond since command is valid and authorized
258  done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
259 
260  Route route;
261  route.faceId = parameters.getFaceId();
262  route.origin = parameters.getOrigin();
263 
264  beginRemoveRoute(parameters.getName(), route, [] (RibUpdateResult) {});
265 }
266 
267 void
268 RibManager::listEntries(const Name& topPrefix, const Interest& interest,
270 {
271  auto now = time::steady_clock::now();
272  for (const auto& kv : m_rib) {
273  const rib::RibEntry& entry = *kv.second;
274  ndn::nfd::RibEntry item;
275  item.setName(entry.getName());
276  for (const Route& route : entry.getRoutes()) {
277  ndn::nfd::Route r;
278  r.setFaceId(route.faceId);
279  r.setOrigin(route.origin);
280  r.setCost(route.cost);
281  r.setFlags(route.flags);
282  if (route.expires) {
283  r.setExpirationPeriod(time::duration_cast<time::milliseconds>(*route.expires - now));
284  }
285  item.addRoute(r);
286  }
287  context.append(item.wireEncode());
288  }
289  context.end();
290 }
291 
292 void
293 RibManager::setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters)
294 {
295  bool isSelfRegistration = (parameters.getFaceId() == 0);
296  if (isSelfRegistration) {
297  shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request.getTag<lp::IncomingFaceIdTag>();
298  // NDNLPv2 says "application MUST be prepared to receive a packet without IncomingFaceId field",
299  // but it's fine to assert IncomingFaceId is available, because InternalFace lives inside NFD
300  // and is initialized synchronously with IncomingFaceId field enabled.
301  BOOST_ASSERT(incomingFaceIdTag != nullptr);
302  parameters.setFaceId(*incomingFaceIdTag);
303  }
304 }
305 
307 RibManager::makeAuthorization(const std::string& verb)
308 {
309  return [this] (const Name& prefix, const Interest& interest,
310  const ndn::mgmt::ControlParameters* params,
311  const ndn::mgmt::AcceptContinuation& accept,
312  const ndn::mgmt::RejectContinuation& reject) {
313  BOOST_ASSERT(params != nullptr);
314  BOOST_ASSERT(typeid(*params) == typeid(ndn::nfd::ControlParameters));
315  BOOST_ASSERT(prefix == LOCALHOST_TOP_PREFIX || prefix == LOCALHOP_TOP_PREFIX);
316 
317  auto& validator = prefix == LOCALHOST_TOP_PREFIX ? m_localhostValidator : m_localhopValidator;
318  validator.validate(interest,
319  bind([&interest, this, accept] { extractRequester(interest, accept); }),
320  bind([reject] { reject(ndn::mgmt::RejectReply::STATUS403); }));
321  };
322 }
323 
324 std::ostream&
325 operator<<(std::ostream& os, RibManager::SlAnnounceResult res)
326 {
327  switch (res) {
329  return os << "OK";
331  return os << "ERROR";
333  return os << "VALIDATION_FAILURE";
335  return os << "EXPIRED";
337  return os << "NOT_FOUND";
338  }
339  NDN_THROW(std::invalid_argument("Unknown SlAnnounceResult"));
340 }
341 
343 RibManager::getSlAnnounceResultFromRibUpdateResult(RibUpdateResult r)
344 {
345  switch (r) {
346  case RibUpdateResult::OK:
347  return SlAnnounceResult::OK;
348  case RibUpdateResult::ERROR:
350  case RibUpdateResult::EXPIRED:
352  }
354 }
355 
356 void
358  time::milliseconds maxLifetime, const SlAnnounceCallback& cb)
359 {
360  BOOST_ASSERT(pa.getData());
361 
362  m_paValidator.validate(*pa.getData(),
363  [=] (const Data&) {
364  Route route(pa, faceId);
365  route.expires = std::min(route.annExpires, time::steady_clock::now() + maxLifetime);
366  beginAddRoute(pa.getAnnouncedName(), route, nullopt,
367  [=] (RibUpdateResult ribRes) {
368  auto res = getSlAnnounceResultFromRibUpdateResult(ribRes);
369  NFD_LOG_INFO("slAnnounce " << pa.getAnnouncedName() << " " << faceId << ": " << res);
370  cb(res);
371  });
372  },
373  [=] (const Data&, ndn::security::v2::ValidationError err) {
374  NFD_LOG_INFO("slAnnounce " << pa.getAnnouncedName() << " " << faceId <<
375  " validation error: " << err);
376  cb(SlAnnounceResult::VALIDATION_FAILURE);
377  }
378  );
379 }
380 
381 void
382 RibManager::slRenew(const Name& name, uint64_t faceId, time::milliseconds maxLifetime,
383  const SlAnnounceCallback& cb)
384 {
385  Route routeQuery;
386  routeQuery.faceId = faceId;
388  Route* oldRoute = m_rib.findLongestPrefix(name, routeQuery);
389 
390  if (oldRoute == nullptr || !oldRoute->announcement) {
391  NFD_LOG_DEBUG("slRenew " << name << " " << faceId << ": not found");
392  return cb(SlAnnounceResult::NOT_FOUND);
393  }
394  Name routeName = oldRoute->announcement->getAnnouncedName();
395 
396  Route route = *oldRoute;
397  route.expires = std::min(route.annExpires, time::steady_clock::now() + maxLifetime);
398  beginAddRoute(routeName, route, nullopt,
399  [=] (RibUpdateResult ribRes) {
400  auto res = getSlAnnounceResultFromRibUpdateResult(ribRes);
401  NFD_LOG_INFO("slRenew " << name << " " << faceId << ": " << res << " " << routeName);
402  cb(res);
403  });
404 }
405 
406 void
407 RibManager::slFindAnn(const Name& name, const SlFindAnnCallback& cb) const
408 {
409  shared_ptr<rib::RibEntry> entry;
410  auto exactMatch = m_rib.find(name);
411  if (exactMatch != m_rib.end()) {
412  entry = exactMatch->second;
413  }
414  else {
415  entry = m_rib.findParent(name);
416  }
417  if (entry == nullptr) {
418  return cb(nullopt);
419  }
420 
421  auto pa = entry->getPrefixAnnouncement();
422  pa.toData(m_keyChain);
423  cb(pa);
424 }
425 
426 void
427 RibManager::fetchActiveFaces()
428 {
429  NFD_LOG_DEBUG("Fetching active faces");
430 
431  m_nfdController.fetch<ndn::nfd::FaceDataset>(
432  bind(&RibManager::removeInvalidFaces, this, _1),
433  bind(&RibManager::onFetchActiveFacesFailure, this, _1, _2),
435 }
436 
437 void
438 RibManager::onFetchActiveFacesFailure(uint32_t code, const std::string& reason)
439 {
440  NFD_LOG_DEBUG("Face Status Dataset request failure " << code << " " << reason);
441  scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
442 }
443 
444 void
445 RibManager::scheduleActiveFaceFetch(const time::seconds& timeToWait)
446 {
447  m_activeFaceFetchEvent = getScheduler().schedule(timeToWait, [this] { fetchActiveFaces(); });
448 }
449 
450 void
451 RibManager::removeInvalidFaces(const std::vector<ndn::nfd::FaceStatus>& activeFaces)
452 {
453  NFD_LOG_DEBUG("Checking for invalid face registrations");
454 
455  std::set<uint64_t> activeFaceIds;
456  for (const auto& faceStatus : activeFaces) {
457  activeFaceIds.insert(faceStatus.getFaceId());
458  }
459  getGlobalIoService().post([=] { m_rib.beginRemoveFailedFaces(activeFaceIds); });
460 
461  // Reschedule the check for future clean up
462  scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
463 }
464 
465 void
466 RibManager::onNotification(const ndn::nfd::FaceEventNotification& notification)
467 {
468  NFD_LOG_TRACE("onNotification: " << notification);
469 
470  if (notification.getKind() == ndn::nfd::FACE_EVENT_DESTROYED) {
471  NFD_LOG_DEBUG("Received notification for destroyed FaceId " << notification.getFaceId());
472  getGlobalIoService().post([this, id = notification.getFaceId()] { m_rib.beginRemoveFace(id); });
473  }
474 }
475 
476 } // namespace nfd
ndn::nfd::FaceDataset
represents a faces/list dataset
Definition: status-dataset.hpp:150
ndn::PrefixAnnouncement::getData
const optional< Data > & getData() const
Get the Data representing the prefix announcement, if available.
Definition: prefix-announcement.hpp:59
ndn::nfd::Route
represents a route in a RibEntry
Definition: rib-entry.hpp:43
NFD_LOG_TRACE
#define NFD_LOG_TRACE
Definition: logger.hpp:37
nfd::RibManager::SlAnnounceResult::ERROR
@ ERROR
unspecified error
nfd::rib::Route::origin
ndn::nfd::RouteOrigin origin
Definition: route.hpp:82
ndn::security::v2::ValidationError
Validation error code and optional detailed error message.
Definition: validation-error.hpp:35
nfd::RibManager::SlAnnounceCallback
std::function< void(SlAnnounceResult res)> SlAnnounceCallback
Definition: rib-manager.hpp:101
rib-entry.hpp
NFD_LOG_INFO
#define NFD_LOG_INFO
Definition: logger.hpp:39
global.hpp
nfd::LOCALHOST_TOP_PREFIX
static const Name LOCALHOST_TOP_PREFIX
Definition: rib-manager.cpp:46
nfd::detail::SimulatorIo::post
void post(const std::function< void()> &callback)
Definition: global.cpp:35
nfd::fib::Fib::getMaxDepth
static constexpr size_t getMaxDepth()
Maximum number of components in a FIB entry prefix.
Definition: fib.hpp:88
face-status.hpp
ndn::mgmt::AcceptContinuation
std::function< void(const std::string &requester)> AcceptContinuation
a function to be called if authorization is successful
Definition: dispatcher.hpp:45
nfd::rib::Route::cost
uint64_t cost
Definition: route.hpp:83
nonstd::optional_lite::std11::move
T & move(T &t)
Definition: optional.hpp:421
ndn::mgmt::StatusDatasetContext::append
void append(const Block &block)
append a Block to the response
Definition: status-dataset-context.cpp:69
ndn::tlv::Interest
@ Interest
Definition: tlv.hpp:65
ndn::nfd::ROUTE_ORIGIN_APP
@ ROUTE_ORIGIN_APP
Definition: nfd-constants.hpp:101
certificate-fetcher-direct-fetch.hpp
ndn::nfd::Route::setCost
Route & setCost(uint64_t cost)
Definition: rib-entry.cpp:68
nfd::RibManager::SlAnnounceResult::VALIDATION_FAILURE
@ VALIDATION_FAILURE
the announcement cannot be verified against the trust schema
nfd::RibManager::slAnnounce
void slAnnounce(const ndn::PrefixAnnouncement &pa, uint64_t faceId, time::milliseconds maxLifetime, const SlAnnounceCallback &cb)
Insert a route by prefix announcement from self-learning strategy.
Definition: rib-manager.cpp:357
ndn::util::NotificationSubscriberBase::start
void start()
start or resume receiving notifications
Definition: notification-subscriber.cpp:52
ndn::nfd::Route::setFlags
Route & setFlags(uint64_t flags)
Definition: rib-entry.cpp:76
ndn::SimpleTag
provides a tag type for simple types
Definition: tag.hpp:59
ndn::nfd::FACE_EVENT_DESTROYED
@ FACE_EVENT_DESTROYED
face was destroyed
Definition: nfd-constants.hpp:80
ndn::time::steady_clock::now
static time_point now() noexcept
Definition: time.cpp:80
fib.hpp
ndn::mgmt::CommandContinuation
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
Definition: dispatcher.hpp:95
nfd::RibManager::registerWithNfd
void registerWithNfd()
Start accepting commands and dataset requests.
Definition: rib-manager.cpp:98
ndn::nfd::ControlResponse
mgmt::ControlResponse ControlResponse
Definition: control-response.hpp:30
NDN_CXX_UNREACHABLE
#define NDN_CXX_UNREACHABLE
Definition: backports.hpp:72
nfd::RibManager::RibManager
RibManager(rib::Rib &rib, ndn::Face &face, ndn::KeyChain &keyChain, ndn::nfd::Controller &nfdController, Dispatcher &dispatcher)
Definition: rib-manager.cpp:51
ndn::nfd::Route::setExpirationPeriod
Route & setExpirationPeriod(time::milliseconds expirationPeriod)
Definition: rib-entry.cpp:84
nfd::ManagerBase::Error
Definition: manager-base.hpp:51
nfd::ManagerBase::registerStatusDatasetHandler
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
Definition: manager-base.cpp:47
ndn::nfd::Controller
NFD Management protocol client.
Definition: controller.hpp:52
ndn::nfd::FaceEventNotification::getKind
FaceEventKind getKind() const
Definition: face-event-notification.hpp:61
nfd::rib::Rib::onRouteExpiration
void onRouteExpiration(const Name &prefix, const Route &route)
Definition: rib.cpp:202
ndn::nfd::RibEntry::wireEncode
size_t wireEncode(EncodingImpl< TAG > &block) const
Definition: rib-entry.cpp:256
ndn::Face
Provide a communication channel with local or remote NDN forwarder.
Definition: face.hpp:90
ndn::mgmt::ControlParameters
base class for a struct that contains ControlCommand parameters
Definition: control-parameters.hpp:33
nfd::rib::RibUpdate::UNREGISTER
@ UNREGISTER
Definition: rib-update.hpp:45
ndn::nfd::FaceTraits::getFaceId
uint64_t getFaceId() const
Definition: face-traits.hpp:47
ndn::PrefixAnnouncement
A prefix announcement object that represents an application's intent of registering a prefix toward i...
Definition: prefix-announcement.hpp:34
nfd::RibManager::enableLocalhop
void enableLocalhop(const ConfigSection &section, const std::string &filename)
Apply localhop_security configuration and allow accepting commands on /localhop/nfd/rib prefix.
Definition: rib-manager.cpp:79
nfd::getGlobalIoService
detail::SimulatorIo & getGlobalIoService()
Returns the global io_service instance for the calling thread.
Definition: global.cpp:49
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
rib.hpp
ndn::nfd::FaceEventNotification
represents a Face status change notification
Definition: face-event-notification.hpp:36
ndn::nfd::FibAddNextHopCommand
represents a fib/add-nexthop command
Definition: control-command.hpp:201
ns3::ndn::Name
Name
Definition: ndn-common.cpp:25
ndn::nfd::RibEntry
represents an item in NFD RIB dataset
Definition: rib-entry.hpp:154
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::MGMT_MODULE_NAME
static const std::string MGMT_MODULE_NAME
Definition: rib-manager.cpp:45
nfd::rib::Route::faceId
uint64_t faceId
Definition: route.hpp:81
nfd::RibManager::SlAnnounceResult::OK
@ OK
RIB and FIB have been updated.
nfd::RibManager::SlAnnounceResult::NOT_FOUND
@ NOT_FOUND
route does not exist (slRenew only)
nfd::rib::Route::setExpirationEvent
void setExpirationEvent(const scheduler::EventId &eid)
Definition: route.hpp:63
nfd::RibManager::enableLocalFields
void enableLocalFields()
Enable NDNLP IncomingFaceId field in order to support self-registration commands.
Definition: rib-manager.cpp:114
ndn::security::v2::KeyChain
The interface of signing key management.
Definition: key-chain.hpp:47
nfd::RibManager::disableLocalhop
void disableLocalhop()
Disallow accepting commands on /localhop/nfd/rib prefix.
Definition: rib-manager.cpp:86
ndn::mgmt::StatusDatasetContext
provides a context for generating response to a StatusDataset request
Definition: status-dataset-context.hpp:37
nfd::rib::Rib
represents the Routing Information Base
Definition: rib.hpp:60
NDN_THROW
#define NDN_THROW(e)
Definition: exception.hpp:61
nfd::getScheduler
Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.
Definition: global.cpp:70
ndn::security::ValidatorConfig::load
void load(const std::string &filename)
Definition: validator-config.cpp:42
nfd::RibManager::SlAnnounceResult
SlAnnounceResult
Definition: rib-manager.hpp:93
nfd::ACTIVE_FACE_FETCH_INTERVAL
static const time::seconds ACTIVE_FACE_FETCH_INTERVAL
Definition: rib-manager.cpp:47
nfd::rib::RibUpdate::REGISTER
@ REGISTER
Definition: rib-update.hpp:44
ndn::mgmt::Authorization
std::function< void(const Name &prefix, const Interest &interest, const ControlParameters *params, const AcceptContinuation &accept, const RejectContinuation &reject)> Authorization
a function that performs authorization
Definition: dispatcher.hpp:77
ndn::tlv::nfd::ControlParameters
@ ControlParameters
Definition: tlv-nfd.hpp:35
nfd::rib::Rib::insert
void insert(const Name &prefix, const Route &route)
Definition: rib.cpp:92
ndn::mgmt::Dispatcher::addTopPrefix
void addTopPrefix(const Name &prefix, bool wantRegister=true, const security::SigningInfo &signingInfo=security::SigningInfo())
add a top-level prefix
Definition: dispatcher.cpp:58
ndn::nfd::Controller::start
void start(const ControlParameters &parameters, const CommandSucceedCallback &onSuccess, const CommandFailCallback &onFailure, const CommandOptions &options=CommandOptions())
start command execution
Definition: controller.hpp:78
nonstd::optional_lite::nullopt
const nullopt_t nullopt((nullopt_t::init()))
nfd::operator<<
std::ostream & operator<<(std::ostream &os, const Network &network)
Definition: network.cpp:79
ndn::security::v2::Validator::validate
void validate(const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
Asynchronously validate data.
Definition: validator.cpp:75
ndn::nfd::FaceUpdateCommand
represents a faces/update command
Definition: control-command.hpp:161
rib-manager.hpp
ndn::mgmt::ControlResponse
ControlCommand response.
Definition: control-response.hpp:33
nfd::RibManager::SlAnnounceResult::EXPIRED
@ EXPIRED
the announcement has expired
ndn::util::NotificationSubscriber::onNotification
signal::Signal< NotificationSubscriber, Notification > onNotification
fires when a Notification is received
Definition: notification-subscriber.hpp:171
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
ndn::nfd::CommandOptions
contains options for ControlCommand execution
Definition: command-options.hpp:35
NFD_LOG_DEBUG
#define NFD_LOG_DEBUG
Definition: logger.hpp:38
nfd::RibManager
Implements the RIB Management of NFD Management Protocol.
Definition: rib-manager.hpp:50
nfd::ConfigSection
boost::property_tree::ptree ConfigSection
a config file section
Definition: ndn-l3-protocol.hpp:39
nfd::RibManager::LOCALHOP_TOP_PREFIX
static const Name LOCALHOP_TOP_PREFIX
Definition: rib-manager.hpp:243
nfd::ManagerBase
A collection of common functions shared by all NFD managers, such as communicating with the dispatche...
Definition: manager-base.hpp:48
ndn::nfd::RibEntry::setName
RibEntry & setName(const Name &prefix)
Definition: rib-entry.cpp:231
ndn::nfd::ControlParameters
represents parameters in a ControlCommand request or response
Definition: control-parameters.hpp:82
nfd::rib::Route::announcement
optional< ndn::PrefixAnnouncement > announcement
The prefix announcement that caused the creation of this route.
Definition: route.hpp:91
ndn::mgmt::RejectReply::STATUS403
@ STATUS403
reply with a ControlResponse where StatusCode is 403
nfd::rib::RibEntry
RibEntry
Definition: rib-entry.cpp:34
ndn::mgmt::Dispatcher
represents a dispatcher on server side of NFD Management protocol
Definition: dispatcher.hpp:131
ndn::to_string
std::string to_string(const T &val)
Definition: backports.hpp:102
ndn::mgmt::StatusDatasetContext::end
void end()
end the response successfully after appending zero or more blocks
Definition: status-dataset-context.cpp:95
ndn::tlv::nfd::Route
@ Route
Definition: tlv-nfd.hpp:103
ndn::name
Definition: name-component-types.hpp:33
nfd::rib::Route
represents a route for a name prefix
Definition: route.hpp:44
ndn::nfd::ROUTE_ORIGIN_PREFIXANN
@ ROUTE_ORIGIN_PREFIXANN
Definition: nfd-constants.hpp:106
nfd::RibManager::applyLocalhostConfig
void applyLocalhostConfig(const ConfigSection &section, const std::string &filename)
Apply localhost_security configuration.
Definition: rib-manager.cpp:73
nfd::rib::Route::expires
optional< time::steady_clock::TimePoint > expires
Definition: route.hpp:85
tags.hpp
ndn::mgmt::RejectContinuation
std::function< void(RejectReply reply)> RejectContinuation
a function to be called if authorization is rejected
Definition: dispatcher.hpp:60
ndn::nfd::BIT_LOCAL_FIELDS_ENABLED
@ BIT_LOCAL_FIELDS_ENABLED
whether local fields are enabled on a face
Definition: nfd-constants.hpp:70
nfd::rib::Route::annExpires
time::steady_clock::TimePoint annExpires
Expiration time of the prefix announcement.
Definition: route.hpp:101
nfd::ManagerBase::extractRequester
void extractRequester(const Interest &interest, ndn::mgmt::AcceptContinuation accept)
Extracts the requester from a ControlCommand request.
Definition: manager-base.cpp:62
ndn::nfd::RibEntry::addRoute
RibEntry & addRoute(const Route &route)
Definition: rib-entry.cpp:239
NFD_LOG_INIT
#define NFD_LOG_INIT(name)
Definition: logger.hpp:31
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
nfd::RibManager::applyPaConfig
void applyPaConfig(const ConfigSection &section, const std::string &filename)
Apply prefix_announcement_validation configuration.
Definition: rib-manager.cpp:92
logger.hpp
ndn::nfd::ROUTE_FLAG_CHILD_INHERIT
@ ROUTE_FLAG_CHILD_INHERIT
Definition: nfd-constants.hpp:125
nfd::RibManager::SlFindAnnCallback
std::function< void(optional< ndn::PrefixAnnouncement >)> SlFindAnnCallback
Definition: rib-manager.hpp:102
ndn::nfd::Route::setFaceId
Route & setFaceId(uint64_t faceId)
Definition: rib-entry.cpp:52
nfd::rib::Rib::beginApplyUpdate
void beginApplyUpdate(const RibUpdate &update, const UpdateSuccessCallback &onSuccess, const UpdateFailureCallback &onFailure)
passes the provided RibUpdateBatch to FibUpdater to calculate and send FibUpdates.
Definition: rib.cpp:351
ndn::nfd::Route::setOrigin
Route & setOrigin(RouteOrigin origin)
Definition: rib-entry.cpp:60