27 #include <ndn-cxx/management/nfd-fib-entry.hpp> 34 function<shared_ptr<Face>(
FaceId)> getFace,
41 registerCommandHandler<ndn::nfd::FibAddNextHopCommand>(
"add-nexthop",
42 bind(&FibManager::addNextHop,
this, _2, _3, _4, _5));
43 registerCommandHandler<ndn::nfd::FibRemoveNextHopCommand>(
"remove-nexthop",
44 bind(&FibManager::removeNextHop,
this, _2, _3, _4, _5));
50 FibManager::addNextHop(
const Name& topPrefix,
const Interest& interest,
54 setFaceForSelfRegistration(interest, parameters);
58 uint64_t cost = parameters.
getCost();
61 <<
" faceid: " << faceId
62 <<
" cost: " << cost);
64 auto face = m_getFace(faceId);
65 if (static_cast<bool>(
face)) {
66 auto entry = m_fib.
insert(prefix).first;
68 entry->addNextHop(
face, cost);
71 <<
" prefix:" << prefix
72 <<
" faceid: " << faceId
73 <<
" cost: " << cost);
78 NFD_LOG_INFO(
"add-nexthop result: FAIL reason: unknown-faceid: " << faceId);
84 FibManager::removeNextHop(
const Name& topPrefix,
const Interest& interest,
88 setFaceForSelfRegistration(interest, parameters);
91 <<
" faceid: " << parameters.
getFaceId());
94 if (static_cast<bool>(face)) {
96 if (static_cast<bool>(entry)) {
97 entry->removeNextHop(face);
99 <<
" faceid: " << parameters.
getFaceId());
101 if (!entry->hasNextHops()) {
117 FibManager::listEntries(
const Name& topPrefix,
const Interest& interest,
120 for (
auto&& entry : m_fib) {
121 auto prefix = entry.getPrefix();
123 const auto& nextHops = entry.getNextHops();
125 for (
auto&& next : nextHops) {
127 nextHopRecord.
setFaceId(next.getFace()->getId());
128 nextHopRecord.
setCost(next.getCost());
143 bool isSelfRegistration = (parameters.
getFaceId() == 0);
144 if (isSelfRegistration) {
149 BOOST_ASSERT(incomingFaceIdTag !=
nullptr);
150 parameters.
setFaceId(*incomingFaceIdTag);
ControlParameters & setFaceId(uint64_t faceId)
a collection of common functions shared by all NFD managers, such as communicating with the dispatche...
shared_ptr< T > getTag() const
get a tag item
#define NFD_LOG_DEBUG(expression)
NextHopRecord & setFaceId(uint64_t faceId)
represents parameters in a ControlCommand request or response
std::pair< shared_ptr< fib::Entry >, bool > insert(const Name &prefix)
inserts a FIB entry for prefix If an entry for exact same prefix exists, that entry is returned...
FibEntry & setPrefix(const Name &prefix)
represents a dispatcher on server side of NFD Management protocol
size_t wireEncode(EncodingImpl< TAG > &encoder) const
represents an Interest packet
shared_ptr< fib::Entry > findExactMatch(const Name &prefix) const
provides a tag type for simple types
const Name & getName() const
size_t wireEncode(EncodingImpl< TAG > &block) const
ndn::mgmt::ControlResponse ControlResponse
#define NFD_LOG_INFO(expression)
void erase(const Name &prefix)
Copyright (c) 2011-2015 Regents of the University of California.
void end()
end the response successfully after appending zero or more blocks
NextHopRecord & setCost(uint64_t cost)
Name abstraction to represent an absolute name.
FibEntry & addNextHopRecord(const NextHopRecord &nextHopRecord)
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
uint64_t getFaceId() const
FibManager(Fib &fib, function< shared_ptr< Face >(FaceId)> getFace, Dispatcher &dispatcher, CommandValidator &validator)
construct a FibManger
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
void append(const Block &block)
append a Block to the response
provides a context for generating response to a StatusDataset request
uint64_t FaceId
identifies a face
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)