28 #include <ndn-cxx/lp/tags.hpp> 29 #include <ndn-cxx/mgmt/nfd/fib-entry.hpp> 41 , m_faceTable(faceTable)
43 registerCommandHandler<ndn::nfd::FibAddNextHopCommand>(
"add-nexthop",
44 bind(&FibManager::addNextHop,
this, _2, _3, _4, _5));
45 registerCommandHandler<ndn::nfd::FibRemoveNextHopCommand>(
"remove-nexthop",
46 bind(&FibManager::removeNextHop,
this, _2, _3, _4, _5));
52 FibManager::addNextHop(
const Name& topPrefix,
const Interest& interest,
56 setFaceForSelfRegistration(interest, parameters);
60 uint64_t cost = parameters.
getCost();
63 <<
" faceid: " << faceId
64 <<
" cost: " << cost);
67 if (face !=
nullptr) {
72 <<
" prefix:" << prefix
73 <<
" faceid: " << faceId
74 <<
" cost: " << cost);
79 NFD_LOG_INFO(
"add-nexthop result: FAIL reason: unknown-faceid: " << faceId);
85 FibManager::removeNextHop(
const Name& topPrefix,
const Interest& interest,
89 setFaceForSelfRegistration(interest, parameters);
92 <<
" faceid: " << parameters.
getFaceId());
95 if (face !=
nullptr) {
97 if (entry !=
nullptr) {
100 <<
" faceid: " << parameters.
getFaceId());
118 FibManager::listEntries(
const Name& topPrefix,
const Interest& interest,
121 for (
auto&& entry : m_fib) {
122 auto prefix = entry.getPrefix();
124 const auto& nextHops = entry.getNextHops();
126 for (
auto&& next : nextHops) {
128 nextHopRecord.
setFaceId(next.getFace().getId());
129 nextHopRecord.
setCost(next.getCost());
144 bool isSelfRegistration = (parameters.
getFaceId() == 0);
145 if (isSelfRegistration) {
150 BOOST_ASSERT(incomingFaceIdTag !=
nullptr);
151 parameters.
setFaceId(*incomingFaceIdTag);
ControlParameters & setFaceId(uint64_t faceId)
shared_ptr< T > getTag() const
get a tag item
std::pair< Entry *, bool > insert(const Name &prefix)
inserts a FIB entry for prefix
Entry * findExactMatch(const Name &prefix)
performs an exact match lookup
void erase(const Name &prefix)
NextHopRecord & setFaceId(uint64_t faceId)
represents parameters in a ControlCommand request or response
FibEntry & setPrefix(const Name &prefix)
generalization of a network interface
represents a dispatcher on server side of NFD Management protocol
size_t wireEncode(EncodingImpl< TAG > &encoder) const
void addNextHop(Face &face, uint64_t cost)
adds a NextHop record
represents an Interest packet
#define NFD_LOG_DEBUG(expression)
#define NFD_LOG_INFO(expression)
Face * get(FaceId id) const
get face by FaceId
provides a tag type for simple types
void removeNextHop(const Face &face)
removes a NextHop record
#define NFD_LOG_TRACE(expression)
const Name & getName() const
size_t wireEncode(EncodingImpl< TAG > &block) const
FibManager(Fib &fib, const FaceTable &faceTable, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
ndn::mgmt::ControlResponse ControlResponse
Copyright (c) 2011-2015 Regents of the University of California.
void end()
end the response successfully after appending zero or more blocks
represents the Forwarding Information Base (FIB)
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
provides ControlCommand authorization according to NFD configuration file
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
a collection of common functions shared by all NFD managers, such as communicating with the dispatche...
#define NFD_LOG_INIT(name)
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)