face: Fixing bug with InternalFace considered not local and changing "isLocal" method to be pure virtual

This way the decision about the face locality has to be done explicitly
inside specific face implementation and potentially avoids problems.

Change-Id: I5219cce87385313546453d14a5a7ca4542893911
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index cef9c1b..5ca8f29 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -53,12 +53,6 @@
 }
 
 bool
-Face::isLocal() const
-{
-  return false;
-}
-
-bool
 Face::isMultiAccess() const
 {
   return false;
diff --git a/daemon/face/face.hpp b/daemon/face/face.hpp
index d4e4578..924b4fa 100644
--- a/daemon/face/face.hpp
+++ b/daemon/face/face.hpp
@@ -84,6 +84,13 @@
   virtual void
   close() = 0;
 
+  /** \brief Get whether face is connected to a local app
+   *
+   *  In this base class this property is always false.
+   */
+  virtual bool
+  isLocal() const = 0;
+  
   /** \brief Get whether underlying communication is up
    *
    *  In this base class this property is always true.
@@ -102,13 +109,6 @@
   virtual const std::string&
   getDescription() const;
 
-  /** \brief Get whether face is connected to a local app
-   *
-   *  In this base class this property is always false.
-   */
-  virtual bool
-  isLocal() const;
-
   /** \brief Get whether packets sent this Face may reach multiple peers
    *
    *  In this base class this property is always false.
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index 9573813..ac08421 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -34,7 +34,7 @@
 
   virtual void
   close();
-  
+
 protected:
   void
   handleSend(const boost::system::error_code& error,
diff --git a/daemon/face/tcp-face.cpp b/daemon/face/tcp-face.cpp
index 774a4d0..874de98 100644
--- a/daemon/face/tcp-face.cpp
+++ b/daemon/face/tcp-face.cpp
@@ -18,4 +18,11 @@
 {
 }
 
+bool
+TcpFace::isLocal() const
+{
+  return false;
+}
+
+
 } // namespace nfd
diff --git a/daemon/face/tcp-face.hpp b/daemon/face/tcp-face.hpp
index 98593a0..c41f601 100644
--- a/daemon/face/tcp-face.hpp
+++ b/daemon/face/tcp-face.hpp
@@ -23,6 +23,9 @@
 
   explicit
   TcpFace(const shared_ptr<protocol::socket>& socket);
+
+  virtual bool
+  isLocal() const;
 };
 
 } // namespace nfd
diff --git a/daemon/mgmt/internal-face.cpp b/daemon/mgmt/internal-face.cpp
index 32c03a1..1f1a6cb 100644
--- a/daemon/mgmt/internal-face.cpp
+++ b/daemon/mgmt/internal-face.cpp
@@ -98,6 +98,11 @@
   throw Error("Internal face cannot be closed");
 }
 
+bool
+InternalFace::isLocal() const
+{
+  return true;
+}
 
 void
 InternalFace::setInterestFilter(const Name& filter,
diff --git a/daemon/mgmt/internal-face.hpp b/daemon/mgmt/internal-face.hpp
index 8d5805c..0e17b3b 100644
--- a/daemon/mgmt/internal-face.hpp
+++ b/daemon/mgmt/internal-face.hpp
@@ -36,6 +36,13 @@
   virtual void
   close();
 
+  /** \brief Get whether face is connected to a local app
+   *
+   *  Always true for a InternalFace.
+   */
+  virtual bool
+  isLocal() const;
+
   // Methods implementing AppFace interface. Do not invoke from forwarder.
 
   virtual void
diff --git a/tests/face/dummy-face.hpp b/tests/face/dummy-face.hpp
index e78f4cc..7de128d 100644
--- a/tests/face/dummy-face.hpp
+++ b/tests/face/dummy-face.hpp
@@ -18,7 +18,9 @@
 class DummyFace : public Face
 {
 public:
-  DummyFace()
+  explicit
+  DummyFace(bool isLocal = false)
+    : m_isLocal(isLocal)
   {
   }
   
@@ -36,6 +38,15 @@
   close()
   {
   }
+
+  virtual bool
+  isLocal() const
+  {
+    return m_isLocal;
+  }
+
+private:
+  bool m_isLocal;
 };
 
 } // namespace nfd
diff --git a/tests/fw/forwarder.cpp b/tests/fw/forwarder.cpp
index 433c36b..ed8f6a7 100644
--- a/tests/fw/forwarder.cpp
+++ b/tests/fw/forwarder.cpp
@@ -38,6 +38,12 @@
   {
   }
 
+  virtual bool
+  isLocal() const
+  {
+    return false;
+  }
+
   void
   receiveInterest(const Interest& interest)
   {