face/mgmt/fw/tools: add localUri to FaceStatus and FaceEventNotification
refs #1396 Change-Id: I6084745c62c44a409ecbd4a795cb712475e32416
This commit is contained in:
@@ -28,94 +28,94 @@ public:
|
||||
|
||||
/// incoming Interest (total packets since Face establishment)
|
||||
const FaceCounter&
|
||||
getInInterest() const;
|
||||
getNInInterests() const;
|
||||
|
||||
FaceCounter&
|
||||
getInInterest();
|
||||
getNInInterests();
|
||||
|
||||
/// incoming Data (total packets since Face establishment)
|
||||
const FaceCounter&
|
||||
getInData() const;
|
||||
getNInDatas() const;
|
||||
|
||||
FaceCounter&
|
||||
getInData();
|
||||
getNInDatas();
|
||||
|
||||
/// outgoing Interest (total packets since Face establishment)
|
||||
const FaceCounter&
|
||||
getOutInterest() const;
|
||||
getNOutInterests() const;
|
||||
|
||||
FaceCounter&
|
||||
getOutInterest();
|
||||
getNOutInterests();
|
||||
|
||||
/// outgoing Data (total packets since Face establishment)
|
||||
const FaceCounter&
|
||||
getOutData() const;
|
||||
getNOutDatas() const;
|
||||
|
||||
FaceCounter&
|
||||
getOutData();
|
||||
getNOutDatas();
|
||||
|
||||
private:
|
||||
FaceCounter m_inInterest;
|
||||
FaceCounter m_inData;
|
||||
FaceCounter m_outInterest;
|
||||
FaceCounter m_outData;
|
||||
FaceCounter m_nInInterests;
|
||||
FaceCounter m_nInDatas;
|
||||
FaceCounter m_outInterests;
|
||||
FaceCounter m_outDatas;
|
||||
};
|
||||
|
||||
inline
|
||||
FaceCounters::FaceCounters()
|
||||
: m_inInterest(0)
|
||||
, m_inData(0)
|
||||
, m_outInterest(0)
|
||||
, m_outData(0)
|
||||
: m_nInInterests(0)
|
||||
, m_nInDatas(0)
|
||||
, m_outInterests(0)
|
||||
, m_outDatas(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline const FaceCounter&
|
||||
FaceCounters::getInInterest() const
|
||||
FaceCounters::getNInInterests() const
|
||||
{
|
||||
return m_inInterest;
|
||||
return m_nInInterests;
|
||||
}
|
||||
|
||||
inline FaceCounter&
|
||||
FaceCounters::getInInterest()
|
||||
FaceCounters::getNInInterests()
|
||||
{
|
||||
return m_inInterest;
|
||||
return m_nInInterests;
|
||||
}
|
||||
|
||||
inline const FaceCounter&
|
||||
FaceCounters::getInData() const
|
||||
FaceCounters::getNInDatas() const
|
||||
{
|
||||
return m_inData;
|
||||
return m_nInDatas;
|
||||
}
|
||||
|
||||
inline FaceCounter&
|
||||
FaceCounters::getInData()
|
||||
FaceCounters::getNInDatas()
|
||||
{
|
||||
return m_inData;
|
||||
return m_nInDatas;
|
||||
}
|
||||
|
||||
inline const FaceCounter&
|
||||
FaceCounters::getOutInterest() const
|
||||
FaceCounters::getNOutInterests() const
|
||||
{
|
||||
return m_outInterest;
|
||||
return m_outInterests;
|
||||
}
|
||||
|
||||
inline FaceCounter&
|
||||
FaceCounters::getOutInterest()
|
||||
FaceCounters::getNOutInterests()
|
||||
{
|
||||
return m_outInterest;
|
||||
return m_outInterests;
|
||||
}
|
||||
|
||||
inline const FaceCounter&
|
||||
FaceCounters::getOutData() const
|
||||
FaceCounters::getNOutDatas() const
|
||||
{
|
||||
return m_outData;
|
||||
return m_outDatas;
|
||||
}
|
||||
|
||||
inline FaceCounter&
|
||||
FaceCounters::getOutData()
|
||||
FaceCounters::getNOutDatas()
|
||||
{
|
||||
return m_outData;
|
||||
return m_outDatas;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ Face::Face(const FaceUri& remoteUri, const FaceUri& localUri, bool isLocal)
|
||||
, m_localUri(localUri)
|
||||
, m_isOnDemand(false)
|
||||
{
|
||||
onReceiveInterest += bind(&increaseCounter, boost::ref(m_counters.getInInterest()));
|
||||
onReceiveData += bind(&increaseCounter, boost::ref(m_counters.getInData()));
|
||||
onSendInterest += bind(&increaseCounter, boost::ref(m_counters.getOutInterest()));
|
||||
onSendData += bind(&increaseCounter, boost::ref(m_counters.getOutData()));
|
||||
onReceiveInterest += bind(&increaseCounter, boost::ref(m_counters.getNInInterests()));
|
||||
onReceiveData += bind(&increaseCounter, boost::ref(m_counters.getNInDatas()));
|
||||
onSendInterest += bind(&increaseCounter, boost::ref(m_counters.getNOutInterests()));
|
||||
onSendData += bind(&increaseCounter, boost::ref(m_counters.getNOutDatas()));
|
||||
}
|
||||
|
||||
Face::~Face()
|
||||
|
||||
@@ -120,11 +120,6 @@ public: // attributes
|
||||
const FaceCounters&
|
||||
getCounters() const;
|
||||
|
||||
/** \deprecated use getRemoteUri instead
|
||||
*/
|
||||
const FaceUri&
|
||||
getUri() const;
|
||||
|
||||
/** \return a FaceUri that represents the remote endpoint
|
||||
*/
|
||||
const FaceUri&
|
||||
@@ -182,12 +177,6 @@ Face::getMutableCounters()
|
||||
return m_counters;
|
||||
}
|
||||
|
||||
inline const FaceUri&
|
||||
Face::getUri() const
|
||||
{
|
||||
return this->getRemoteUri();
|
||||
}
|
||||
|
||||
inline const FaceUri&
|
||||
Face::getRemoteUri() const
|
||||
{
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace nfd {
|
||||
|
||||
NFD_LOG_INIT("MulticastUdpFace");
|
||||
|
||||
MulticastUdpFace::MulticastUdpFace(const shared_ptr<protocol::socket>& socket,
|
||||
const protocol::endpoint& localEndpoint)
|
||||
MulticastUdpFace::MulticastUdpFace(const shared_ptr<MulticastUdpFace::protocol::socket>& socket,
|
||||
const MulticastUdpFace::protocol::endpoint& localEndpoint)
|
||||
: DatagramFace<protocol>(FaceUri(socket->local_endpoint()),
|
||||
FaceUri(localEndpoint),
|
||||
socket, false)
|
||||
|
||||
@@ -36,7 +36,8 @@ FaceTable::add(shared_ptr<Face> face)
|
||||
FaceId faceId = ++m_lastFaceId;
|
||||
face->setId(faceId);
|
||||
m_faces[faceId] = face;
|
||||
NFD_LOG_INFO("Added face id=" << faceId << " uri=" << face->getUri());
|
||||
NFD_LOG_INFO("Added face id=" << faceId << " remote=" << face->getRemoteUri() <<
|
||||
" local=" << face->getLocalUri());
|
||||
|
||||
face->onReceiveInterest += bind(&Forwarder::onInterest,
|
||||
&m_forwarder, boost::ref(*face), _1);
|
||||
@@ -56,7 +57,8 @@ FaceTable::remove(shared_ptr<Face> face)
|
||||
FaceId faceId = face->getId();
|
||||
m_faces.erase(faceId);
|
||||
face->setId(INVALID_FACEID);
|
||||
NFD_LOG_INFO("Removed face id=" << faceId << " uri=" << face->getUri());
|
||||
NFD_LOG_INFO("Removed face id=" << faceId << " remote=" << face->getRemoteUri() <<
|
||||
" local=" << face->getLocalUri());
|
||||
|
||||
// XXX This clears all subscriptions, because EventEmitter
|
||||
// does not support only removing Forwarder's subscription
|
||||
|
||||
@@ -39,7 +39,7 @@ Forwarder::onIncomingInterest(Face& inFace, const Interest& interest)
|
||||
NFD_LOG_DEBUG("onIncomingInterest face=" << inFace.getId() <<
|
||||
" interest=" << interest.getName());
|
||||
const_cast<Interest&>(interest).setIncomingFaceId(inFace.getId());
|
||||
m_counters.getInInterest() ++;
|
||||
m_counters.getNInInterests() ++;
|
||||
|
||||
// /localhost scope control
|
||||
bool isViolatingLocalhost = !inFace.isLocal() &&
|
||||
@@ -155,7 +155,7 @@ Forwarder::onOutgoingInterest(shared_ptr<pit::Entry> pitEntry, Face& outFace)
|
||||
|
||||
// send Interest
|
||||
outFace.sendInterest(interest);
|
||||
m_counters.getOutInterest() ++;
|
||||
m_counters.getNOutInterests() ++;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -186,7 +186,7 @@ Forwarder::onIncomingData(Face& inFace, const Data& data)
|
||||
// receive Data
|
||||
NFD_LOG_DEBUG("onIncomingData face=" << inFace.getId() << " data=" << data.getName());
|
||||
const_cast<Data&>(data).setIncomingFaceId(inFace.getId());
|
||||
m_counters.getInData() ++;
|
||||
m_counters.getNInDatas() ++;
|
||||
|
||||
// /localhost scope control
|
||||
bool isViolatingLocalhost = !inFace.isLocal() &&
|
||||
@@ -282,7 +282,7 @@ Forwarder::onOutgoingData(const Data& data, Face& outFace)
|
||||
|
||||
// send Data
|
||||
outFace.sendData(data);
|
||||
m_counters.getOutData() ++;
|
||||
m_counters.getNOutDatas() ++;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (C) 2014 Named Data Networking Project
|
||||
* See COPYING for copyright and distribution information.
|
||||
*/
|
||||
|
||||
#ifndef NFD_MGMT_FACE_FLAGS_HPP
|
||||
#define NFD_MGMT_FACE_FLAGS_HPP
|
||||
|
||||
#include "face/face.hpp"
|
||||
#include <ndn-cpp-dev/management/nfd-face-flags.hpp>
|
||||
|
||||
namespace nfd {
|
||||
|
||||
inline uint64_t
|
||||
getFaceFlags(const Face& face)
|
||||
{
|
||||
uint64_t flags = 0;
|
||||
if (face.isLocal()) {
|
||||
flags |= ndn::nfd::FACE_IS_LOCAL;
|
||||
}
|
||||
if (face.isOnDemand()) {
|
||||
flags |= ndn::nfd::FACE_IS_ON_DEMAND;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
} // namespace nfd
|
||||
|
||||
#endif // NFD_MGMT_FACE_FLAGS_HPP
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "face-manager.hpp"
|
||||
#include "face-flags.hpp"
|
||||
|
||||
#include "core/logger.hpp"
|
||||
#include "core/face-uri.hpp"
|
||||
@@ -562,7 +563,7 @@ FaceManager::addCreatedFaceToForwarder(const shared_ptr<Face>& newFace)
|
||||
{
|
||||
m_faceTable.add(newFace);
|
||||
|
||||
NFD_LOG_DEBUG("Created face " << newFace->getUri() << " ID " << newFace->getId());
|
||||
//NFD_LOG_DEBUG("Created face " << newFace->getRemoteUri() << " ID " << newFace->getId());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -642,25 +643,27 @@ FaceManager::destroyFace(const Interest& request,
|
||||
void
|
||||
FaceManager::onAddFace(shared_ptr<Face> face)
|
||||
{
|
||||
ndn::nfd::FaceEventNotification faceCreated(ndn::nfd::FACE_EVENT_CREATED,
|
||||
face->getId(),
|
||||
face->getUri().toString(),
|
||||
(face->isLocal() ? ndn::nfd::FACE_IS_LOCAL : 0) |
|
||||
(face->isOnDemand() ? ndn::nfd::FACE_IS_ON_DEMAND : 0));
|
||||
ndn::nfd::FaceEventNotification notification;
|
||||
notification.setKind(ndn::nfd::FACE_EVENT_CREATED)
|
||||
.setFaceId(face->getId())
|
||||
.setRemoteUri(face->getRemoteUri().toString())
|
||||
.setLocalUri(face->getLocalUri().toString())
|
||||
.setFlags(getFaceFlags(*face));
|
||||
|
||||
m_notificationStream.postNotification(faceCreated);
|
||||
m_notificationStream.postNotification(notification);
|
||||
}
|
||||
|
||||
void
|
||||
FaceManager::onRemoveFace(shared_ptr<Face> face)
|
||||
{
|
||||
ndn::nfd::FaceEventNotification faceDestroyed(ndn::nfd::FACE_EVENT_DESTROYED,
|
||||
face->getId(),
|
||||
face->getUri().toString(),
|
||||
(face->isLocal() ? ndn::nfd::FACE_IS_LOCAL : 0) |
|
||||
(face->isOnDemand() ? ndn::nfd::FACE_IS_ON_DEMAND : 0));
|
||||
ndn::nfd::FaceEventNotification notification;
|
||||
notification.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
|
||||
.setFaceId(face->getId())
|
||||
.setRemoteUri(face->getRemoteUri().toString())
|
||||
.setLocalUri(face->getLocalUri().toString())
|
||||
.setFlags(getFaceFlags(*face));
|
||||
|
||||
m_notificationStream.postNotification(faceDestroyed);
|
||||
m_notificationStream.postNotification(notification);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
*/
|
||||
|
||||
#include "face-status-publisher.hpp"
|
||||
#include "face-flags.hpp"
|
||||
#include "core/logger.hpp"
|
||||
#include <ndn-cpp-dev/management/nfd-face-status.hpp>
|
||||
|
||||
namespace nfd {
|
||||
|
||||
@@ -33,45 +35,22 @@ FaceStatusPublisher::generate(ndn::EncodingBuffer& outBuffer)
|
||||
size_t totalLength = 0;
|
||||
|
||||
for (FaceTable::const_reverse_iterator i = m_faceTable.rbegin();
|
||||
i != m_faceTable.rend();
|
||||
++i)
|
||||
{
|
||||
const shared_ptr<Face>& face = *i;
|
||||
const FaceCounters& counters = face->getCounters();
|
||||
const std::string uri = face->getUri().toString();
|
||||
i != m_faceTable.rend(); ++i) {
|
||||
const shared_ptr<Face>& face = *i;
|
||||
const FaceCounters& counters = face->getCounters();
|
||||
|
||||
size_t statusLength = 0;
|
||||
ndn::nfd::FaceStatus status;
|
||||
status.setFaceId(face->getId())
|
||||
.setRemoteUri(face->getRemoteUri().toString())
|
||||
.setLocalUri(face->getLocalUri().toString())
|
||||
.setFlags(getFaceFlags(*face))
|
||||
.setNInInterests(counters.getNInInterests())
|
||||
.setNInDatas(counters.getNInDatas())
|
||||
.setNOutInterests(counters.getNOutInterests())
|
||||
.setNOutDatas(counters.getNOutDatas());
|
||||
|
||||
statusLength += prependNonNegativeIntegerBlock(outBuffer,
|
||||
ndn::tlv::nfd::NOutDatas,
|
||||
counters.getOutData());
|
||||
|
||||
statusLength += prependNonNegativeIntegerBlock(outBuffer,
|
||||
ndn::tlv::nfd::NOutInterests,
|
||||
counters.getOutInterest());
|
||||
|
||||
statusLength += prependNonNegativeIntegerBlock(outBuffer,
|
||||
ndn::tlv::nfd::NInDatas,
|
||||
counters.getInData());
|
||||
|
||||
statusLength += prependNonNegativeIntegerBlock(outBuffer,
|
||||
ndn::tlv::nfd::NInInterests,
|
||||
counters.getInInterest());
|
||||
|
||||
statusLength += prependByteArrayBlock(outBuffer,
|
||||
ndn::tlv::nfd::Uri,
|
||||
reinterpret_cast<const uint8_t*>(uri.c_str()),
|
||||
uri.size());
|
||||
|
||||
statusLength += prependNonNegativeIntegerBlock(outBuffer,
|
||||
ndn::tlv::nfd::FaceId,
|
||||
face->getId());
|
||||
|
||||
statusLength += outBuffer.prependVarNumber(statusLength);
|
||||
statusLength += outBuffer.prependVarNumber(ndn::tlv::nfd::FaceStatus);
|
||||
|
||||
totalLength += statusLength;
|
||||
}
|
||||
totalLength += status.wireEncode(outBuffer);
|
||||
}
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ StatusServer::collectStatus() const
|
||||
status->setNCsEntries(m_forwarder.getCs().size());
|
||||
|
||||
const ForwarderCounters& counters = m_forwarder.getCounters();
|
||||
status->setNInInterests(counters.getInInterest());
|
||||
status->setNInDatas(counters.getInData());
|
||||
status->setNOutInterests(counters.getOutInterest());
|
||||
status->setNOutDatas(counters.getOutData());
|
||||
status->setNInInterests(counters.getNInInterests());
|
||||
status->setNInDatas(counters.getNInDatas());
|
||||
status->setNOutInterests(counters.getNOutInterests());
|
||||
status->setNOutDatas(counters.getNOutDatas());
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
+7
-7
@@ -25,15 +25,15 @@ BOOST_AUTO_TEST_CASE(Description)
|
||||
BOOST_AUTO_TEST_CASE(LocalControlHeaderEnabled)
|
||||
{
|
||||
DummyLocalFace face;
|
||||
|
||||
|
||||
BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(), false);
|
||||
|
||||
|
||||
face.setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID, true);
|
||||
BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(), true);
|
||||
BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID), true);
|
||||
BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(
|
||||
LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID), false);
|
||||
|
||||
|
||||
face.setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID, false);
|
||||
BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(), false);
|
||||
BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(
|
||||
@@ -44,10 +44,10 @@ BOOST_AUTO_TEST_CASE(Counters)
|
||||
{
|
||||
DummyFace face;
|
||||
const FaceCounters& counters = face.getCounters();
|
||||
BOOST_CHECK_EQUAL(counters.getInInterest() , 0);
|
||||
BOOST_CHECK_EQUAL(counters.getInData() , 0);
|
||||
BOOST_CHECK_EQUAL(counters.getOutInterest(), 0);
|
||||
BOOST_CHECK_EQUAL(counters.getOutData() , 0);
|
||||
BOOST_CHECK_EQUAL(counters.getNInInterests() , 0);
|
||||
BOOST_CHECK_EQUAL(counters.getNInDatas() , 0);
|
||||
BOOST_CHECK_EQUAL(counters.getNOutInterests(), 0);
|
||||
BOOST_CHECK_EQUAL(counters.getNOutDatas() , 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
+8
-8
@@ -239,16 +239,16 @@ BOOST_FIXTURE_TEST_CASE(EndToEnd4, EndToEndFixture)
|
||||
BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
|
||||
|
||||
const FaceCounters& counters1 = face1->getCounters();
|
||||
BOOST_CHECK_EQUAL(counters1.getInInterest() , 1);
|
||||
BOOST_CHECK_EQUAL(counters1.getInData() , 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getOutData() , 1);
|
||||
BOOST_CHECK_EQUAL(counters1.getNInInterests() , 1);
|
||||
BOOST_CHECK_EQUAL(counters1.getNInDatas() , 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getNOutDatas() , 1);
|
||||
|
||||
const FaceCounters& counters2 = face2->getCounters();
|
||||
BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getInData() , 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getOutInterest(), 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getOutData() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getNInInterests() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getNInDatas() , 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getNOutInterests(), 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getNOutDatas() , 3);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(EndToEnd6, EndToEndFixture)
|
||||
|
||||
+8
-8
@@ -412,16 +412,16 @@ BOOST_FIXTURE_TEST_CASE(EndToEnd4, EndToEndFixture)
|
||||
BOOST_CHECK_EQUAL(face1_receivedDatas [3].getName(), data3.getName());
|
||||
|
||||
const FaceCounters& counters1 = face1->getCounters();
|
||||
BOOST_CHECK_EQUAL(counters1.getInInterest() , 2);
|
||||
BOOST_CHECK_EQUAL(counters1.getInData() , 4);
|
||||
BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getOutData() , 1);
|
||||
BOOST_CHECK_EQUAL(counters1.getNInInterests() , 2);
|
||||
BOOST_CHECK_EQUAL(counters1.getNInDatas() , 4);
|
||||
BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getNOutDatas() , 1);
|
||||
|
||||
const FaceCounters& counters2 = face2->getCounters();
|
||||
BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getInData() , 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getOutInterest(), 2);
|
||||
BOOST_CHECK_EQUAL(counters2.getOutData() , 4);
|
||||
BOOST_CHECK_EQUAL(counters2.getNInInterests() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getNInDatas() , 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getNOutInterests(), 2);
|
||||
BOOST_CHECK_EQUAL(counters2.getNOutDatas() , 4);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(EndToEnd6, EndToEndFixture)
|
||||
|
||||
@@ -197,16 +197,16 @@ BOOST_FIXTURE_TEST_CASE(EndToEnd, EndToEndFixture)
|
||||
BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
|
||||
|
||||
const FaceCounters& counters1 = face1->getCounters();
|
||||
BOOST_CHECK_EQUAL(counters1.getInInterest() , 1);
|
||||
BOOST_CHECK_EQUAL(counters1.getInData() , 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getOutData() , 1);
|
||||
BOOST_CHECK_EQUAL(counters1.getNInInterests() , 1);
|
||||
BOOST_CHECK_EQUAL(counters1.getNInDatas() , 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getNOutInterests(), 3);
|
||||
BOOST_CHECK_EQUAL(counters1.getNOutDatas() , 1);
|
||||
|
||||
const FaceCounters& counters2 = face2->getCounters();
|
||||
BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getInData() , 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getOutInterest(), 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getOutData() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getNInInterests() , 3);
|
||||
BOOST_CHECK_EQUAL(counters2.getNInDatas() , 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getNOutInterests(), 1);
|
||||
BOOST_CHECK_EQUAL(counters2.getNOutDatas() , 3);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
|
||||
|
||||
+9
-11
@@ -35,32 +35,30 @@ BOOST_AUTO_TEST_CASE(SimpleExchange)
|
||||
forwarder.addFace(face2);
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
std::pair<shared_ptr<fib::Entry>, bool> fibInsertResult =
|
||||
fib.insert(Name("ndn:/A"));
|
||||
shared_ptr<fib::Entry> fibEntry = fibInsertResult.first;
|
||||
shared_ptr<fib::Entry> fibEntry = fib.insert(Name("ndn:/A")).first;
|
||||
fibEntry->addNextHop(face2, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getInInterest (), 0);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getOutInterest(), 0);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNInInterests (), 0);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutInterests(), 0);
|
||||
face1->receiveInterest(*interestAB);
|
||||
g_io.run();
|
||||
g_io.reset();
|
||||
BOOST_REQUIRE_EQUAL(face2->m_sentInterests.size(), 1);
|
||||
BOOST_CHECK(face2->m_sentInterests[0].getName().equals(nameAB));
|
||||
BOOST_CHECK_EQUAL(face2->m_sentInterests[0].getIncomingFaceId(), face1->getId());
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getInInterest (), 1);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getOutInterest(), 1);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNInInterests (), 1);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutInterests(), 1);
|
||||
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getInData (), 0);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getOutData(), 0);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNInDatas (), 0);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutDatas(), 0);
|
||||
face2->receiveData(*dataABC);
|
||||
g_io.run();
|
||||
g_io.reset();
|
||||
BOOST_REQUIRE_EQUAL(face1->m_sentDatas.size(), 1);
|
||||
BOOST_CHECK(face1->m_sentDatas[0].getName().equals(nameABC));
|
||||
BOOST_CHECK_EQUAL(face1->m_sentDatas[0].getIncomingFaceId(), face2->getId());
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getInData (), 1);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getOutData(), 1);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNInDatas (), 1);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutDatas(), 1);
|
||||
}
|
||||
|
||||
class ScopeLocalhostIncomingTestForwarder : public Forwarder
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/* -*- 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 "mgmt/face-flags.hpp"
|
||||
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/face/dummy-face.hpp"
|
||||
|
||||
namespace nfd {
|
||||
namespace tests {
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(MgmtFaceFlags, BaseFixture)
|
||||
|
||||
template<typename DummyFaceBase>
|
||||
class DummyOnDemandFace : public DummyFaceBase
|
||||
{
|
||||
public:
|
||||
DummyOnDemandFace()
|
||||
{
|
||||
this->setOnDemand(true);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Get)
|
||||
{
|
||||
DummyFace face1;
|
||||
BOOST_CHECK_EQUAL(getFaceFlags(face1), 0);
|
||||
|
||||
DummyLocalFace face2;
|
||||
BOOST_CHECK_EQUAL(getFaceFlags(face2), static_cast<uint64_t>(ndn::nfd::FACE_IS_LOCAL));
|
||||
|
||||
DummyOnDemandFace<DummyFace> face3;
|
||||
BOOST_CHECK_EQUAL(getFaceFlags(face3), static_cast<uint64_t>(ndn::nfd::FACE_IS_ON_DEMAND));
|
||||
|
||||
DummyOnDemandFace<DummyLocalFace> face4;
|
||||
BOOST_CHECK_EQUAL(getFaceFlags(face4), static_cast<uint64_t>(ndn::nfd::FACE_IS_LOCAL |
|
||||
ndn::nfd::FACE_IS_ON_DEMAND));
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace tests
|
||||
} // namespace nfd
|
||||
@@ -1323,9 +1323,10 @@ public:
|
||||
|
||||
ndn::nfd::FaceEventNotification notification(wire);
|
||||
|
||||
BOOST_CHECK_EQUAL(notification.getKind(), expectedFaceEvent.getKind());
|
||||
BOOST_CHECK_EQUAL(notification.getFaceId(), expectedFaceEvent.getFaceId());
|
||||
BOOST_CHECK_EQUAL(notification.getUri(), expectedFaceEvent.getUri());
|
||||
BOOST_CHECK_EQUAL(notification.getEventKind(), expectedFaceEvent.getEventKind());
|
||||
BOOST_CHECK_EQUAL(notification.getRemoteUri(), expectedFaceEvent.getRemoteUri());
|
||||
BOOST_CHECK_EQUAL(notification.getLocalUri(), expectedFaceEvent.getLocalUri());
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1428,10 +1429,12 @@ BOOST_FIXTURE_TEST_CASE(OnCreated, AuthorizedCommandFixture<FaceFixture>)
|
||||
|
||||
shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
|
||||
|
||||
ndn::nfd::FaceEventNotification expectedFaceEvent(ndn::nfd::FACE_EVENT_CREATED,
|
||||
1,
|
||||
dummy->getUri().toString(),
|
||||
0);
|
||||
ndn::nfd::FaceEventNotification expectedFaceEvent;
|
||||
expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_CREATED)
|
||||
.setFaceId(1)
|
||||
.setRemoteUri(dummy->getRemoteUri().toString())
|
||||
.setLocalUri(dummy->getLocalUri().toString())
|
||||
.setFlags(0);
|
||||
|
||||
Block encodedResultParameters(resultParameters.wireEncode());
|
||||
|
||||
@@ -1488,9 +1491,12 @@ BOOST_FIXTURE_TEST_CASE(DestroyFace, AuthorizedCommandFixture<FaceFixture>)
|
||||
shared_ptr<Interest> command(make_shared<Interest>(commandName));
|
||||
generateCommand(*command);
|
||||
|
||||
ndn::nfd::FaceEventNotification expectedFaceEvent(ndn::nfd::FACE_EVENT_DESTROYED,
|
||||
dummy->getId(),
|
||||
dummy->getUri().toString(), 0);
|
||||
ndn::nfd::FaceEventNotification expectedFaceEvent;
|
||||
expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
|
||||
.setFaceId(dummy->getId())
|
||||
.setRemoteUri(dummy->getRemoteUri().toString())
|
||||
.setLocalUri(dummy->getLocalUri().toString())
|
||||
.setFlags(0);
|
||||
|
||||
getFace()->onReceiveData +=
|
||||
bind(&FaceFixture::callbackDispatch, this, _1,
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
#include "mgmt/face-status-publisher.hpp"
|
||||
#include "mgmt/app-face.hpp"
|
||||
#include "mgmt/internal-face.hpp"
|
||||
#include "mgmt/face-flags.hpp"
|
||||
#include "fw/forwarder.hpp"
|
||||
#include "../face/dummy-face.hpp"
|
||||
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/face/dummy-face.hpp"
|
||||
|
||||
#include <ndn-cpp-dev/encoding/tlv.hpp>
|
||||
#include <ndn-cpp-dev/management/nfd-face-status.hpp>
|
||||
|
||||
namespace nfd {
|
||||
namespace tests {
|
||||
@@ -34,16 +35,16 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setCounters(FaceCounter inInterest,
|
||||
FaceCounter inData,
|
||||
FaceCounter outInterest,
|
||||
FaceCounter outData)
|
||||
setCounters(FaceCounter nInInterests,
|
||||
FaceCounter nInDatas,
|
||||
FaceCounter nOutInterests,
|
||||
FaceCounter nOutDatas)
|
||||
{
|
||||
FaceCounters& counters = getMutableCounters();
|
||||
counters.getInInterest() = inInterest;
|
||||
counters.getInData() = inData;
|
||||
counters.getOutInterest() = outInterest;
|
||||
counters.getOutData() = outData;
|
||||
counters.getNInInterests() = nInInterests;
|
||||
counters.getNInDatas() = nInDatas;
|
||||
counters.getNOutInterests() = nOutInterests;
|
||||
counters.getNOutDatas() = nOutDatas;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,66 +103,20 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
validateFaceStatus(const Block& status, const shared_ptr<Face>& reference)
|
||||
validateFaceStatus(const Block& statusBlock, const shared_ptr<Face>& reference)
|
||||
{
|
||||
ndn::nfd::FaceStatus status;
|
||||
BOOST_REQUIRE_NO_THROW(status.wireDecode(statusBlock));
|
||||
const FaceCounters& counters = reference->getCounters();
|
||||
|
||||
FaceId faceId = INVALID_FACEID;
|
||||
std::string uri;
|
||||
FaceCounter inInterest = 0;
|
||||
FaceCounter inData = 0;
|
||||
FaceCounter outInterest = 0;
|
||||
FaceCounter outData = 0;
|
||||
|
||||
status.parse();
|
||||
|
||||
for (Block::element_const_iterator i = status.elements_begin();
|
||||
i != status.elements_end();
|
||||
++i)
|
||||
{
|
||||
// parse a full set of FaceStatus sub-blocks
|
||||
faceId =
|
||||
checkedReadNonNegativeIntegerType(i,
|
||||
status.elements_end(),
|
||||
ndn::tlv::nfd::FaceId);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(faceId, reference->getId());
|
||||
|
||||
BOOST_REQUIRE(i->type() == ndn::tlv::nfd::Uri);
|
||||
|
||||
uri.append(reinterpret_cast<const char*>(i->value()), i->value_size());
|
||||
++i;
|
||||
|
||||
BOOST_REQUIRE(i != status.elements_end());
|
||||
|
||||
BOOST_REQUIRE_EQUAL(uri, reference->getUri().toString());
|
||||
|
||||
inInterest =
|
||||
checkedReadNonNegativeIntegerType(i,
|
||||
status.elements_end(),
|
||||
ndn::tlv::nfd::NInInterests);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(inInterest, counters.getInInterest());
|
||||
|
||||
inData =
|
||||
checkedReadNonNegativeIntegerType(i,
|
||||
status.elements_end(),
|
||||
ndn::tlv::nfd::NInDatas);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(inData, counters.getInData());
|
||||
|
||||
outInterest =
|
||||
checkedReadNonNegativeIntegerType(i,
|
||||
status.elements_end(),
|
||||
ndn::tlv::nfd::NOutInterests);
|
||||
BOOST_REQUIRE_EQUAL(outInterest, counters.getOutInterest());
|
||||
|
||||
outData =
|
||||
readNonNegativeIntegerType(*i,
|
||||
ndn::tlv::nfd::NOutDatas);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(outData, counters.getOutData());
|
||||
}
|
||||
BOOST_CHECK_EQUAL(status.getFaceId(), reference->getId());
|
||||
BOOST_CHECK_EQUAL(status.getRemoteUri(), reference->getRemoteUri().toString());
|
||||
BOOST_CHECK_EQUAL(status.getLocalUri(), reference->getLocalUri().toString());
|
||||
BOOST_CHECK_EQUAL(status.getFlags(), getFaceFlags(*reference));
|
||||
BOOST_CHECK_EQUAL(status.getNInInterests(), counters.getNInInterests());
|
||||
BOOST_CHECK_EQUAL(status.getNInDatas(), counters.getNInDatas());
|
||||
BOOST_CHECK_EQUAL(status.getNOutInterests(), counters.getNOutInterests());
|
||||
BOOST_CHECK_EQUAL(status.getNOutDatas(), counters.getNOutDatas());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
void
|
||||
processCreateFace(const FaceEventNotification& notification)
|
||||
{
|
||||
FaceUri uri(notification.getUri());
|
||||
FaceUri uri(notification.getRemoteUri());
|
||||
|
||||
if (isFiltered(uri))
|
||||
{
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
// process
|
||||
FaceEventNotification notification(data.getContent().blockFromValue());
|
||||
|
||||
if (notification.getEventKind() == FACE_EVENT_CREATED &&
|
||||
if (notification.getKind() == FACE_EVENT_CREATED &&
|
||||
!notification.isLocal() &&
|
||||
notification.isOnDemand())
|
||||
{
|
||||
|
||||
@@ -158,12 +158,13 @@ public:
|
||||
nfd::FaceStatus faceStatus(block);
|
||||
|
||||
std::cout << " faceid=" << faceStatus.getFaceId()
|
||||
<< " uri=" << faceStatus.getUri()
|
||||
<< " remote=" << faceStatus.getRemoteUri()
|
||||
<< " local=" << faceStatus.getLocalUri()
|
||||
<< " counters={"
|
||||
<< "in={" << faceStatus.getInInterest() << "i "
|
||||
<< faceStatus.getInData() << "d}"
|
||||
<< " out={" << faceStatus.getOutInterest() << "i "
|
||||
<< faceStatus.getOutData() << "d}"
|
||||
<< "in={" << faceStatus.getNInInterests() << "i "
|
||||
<< faceStatus.getNInDatas() << "d}"
|
||||
<< " out={" << faceStatus.getNOutInterests() << "i "
|
||||
<< faceStatus.getNOutDatas() << "d}"
|
||||
<< "}" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user