**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/src/lsa/lsa.hpp b/src/lsa/lsa.hpp
new file mode 100644
index 0000000..1bd4382
--- /dev/null
+++ b/src/lsa/lsa.hpp
@@ -0,0 +1,160 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2020, The University of Memphis,
+ * Regents of the University of California,
+ * Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NLSR_LSA_LSA_HPP
+#define NLSR_LSA_LSA_HPP
+
+#include "name-prefix-list.hpp"
+#include "adjacent.hpp"
+#include "adjacency-list.hpp"
+#include "test-access-control.hpp"
+
+#include <ndn-cxx/util/scheduler.hpp>
+#include <ndn-cxx/util/time.hpp>
+
+namespace nlsr {
+
+/*!
+ \brief Data abstraction for Lsa
+ Lsa := LSA-TYPE TLV-LENGTH
+ Name
+ SequenceNumber
+ ExpirationTimePoint
+ */
+class Lsa
+{
+public:
+ class Error : public ndn::tlv::Error
+ {
+ public:
+ explicit
+ Error(const std::string& what)
+ : ndn::tlv::Error(what)
+ {
+ }
+ };
+
+ enum class Type {
+ ADJACENCY,
+ COORDINATE,
+ NAME,
+ BASE
+ };
+
+protected:
+ Lsa(const ndn::Name& originRouter, uint32_t seqNo,
+ ndn::time::system_clock::TimePoint expirationTimePoint);
+
+ Lsa() = default;
+
+public:
+ virtual
+ ~Lsa() = default;
+
+ virtual Type
+ getType() const
+ {
+ return Type::BASE;
+ }
+
+ void
+ setSeqNo(uint64_t seqNo)
+ {
+ m_seqNo = seqNo;
+ m_baseWire.reset();
+ }
+
+ uint64_t
+ getSeqNo() const
+ {
+ return m_seqNo;
+ }
+
+ const ndn::Name&
+ getOriginRouter() const
+ {
+ return m_originRouter;
+ }
+
+ const ndn::time::system_clock::TimePoint&
+ getExpirationTimePoint() const
+ {
+ return m_expirationTimePoint;
+ }
+
+ void
+ setExpirationTimePoint(const ndn::time::system_clock::TimePoint& lt)
+ {
+ m_expirationTimePoint = lt;
+ m_baseWire.reset();
+ }
+
+ void
+ setExpiringEventId(ndn::scheduler::EventId eid)
+ {
+ m_expiringEventId = std::move(eid);
+ }
+
+ ndn::scheduler::EventId
+ getExpiringEventId() const
+ {
+ return m_expiringEventId;
+ }
+
+ /*! \brief Gets the key for this LSA.
+
+ Format is: \<router name\>/\<LSA type>\
+ */
+ ndn::Name
+ getKey() const;
+
+ /*! Get data common to all LSA types.
+ */
+ std::string
+ toString() const;
+
+ template<ndn::encoding::Tag TAG>
+ size_t
+ wireEncode(ndn::EncodingImpl<TAG>& block) const;
+
+ void
+ wireDecode(const ndn::Block& wire);
+
+PUBLIC_WITH_TESTS_ELSE_PROTECTED:
+ ndn::Name m_originRouter;
+ uint64_t m_seqNo = 0;
+ ndn::time::system_clock::TimePoint m_expirationTimePoint;
+ ndn::scheduler::EventId m_expiringEventId;
+
+ mutable ndn::Block m_baseWire;
+};
+
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Lsa);
+
+std::ostream&
+operator<<(std::ostream& os, const Lsa::Type& type);
+
+std::istream&
+operator>>(std::istream& is, Lsa::Type& type);
+
+} // namespace nlsr
+
+#endif // NLSR_LSA_LSA_HPP