lsdb: rebuild using boost::multi_index to replace 3 LSA lists
refs: #4127
Co-authored-by: Nick Gordon <nmgordon@memphis.edu>
Change-Id: Ic179f90019e472157b0d61c6db02a4afaf4843b6
diff --git a/src/lsa/name-lsa.cpp b/src/lsa/name-lsa.cpp
index f73014b..cfdfd77 100644
--- a/src/lsa/name-lsa.cpp
+++ b/src/lsa/name-lsa.cpp
@@ -24,9 +24,9 @@
namespace nlsr {
-NameLsa::NameLsa(const ndn::Name& originRouter, uint32_t seqNo,
+NameLsa::NameLsa(const ndn::Name& originRouter, uint64_t seqNo,
const ndn::time::system_clock::TimePoint& timepoint,
- NamePrefixList& npl)
+ const NamePrefixList& npl)
: Lsa(originRouter, seqNo, timepoint)
{
for (const auto& name : npl.getNames()) {
@@ -64,7 +64,7 @@
const ndn::Block&
NameLsa::wireEncode() const
{
- if (m_wire.hasWire() && m_baseWire.hasWire()) {
+ if (m_wire.hasWire()) {
return m_wire;
}
@@ -91,7 +91,7 @@
m_wire.parse();
- ndn::Block::element_const_iterator val = m_wire.elements_begin();
+ auto val = m_wire.elements_begin();
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Lsa) {
Lsa::wireDecode(*val);
@@ -121,18 +121,24 @@
return m_npl == other.getNpl();
}
-std::ostream&
-operator<<(std::ostream& os, const NameLsa& lsa)
+std::string
+NameLsa::toString() const
{
- os << lsa.toString();
+ std::ostringstream os;
+ os << Lsa::toString();
os << " Names:\n";
int i = 0;
- auto names = lsa.getNpl().getNames();
- for (const auto& name : names) {
+ for (const auto& name : m_npl.getNames()) {
os << " Name " << i++ << ": " << name << "\n";
}
- return os;
+ return os.str();
+}
+
+std::ostream&
+operator<<(std::ostream& os, const NameLsa& lsa)
+{
+ return os << lsa.toString();
}
} // namespace nlsr