Loading...
Searching...
No Matches
sequencing-manager.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2021, 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_SEQUENCING_MANAGER_HPP
23#define NLSR_SEQUENCING_MANAGER_HPP
24
25#include "conf-parameter.hpp"
26#include "lsa/lsa.hpp"
28
29#include <ndn-cxx/face.hpp>
30
31#include <list>
32#include <string>
33
34namespace nlsr {
35
37{
38public:
39 SequencingManager(const std::string& filePath, int hypState);
40
41 void
42 setLsaSeq(uint64_t seqNo, Lsa::Type lsaType)
43 {
44 switch (lsaType) {
46 m_adjLsaSeq = seqNo;
47 break;
49 m_corLsaSeq = seqNo;
50 break;
51 case Lsa::Type::NAME:
52 m_nameLsaSeq = seqNo;
53 break;
54 default:
55 return;
56 }
57 }
58
59 uint64_t
61 {
62 switch (lsaType) {
64 return m_adjLsaSeq;
66 return m_corLsaSeq;
67 case Lsa::Type::NAME:
68 return m_nameLsaSeq;
69 default:
70 return 0;
71 }
72 }
73
74 uint64_t
76 {
77 return m_nameLsaSeq;
78 }
79
80 void
81 setNameLsaSeq(uint64_t nlsn)
82 {
83 m_nameLsaSeq = nlsn;
84 }
85
86 uint64_t
88 {
89 return m_adjLsaSeq;
90 }
91
92 void
93 setAdjLsaSeq(uint64_t alsn)
94 {
95 m_adjLsaSeq = alsn;
96 }
97
98 uint64_t
100 {
101 return m_corLsaSeq;
102 }
103
104 void
105 setCorLsaSeq(uint64_t clsn)
106 {
107 m_corLsaSeq = clsn;
108 }
109
110 void
112 {
113 m_nameLsaSeq++;
114 }
115
116 void
118 {
119 m_adjLsaSeq++;
120 }
121
122 void
124 {
125 m_corLsaSeq++;
126 }
127
128 void
129 writeSeqNoToFile() const;
130
132 void
133 initiateSeqNoFromFile();
134
135private:
142 void
143 setSeqFileDirectory(const std::string& filePath);
144
145 void
146 writeLog() const;
147
148private:
149 uint64_t m_nameLsaSeq = 0;
150 uint64_t m_adjLsaSeq = 0;
151 uint64_t m_corLsaSeq = 0;
152 std::string m_seqFileNameWithPath;
153
155 int m_hyperbolicState;
156};
157
158} // namespace nlsr
159#endif // NLSR_SEQUENCING_MANAGER_HPP
uint64_t getLsaSeq(Lsa::Type lsaType)
void setNameLsaSeq(uint64_t nlsn)
void setLsaSeq(uint64_t seqNo, Lsa::Type lsaType)
void setCorLsaSeq(uint64_t clsn)
void setAdjLsaSeq(uint64_t alsn)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE