route: Fixing unregistration of fib entries

FaceMap was constructed from the face result of face registration.
But result gives a diffrent uri (instead of maia.cs.memphis.edu
it gives 141.225.11.107:6363). When unregistering it was not
working as NLSR tries to compare face uri of naming format. Fixed
that issue. Now unregistration of name prefixes works fine.

Change-Id: Iafb3790113f735b1bb0ea68360bf70d09ec54243
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 3cf0b3c..ade99d5 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -295,7 +295,8 @@
                     uint64_t faceCost, const ndn::time::milliseconds& timeout)
 {
   createFace(faceUri,
-             ndn::bind(&Fib::registerPrefixInNfd, this,_1, namePrefix, faceCost, timeout),
+             ndn::bind(&Fib::registerPrefixInNfd, this,_1, namePrefix, faceCost, timeout,
+                       faceUri),
              ndn::bind(&Fib::onFailure, this, _1, _2,"Failed in name registration"));
 }
 
@@ -317,7 +318,8 @@
 void
 Fib::registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult, 
                          const ndn::Name& namePrefix, uint64_t faceCost,
-                         const ndn::time::milliseconds& timeout)
+                         const ndn::time::milliseconds& timeout,
+                         const std::string& faceUri)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
@@ -329,7 +331,7 @@
   m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
                                                    ndn::bind(&Fib::onRegistration, this, _1,
                                                              "Successful in name registration",
-                                                             faceCreateResult.getUri()),
+                                                             faceUri),
                                                    ndn::bind(&Fib::onFailure, this, _1, _2,
                                                              "Failed in name registration"));
 }
@@ -357,6 +359,7 @@
 Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
 {
   uint32_t faceId = m_faceMap.getFaceId(faceUri);
+  _LOG_DEBUG("Unregister prefix: " << namePrefix << " Face Uri: " << faceUri);
   if (faceId > 0) {
     ndn::nfd::ControlParameters controlParameters;
     controlParameters
@@ -364,7 +367,7 @@
       .setFaceId(faceId)
       .setOrigin(128);
     m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
-                                                     ndn::bind(&Fib::onSuccess, this, _1,
+                                                     ndn::bind(&Fib::onUnregistration, this, _1,
                                                                "Successful in unregistering name"),
                                                      ndn::bind(&Fib::onFailure, this, _1, _2,
                                                                "Failed in unregistering name"));
@@ -392,15 +395,19 @@
 Fib::onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
                     const std::string& message, const std::string& faceUri)
 {
+  _LOG_DEBUG("Register successful Prefix: " << commandSuccessResult.getName() <<
+             " Face Uri: " << faceUri);
   m_faceMap.update(faceUri, commandSuccessResult.getFaceId());
   m_faceMap.writeLog();
 }
 
 
 void
-Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
-               const std::string& message)
+Fib::onUnregistration(const ndn::nfd::ControlParameters& commandSuccessResult,
+                      const std::string& message)
 {
+  _LOG_DEBUG("Unregister successful Prefix: " << commandSuccessResult.getName() <<
+             " Face Id: " << commandSuccessResult.getFaceId());
 }
 
 void
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 5121535..c593a5b 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -124,7 +124,8 @@
   void
   registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
                       const ndn::Name& namePrefix, uint64_t faceCost,
-                      const ndn::time::milliseconds& timeout);
+                      const ndn::time::milliseconds& timeout,
+                      const std::string& faceUri);
 
   void
   registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
@@ -146,8 +147,8 @@
                  const std::string& message, const std::string& faceUri);
 
   void
-  onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
-            const std::string& message);
+  onUnregistration(const ndn::nfd::ControlParameters& commandSuccessResult,
+                   const std::string& message);
 
   void
   onFailure(uint32_t code, const std::string& error, const std::string& message);