face/mgmt/fw/tools: add localUri to FaceStatus and FaceEventNotification
refs #1396
Change-Id: I6084745c62c44a409ecbd4a795cb712475e32416
diff --git a/daemon/face/face-counter.hpp b/daemon/face/face-counter.hpp
index ba3b98e..683e6e5 100644
--- a/daemon/face/face-counter.hpp
+++ b/daemon/face/face-counter.hpp
@@ -28,94 +28,94 @@
/// 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;
}
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index c0241fc..517b230 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -24,10 +24,10 @@
, 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()
diff --git a/daemon/face/face.hpp b/daemon/face/face.hpp
index 3cb7160..2f555a6 100644
--- a/daemon/face/face.hpp
+++ b/daemon/face/face.hpp
@@ -120,11 +120,6 @@
const FaceCounters&
getCounters() const;
- /** \deprecated use getRemoteUri instead
- */
- const FaceUri&
- getUri() const;
-
/** \return a FaceUri that represents the remote endpoint
*/
const FaceUri&
@@ -183,12 +178,6 @@
}
inline const FaceUri&
-Face::getUri() const
-{
- return this->getRemoteUri();
-}
-
-inline const FaceUri&
Face::getRemoteUri() const
{
return m_remoteUri;
diff --git a/daemon/face/multicast-udp-face.cpp b/daemon/face/multicast-udp-face.cpp
index 7866603..d96c183 100644
--- a/daemon/face/multicast-udp-face.cpp
+++ b/daemon/face/multicast-udp-face.cpp
@@ -10,8 +10,8 @@
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)
diff --git a/daemon/fw/face-table.cpp b/daemon/fw/face-table.cpp
index f59ff14..7b096fa 100644
--- a/daemon/fw/face-table.cpp
+++ b/daemon/fw/face-table.cpp
@@ -36,7 +36,8 @@
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 @@
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
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 8ffda2f..8ce48f7 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -39,7 +39,7 @@
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 @@
// send Interest
outFace.sendInterest(interest);
- m_counters.getOutInterest() ++;
+ m_counters.getNOutInterests() ++;
}
void
@@ -186,7 +186,7 @@
// 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 @@
// send Data
outFace.sendData(data);
- m_counters.getOutData() ++;
+ m_counters.getNOutDatas() ++;
}
static inline bool
diff --git a/daemon/mgmt/face-flags.hpp b/daemon/mgmt/face-flags.hpp
new file mode 100644
index 0000000..f9c50e1
--- /dev/null
+++ b/daemon/mgmt/face-flags.hpp
@@ -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
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index e184c00..183af17 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -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 @@
{
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 @@
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);
}
diff --git a/daemon/mgmt/face-status-publisher.cpp b/daemon/mgmt/face-status-publisher.cpp
index 3589d7b..06b205f 100644
--- a/daemon/mgmt/face-status-publisher.cpp
+++ b/daemon/mgmt/face-status-publisher.cpp
@@ -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 @@
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;
}
diff --git a/daemon/mgmt/status-server.cpp b/daemon/mgmt/status-server.cpp
index 5c4bd1a..6176659 100644
--- a/daemon/mgmt/status-server.cpp
+++ b/daemon/mgmt/status-server.cpp
@@ -54,10 +54,10 @@
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;
}
diff --git a/tests/face/face.cpp b/tests/face/face.cpp
index 1ad6f52..6187035 100644
--- a/tests/face/face.cpp
+++ b/tests/face/face.cpp
@@ -25,15 +25,15 @@
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 @@
{
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()
diff --git a/tests/face/tcp.cpp b/tests/face/tcp.cpp
index b98107e..6bbe4ba 100644
--- a/tests/face/tcp.cpp
+++ b/tests/face/tcp.cpp
@@ -239,16 +239,16 @@
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)
diff --git a/tests/face/udp.cpp b/tests/face/udp.cpp
index 157602d..d4bd8bb 100644
--- a/tests/face/udp.cpp
+++ b/tests/face/udp.cpp
@@ -412,16 +412,16 @@
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)
diff --git a/tests/face/unix-stream.cpp b/tests/face/unix-stream.cpp
index 2c7c177..4d7d984 100644
--- a/tests/face/unix-stream.cpp
+++ b/tests/face/unix-stream.cpp
@@ -197,16 +197,16 @@
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)
diff --git a/tests/fw/forwarder.cpp b/tests/fw/forwarder.cpp
index c96e57a..53cb145 100644
--- a/tests/fw/forwarder.cpp
+++ b/tests/fw/forwarder.cpp
@@ -35,32 +35,30 @@
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
diff --git a/tests/mgmt/face-flags.cpp b/tests/mgmt/face-flags.cpp
new file mode 100644
index 0000000..00e4c8b
--- /dev/null
+++ b/tests/mgmt/face-flags.cpp
@@ -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
diff --git a/tests/mgmt/face-manager.cpp b/tests/mgmt/face-manager.cpp
index 1c3734d..4d6830c 100644
--- a/tests/mgmt/face-manager.cpp
+++ b/tests/mgmt/face-manager.cpp
@@ -1323,9 +1323,10 @@
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 @@
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 @@
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,
diff --git a/tests/mgmt/face-status-publisher-common.hpp b/tests/mgmt/face-status-publisher-common.hpp
index 59e99f8..2e7ec55 100644
--- a/tests/mgmt/face-status-publisher-common.hpp
+++ b/tests/mgmt/face-status-publisher-common.hpp
@@ -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 @@
}
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 @@
}
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
diff --git a/tools/nfd-autoreg.cpp b/tools/nfd-autoreg.cpp
index ca7d1e6..79859a1 100644
--- a/tools/nfd-autoreg.cpp
+++ b/tools/nfd-autoreg.cpp
@@ -79,7 +79,7 @@
void
processCreateFace(const FaceEventNotification& notification)
{
- FaceUri uri(notification.getUri());
+ FaceUri uri(notification.getRemoteUri());
if (isFiltered(uri))
{
@@ -111,7 +111,7 @@
// process
FaceEventNotification notification(data.getContent().blockFromValue());
- if (notification.getEventKind() == FACE_EVENT_CREATED &&
+ if (notification.getKind() == FACE_EVENT_CREATED &&
!notification.isLocal() &&
notification.isOnDemand())
{
diff --git a/tools/nfd-status.cpp b/tools/nfd-status.cpp
index f1e5afd..efe1283 100644
--- a/tools/nfd-status.cpp
+++ b/tools/nfd-status.cpp
@@ -158,12 +158,13 @@
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;
}