bf6a93da4e
GlobalConfigurationFixture uses unit-tests.conf to determine default and module specific logging levels. Logging will gracefully default to INFO if unit-tests.conf is not found. See unit-tests.conf.sample for a sample configuration file. refs: #1375, #1267 Change-Id: Ib0c4eb4149748e6658f94ef1afa23ddd3072c0fa
71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
/**
|
|
* Copyright (C) 2014 Named Data Networking Project
|
|
* See COPYING for copyright and distribution information.
|
|
*/
|
|
|
|
#include "fib-enumeration-publisher.hpp"
|
|
|
|
#include "core/logger.hpp"
|
|
|
|
#include <ndn-cpp-dev/management/nfd-fib-entry.hpp>
|
|
|
|
namespace nfd {
|
|
|
|
NFD_LOG_INIT("FibEnumerationPublisher");
|
|
|
|
FibEnumerationPublisher::FibEnumerationPublisher(const Fib& fib,
|
|
shared_ptr<AppFace> face,
|
|
const Name& prefix)
|
|
: SegmentPublisher(face, prefix)
|
|
, m_fib(fib)
|
|
{
|
|
|
|
}
|
|
|
|
FibEnumerationPublisher::~FibEnumerationPublisher()
|
|
{
|
|
|
|
}
|
|
|
|
size_t
|
|
FibEnumerationPublisher::generate(ndn::EncodingBuffer& outBuffer)
|
|
{
|
|
size_t totalLength = 0;
|
|
|
|
/// \todo Enable use of Fib::const_reverse_iterator (when it is available)
|
|
for (Fib::const_iterator i = m_fib.begin(); i != m_fib.end(); ++i)
|
|
{
|
|
const fib::Entry& entry = *i;
|
|
const Name& prefix = entry.getPrefix();
|
|
size_t fibEntryLength = 0;
|
|
|
|
ndn::nfd::FibEntry tlvEntry;
|
|
const fib::NextHopList& nextHops = entry.getNextHops();
|
|
|
|
for (fib::NextHopList::const_iterator j = nextHops.begin();
|
|
j != nextHops.end();
|
|
++j)
|
|
{
|
|
const fib::NextHop& next = *j;
|
|
ndn::nfd::NextHopRecord nextHopRecord;
|
|
nextHopRecord.setFaceId(next.getFace()->getId());
|
|
nextHopRecord.setCost(next.getCost());
|
|
|
|
tlvEntry.addNextHopRecord(nextHopRecord);
|
|
}
|
|
|
|
tlvEntry.setPrefix(prefix);
|
|
fibEntryLength += tlvEntry.wireEncode(outBuffer);
|
|
|
|
NFD_LOG_DEBUG("generate: fib entry length = " << fibEntryLength);
|
|
|
|
totalLength += fibEntryLength;
|
|
}
|
|
NFD_LOG_DEBUG("generate: Total length = " << totalLength);
|
|
return totalLength;
|
|
}
|
|
|
|
|
|
} // namespace nfd
|