|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
35 #include <boost/range/adaptor/transformed.hpp>
45 , m_faceTable(faceTable)
47 registerCommandHandler<ndn::nfd::FibAddNextHopCommand>(
"add-nexthop",
48 bind(&FibManager::addNextHop,
this, _2, _3, _4, _5));
49 registerCommandHandler<ndn::nfd::FibRemoveNextHopCommand>(
"remove-nexthop",
50 bind(&FibManager::removeNextHop,
this, _2, _3, _4, _5));
56 FibManager::addNextHop(
const Name& topPrefix,
const Interest& interest,
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");
79 fib::Entry* entry = m_fib.
insert(prefix).first;
82 NFD_LOG_TRACE(
"fib/add-nexthop(" << prefix <<
',' << faceId <<
',' << cost <<
"): OK");
87 FibManager::removeNextHop(
const Name& topPrefix,
const Interest& interest,
91 setFaceForSelfRegistration(interest, parameters);
92 const Name& prefix = parameters.getName();
93 FaceId faceId = parameters.getFaceId();
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())
132 .setCost(nh.getCost());
145 bool isSelfRegistration = (parameters.getFaceId() == 0);
146 if (isSelfRegistration) {
151 BOOST_ASSERT(incomingFaceIdTag !=
nullptr);
152 parameters.setFaceId(*incomingFaceIdTag);
static constexpr size_t getMaxDepth()
Maximum number of components in a FIB entry prefix.
void append(const Block &block)
append a Block to the response
provides a tag type for simple types
size_t size() const
Returns the number of components.
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
mgmt::ControlResponse ControlResponse
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
void addOrUpdateNextHop(Entry &entry, Face &face, uint64_t cost)
Add a NextHop record.
std::pair< Entry *, bool > insert(const Name &prefix)
Find or insert a FIB entry.
@ NO_SUCH_NEXTHOP
the nexthop is not found
FibManager(fib::Fib &fib, const FaceTable &faceTable, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
Implements the FIB Management of NFD Management Protocol.
Represents an absolute name.
Copyright (c) 2011-2015 Regents of the University of California.
uint64_t FaceId
Identifies a face.
Entry * findExactMatch(const Name &prefix)
Performs an exact match lookup.
provides a context for generating response to a StatusDataset request
@ NEXTHOP_REMOVED
the nexthop is removed and the fib entry stays
Represents an Interest packet.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
size_t wireEncode(EncodingImpl< TAG > &block) const
Face * get(FaceId id) const
get face by FaceId
A collection of common functions shared by all NFD managers, such as communicating with the dispatche...
represents parameters in a ControlCommand request or response
const Name & getName() const
@ FIB_ENTRY_REMOVED
the nexthop is removed and the fib entry is removed
FibEntry & setNextHopRecords(InputIt first, InputIt last)
represents a dispatcher on server side of NFD Management protocol
std::string to_string(const T &val)
void end()
end the response successfully after appending zero or more blocks
FibEntry & setPrefix(const Name &prefix)
RemoveNextHopResult removeNextHop(Entry &entry, const Face &face)
Remove the NextHop record for face from entry.
Represents the Forwarding Information Base (FIB)
Provides ControlCommand authorization according to NFD configuration file.
uint64_t getFaceId() const
#define NFD_LOG_INIT(name)