NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
fib-enumeration-publisher.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25
#include "
fib-enumeration-publisher.hpp
"
26
#include "
core/logger.hpp
"
27
#include "
table/fib.hpp
"
28
29
#include <ndn-cxx/management/nfd-fib-entry.hpp>
30
31
namespace
nfd {
32
33
NFD_LOG_INIT
(
"FibEnumerationPublisher"
);
34
35
FibEnumerationPublisher::FibEnumerationPublisher
(
const
Fib
& fib,
36
AppFace
& face,
37
const
Name
& prefix,
38
ndn::KeyChain& keyChain)
39
:
SegmentPublisher
(face, prefix, keyChain)
40
, m_fib(fib)
41
{
42
}
43
44
FibEnumerationPublisher::~FibEnumerationPublisher
()
45
{
46
}
47
48
size_t
49
FibEnumerationPublisher::generate
(ndn::EncodingBuffer& outBuffer)
50
{
51
size_t
totalLength = 0;
52
54
for
(
Fib::const_iterator
i = m_fib.
begin
(); i != m_fib.
end
(); ++i)
55
{
56
const
fib::Entry
& entry = *i;
57
const
Name
& prefix = entry.
getPrefix
();
58
size_t
fibEntryLength = 0;
59
60
ndn::nfd::FibEntry tlvEntry;
61
const
fib::NextHopList
& nextHops = entry.
getNextHops
();
62
63
for
(fib::NextHopList::const_iterator j = nextHops.begin();
64
j != nextHops.end();
65
++j)
66
{
67
const
fib::NextHop
& next = *j;
68
ndn::nfd::NextHopRecord nextHopRecord;
69
nextHopRecord.setFaceId(next.
getFace
()->getId());
70
nextHopRecord.
setCost
(next.
getCost
());
71
72
tlvEntry.addNextHopRecord(nextHopRecord);
73
}
74
75
tlvEntry.setPrefix(prefix);
76
fibEntryLength += tlvEntry.wireEncode(outBuffer);
77
78
NFD_LOG_DEBUG
(
"generate: fib entry length = "
<< fibEntryLength);
79
80
totalLength += fibEntryLength;
81
}
82
NFD_LOG_DEBUG
(
"generate: Total length = "
<< totalLength);
83
return
totalLength;
84
}
85
86
87
}
// namespace nfd
nfd::SegmentPublisher
provides a publisher of Status Dataset or other segmented octet stream
Definition:
segment-publisher.hpp:40
nfd::AppFace
Definition:
app-face.hpp:37
nfd::fib::Entry::getNextHops
const NextHopList & getNextHops() const
Definition:
fib-entry.hpp:121
fib-enumeration-publisher.hpp
nfd::fib::NextHop::getCost
uint64_t getCost() const
Definition:
fib-nexthop.cpp:50
NFD_LOG_DEBUG
#define NFD_LOG_DEBUG(expression)
Definition:
logger.hpp:36
nfd::fib::Entry
represents a FIB entry
Definition:
fib-entry.hpp:53
nfd::fib::Entry::getPrefix
const Name & getPrefix() const
Definition:
fib-entry.hpp:115
nfd::FibEnumerationPublisher::~FibEnumerationPublisher
virtual ~FibEnumerationPublisher()
Definition:
fib-enumeration-publisher.cpp:44
nfd::Fib
represents the FIB
Definition:
fib.hpp:44
fib.hpp
nfd::Fib::begin
const_iterator begin() const
returns an iterator pointing to the first FIB entry
Definition:
fib.cpp:180
logger.hpp
nfd::FibEnumerationPublisher::generate
virtual size_t generate(ndn::EncodingBuffer &outBuffer)
In a derived class, write the octets into outBuffer.
Definition:
fib-enumeration-publisher.cpp:49
ns3::ndn::Name
Name
Definition:
ndn-common.cpp:25
nfd::fib::NextHopList
std::vector< fib::NextHop > NextHopList
Definition:
fib-entry.hpp:48
nfd::fib::NextHop::setCost
void setCost(uint64_t cost)
Definition:
fib-nexthop.cpp:44
nfd::Fib::const_iterator
Definition:
fib.hpp:113
nfd::fib::NextHop::getFace
const shared_ptr< Face > & getFace() const
Definition:
fib-nexthop.cpp:38
NFD_LOG_INIT
#define NFD_LOG_INIT(name)
Definition:
logger.hpp:33
nfd::Fib::end
const_iterator end() const
returns an iterator referring to the past-the-end FIB entry
Definition:
fib.hpp:172
nfd::FibEnumerationPublisher::FibEnumerationPublisher
FibEnumerationPublisher(const Fib &fib, AppFace &face, const Name &prefix, ndn::KeyChain &keyChain)
Definition:
fib-enumeration-publisher.cpp:35
nfd::fib::NextHop
represents a nexthop record in FIB entry
Definition:
fib-nexthop.hpp:38
ndnSIM
NFD
daemon
mgmt
fib-enumeration-publisher.cpp
Generated on Wed Feb 18 2015 16:31:16 for ndnSIM by
1.8.7