adj-lsa.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2023, The University of Memphis,
4  * Regents of the University of California,
5  * Arizona Board of Regents.
6  *
7  * This file is part of NLSR (Named-data Link State Routing).
8  * See AUTHORS.md for complete list of NLSR authors and contributors.
9  *
10  * NLSR is free software: you can redistribute it and/or modify it under the terms
11  * of the GNU General Public License as published by the Free Software Foundation,
12  * either version 3 of the License, or (at your option) any later version.
13  *
14  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef NLSR_LSA_ADJ_LSA_HPP
23 #define NLSR_LSA_ADJ_LSA_HPP
24 
25 #include "lsa.hpp"
26 #include "test-access-control.hpp"
27 
28 namespace nlsr {
29 
37 class AdjLsa : public Lsa
38 {
39 public:
41 
42  AdjLsa() = default;
43 
44  AdjLsa(const ndn::Name& originR, uint64_t seqNo,
45  const ndn::time::system_clock::time_point& timepoint,
46  uint32_t noLink, AdjacencyList& adl);
47 
48  AdjLsa(const ndn::Block& block);
49 
50  Lsa::Type
51  getType() const override
52  {
53  return type();
54  }
55 
56  static constexpr Lsa::Type
57  type()
58  {
59  return Lsa::Type::ADJACENCY;
60  }
61 
62  const AdjacencyList&
63  getAdl() const
64  {
65  return m_adl;
66  }
67 
68  void
70  {
71  m_wire.reset();
72  m_adl.reset();
73  }
74 
75  void
77  {
78  m_wire.reset();
79  m_adl.insert(adj);
80  }
81 
82  uint32_t
84  {
85  return m_noLink;
86  }
87 
88  bool
89  isEqualContent(const AdjLsa& alsa) const;
90 
92  begin() const
93  {
94  return m_adl.begin();
95  }
96 
98  end() const
99  {
100  return m_adl.end();
101  }
102 
103  template<ndn::encoding::Tag TAG>
104  size_t
105  wireEncode(ndn::EncodingImpl<TAG>& block) const;
106 
107  const ndn::Block&
108  wireEncode() const override;
109 
110  void
111  wireDecode(const ndn::Block& wire);
112 
113  std::string
114  toString() const override;
115 
116  std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
117  update(const std::shared_ptr<Lsa>& lsa) override;
118 
119 private:
120  uint32_t m_noLink;
121 
123  AdjacencyList m_adl;
124 };
125 
127 
128 std::ostream&
129 operator<<(std::ostream& os, const AdjLsa& lsa);
130 
131 } // namespace nlsr
132 
133 #endif // NLSR_LSA_ADJ_LSA_HPP
Data abstraction for AdjLsa AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH Lsa Adjacency*.
Definition: adj-lsa.hpp:38
const_iterator begin() const
Definition: adj-lsa.hpp:92
std::tuple< bool, std::list< ndn::Name >, std::list< ndn::Name > > update(const std::shared_ptr< Lsa > &lsa) override
Definition: adj-lsa.cpp:143
AdjLsa()=default
const ndn::Block & wireEncode() const override
Definition: adj-lsa.cpp:73
void wireDecode(const ndn::Block &wire)
Definition: adj-lsa.cpp:91
const_iterator end() const
Definition: adj-lsa.hpp:98
Lsa::Type getType() const override
Definition: adj-lsa.hpp:51
static constexpr Lsa::Type type()
Definition: adj-lsa.hpp:57
uint32_t getNoLink()
Definition: adj-lsa.hpp:83
bool isEqualContent(const AdjLsa &alsa) const
Definition: adj-lsa.cpp:46
void addAdjacent(Adjacent adj)
Definition: adj-lsa.hpp:76
void resetAdl()
Definition: adj-lsa.hpp:69
AdjacencyList::const_iterator const_iterator
Definition: adj-lsa.hpp:40
std::string toString() const override
Definition: adj-lsa.cpp:124
const AdjacencyList & getAdl() const
Definition: adj-lsa.hpp:63
std::list< Adjacent >::const_iterator const_iterator
const_iterator begin() const
bool insert(const Adjacent &adjacent)
const_iterator end() const
A neighbor reachable over a Face.
Definition: adjacent.hpp:47
Data abstraction for Lsa Lsa := LSA-TYPE TLV-LENGTH Name SequenceNumber ExpirationTimePoint.
Definition: lsa.hpp:42
ndn::Block m_wire
Definition: lsa.hpp:144
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:176
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE