Implements the RIB Management of NFD Management Protocol. More...
#include <rib-manager.hpp>
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 &rib, ndn::Face &face, ndn::KeyChain &keyChain, ndn::nfd::Controller &nfdController, Dispatcher &dispatcher) | |
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 | applyPaConfig (const ConfigSection §ion, const std::string &filename) |
Apply prefix_announcement_validation configuration. 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 | |
virtual | ~ManagerBase () |
const std::string & | getModule () const |
Static Public Attributes | |
static const Name | LOCALHOP_TOP_PREFIX = "/localhop/nfd" |
Additional Inherited Members | |
Protected Member Functions inherited from nfd::ManagerBase | |
ManagerBase (const std::string &module, Dispatcher &dispatcher) | |
ManagerBase (const std::string &module, Dispatcher &dispatcher, CommandAuthenticator &authenticator) | |
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) |
PartialName | makeRelPrefix (const std::string &verb) |
Generates the relative prefix for a handler by appending the verb name to the module name. More... | |
Static Protected Member Functions inherited from nfd::ManagerBase | |
static bool | validateParameters (const ControlCommand &command, const ndn::mgmt::ControlParameters ¶meters) |
Validates the parameters for a given command . More... | |
static void | handleCommand (shared_ptr< ControlCommand > command, const ControlCommandHandler &handler, const Name &prefix, const Interest &interest, const ndn::mgmt::ControlParameters ¶ms, const ndn::mgmt::CommandContinuation &done) |
Handles a control command. More... | |
Protected Attributes inherited from nfd::ManagerBase | |
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED | __pad0__: using ControlCommandHandler = std::function<void(const ControlCommand& command |
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name & | prefix |
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name const Interest & | interest |
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name const Interest const ControlParameters & | parameters |
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name const Interest const ControlParameters const ndn::mgmt::CommandContinuation | done |
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED | __pad1__: static void extractRequester(const Interest& interest |
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const ndn::mgmt::AcceptContinuation & | accept |
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad2__: virtual ndn::mgmt::Authorization makeAuthorization(const std::string& verb) |
Implements the RIB Management of NFD Management Protocol.
Definition at line 49 of file rib-manager.hpp.
using nfd::RibManager::SlAnnounceCallback = std::function<void(SlAnnounceResult res)> |
Definition at line 101 of file rib-manager.hpp.
using nfd::RibManager::SlFindAnnCallback = std::function<void(optional<ndn::PrefixAnnouncement>)> |
Definition at line 102 of file rib-manager.hpp.
|
strong |
Definition at line 93 of file rib-manager.hpp.
nfd::RibManager::RibManager | ( | rib::Rib & | rib, |
ndn::Face & | face, | ||
ndn::KeyChain & | keyChain, | ||
ndn::nfd::Controller & | nfdController, | ||
Dispatcher & | dispatcher | ||
) |
Definition at line 51 of file rib-manager.cpp.
References nfd::ManagerBase::registerStatusDatasetHandler().
void nfd::RibManager::applyLocalhostConfig | ( | const ConfigSection & | section, |
const std::string & | filename | ||
) |
Apply localhost_security configuration.
Definition at line 73 of file rib-manager.cpp.
References ndn::security::ValidatorConfig::load().
Referenced by nfd::rib::Service::get().
void nfd::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 79 of file rib-manager.cpp.
References ndn::security::ValidatorConfig::load().
Referenced by nfd::rib::Service::get().
void nfd::RibManager::disableLocalhop | ( | ) |
Disallow accepting commands on /localhop/nfd/rib prefix.
Definition at line 86 of file rib-manager.cpp.
void nfd::RibManager::applyPaConfig | ( | const ConfigSection & | section, |
const std::string & | filename | ||
) |
Apply prefix_announcement_validation configuration.
Definition at line 92 of file rib-manager.cpp.
References ndn::security::ValidatorConfig::load().
Referenced by nfd::rib::Service::get().
void nfd::RibManager::registerWithNfd | ( | ) |
Start accepting commands and dataset requests.
Definition at line 98 of file rib-manager.cpp.
References LOCALHOP_TOP_PREFIX, NFD_LOG_INFO, ndn::util::NotificationSubscriber< Notification >::onNotification, and ndn::util::NotificationSubscriberBase::start().
Referenced by nfd::rib::Service::Service().
void nfd::RibManager::enableLocalFields | ( | ) |
Enable NDNLP IncomingFaceId field in order to support self-registration commands.
Definition at line 114 of file rib-manager.cpp.
References nfd::ManagerBase::accept, ndn::nfd::RibEntry::addRoute(), ndn::mgmt::Dispatcher::addTopPrefix(), ndn::mgmt::StatusDatasetContext::append(), nfd::rib::Rib::beginApplyUpdate(), ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, ndn::tlv::nfd::ControlParameters, nfd::rib::Route::cost, nfd::ManagerBase::done, ndn::mgmt::StatusDatasetContext::end(), nfd::rib::Route::expires, nfd::rib::Route::faceId, nfd::rib::Route::flags, ndn::nfd::ControlParameters::getCost(), ndn::nfd::ControlParameters::getExpirationPeriod(), ndn::nfd::ControlParameters::getFaceId(), ndn::nfd::ControlParameters::getFlags(), nfd::fib::Fib::getMaxDepth(), nfd::rib::RibEntry::getName(), ndn::nfd::ControlParameters::getName(), ndn::nfd::ControlParameters::getOrigin(), nfd::rib::RibEntry::getRoutes(), nfd::getScheduler(), ndn::TagHost::getTag(), ndn::nfd::ControlParameters::hasExpirationPeriod(), nfd::rib::Rib::insert(), nfd::ManagerBase::interest, LOCALHOP_TOP_PREFIX, nonstd::optional_lite::std11::move(), ns3::ndn::Name, NDN_THROW, NFD_LOG_DEBUG, NFD_LOG_INFO, NFD_LOG_TRACE, ndn::time::steady_clock::now(), nfd::rib::Rib::onRouteExpiration(), nfd::rib::Route::origin, nfd::ManagerBase::parameters, nfd::ManagerBase::prefix, nfd::rib::RibUpdate::REGISTER, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT, ndn::nfd::ROUTE_ORIGIN_APP, nfd::rib::RibUpdate::setAction(), ndn::nfd::Route::setCost(), nfd::rib::Route::setExpirationEvent(), ndn::nfd::Route::setExpirationPeriod(), ndn::nfd::Route::setFaceId(), ndn::nfd::ControlParameters::setFaceId(), ndn::nfd::Route::setFlags(), nfd::rib::RibUpdate::setName(), ndn::nfd::RibEntry::setName(), ndn::nfd::Route::setOrigin(), nfd::rib::RibUpdate::setRoute(), ndn::Name::size(), ndn::nfd::Controller::start(), ndn::mgmt::STATUS403, ndn::to_string(), ndn::Name::toUri(), nfd::rib::RibUpdate::UNREGISTER, ndn::nfd::ControlParameters::wireEncode(), and ndn::nfd::RibEntry::wireEncode().
Referenced by nfd::rib::Service::Service().
void nfd::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 357 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, and VALIDATION_FAILURE.
Referenced by nfd::fw::SelfLearningStrategy::afterReceiveNack().
void nfd::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 382 of file rib-manager.cpp.
References nfd::rib::Route::annExpires, nfd::rib::Route::announcement, nfd::rib::Route::expires, nfd::rib::Route::faceId, nfd::rib::Rib::findLongestPrefix(), 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.
Referenced by nfd::fw::SelfLearningStrategy::afterReceiveNack().
void nfd::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 407 of file rib-manager.cpp.
References nfd::rib::Rib::beginRemoveFace(), nfd::rib::Rib::beginRemoveFailedFaces(), nfd::rib::Rib::end(), ndn::nfd::FACE_EVENT_DESTROYED, ndn::nfd::Controller::fetch(), nfd::rib::Rib::find(), nfd::rib::Rib::findParent(), ndn::nfd::FaceTraits< C >::getFaceId(), nfd::getGlobalIoService(), ndn::nfd::FaceEventNotification::getKind(), nfd::getScheduler(), NFD_LOG_DEBUG, NFD_LOG_TRACE, nonstd::optional_lite::nullopt, and nfd::detail::SimulatorIo::post().
Referenced by nfd::fw::SelfLearningStrategy::afterReceiveNack().
|
static |
Definition at line 243 of file rib-manager.hpp.
Referenced by enableLocalFields(), nfd::rib::Service::get(), nfd::rib::HostToGatewayReadvertisePolicy::handleNewRoute(), and registerWithNfd().