Loading...
Searching...
No Matches
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-2025, 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#include "name-prefix-list.hpp"
27
28#include <boost/operators.hpp>
29
30namespace nlsr {
31
42class NameLsa : public Lsa, private boost::equality_comparable<NameLsa>
43{
44public:
45 NameLsa() = default;
46
47 NameLsa(const ndn::Name& originRouter, uint64_t seqNo,
48 const ndn::time::system_clock::time_point& timepoint,
49 const NamePrefixList& npl);
50
51 explicit
52 NameLsa(const ndn::Block& block);
53
55 getType() const override
56 {
57 return type();
58 }
59
60 static constexpr Lsa::Type
62 {
63 return Lsa::Type::NAME;
64 }
65
68 {
69 return m_npl;
70 }
71
72 const NamePrefixList&
73 getNpl() const
74 {
75 return m_npl;
76 }
77
78 void
79 addName(const PrefixInfo& name)
80 {
81 m_wire.reset();
82 m_npl.insert(name);
83 }
84
85 void
87 {
88 m_wire.reset();
89 m_npl.erase(name.getName());
90 }
91
92 template<ndn::encoding::Tag TAG>
93 size_t
94 wireEncode(ndn::EncodingImpl<TAG>& block) const;
95
96 const ndn::Block&
97 wireEncode() const override;
98
99 void
100 wireDecode(const ndn::Block& wire);
101
102 std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
103 update(const std::shared_ptr<Lsa>& lsa) override;
104
105private:
106 void
107 print(std::ostream& os) const override;
108
109private: // non-member operators
110 // NOTE: the following "hidden friend" operators are available via
111 // argument-dependent lookup only and must be defined inline.
112 // boost::equality_comparable provides != operator.
113
114 friend bool
115 operator==(const NameLsa& lhs, const NameLsa& rhs)
116 {
117 return lhs.m_npl == rhs.m_npl;
118 }
119
120private:
121 NamePrefixList m_npl;
122};
123
125
126} // namespace nlsr
127
128#endif // NLSR_LSA_NAME_LSA_HPP
Represents a Link State Announcement (LSA).
Definition lsa.hpp:48
ndn::Block m_wire
Definition lsa.hpp:144
Represents an LSA of name prefixes announced by the origin router.
Definition name-lsa.hpp:43
NameLsa()=default
NamePrefixList & getNpl()
Definition name-lsa.hpp:67
void removeName(const PrefixInfo &name)
Definition name-lsa.hpp:86
static constexpr Lsa::Type type()
Definition name-lsa.hpp:61
void addName(const PrefixInfo &name)
Definition name-lsa.hpp:79
void wireDecode(const ndn::Block &wire)
Definition name-lsa.cpp:83
friend bool operator==(const NameLsa &lhs, const NameLsa &rhs)
Definition name-lsa.hpp:115
const NamePrefixList & getNpl() const
Definition name-lsa.hpp:73
const ndn::Block & wireEncode() const override
Definition name-lsa.cpp:65
Lsa::Type getType() const override
Definition name-lsa.hpp:55
bool erase(const ndn::Name &name, const std::string &source="")
Deletes name and source combination.
bool insert(const ndn::Name &name, const std::string &source="", double cost=0)
Inserts name and source combination.
const ndn::Name & getName() const
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)