28 const ndn::time::system_clock::time_point& timepoint,
AdjacencyList& adl)
29 :
Lsa(originRouter, seqNo, timepoint)
31 for (
const auto& adjacent : adl.
getAdjList()) {
43 template<ndn::encoding::Tag TAG>
47 size_t totalLength = 0;
50 for (
auto it = list.rbegin(); it != list.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) {
109 NDN_THROW(
Error(
"Adjacency", val->type()));
116 AdjLsa::print(std::ostream& os)
const
118 os <<
" Adjacent(s):\n";
120 int adjacencyIndex = 0;
121 for (
const auto& adjacency : m_adl) {
122 os <<
" Adjacent " << adjacencyIndex++
123 <<
": (name=" << adjacency.getName()
124 <<
", uri=" << adjacency.getFaceUri()
125 <<
", cost=" << adjacency.getLinkCost() <<
")\n";
129 std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
132 auto alsa = std::static_pointer_cast<AdjLsa>(lsa);
133 if (*
this != *alsa) {
135 for (
const auto& adjacent : alsa->getAdl()) {
138 return {
true, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
140 return {
false, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
Represents an LSA of adjacencies of the origin router in link-state mode.
std::tuple< bool, std::list< ndn::Name >, std::list< ndn::Name > > update(const std::shared_ptr< Lsa > &lsa) override
const ndn::Block & wireEncode() const override
void wireDecode(const ndn::Block &wire)
void addAdjacent(const Adjacent &adj)
bool insert(const Adjacent &adjacent)
std::list< Adjacent > & getAdjList()
A neighbor reachable over a Face.
Represents a Link State Announcement (LSA).
virtual const ndn::Block & wireEncode() const =0
void wireDecode(const ndn::Block &wire)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)