sequencing-manager: remove support for old combined seq no file
refs: #4143
Change-Id: I3334ef136f75b18225828ebfba17f63c468708db
diff --git a/src/sequencing-manager.cpp b/src/sequencing-manager.cpp
index bae9e68..c7c6c7e 100644
--- a/src/sequencing-manager.cpp
+++ b/src/sequencing-manager.cpp
@@ -34,11 +34,8 @@
INIT_LOGGER(SequencingManager);
-SequencingManager::SequencingManager(std::string filePath, int hypState)
- : m_nameLsaSeq(0)
- , m_adjLsaSeq(0)
- , m_corLsaSeq(0)
- , m_hyperbolicState(hypState)
+SequencingManager::SequencingManager(const std::string& filePath, int hypState)
+ : m_hyperbolicState(hypState)
{
setSeqFileDirectory(filePath);
initiateSeqNoFromFile();
@@ -63,44 +60,24 @@
NLSR_LOG_DEBUG("Seq File Name: " << m_seqFileNameWithPath);
std::ifstream inputFile(m_seqFileNameWithPath.c_str());
+ std::string seqType;
// Good checks that file is not (bad or eof or fail)
if (inputFile.good()) {
- std::string lsaOrCombinedSeqNo;
- uint64_t seqNo = 0;
-
- // If file has a combined seq number, lsaOrCombinedSeqNo would hold it
- // and seqNo will be zero everytime
- inputFile >> lsaOrCombinedSeqNo >> seqNo;
- m_nameLsaSeq = seqNo;
-
- inputFile >> lsaOrCombinedSeqNo >> seqNo;
- m_adjLsaSeq = seqNo;
-
- inputFile >> lsaOrCombinedSeqNo >> seqNo;
- m_corLsaSeq = seqNo;
-
- // File was in old format and had a combined sequence number
- // if all of the seqNo should are still zero and
- // lsaOrCombinedSeqNo != CorLsaSeq
- if (m_nameLsaSeq == 0 && m_adjLsaSeq == 0 && m_corLsaSeq == 0 &&
- lsaOrCombinedSeqNo != "CorLsaSeq") {
- NLSR_LOG_DEBUG("Old file had combined sequence number: " << lsaOrCombinedSeqNo);
- std::istringstream iss(lsaOrCombinedSeqNo);
- iss >> seqNo;
- m_adjLsaSeq = (seqNo & 0xFFFFF);
- m_corLsaSeq = ((seqNo >> 20) & 0xFFFFF);
- m_nameLsaSeq = ((seqNo >> 40) & 0xFFFFFF);
- }
+ inputFile >> seqType >> m_nameLsaSeq;
+ inputFile >> seqType >> m_adjLsaSeq;
+ inputFile >> seqType >> m_corLsaSeq;
inputFile.close();
+ // Increment by 10 in case last run of NLSR was not able to write to file
+ // before crashing
m_nameLsaSeq += 10;
// Increment the adjacency LSA seq. no. if link-state or dry HR is enabled
if (m_hyperbolicState != HYPERBOLIC_STATE_ON) {
if (m_corLsaSeq != 0) {
- NLSR_LOG_WARN("This router was previously configured for hyperbolic"
- << " routing without clearing the seq. no. file.");
+ NLSR_LOG_WARN("This router was previously configured for hyperbolic " <<
+ "routing without clearing the seq. no. file.");
m_corLsaSeq = 0;
}
m_adjLsaSeq += 10;
@@ -109,8 +86,8 @@
// Similarly, increment the coordinate LSA seq. no only if link-state is disabled.
if (m_hyperbolicState != HYPERBOLIC_STATE_OFF) {
if (m_adjLsaSeq != 0) {
- NLSR_LOG_WARN("This router was previously configured for link-state"
- << " routing without clearing the seq. no. file.");
+ NLSR_LOG_WARN("This router was previously configured for link-state " <<
+ "routing without clearing the seq. no. file.");
m_adjLsaSeq = 0;
}
m_corLsaSeq += 10;
@@ -137,7 +114,6 @@
void
SequencingManager::writeLog() const
{
- NLSR_LOG_DEBUG("----SequencingManager----");
if (m_hyperbolicState == HYPERBOLIC_STATE_OFF ||
m_hyperbolicState == HYPERBOLIC_STATE_DRY_RUN) {
NLSR_LOG_DEBUG("Adj LSA seq no: " << m_adjLsaSeq);
diff --git a/src/sequencing-manager.hpp b/src/sequencing-manager.hpp
index 85e323b..307aab5 100644
--- a/src/sequencing-manager.hpp
+++ b/src/sequencing-manager.hpp
@@ -36,7 +36,7 @@
class SequencingManager
{
public:
- SequencingManager(std::string filePath, int hypState);
+ SequencingManager(const std::string& filePath, int hypState);
uint64_t
getNameLsaSeq() const
@@ -113,9 +113,9 @@
writeLog() const;
private:
- uint64_t m_nameLsaSeq;
- uint64_t m_adjLsaSeq;
- uint64_t m_corLsaSeq;
+ uint64_t m_nameLsaSeq = 0;
+ uint64_t m_adjLsaSeq = 0;
+ uint64_t m_corLsaSeq = 0;
std::string m_seqFileNameWithPath;
PUBLIC_WITH_TESTS_ELSE_PRIVATE: