**breaking** consolidate src/tlv/*lsa* into src/lsa/*lsa*

Lsa de/serialize functions are replaced by wireEncode/Decode.
Update LSA wire formats. Change TLV assignments as required.
Update nlsrc to print using new encoding.

refs: #4787

Change-Id: Ie8d40b7836d51ea5bb444c8db208dc2b3a0d1cec
diff --git a/tools/nlsrc.cpp b/tools/nlsrc.cpp
index f4e5965..a943b85 100644
--- a/tools/nlsrc.cpp
+++ b/tools/nlsrc.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2019,  The University of Memphis,
+ * Copyright (c) 2014-2020,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -252,22 +252,22 @@
 void
 Nlsrc::fetchAdjacencyLsas()
 {
-  fetchFromLsdb<nlsr::tlv::AdjacencyLsa>(nlsr::dataset::ADJACENCY_COMPONENT,
-                                         std::bind(&Nlsrc::recordAdjacencyLsa, this, _1));
+  fetchFromLsdb<nlsr::AdjLsa>(nlsr::dataset::ADJACENCY_COMPONENT,
+                              std::bind(&Nlsrc::recordLsa, this, _1));
 }
 
 void
 Nlsrc::fetchCoordinateLsas()
 {
-  fetchFromLsdb<nlsr::tlv::CoordinateLsa>(nlsr::dataset::COORDINATE_COMPONENT,
-                                          std::bind(&Nlsrc::recordCoordinateLsa, this, _1));
+  fetchFromLsdb<nlsr::CoordinateLsa>(nlsr::dataset::COORDINATE_COMPONENT,
+                                     std::bind(&Nlsrc::recordLsa, this, _1));
 }
 
 void
 Nlsrc::fetchNameLsas()
 {
-  fetchFromLsdb<nlsr::tlv::NameLsa>(nlsr::dataset::NAME_COMPONENT,
-                                    std::bind(&Nlsrc::recordNameLsa, this, _1));
+  fetchFromLsdb<nlsr::NameLsa>(nlsr::dataset::NAME_COMPONENT,
+                               std::bind(&Nlsrc::recordLsa, this, _1));
 }
 
 void
@@ -340,66 +340,36 @@
             << ", error: " << error << ")"  << std::endl;
 }
 
-std::string
-Nlsrc::getLsaInfoString(const nlsr::tlv::LsaInfo& info)
-{
-  std::ostringstream os;
-  os << "      info=" << info;
-
-  return os.str();
-}
-
 void
-Nlsrc::recordAdjacencyLsa(const nlsr::tlv::AdjacencyLsa& lsa)
+Nlsrc::recordLsa(const nlsr::Lsa& lsa)
 {
-  Router& router = getRouterLsdb(lsa.getLsaInfo());
+  const auto& pair = m_routers.emplace(lsa.getOriginRouter(), Router());
+  Router& router = pair.first->second;
 
   std::ostringstream os;
-  os << "    AdjacencyLsa:" << std::endl;
 
-  os << getLsaInfoString(lsa.getLsaInfo()) << std::endl;
-
-  for (const auto& adjacency : lsa.getAdjacencies()) {
-    os << "      adjacency=" << adjacency << std::endl;
+  switch (lsa.getType()) {
+    case nlsr::Lsa::Type::ADJACENCY: {
+      const nlsr::AdjLsa& adjLsa = static_cast<const nlsr::AdjLsa&>(lsa);
+      os << adjLsa;
+      router.adjacencyLsaString = os.str();
+      break;
+    }
+    case nlsr::Lsa::Type::COORDINATE: {
+      const nlsr::CoordinateLsa& coorLsa = static_cast<const nlsr::CoordinateLsa&>(lsa);
+      os << coorLsa;
+      router.coordinateLsaString = os.str();
+      break;
+    }
+    case nlsr::Lsa::Type::NAME: {
+      const nlsr::NameLsa& nameLsa = static_cast<const nlsr::NameLsa&>(lsa);
+      os << nameLsa;
+      router.nameLsaString = os.str();
+      break;
+    }
+    default:
+      break;
   }
-
-  router.adjacencyLsaString = os.str();
-}
-
-void
-Nlsrc::recordCoordinateLsa(const nlsr::tlv::CoordinateLsa& lsa)
-{
-  Router& router = getRouterLsdb(lsa.getLsaInfo());
-
-  std::ostringstream os;
-  os << "    Coordinate LSA:" << std::endl;
-
-  os << getLsaInfoString(lsa.getLsaInfo()) << std::endl;
-
-  int i = 0;
-  for (auto const& value: lsa.getHyperbolicAngle()) {
-    os << "    Hyp Angle " << i++ << ": "<< value << " ";
-  }
-  os << "\n   radius=" << lsa.getHyperbolicRadius() << std::endl;
-
-  router.coordinateLsaString = os.str();
-}
-
-void
-Nlsrc::recordNameLsa(const nlsr::tlv::NameLsa& lsa)
-{
-  Router& router = getRouterLsdb(lsa.getLsaInfo());
-
-  std::ostringstream os;
-  os << "    Name LSA:" << std::endl;
-
-  os << getLsaInfoString(lsa.getLsaInfo()) << std::endl;
-
-  for (const auto& name : lsa.getNames()) {
-    os << "      name=" << name << std::endl;
-  }
-
-  router.nameLsaString = os.str();
 }
 
 void
@@ -469,15 +439,19 @@
   printRT();
 }
 
-Nlsrc::Router&
-Nlsrc::getRouterLsdb(const nlsr::tlv::LsaInfo& info)
+std::string
+Nlsrc::getLsaInfo(const nlsr::Lsa& lsa)
 {
-  const ndn::Name& originRouterName = info.getOriginRouter();
+  auto duration = ndn::time::duration_cast<ndn::time::seconds>(lsa.getExpirationTimePoint() -
+                                                               ndn::time::system_clock::now());
+  std::ostringstream os;
+  os << "     LsaInfo("
+     << "OriginRouter: " << lsa.getOriginRouter() << ", "
+     << "SequenceNumber: " << lsa.getSeqNo() << ", "
+     << "ExpirationPeriod: " << duration;
+     os << ")\n\n";
 
-  const auto& pair =
-    m_routers.insert(std::make_pair(originRouterName, Router()));
-
-  return pair.first->second;
+  return os.str();
 }
 
 } // namespace nlsrc