blob: 12e9346973a5cff913b6cdaff112ca38ad71e61e [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_ADJ_LSA_HPP
23#define NLSR_LSA_ADJ_LSA_HPP
24
25#include "lsa.hpp"
26#include "test-access-control.hpp"
27
28namespace nlsr {
29
30/*!
31 \brief Data abstraction for AdjLsa
32 AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH
33 Lsa
34 Adjacency*
35
36 */
37class AdjLsa : public Lsa
38{
39public:
40 typedef AdjacencyList::const_iterator const_iterator;
41
42 AdjLsa() = default;
43
44 AdjLsa(const ndn::Name& originR, uint32_t seqNo,
45 const ndn::time::system_clock::TimePoint& 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 Lsa::Type::ADJACENCY;
54 }
55
56 const AdjacencyList&
57 getAdl() const
58 {
59 return m_adl;
60 }
61
62 void
63 resetAdl()
64 {
65 m_wire.reset();
66 m_adl.reset();
67 }
68
69 void
70 addAdjacent(Adjacent adj)
71 {
72 m_wire.reset();
73 m_adl.insert(adj);
74 }
75
76 uint32_t
77 getNoLink()
78 {
79 return m_noLink;
80 }
81
82 bool
83 isEqualContent(const AdjLsa& alsa) const;
84
85 const_iterator
86 begin() const
87 {
88 return m_adl.begin();
89 }
90
91 const_iterator
92 end() const
93 {
94 return m_adl.end();
95 }
96
97 template<ndn::encoding::Tag TAG>
98 size_t
99 wireEncode(ndn::EncodingImpl<TAG>& block) const;
100
101 const ndn::Block&
102 wireEncode() const;
103
104 void
105 wireDecode(const ndn::Block& wire);
106
107private:
108 uint32_t m_noLink;
109
110PUBLIC_WITH_TESTS_ELSE_PRIVATE:
111 AdjacencyList m_adl;
112
113 mutable ndn::Block m_wire;
114};
115
116NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdjLsa);
117
118std::ostream&
119operator<<(std::ostream& os, const AdjLsa& lsa);
120
121} // namespace nlsr
122
123#endif // NLSR_LSA_ADJ_LSA_HPP