route: Adjust cost to integer before registering

refs: #1907

Change-Id: I471cd2eafb65a8458b4f527a3c3d7ea6682f5627
diff --git a/src/route/fib-entry.cpp b/src/route/fib-entry.cpp
index a7eb68f..07346f0 100644
--- a/src/route/fib-entry.cpp
+++ b/src/route/fib-entry.cpp
@@ -31,30 +31,6 @@
 
 using namespace std;
 
-bool
-FibEntry::isEqualNextHops(NexthopList& nhlOther)
-{
-  if (m_nexthopList.getSize() != nhlOther.getSize()) {
-    return false;
-  }
-  else {
-    uint32_t nhCount = 0;
-    std::list<NextHop>::iterator it1, it2;
-    for (it1 = m_nexthopList.getNextHops().begin(),
-         it2 = nhlOther.getNextHops().begin() ;
-         it1 != m_nexthopList.getNextHops().end() ; it1++, it2++) {
-      if (it1->getConnectingFaceUri() == it2->getConnectingFaceUri()) {
-        it1->setRouteCost(it2->getRouteCost());
-        nhCount++;
-      }
-      else {
-        break;
-      }
-    }
-    return nhCount == m_nexthopList.getSize();
-  }
-}
-
 void
 FibEntry::writeLog()
 {
diff --git a/src/route/fib-entry.hpp b/src/route/fib-entry.hpp
index 7f39fdd..2c98002 100644
--- a/src/route/fib-entry.hpp
+++ b/src/route/fib-entry.hpp
@@ -102,9 +102,6 @@
     return m_seqNo;
   }
 
-  bool
-  isEqualNextHops(NexthopList& nhlOther);
-
   void
   writeLog();
 
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index de9d365..1e8b9ed 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -112,7 +112,7 @@
     if (isPrefixUpdatable(name)) {
       // Add nexthop to NDN-FIB
       registerPrefix(name, hopIt->getConnectingFaceUri(),
-                     std::ceil(hopIt->getRouteCost()),
+                     hopIt->getRouteCostAsAdjustedInteger(),
                      ndn::time::seconds(m_refreshTime + GRACE_PERIOD),
                      ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
     }
diff --git a/src/route/nexthop-list.cpp b/src/route/nexthop-list.cpp
index 0822d38..9ef6fd3 100644
--- a/src/route/nexthop-list.cpp
+++ b/src/route/nexthop-list.cpp
@@ -41,7 +41,7 @@
 nexthopRemoveCompare(NextHop& nh1, NextHop& nh2)
 {
   return (nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri() &&
-          nh1.getRouteCost() == nh2.getRouteCost()) ;
+          nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) ;
 }
 
 static bool
diff --git a/src/route/nexthop.hpp b/src/route/nexthop.hpp
index a354752..a4feec2 100644
--- a/src/route/nexthop.hpp
+++ b/src/route/nexthop.hpp
@@ -56,10 +56,15 @@
   }
 
   uint64_t
+  getRouteCostAsAdjustedInteger() const
+  {
+    return static_cast<uint64_t>(m_routeCost*HYPERBOLIC_COST_ADJUSTMENT_FACTOR);
+  }
+
+  double
   getRouteCost() const
   {
-    uint64_t routeCost = static_cast<uint64_t>(ceil(m_routeCost));
-    return routeCost;
+    return m_routeCost;
   }
 
   void
@@ -71,6 +76,7 @@
 private:
   std::string m_connectingFaceUri;
   double m_routeCost;
+  static const uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 100;
 };
 
 }//namespace nlsr