29 #include <ndn-cxx/lp/tags.hpp> 30 #include <ndn-cxx/mgmt/nfd/fib-entry.hpp> 32 #include <boost/range/adaptor/transformed.hpp> 44 , m_faceTable(faceTable)
46 registerCommandHandler<ndn::nfd::FibAddNextHopCommand>(
"add-nexthop",
47 bind(&FibManager::addNextHop,
this, _2, _3, _4, _5));
48 registerCommandHandler<ndn::nfd::FibRemoveNextHopCommand>(
"remove-nexthop",
49 bind(&FibManager::removeNextHop,
this, _2, _3, _4, _5));
55 FibManager::addNextHop(
const Name& topPrefix,
const Interest& interest,
59 setFaceForSelfRegistration(interest, parameters);
63 uint64_t cost = parameters.
getCost();
66 <<
" faceid: " << faceId
67 <<
" cost: " << cost);
70 if (face !=
nullptr) {
71 fib::Entry* entry = m_fib.insert(prefix).first;
75 <<
" prefix:" << prefix
76 <<
" faceid: " << faceId
77 <<
" cost: " << cost);
82 NFD_LOG_INFO(
"add-nexthop result: FAIL reason: unknown-faceid: " << faceId);
88 FibManager::removeNextHop(
const Name& topPrefix,
const Interest& interest,
92 setFaceForSelfRegistration(interest, parameters);
95 <<
" faceid: " << parameters.
getFaceId());
98 if (face !=
nullptr) {
100 if (entry !=
nullptr) {
103 <<
" faceid: " << parameters.
getFaceId());
121 FibManager::listEntries(
const Name& topPrefix,
const Interest& interest,
124 for (
const auto& entry : m_fib) {
125 const auto& nexthops = entry.getNextHops() |
126 boost::adaptors::transformed([] (
const fib::NextHop& nh) {
128 .setFaceId(nh.
getFace().getId())
132 .setPrefix(entry.getPrefix())
133 .setNextHopRecords(std::begin(nexthops), std::end(nexthops))
142 bool isSelfRegistration = (parameters.
getFaceId() == 0);
143 if (isSelfRegistration) {
148 BOOST_ASSERT(incomingFaceIdTag !=
nullptr);
149 parameters.
setFaceId(*incomingFaceIdTag);
ControlParameters & setFaceId(uint64_t faceId)
represents parameters in a ControlCommand request or response
represents a dispatcher on server side of NFD Management protocol
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)
provides a tag type for simple types
void removeNextHop(const Face &face)
removes a NextHop record
#define NFD_LOG_TRACE(expression)
size_t wireEncode(EncodingImpl< TAG > &encoder) const
FibManager(Fib &fib, const FaceTable &faceTable, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
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
const Name & getName() const
Represents an absolute name.
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
shared_ptr< T > getTag() const
get a tag item
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)
Face * get(FaceId id) const
get face by FaceId
represents a nexthop record in FIB entry