management: nfdc support and link error fix

Static INVALID_FACE_ID constant was causing link error (multiple
definitions). Now it is defined just as a constant and moved to
the general-purpose NFD-related ``encoding/tlv-nfd.hpp`` header.

Change-Id: I04295fa07f809aae9a24a531e31facf09c78729f
refs: #1198
diff --git a/src/management/nfd-controller.cpp b/src/management/nfd-controller.cpp
index 00a5378..c6fa7e7 100644
--- a/src/management/nfd-controller.cpp
+++ b/src/management/nfd-controller.cpp
@@ -9,6 +9,7 @@
 
 #include "nfd-controller.hpp"
 #include "nfd-fib-management-options.hpp"
+#include "nfd-face-management-options.hpp"
 #include "nfd-control-response.hpp"
 
 namespace ndn {
@@ -45,7 +46,7 @@
         onFail("Face ID is not set, should have been set after a successful prefix registration command");
       return;
     }
-  
+
   startFibCommand("remove-nexthop",
                   FibManagementOptions()
                   .setName(prefixToRegister)
@@ -65,7 +66,7 @@
     .append(options.wireEncode());
 
   Interest fibCommandInterest(fibCommandInterestName);
-  m_keyChain.sign(fibCommandInterest);
+  // m_keyChain.sign(fibCommandInterest);
 
   m_face.expressInterest(fibCommandInterest,
                          bind(&Controller::processFibCommandResponse, this, _2,
@@ -81,11 +82,6 @@
   onSuccess();
 }
 
-// void
-// processFaceActionResponse(Data& data,
-//                           const FaceOperationSucceedCallback& onSuccess,
-//                           const FailCallback&    onFail);
-
 void
 Controller::processFibCommandResponse(Data& data,
                                       const FibCommandSucceedCallback& onSuccess,
@@ -94,7 +90,6 @@
   try
     {
       ControlResponse response(data.getContent().blockFromValue());
-
       if (response.getCode() != 200)
         return onFail(response.getText());
 
@@ -108,5 +103,45 @@
     }
 }
 
+void
+Controller::startFaceCommand(const std::string& command,
+                             const FaceManagementOptions& options,
+                             const FaceCommandSucceedCallback& onSuccess,
+                             const FailCallback& onFail)
+{
+  Name faceCommandInterestName("/localhost/nfd/faces");
+  faceCommandInterestName
+    .append(command)
+    .append(options.wireEncode());
+
+  Interest faceCommandInterest(faceCommandInterestName);
+  // m_keyChain.sign(fibCommandInterest);
+
+  m_face.expressInterest(faceCommandInterest,
+                         bind(&Controller::processFaceCommandResponse, this, _2,
+                              onSuccess, onFail),
+                         bind(onFail, "Command Interest timed out"));
+}
+
+void
+Controller::processFaceCommandResponse(Data& data,
+                                       const FaceCommandSucceedCallback& onSuccess,
+                                       const FailCallback& onFail)
+{
+  try
+    {
+      ControlResponse response(data.getContent().blockFromValue());
+      if (response.getCode() != 200)
+        return onFail(response.getText());
+
+      FaceManagementOptions options(response.getBody());
+      return onSuccess(options);
+    }
+  catch(ndn::Tlv::Error& e)
+    {
+      if (static_cast<bool>(onFail))
+        return onFail(e.what());
+    }
+}
 } // namespace nfd
 } // namespace ndn