mgmt: echo FibManagementOptions as response body on command success

Add support for commands with FaceId == zero

refs: #1236

Change-Id: If67e955668d5a3622893582111601d358df9137e
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index 01e2cc8..0b20c02 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -80,6 +80,8 @@
   const Name& command = request.getName();
   const size_t commandNComps = command.size();
 
+
+
   if (FIB_MANAGER_COMMAND_UNSIGNED_NCOMPS <= commandNComps &&
       commandNComps < FIB_MANAGER_COMMAND_SIGNED_NCOMPS)
     {
@@ -117,7 +119,6 @@
         }
 
       NFD_LOG_INFO("command result: processing verb: " << verb);
-
       ControlResponse response;
       (verbProcessor->second)(this, options, response);
 
@@ -149,6 +150,12 @@
       NFD_LOG_INFO("Bad command option parse: " << command);
       return false;
     }
+
+  if (extractedOptions.getFaceId() == 0)
+    {
+      extractedOptions.setFaceId(request.getIncomingFaceId());
+    }
+
   NFD_LOG_DEBUG("Options parsed OK");
   return true;
 }
@@ -161,7 +168,7 @@
   NFD_LOG_INFO("insert result: OK"
                << " prefix: " << options.getName());
   std::pair<shared_ptr<fib::Entry>, bool> insertResult = m_managedFib.insert(options.getName());
-  setResponse(response, 200, "OK");
+  setResponse(response, 200, "Success", options.wireEncode());
 }
 
 void
@@ -173,7 +180,7 @@
                << " prefix: " << options.getName());
 
   m_managedFib.remove(options.getName());
-  setResponse(response, 200, "OK");
+  setResponse(response, 200, "Success", options.wireEncode());
 }
 
 static inline bool
@@ -202,7 +209,7 @@
                        << " prefix:" << options.getName()
                        << " faceid: " << options.getFaceId()
                        << " cost: " << options.getCost());
-          setResponse(response, 200, "OK");
+          setResponse(response, 200, "Success", options.wireEncode());
         }
       else
         {
@@ -234,7 +241,7 @@
           NFD_LOG_INFO("remove-nexthop result: OK prefix: " << options.getName()
                        << " faceid: " << options.getFaceId());
 
-          setResponse(response, 200, "OK");
+          setResponse(response, 200, "Success", options.wireEncode());
         }
       else
         {
diff --git a/daemon/mgmt/manager-base.hpp b/daemon/mgmt/manager-base.hpp
index e8d63cf..8fb8cd3 100644
--- a/daemon/mgmt/manager-base.hpp
+++ b/daemon/mgmt/manager-base.hpp
@@ -30,6 +30,11 @@
   setResponse(ControlResponse& response,
               uint32_t code,
               const std::string& text);
+  void
+  setResponse(ControlResponse& response,
+              uint32_t code,
+              const std::string& text,
+              const Block& body);
 
   void
   sendResponse(const Name& name,
@@ -53,6 +58,16 @@
   response.setText(text);
 }
 
+inline void
+ManagerBase::setResponse(ControlResponse& response,
+                         uint32_t code,
+                         const std::string& text,
+                         const Block& body)
+{
+  setResponse(response, code, text);
+  response.setBody(body);
+}
+
 
 } // namespace nfd