28 const ndn::time::system_clock::time_point& timepoint,
30 :
Lsa(originRouter, seqNo, timepoint)
32 for (
const auto& name : npl.
getNames()) {
42 template<ndn::encoding::Tag TAG>
46 size_t totalLength = 0;
50 for (
auto it = names.rbegin(); it != names.rend(); ++it) {
51 totalLength += it->wireEncode(block);
56 totalLength += block.prependVarNumber(totalLength);
71 ndn::EncodingEstimator estimator;
74 ndn::EncodingBuffer buffer(estimatedSize, 0);
93 auto val =
m_wire.elements_begin();
100 NDN_THROW(
Error(
"Missing required Lsa field"));
104 for (; val !=
m_wire.elements_end(); ++val) {
105 if (val->type() == ndn::tlv::Name) {
106 npl.
insert(ndn::Name(*val));
109 NDN_THROW(
Error(
"Name", val->type()));
118 return m_npl == other.
getNpl();
124 std::ostringstream os;
128 for (
const auto& name : m_npl.
getNames()) {
129 os <<
" Name " << i++ <<
": " << name <<
"\n";
135 std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
138 auto nlsa = std::static_pointer_cast<NameLsa>(lsa);
139 bool updated =
false;
142 nlsa->getNpl().sort();
146 std::list<ndn::Name> newNames = nlsa->getNpl().getNames();
147 std::list<ndn::Name> oldNames = m_npl.
getNames();
148 std::list<ndn::Name> namesToAdd;
149 std::set_difference(newNames.begin(), newNames.end(), oldNames.begin(), oldNames.end(),
150 std::inserter(namesToAdd, namesToAdd.begin()));
151 for (
const auto& name : namesToAdd) {
159 std::list<ndn::Name> namesToRemove;
160 std::set_difference(oldNames.begin(), oldNames.end(), newNames.begin(), newNames.end(),
161 std::inserter(namesToRemove, namesToRemove.begin()));
162 for (
const auto& name : namesToRemove) {
167 return {updated, namesToAdd, namesToRemove};
Data abstraction for Lsa Lsa := LSA-TYPE TLV-LENGTH Name SequenceNumber ExpirationTimePoint.
virtual const ndn::Block & wireEncode() const =0
std::string getString() const
void wireDecode(const ndn::Block &wire)
Data abstraction for NameLsa NameLsa := NAME-LSA-TYPE TLV-LENGTH Lsa Name+.
NamePrefixList & getNpl()
std::string toString() const override
void addName(const ndn::Name &name)
std::tuple< bool, std::list< ndn::Name >, std::list< ndn::Name > > update(const std::shared_ptr< Lsa > &lsa) override
void removeName(const ndn::Name &name)
void wireDecode(const ndn::Block &wire)
const ndn::Block & wireEncode() const override
bool isEqualContent(const NameLsa &other) const
bool insert(const ndn::Name &name, const std::string &source="")
inserts name into NamePrefixList
std::list< ndn::Name > getNames() const
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)