blob: 3223839f4a6f8fce005c6bbe8fad79e26b9a1a9a [file] [log] [blame]
Ashlesh Gawande0db4d4d2020-02-05 20:30:02 -08001/* -*- 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
27namespace nlsr {
28
29/*!
30 \brief Data abstraction for NameLsa
31 NameLsa := NAME-LSA-TYPE TLV-LENGTH
32 Lsa
33 Name+
34 */
35class NameLsa : public Lsa
36{
37public:
38 NameLsa() = default;
39
40 NameLsa(const ndn::Name& originRouter, uint32_t seqNo,
41 const ndn::time::system_clock::TimePoint& timepoint,
42 NamePrefixList& npl);
43
44 NameLsa(const ndn::Block& block);
45
46 Lsa::Type
47 getType() const override
48 {
49 return Lsa::Type::NAME;
50 }
51
52 NamePrefixList&
53 getNpl()
54 {
55 return m_npl;
56 }
57
58 const NamePrefixList&
59 getNpl() const
60 {
61 return m_npl;
62 }
63
64 void
65 addName(const ndn::Name& name)
66 {
67 m_wire.reset();
68 m_npl.insert(name);
69 }
70
71 void
72 removeName(const ndn::Name& name)
73 {
74 m_wire.reset();
75 m_npl.remove(name);
76 }
77
78 bool
79 isEqualContent(const NameLsa& other) const;
80
81 template<ndn::encoding::Tag TAG>
82 size_t
83 wireEncode(ndn::EncodingImpl<TAG>& block) const;
84
85 const ndn::Block&
86 wireEncode() const;
87
88 void
89 wireDecode(const ndn::Block& wire);
90
91private:
92 NamePrefixList m_npl;
93 mutable ndn::Block m_wire;
94};
95
96NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NameLsa);
97
98std::ostream&
99operator<<(std::ostream& os, const NameLsa& lsa);
100
101} // namespace nlsr
102
103#endif // NLSR_LSA_NAME_LSA_HPP