communication+route: Do not advertise Adjacency LSAs when hyperbolic routing is enabled

refs: #2402

Change-Id: If204807733f858606e31a0ff8231f140905063cf
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 2f098fe..1835ef8 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -380,7 +380,12 @@
         // has met the HELLO retry threshold
         adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
 
-        m_nlsrLsdb.scheduleAdjLsaBuild();
+        if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
+          getRoutingTable().scheduleRoutingTableCalculation(*this);
+        }
+        else {
+          m_nlsrLsdb.scheduleAdjLsaBuild();
+        }
       }
     }
   }
diff --git a/src/route/map.cpp b/src/route/map.cpp
index a34f415..3b7378b 100644
--- a/src/route/map.cpp
+++ b/src/route/map.cpp
@@ -113,6 +113,14 @@
 }
 
 void
+Map::createFromCoordinateLsdb(Nlsr& nlsr)
+{
+  for (CoordinateLsa lsa : nlsr.getLsdb().getCoordinateLsdb()) {
+    addEntry(lsa.getOrigRouter());
+  }
+}
+
+void
 Map::reset()
 {
   m_table.clear();
diff --git a/src/route/map.hpp b/src/route/map.hpp
index 8f7d0f4..c13869e 100644
--- a/src/route/map.hpp
+++ b/src/route/map.hpp
@@ -50,6 +50,9 @@
   void
   createFromAdjLsdb(Nlsr& pnlsr);
 
+  void
+  createFromCoordinateLsdb(Nlsr& nlsr);
+
   const ndn::Name
   getRouterNameByMappingNo(int32_t mn);
 
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 343767a..e538153 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -49,9 +49,20 @@
   if (pnlsr.getIsRoutingTableCalculating() == false) {
     //setting routing table calculation
     pnlsr.setIsRoutingTableCalculating(true);
-    if (pnlsr.getLsdb().doesLsaExist(
-          pnlsr.getConfParameter().getRouterPrefix().toUri() + "/" + "adjacency",
-          std::string("adjacency"))) {
+
+    bool isHrEnabled = pnlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF;
+
+    if ((!isHrEnabled
+         &&
+         pnlsr.getLsdb()
+         .doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
+                       + "/" + "adjacency", std::string("adjacency")))
+        ||
+        (isHrEnabled
+         &&
+         pnlsr.getLsdb()
+         .doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
+                       + "/" + "coordinate", std::string("coordinate")))) {
       if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
         _LOG_TRACE("Clearing old routing table");
         clearRoutingTable();
@@ -127,7 +138,7 @@
 RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
 {
   Map map;
-  map.createFromAdjLsdb(nlsr);
+  map.createFromCoordinateLsdb(nlsr);
   map.writeLog();
 
   size_t nRouters = map.getMapSize();
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index 0547c6c..63551fa 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -85,6 +85,7 @@
   receiveUpdate(updateName, syncSeqNo, sync);
 
   std::vector<ndn::Interest>& interests = face->sentInterests;
+
   std::vector<ndn::Interest>::iterator it = interests.begin();
 
   BOOST_REQUIRE_EQUAL(interests.size(), 2);
@@ -158,12 +159,21 @@
 
   BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
 
-  ++it;
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
+  if (nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
+      ++it;
+      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
+  }
+  else if (nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
+      ++it;
+      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
+  }
+  else {
+      ++it;
+      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
 
-  ++it;
-  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
-
+      ++it;
+      BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
+  }
 }
 
 BOOST_AUTO_TEST_CASE(NoUpdateForSelf)