Serve commands and datasets in NFD RIB management protocol. More...
#include <rib-manager.hpp>
Classes | |
class | Error |
Public Types | |
enum | SlAnnounceResult { SlAnnounceResult::OK, SlAnnounceResult::ERROR, SlAnnounceResult::VALIDATION_FAILURE, SlAnnounceResult::EXPIRED, SlAnnounceResult::NOT_FOUND } |
using | SlAnnounceCallback = std::function< void(SlAnnounceResult res)> |
using | SlFindAnnCallback = std::function< void(optional< ndn::PrefixAnnouncement >)> |
Public Member Functions | |
RibManager (Rib &rib, ndn::Face &face, ndn::KeyChain &keyChain, ndn::nfd::Controller &nfdController, Dispatcher &dispatcher, ndn::util::Scheduler &scheduler) | |
void | applyLocalhostConfig (const ConfigSection §ion, const std::string &filename) |
Apply localhost_security configuration. More... | |
void | enableLocalhop (const ConfigSection §ion, const std::string &filename) |
Apply localhop_security configuration and allow accepting commands on /localhop/nfd/rib prefix. More... | |
void | disableLocalhop () |
Disallow accepting commands on /localhop/nfd/rib prefix. More... | |
void | registerWithNfd () |
Start accepting commands and dataset requests. More... | |
void | enableLocalFields () |
Enable NDNLP IncomingFaceId field in order to support self-registration commands. More... | |
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. More... | |
void | slRenew (const Name &name, uint64_t faceId, time::milliseconds maxLifetime, const SlAnnounceCallback &cb) |
Renew a route created by prefix announcement from self-learning strategy. More... | |
void | slFindAnn (const Name &name, const SlFindAnnCallback &cb) const |
Retrieve an outgoing prefix announcement for self-learning strategy. More... | |
Public Member Functions inherited from nfd::ManagerBase | |
ManagerBase (Dispatcher &dispatcher, const std::string &module) | |
virtual | ~ManagerBase () |
const std::string & | getModule () const |
Static Public Attributes | |
static const Name | LOCALHOP_TOP_PREFIX = "/localhop/nfd" |
Additional Inherited Members | |
Protected Types inherited from nfd::ManagerBase | |
using | ControlCommandHandler = std::function< void(const ControlCommand &command, const Name &prefix, const Interest &interest, const ControlParameters ¶meters, const ndn::mgmt::CommandContinuation done)> |
Protected Member Functions inherited from nfd::ManagerBase | |
template<typename Command > | |
void | registerCommandHandler (const std::string &verb, const ControlCommandHandler &handler) |
void | registerStatusDatasetHandler (const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler) |
ndn::mgmt::PostNotification | registerNotificationStream (const std::string &verb) |
void | extractRequester (const Interest &interest, ndn::mgmt::AcceptContinuation accept) |
extract a requester from a ControlCommand request More... | |
Serve commands and datasets in NFD RIB management protocol.
Definition at line 47 of file rib-manager.hpp.
using nfd::rib::RibManager::SlAnnounceCallback = std::function<void(SlAnnounceResult res)> |
Definition at line 99 of file rib-manager.hpp.
using nfd::rib::RibManager::SlFindAnnCallback = std::function<void(optional<ndn::PrefixAnnouncement>)> |
Definition at line 100 of file rib-manager.hpp.
|
strong |
Definition at line 91 of file rib-manager.hpp.
nfd::rib::RibManager::RibManager | ( | Rib & | rib, |
ndn::Face & | face, | ||
ndn::KeyChain & | keyChain, | ||
ndn::nfd::Controller & | nfdController, | ||
Dispatcher & | dispatcher, | ||
ndn::util::Scheduler & | scheduler | ||
) |
Definition at line 49 of file rib-manager.cpp.
References nfd::ManagerBase::registerStatusDatasetHandler().
void nfd::rib::RibManager::applyLocalhostConfig | ( | const ConfigSection & | section, |
const std::string & | filename | ||
) |
Apply localhost_security configuration.
Definition at line 72 of file rib-manager.cpp.
References ndn::security::ValidatorConfig::load().
void nfd::rib::RibManager::enableLocalhop | ( | const ConfigSection & | section, |
const std::string & | filename | ||
) |
Apply localhop_security configuration and allow accepting commands on /localhop/nfd/rib prefix.
Definition at line 78 of file rib-manager.cpp.
References ndn::security::ValidatorConfig::load().
void nfd::rib::RibManager::disableLocalhop | ( | ) |
Disallow accepting commands on /localhop/nfd/rib prefix.
Definition at line 85 of file rib-manager.cpp.
void nfd::rib::RibManager::registerWithNfd | ( | ) |
Start accepting commands and dataset requests.
Definition at line 91 of file rib-manager.cpp.
References nfd::rib::ACTIVE_FACE_FETCH_INTERVAL, LOCALHOP_TOP_PREFIX, nfd::rib::LOCALHOST_TOP_PREFIX, NFD_LOG_INFO, ndn::util::NotificationSubscriber< Notification >::onNotification, and ndn::util::NotificationSubscriberBase::start().
void nfd::rib::RibManager::enableLocalFields | ( | ) |
Enable NDNLP IncomingFaceId field in order to support self-registration commands.
Definition at line 107 of file rib-manager.cpp.
References ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, ndn::tlv::nfd::ControlParameters, NFD_LOG_DEBUG, ndn::nfd::Controller::start(), and ndn::to_string().
void nfd::rib::RibManager::slAnnounce | ( | const ndn::PrefixAnnouncement & | pa, |
uint64_t | faceId, | ||
time::milliseconds | maxLifetime, | ||
const SlAnnounceCallback & | cb | ||
) |
Insert a route by prefix announcement from self-learning strategy.
pa | A prefix announcement. It must contain the Data. |
faceId | Face on which the announcement arrives. |
maxLifetime | Maximum route lifetime as imposed by self-learning strategy. |
cb | Callback to receive the operation result. |
If pa
passes validation and is unexpired, inserts or replaces a route for the announced name and faceId whose lifetime is set to the earlier of now+maxLifetime or prefix announcement expiration time, updates FIB, and invokes cb
with SlAnnounceResult::OK. In case pa
expires when validation completes, invokes cb
with SlAnnounceResult::EXPIRED. If pa
cannot be verified by the trust schema given in rib.localhop_security config key, or the relevant config has not been loaded via enableLocalHop
, invokes cb
with SlAnnounceResult::VALIDATION_FAILURE.
Self-learning strategy invokes this method after receiving a Data carrying a prefix announcement.
Definition at line 358 of file rib-manager.cpp.
References nfd::rib::Route::annExpires, nfd::rib::Route::expires, ndn::PrefixAnnouncement::getAnnouncedName(), ndn::PrefixAnnouncement::getData(), NFD_LOG_INFO, ndn::time::steady_clock::now(), nonstd::optional_lite::nullopt, ndn::security::v2::Validator::validate(), and VALIDATION_FAILURE.
void nfd::rib::RibManager::slRenew | ( | const Name & | name, |
uint64_t | faceId, | ||
time::milliseconds | maxLifetime, | ||
const SlAnnounceCallback & | cb | ||
) |
Renew a route created by prefix announcement from self-learning strategy.
name | Data name, for finding RIB entry by longest-prefix-match. |
faceId | Nexthop face. |
maxLifetime | Maximum route lifetime as imposed by self-learning strategy. |
cb | Callback to receive the operation result. |
If the specified route exists, prolongs its lifetime to the earlier of now+maxLifetime or prefix announcement expiration time, and invokes cb
with SlAnnounceResult::OK. If the prefix announcement has expired, invokes cb
with SlAnnounceResult::EXPIRED. If the route is not found, invokes cb
with SlAnnounceResult::NOT_FOUND.
Self-learning strategy invokes this method after an Interest forwarded via a learned route is satisfied.
Definition at line 390 of file rib-manager.cpp.
References nfd::rib::Route::annExpires, nfd::rib::Route::announcement, nfd::rib::Route::expires, nfd::rib::Route::faceId, NFD_LOG_DEBUG, NFD_LOG_INFO, NOT_FOUND, ndn::time::steady_clock::now(), nonstd::optional_lite::nullopt, nfd::rib::Route::origin, and ndn::nfd::ROUTE_ORIGIN_PREFIXANN.
void nfd::rib::RibManager::slFindAnn | ( | const Name & | name, |
const SlFindAnnCallback & | cb | ||
) | const |
Retrieve an outgoing prefix announcement for self-learning strategy.
name | Data name. |
cb | Callback to receive a prefix announcement that announces a prefix of name , or nullopt if no RIB entry is found by longest-prefix-match of name . |
Self-learning strategy invokes this method before sending a Data in reply to a discovery Interest, so as to attach a prefix announcement onto that Data.
Definition at line 415 of file rib-manager.cpp.
References nonstd::optional_lite::nullopt.
|
static |
Definition at line 243 of file rib-manager.hpp.
Referenced by nfd::rib::HostToGatewayReadvertisePolicy::handleNewRoute(), and registerWithNfd().