face: Implementation of encode/decode of LocalControlHeader

LocalControlHeader can only be used on faces that are derived from
LocalFace.  UnixStreamFace is directly inherited from LocalFace,
TCP face has two specializations: generic TcpFace (strictly not local),
and LocalTcpFace.

refs #1213

Change-Id: I8a158c3bc4bb929eedd15757cfddecc0d1049f9f
diff --git a/daemon/mgmt/internal-face.cpp b/daemon/mgmt/internal-face.cpp
index 1f1a6cb..707ee30 100644
--- a/daemon/mgmt/internal-face.cpp
+++ b/daemon/mgmt/internal-face.cpp
@@ -12,7 +12,7 @@
 
 InternalFace::InternalFace()
 {
-
+  setLocal(true);
 }
 
 void
@@ -98,12 +98,6 @@
   throw Error("Internal face cannot be closed");
 }
 
-bool
-InternalFace::isLocal() const
-{
-  return true;
-}
-
 void
 InternalFace::setInterestFilter(const Name& filter,
                                 OnInterest onInterest)
diff --git a/daemon/mgmt/internal-face.hpp b/daemon/mgmt/internal-face.hpp
index 0e17b3b..8d5805c 100644
--- a/daemon/mgmt/internal-face.hpp
+++ b/daemon/mgmt/internal-face.hpp
@@ -36,13 +36,6 @@
   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/daemon/mgmt/local-control-header-manager.cpp b/daemon/mgmt/local-control-header-manager.cpp
index 6a0f056..5717f54 100644
--- a/daemon/mgmt/local-control-header-manager.cpp
+++ b/daemon/mgmt/local-control-header-manager.cpp
@@ -5,6 +5,7 @@
  */
 
 #include "local-control-header-manager.hpp"
+#include "face/local-face.hpp"
 
 namespace nfd {
 
@@ -58,7 +59,15 @@
       return;
     }
 
-  shared_ptr<Face> face = m_getFace(request.getIncomingFaceId());
+  shared_ptr<LocalFace> face =
+    dynamic_pointer_cast<LocalFace>(m_getFace(request.getIncomingFaceId()));
+
+  if (!static_cast<bool>(face))
+    {
+      NFD_LOG_INFO("command result: request to enable control header on non-local face");
+      sendResponse(command, 400, "Command not supported on the requested face");
+      return;
+    }
 
   const Name::Component& module = command.get(COMMAND_PREFIX.size());
   const Name::Component& verb = command.get(COMMAND_PREFIX.size() + 1);
diff --git a/daemon/mgmt/local-control-header-manager.hpp b/daemon/mgmt/local-control-header-manager.hpp
index ab3c08a..8c03e4e 100644
--- a/daemon/mgmt/local-control-header-manager.hpp
+++ b/daemon/mgmt/local-control-header-manager.hpp
@@ -23,7 +23,6 @@
   void
   onLocalControlHeaderRequest(const Interest& request);
 
-
 private:
   function<shared_ptr<Face>(FaceId)> m_getFace;