35 #include <boost/range/adaptor/transformed.hpp> 45 , m_faceTable(faceTable)
47 registerCommandHandler<ndn::nfd::FibAddNextHopCommand>(
"add-nexthop",
48 std::bind(&FibManager::addNextHop,
this, _2, _3, _4, _5));
49 registerCommandHandler<ndn::nfd::FibRemoveNextHopCommand>(
"remove-nexthop",
50 std::bind(&FibManager::removeNextHop,
this, _2, _3, _4, _5));
60 setFaceForSelfRegistration(interest, parameters);
63 uint64_t cost = parameters.
getCost();
66 NFD_LOG_DEBUG(
"fib/add-nexthop(" << prefix <<
',' << faceId <<
',' << cost <<
67 "): FAIL prefix-too-long");
72 Face* face = m_faceTable.
get(faceId);
73 if (face ==
nullptr) {
74 NFD_LOG_DEBUG(
"fib/add-nexthop(" << prefix <<
',' << faceId <<
',' << cost <<
75 "): FAIL unknown-faceid");
82 NFD_LOG_TRACE(
"fib/add-nexthop(" << prefix <<
',' << faceId <<
',' << cost <<
"): OK");
87 FibManager::removeNextHop(
const Name& topPrefix,
const Interest& interest,
91 setFaceForSelfRegistration(interest, parameters);
97 Face* face = m_faceTable.
get(faceId);
98 if (face ==
nullptr) {
99 NFD_LOG_TRACE(
"fib/remove-nexthop(" << prefix <<
',' << faceId <<
"): OK no-face");
104 if (entry ==
nullptr) {
105 NFD_LOG_TRACE(
"fib/remove-nexthop(" << prefix <<
',' << faceId <<
"): OK no-entry");
112 NFD_LOG_TRACE(
"fib/remove-nexthop(" << prefix <<
',' << faceId <<
"): OK no-nexthop");
115 NFD_LOG_TRACE(
"fib/remove-nexthop(" << prefix <<
',' << faceId <<
"): OK entry-erased");
118 NFD_LOG_TRACE(
"fib/remove-nexthop(" << prefix <<
',' << faceId <<
"): OK nexthop-removed");
124 FibManager::listEntries(
const Name& topPrefix,
const Interest& interest,
127 for (
const auto& entry : m_fib) {
128 const auto& nexthops = entry.getNextHops() |
129 boost::adaptors::transformed([] (
const fib::NextHop& nh) {
131 .setFaceId(nh.
getFace().getId())
135 .setPrefix(entry.getPrefix())
136 .setNextHopRecords(std::begin(nexthops), std::end(nexthops))
145 bool isSelfRegistration = (parameters.
getFaceId() == 0);
146 if (isSelfRegistration) {
151 BOOST_ASSERT(incomingFaceIdTag !=
nullptr);
152 parameters.
setFaceId(*incomingFaceIdTag);
RemoveNextHopResult removeNextHop(Entry &entry, const Face &face)
Remove the NextHop record for face from entry.
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name & prefix
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name const Interest & interest
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
std::pair< Entry *, bool > insert(const Name &prefix)
Find or insert a FIB entry.
Entry * findExactMatch(const Name &prefix)
Performs an exact match lookup.
#define NFD_LOG_INIT(name)
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name const Interest const ControlParameters const ndn::mgmt::CommandContinuation done
std::string to_string(const T &val)
represents parameters in a ControlCommand request or response
represents a dispatcher on server side of NFD Management protocol
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Represents an Interest packet.
static constexpr size_t getMaxDepth()
Maximum number of components in a FIB entry prefix.
FibManager(fib::Fib &fib, const FaceTable &faceTable, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
Face * get(FaceId id) const
get face by FaceId
void addOrUpdateNextHop(Entry &entry, Face &face, uint64_t cost)
Add a NextHop record.
provides a tag type for simple types
const Name & getName() const
mgmt::ControlResponse ControlResponse
Implements the FIB Management of NFD Management Protocol.
Copyright (c) 2011-2015 Regents of the University of California.
void end()
Finalizes the response successfully after appending zero or more blocks.
Represents the Forwarding Information Base (FIB)
the nexthop is removed and the fib entry stays
Represents an absolute name.
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
uint64_t getFaceId() const
size_t size() const
Returns the number of components.
void append(span< const uint8_t > bytes)
Appends a sequence of bytes to the response.
Provides ControlCommand authorization according to NFD configuration file.
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED const Name const Interest const ControlParameters & parameters
Provides a context for generating the response to a StatusDataset request.
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
uint64_t FaceId
Identifies a face.
the nexthop is removed and the fib entry is removed
Represents a nexthop record in a FIB entry.