Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 2 | /* |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 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/>. |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 20 | */ |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 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 | |
| 30 | /*! |
| 31 | \brief Data abstraction for AdjLsa |
| 32 | AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH |
| 33 | Lsa |
| 34 | Adjacency* |
| 35 | |
| 36 | */ |
| 37 | class AdjLsa : public Lsa |
| 38 | { |
| 39 | public: |
| 40 | typedef AdjacencyList::const_iterator const_iterator; |
| 41 | |
| 42 | AdjLsa() = default; |
| 43 | |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 44 | AdjLsa(const ndn::Name& originR, uint64_t seqNo, |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 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 | { |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 53 | return type(); |
| 54 | } |
| 55 | |
| 56 | static constexpr Lsa::Type |
| 57 | type() |
| 58 | { |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 59 | return Lsa::Type::ADJACENCY; |
| 60 | } |
| 61 | |
| 62 | const AdjacencyList& |
| 63 | getAdl() const |
| 64 | { |
| 65 | return m_adl; |
| 66 | } |
| 67 | |
| 68 | void |
| 69 | resetAdl() |
| 70 | { |
| 71 | m_wire.reset(); |
| 72 | m_adl.reset(); |
| 73 | } |
| 74 | |
| 75 | void |
| 76 | addAdjacent(Adjacent adj) |
| 77 | { |
| 78 | m_wire.reset(); |
| 79 | m_adl.insert(adj); |
| 80 | } |
| 81 | |
| 82 | uint32_t |
| 83 | getNoLink() |
| 84 | { |
| 85 | return m_noLink; |
| 86 | } |
| 87 | |
| 88 | bool |
| 89 | isEqualContent(const AdjLsa& alsa) const; |
| 90 | |
| 91 | const_iterator |
| 92 | begin() const |
| 93 | { |
| 94 | return m_adl.begin(); |
| 95 | } |
| 96 | |
| 97 | const_iterator |
| 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& |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 108 | wireEncode() const override; |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 109 | |
| 110 | void |
| 111 | wireDecode(const ndn::Block& wire); |
| 112 | |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 113 | std::string |
| 114 | toString() const override; |
| 115 | |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 116 | private: |
| 117 | uint32_t m_noLink; |
| 118 | |
| 119 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 120 | AdjacencyList m_adl; |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdjLsa); |
| 124 | |
| 125 | std::ostream& |
| 126 | operator<<(std::ostream& os, const AdjLsa& lsa); |
| 127 | |
| 128 | } // namespace nlsr |
| 129 | |
| 130 | #endif // NLSR_LSA_ADJ_LSA_HPP |