adapt to Controller::CommandFailCallback with ControlResponse

refs #3739

Change-Id: I193fb11fd96bd91808fc6e3af22a8da2511246e2
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index fc03bc3..4f55af9 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -20,6 +20,7 @@
  * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
  *
  **/
+
 #include "nlsr.hpp"
 #include "lsdb.hpp"
 #include "hello-protocol.hpp"
@@ -211,7 +212,7 @@
                                  ndn::bind(&HelloProtocol::onRegistrationSuccess,
                                            this, _1, adjName,timeout),
                                  ndn::bind(&HelloProtocol::onRegistrationFailure,
-                                           this, _1, _2, adjName));
+                                           this, _1, adjName));
 }
 
 void
@@ -247,10 +248,10 @@
 }
 
 void
-HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error,
+HelloProtocol::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
                                      const ndn::Name& name)
 {
-  _LOG_DEBUG(error << " (code: " << code << ")");
+  _LOG_DEBUG(response.getText() << " (code: " << response.getCode() << ")");
   /*
   * If NLSR can not create face for given faceUri then it will treat this
   * failure as one INFO interest timed out. So that NLSR can move on with
diff --git a/src/hello-protocol.hpp b/src/hello-protocol.hpp
index e22d0e7..b145f6b 100644
--- a/src/hello-protocol.hpp
+++ b/src/hello-protocol.hpp
@@ -26,6 +26,7 @@
 
 #include <ndn-cxx/face.hpp>
 #include <ndn-cxx/management/nfd-control-parameters.hpp>
+#include <ndn-cxx/management/nfd-control-response.hpp>
 #include <ndn-cxx/util/scheduler.hpp>
 
 namespace nlsr {
@@ -70,7 +71,7 @@
                             const std::string& msg);
 
   void
-  onRegistrationFailure(uint32_t code, const std::string& error,
+  onRegistrationFailure(const ndn::nfd::ControlResponse& response,
                         const ndn::Name& name);
 
   void
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 7bc77e2..d5c0038 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -324,9 +324,9 @@
 }
 
 void
-Nlsr::onDestroyFaceFailure(int32_t code, const std::string& error)
+Nlsr::onDestroyFaceFailure(const ndn::nfd::ControlResponse& response)
 {
-  std::cerr << error << " (code: " << code << ")";
+  std::cerr << response.getText() << " (code: " << response.getCode() << ")";
   throw Error("Error: Face destruction failed");
 }
 
@@ -338,7 +338,7 @@
        it != adjacents.end(); it++) {
     m_fib.destroyFace((*it).getConnectingFaceUri(),
                       std::bind(&Nlsr::onDestroyFaceSuccess, this, _1),
-                      std::bind(&Nlsr::onDestroyFaceFailure, this, _1, _2));
+                      std::bind(&Nlsr::onDestroyFaceFailure, this, _1));
   }
 }
 
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index 0da1573..c88f199 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -340,7 +340,7 @@
   onDestroyFaceSuccess(const ndn::nfd::ControlParameters& commandSuccessResult);
 
   void
-  onDestroyFaceFailure(int32_t code, const std::string& error);
+  onDestroyFaceFailure(const ndn::nfd::ControlResponse& response);
 
   void
   onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification);
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index e5a4c43..f61f6f4 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -385,7 +385,7 @@
                                                              "Successful in name registration",
                                                              faceUri),
                                                    ndn::bind(&Fib::onRegistrationFailure,
-                                                             this, _1, _2,
+                                                             this, _1,
                                                              "Failed in name registration",
                                                              parameters,
                                                              faceUri, times));
@@ -426,7 +426,7 @@
                                                      ndn::bind(&Fib::onUnregistration, this, _1,
                                                                "Successful in unregistering name"),
                                                      ndn::bind(&Fib::onUnregistrationFailure,
-                                                               this, _1, _2,
+                                                               this, _1,
                                                                "Failed in unregistering name"));
   }
 }
@@ -442,7 +442,7 @@
   m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
                                                          bind(&Fib::onSetStrategySuccess, this, _1,
                                                               "Successfully set strategy choice"),
-                                                         bind(&Fib::onSetStrategyFailure, this, _1, _2,
+                                                         bind(&Fib::onSetStrategyFailure, this, _1,
                                                               parameters,
                                                               count,
                                                               "Failed to set strategy choice"));
@@ -467,13 +467,13 @@
 }
 
 void
-Fib::onRegistrationFailure(uint32_t code, const std::string& error,
+Fib::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
                            const std::string& message,
                            const ndn::nfd::ControlParameters& parameters,
                            const std::string& faceUri,
                            uint8_t times)
 {
-  _LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
+  _LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
   _LOG_DEBUG("Prefix: " << parameters.getName() << " failed for: " << times);
   if (times < 3) {
     _LOG_DEBUG("Trying to register again...");
@@ -488,10 +488,10 @@
 }
 
 void
-Fib::onUnregistrationFailure(uint32_t code, const std::string& error,
-                            const std::string& message)
+Fib::onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
+                             const std::string& message)
 {
-  _LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
+  _LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
 }
 
 void
@@ -503,10 +503,10 @@
 }
 
 void
-Fib::onSetStrategyFailure(uint32_t code, const std::string& error,
-                         const ndn::nfd::ControlParameters& parameters,
-                         uint32_t count,
-                         const std::string& message)
+Fib::onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
+                          const ndn::nfd::ControlParameters& parameters,
+                          uint32_t count,
+                          const std::string& message)
 {
   _LOG_DEBUG(message << ": " << parameters.getStrategy() << " "
             << "for name: " << parameters.getName());
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 050e0fb..2e61096 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -35,8 +35,8 @@
 
 namespace nlsr {
 
-typedef ndn::function<void(const ndn::nfd::ControlParameters&)> CommandSucceedCallback;
-typedef ndn::function<void(uint32_t/*code*/,const std::string&/*reason*/)> CommandFailCallback;
+typedef ndn::nfd::Controller::CommandSucceedCallback CommandSucceedCallback;
+typedef ndn::nfd::Controller::CommandFailCallback CommandFailCallback;
 
 class AdjacencyList;
 class ConfParameter;
@@ -163,22 +163,22 @@
                    const std::string& message);
 
   void
-  onRegistrationFailure(uint32_t code, const std::string& error,
+  onRegistrationFailure(const ndn::nfd::ControlResponse& response,
                         const std::string& message,
                         const ndn::nfd::ControlParameters& parameters,
                         const std::string& faceUri,
                         uint8_t times);
 
   void
-  onUnregistrationFailure(uint32_t code, const std::string& error,
-                        const std::string& message);
+  onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
+                          const std::string& message);
 
   void
   onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
                        const std::string& message);
 
   void
-  onSetStrategyFailure(uint32_t code, const std::string& error,
+  onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
                        const ndn::nfd::ControlParameters& parameters,
                        uint32_t count,
                        const std::string& message);
diff --git a/src/utility/face-controller.cpp b/src/utility/face-controller.cpp
index 954a074..7b0da61 100644
--- a/src/utility/face-controller.cpp
+++ b/src/utility/face-controller.cpp
@@ -76,7 +76,8 @@
                                   const FaceUri& request)
 {
   _LOG_WARN("Could not convert " << request << " to canonical form: " << reason);
-  onFailure(CANONIZE_ERROR_CODE, "Could not canonize face-uri: " + request.toString());
+  onFailure(ndn::nfd::ControlResponse(CANONIZE_ERROR_CODE,
+                                      "Could not canonize face-uri: " + request.toString()));
 }
 
 } // namespace util
diff --git a/src/utility/face-controller.hpp b/src/utility/face-controller.hpp
index 3c6edb6..09e6163 100644
--- a/src/utility/face-controller.hpp
+++ b/src/utility/face-controller.hpp
@@ -31,8 +31,8 @@
 class FaceController : boost::noncopyable
 {
 public:
-  typedef ndn::function<void(const ndn::nfd::ControlParameters&)> CommandSuccessCallback;
-  typedef ndn::function<void(uint32_t,const std::string&)> CommandFailureCallback;
+  typedef ndn::nfd::Controller::CommandSucceedCallback CommandSuccessCallback;
+  typedef ndn::nfd::Controller::CommandFailCallback CommandFailureCallback;
 
   FaceController(boost::asio::io_service& io, ndn::nfd::Controller& controller)
     : m_ioService(io)