face/mgmt/fw/tools: add localUri to FaceStatus and FaceEventNotification

refs #1396

Change-Id: I6084745c62c44a409ecbd4a795cb712475e32416
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