akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [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, |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 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 | */ |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 21 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 22 | #ifndef NLSR_SEQUENCING_MANAGER_HPP |
| 23 | #define NLSR_SEQUENCING_MANAGER_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 24 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 25 | #include "conf-parameter.hpp" |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 26 | #include "lsa/lsa.hpp" |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 27 | #include "test-access-control.hpp" |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 28 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 29 | #include <ndn-cxx/face.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 30 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 31 | #include <list> |
| 32 | #include <string> |
| 33 | #include <boost/cstdint.hpp> |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 34 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 35 | namespace nlsr { |
Nick Gordon | 5c467f0 | 2016-07-13 13:40:10 -0500 | [diff] [blame] | 36 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 37 | class SequencingManager |
| 38 | { |
| 39 | public: |
Ashlesh Gawande | 55d1b5c | 2019-12-19 16:21:58 -0600 | [diff] [blame] | 40 | SequencingManager(const std::string& filePath, int hypState); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 41 | |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 42 | void |
| 43 | setLsaSeq(uint64_t seqNo, Lsa::Type lsaType) |
| 44 | { |
| 45 | switch (lsaType) { |
| 46 | case Lsa::Type::ADJACENCY: |
| 47 | m_adjLsaSeq = seqNo; |
| 48 | break; |
| 49 | case Lsa::Type::COORDINATE: |
| 50 | m_corLsaSeq = seqNo; |
| 51 | break; |
| 52 | case Lsa::Type::NAME: |
| 53 | m_nameLsaSeq = seqNo; |
| 54 | break; |
| 55 | default: |
| 56 | return; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | uint64_t |
| 61 | getLsaSeq(Lsa::Type lsaType) |
| 62 | { |
| 63 | switch (lsaType) { |
| 64 | case Lsa::Type::ADJACENCY: |
| 65 | return m_adjLsaSeq; |
| 66 | case Lsa::Type::COORDINATE: |
| 67 | return m_corLsaSeq; |
| 68 | case Lsa::Type::NAME: |
| 69 | return m_nameLsaSeq; |
| 70 | default: |
| 71 | return 0; |
| 72 | } |
| 73 | } |
| 74 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 75 | uint64_t |
| 76 | getNameLsaSeq() const |
| 77 | { |
| 78 | return m_nameLsaSeq; |
| 79 | } |
| 80 | |
| 81 | void |
| 82 | setNameLsaSeq(uint64_t nlsn) |
| 83 | { |
| 84 | m_nameLsaSeq = nlsn; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | uint64_t |
| 88 | getAdjLsaSeq() const |
| 89 | { |
| 90 | return m_adjLsaSeq; |
| 91 | } |
| 92 | |
| 93 | void |
| 94 | setAdjLsaSeq(uint64_t alsn) |
| 95 | { |
| 96 | m_adjLsaSeq = alsn; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | uint64_t |
| 100 | getCorLsaSeq() const |
| 101 | { |
| 102 | return m_corLsaSeq; |
| 103 | } |
| 104 | |
| 105 | void |
| 106 | setCorLsaSeq(uint64_t clsn) |
| 107 | { |
| 108 | m_corLsaSeq = clsn; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 109 | } |
| 110 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 111 | void |
| 112 | increaseNameLsaSeq() |
| 113 | { |
| 114 | m_nameLsaSeq++; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | void |
| 118 | increaseAdjLsaSeq() |
| 119 | { |
| 120 | m_adjLsaSeq++; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | void |
| 124 | increaseCorLsaSeq() |
| 125 | { |
| 126 | m_corLsaSeq++; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | void |
Vince Lehman | 0bcf9a3 | 2014-12-10 11:24:45 -0600 | [diff] [blame] | 130 | writeSeqNoToFile() const; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 131 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 132 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 133 | void |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 134 | initiateSeqNoFromFile(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 135 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 136 | private: |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 137 | /*! \brief Set the sequence file directory |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 138 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 139 | If the string is empty, home directory is set as sequence file directory |
| 140 | |
| 141 | \param filePath The directory where sequence file will be stored |
| 142 | */ |
| 143 | void |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 144 | setSeqFileDirectory(const std::string& filePath); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 145 | |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 146 | void |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 147 | writeLog() const; |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 148 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 149 | private: |
Ashlesh Gawande | 55d1b5c | 2019-12-19 16:21:58 -0600 | [diff] [blame] | 150 | uint64_t m_nameLsaSeq = 0; |
| 151 | uint64_t m_adjLsaSeq = 0; |
| 152 | uint64_t m_corLsaSeq = 0; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 153 | std::string m_seqFileNameWithPath; |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 154 | |
| 155 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 156 | int m_hyperbolicState; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 157 | }; |
| 158 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 159 | } // namespace nlsr |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 160 | #endif // NLSR_SEQUENCING_MANAGER_HPP |