publisher: fix encoding bug in routing table publisher

refs: #4453

Change-Id: I03e819e963f0957f3d40ff25e378f2b9b17357b7
diff --git a/tools/nlsrc.cpp b/tools/nlsrc.cpp
index db2de6a..3db6215 100644
--- a/tools/nlsrc.cpp
+++ b/tools/nlsrc.cpp
@@ -240,8 +240,8 @@
 void
 Nlsrc::fetchRtables()
 {
-  fetchFromRt<nlsr::tlv::RoutingTable>(
-    [this] (const nlsr::tlv::RoutingTable& rts) {
+  fetchFromRt<nlsr::tlv::RoutingTableStatus>(
+    [this] (const nlsr::tlv::RoutingTableStatus& rts) {
       recordRtable(rts);
     });
 }
@@ -322,15 +322,6 @@
   return os.str();
 }
 
-std::string
-Nlsrc::getDesString(const nlsr::tlv::Destination& des)
-{
-  std::ostringstream os;
-  os << "    " << des;
-
-  return os.str();
-}
-
 void
 Nlsrc::recordAdjacencyLsa(const nlsr::tlv::AdjacencyLsa& lsa)
 {
@@ -385,20 +376,13 @@
 }
 
 void
-Nlsrc::recordRtable(const nlsr::tlv::RoutingTable& rt)
+Nlsrc::recordRtable(const nlsr::tlv::RoutingTableStatus& rts)
 {
-  Router& router = getRouterRT(rt.getDestination());
-
   std::ostringstream os;
-
-  os << getDesString(rt.getDestination()) << std::endl;
-
-  os << "    NextHopList: " <<std::endl;
-  for (const auto& nhs : rt.getNextHops()) {
-    os << "      " << nhs;
+  for (const auto& rt : rts.getRoutingtable()) {
+    os << rt << std::endl;
   }
-
-  router.rtString = os.str();
+  m_rtString = os.str();
 }
 
 void
@@ -429,15 +413,12 @@
 void
 Nlsrc::printRT()
 {
-  std::cout << "Routing Table Status:" << std::endl;
-
-  for (const auto& item : m_routers) {
-
-    const Router& router = item.second;
-
-    if (!router.rtString.empty()) {
-      std::cout << router.rtString << std::endl;
-    }
+  if (!m_rtString.empty()) {
+    std::cout << "Routing Table" << std::endl;
+    std::cout << m_rtString << std::endl;
+  }
+  else {
+    std::cout << "Routing Table is not calculated yet" << std::endl;
   }
 }
 
@@ -460,17 +441,6 @@
   return pair.first->second;
 }
 
-Nlsrc::Router&
-Nlsrc::getRouterRT(const nlsr::tlv::Destination& des)
-{
-  const ndn::Name& desName = des.getName();
-
-  const auto& pair =
-    m_routers.insert(std::make_pair(desName, Router()));
-
-  return pair.first->second;
-}
-
 } // namespace nlsrc
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/tools/nlsrc.hpp b/tools/nlsrc.hpp
index a5c6368..cc5a1f6 100644
--- a/tools/nlsrc.hpp
+++ b/tools/nlsrc.hpp
@@ -123,9 +123,6 @@
   std::string
   getLsaInfoString(const nlsr::tlv::LsaInfo& info);
 
-  std::string
-  getDesString(const nlsr::tlv::Destination& des);
-
   void
   recordAdjacencyLsa(const nlsr::tlv::AdjacencyLsa& lsa);
 
@@ -136,7 +133,7 @@
   recordNameLsa(const nlsr::tlv::NameLsa& lsa);
 
   void
-  recordRtable(const nlsr::tlv::RoutingTable& rts);
+  recordRtable(const nlsr::tlv::RoutingTableStatus& rts);
 
   void
   printLsdb();
@@ -160,15 +157,11 @@
     std::string adjacencyLsaString;
     std::string coordinateLsaString;
     std::string nameLsaString;
-    std::string rtString;
   };
 
   Router&
   getRouterLsdb(const nlsr::tlv::LsaInfo& info);
 
-  Router&
-  getRouterRT(const nlsr::tlv::Destination& des);
-
   typedef std::map<const ndn::Name, Router> RouterMap;
   RouterMap m_routers;
 
@@ -177,6 +170,7 @@
   ndn::Face& m_face;
   ndn::security::ValidatorNull m_validator;
   std::string commandString;
+  std::string m_rtString;
 
   std::deque<std::function<void()>> m_fetchSteps;