NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
fib-enumeration-publisher.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
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 
36  AppFace& face,
37  const Name& prefix,
38  ndn::KeyChain& keyChain)
39  : SegmentPublisher(face, prefix, keyChain)
40  , m_fib(fib)
41 {
42 }
43 
45 {
46 }
47 
48 size_t
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 
83  NFD_LOG_DEBUG("generate: Total length = " << totalLength);
84  return totalLength;
85 }
86 
87 } // namespace nfd
provides a publisher of Status Dataset or other segmented octet stream
const_iterator begin() const
returns an iterator pointing to the first FIB entry
Definition: fib.cpp:180
const Name & getPrefix() const
Definition: fib-entry.hpp:115
#define NFD_LOG_DEBUG(expression)
Definition: logger.hpp:36
uint64_t getCost() const
Definition: fib-nexthop.cpp:50
const_iterator end() const
returns an iterator referring to the past-the-end FIB entry
Definition: fib.hpp:172
NextHopRecord & setFaceId(uint64_t faceId)
FibEntry & setPrefix(const Name &prefix)
represents a FIB entry
Definition: fib-entry.hpp:53
The packet signing interface.
Definition: key-chain.hpp:48
represents the FIB
Definition: fib.hpp:44
size_t wireEncode(EncodingImpl< TAG > &block) const
EncodingImpl< EncoderTag > EncodingBuffer
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
virtual size_t generate(ndn::EncodingBuffer &outBuffer)
In a derived class, write the octets into outBuffer.
std::vector< fib::NextHop > NextHopList
Definition: fib-entry.hpp:48
NextHopRecord & setCost(uint64_t cost)
Name abstraction to represent an absolute name.
Definition: name.hpp:46
const shared_ptr< Face > & getFace() const
Definition: fib-nexthop.cpp:38
FibEntry & addNextHopRecord(const NextHopRecord &nextHopRecord)
#define NFD_LOG_INIT(name)
Definition: logger.hpp:33
const NextHopList & getNextHops() const
Definition: fib-entry.hpp:121
FibEnumerationPublisher(const Fib &fib, AppFace &face, const Name &prefix, ndn::KeyChain &keyChain)
represents a nexthop record in FIB entry
Definition: fib-nexthop.hpp:38