name-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-2020, 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_NAME_LSA_HPP
23 #define NLSR_LSA_NAME_LSA_HPP
24 
25 #include "lsa.hpp"
26 
27 namespace nlsr {
28 
35 class NameLsa : public Lsa
36 {
37 public:
38  NameLsa() = default;
39 
40  NameLsa(const ndn::Name& originRouter, uint64_t seqNo,
41  const ndn::time::system_clock::TimePoint& timepoint,
42  const NamePrefixList& npl);
43 
44  NameLsa(const ndn::Block& block);
45 
46  Lsa::Type
47  getType() const override
48  {
49  return type();
50  }
51 
52  static constexpr Lsa::Type
53  type()
54  {
55  return Lsa::Type::NAME;
56  }
57 
60  {
61  return m_npl;
62  }
63 
64  const NamePrefixList&
65  getNpl() const
66  {
67  return m_npl;
68  }
69 
70  void
71  addName(const ndn::Name& name)
72  {
73  m_wire.reset();
74  m_npl.insert(name);
75  }
76 
77  void
78  removeName(const ndn::Name& name)
79  {
80  m_wire.reset();
81  m_npl.remove(name);
82  }
83 
84  bool
85  isEqualContent(const NameLsa& other) const;
86 
87  template<ndn::encoding::Tag TAG>
88  size_t
89  wireEncode(ndn::EncodingImpl<TAG>& block) const;
90 
91  const ndn::Block&
92  wireEncode() const override;
93 
94  void
95  wireDecode(const ndn::Block& wire);
96 
97  std::string
98  toString() const override;
99 
100 private:
101  NamePrefixList m_npl;
102 };
103 
105 
106 std::ostream&
107 operator<<(std::ostream& os, const NameLsa& lsa);
108 
109 } // namespace nlsr
110 
111 #endif // NLSR_LSA_NAME_LSA_HPP
Data abstraction for Lsa Lsa := LSA-TYPE TLV-LENGTH Name SequenceNumber ExpirationTimePoint.
Definition: lsa.hpp:42
bool remove(const ndn::Name &name, const std::string &source="")
removes name from NamePrefixList
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:181
const NamePrefixList & getNpl() const
Definition: name-lsa.hpp:65
bool isEqualContent(const NameLsa &other) const
Definition: name-lsa.cpp:119
NamePrefixList & getNpl()
Definition: name-lsa.hpp:59
NameLsa()=default
Lsa::Type getType() const override
Definition: name-lsa.hpp:47
bool insert(const ndn::Name &name, const std::string &source="")
inserts name into NamePrefixList
static constexpr Lsa::Type type()
Definition: name-lsa.hpp:53
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)
ndn::Block m_wire
Definition: lsa.hpp:147
const ndn::Block & wireEncode() const override
Definition: name-lsa.cpp:65
void wireDecode(const ndn::Block &wire)
Definition: name-lsa.cpp:83
void removeName(const ndn::Name &name)
Definition: name-lsa.hpp:78
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Data abstraction for NameLsa NameLsa := NAME-LSA-TYPE TLV-LENGTH Lsa Name+.
Definition: name-lsa.hpp:35
void addName(const ndn::Name &name)
Definition: name-lsa.hpp:71
std::string toString() const override
Definition: name-lsa.cpp:125