31 #include <boost/algorithm/string.hpp> 41 , m_hyperbolicState(hypState)
43 setSeqFileDirectory(filePath);
44 initiateSeqNoFromFile();
51 std::ofstream outputFile(m_seqFileNameWithPath.c_str());
52 std::ostringstream os;
53 os <<
"NameLsaSeq " << std::to_string(m_nameLsaSeq) <<
"\n" 54 <<
"AdjLsaSeq " << std::to_string(m_adjLsaSeq) <<
"\n" 55 <<
"CorLsaSeq " << std::to_string(m_corLsaSeq);
56 outputFile << os.str();
61 SequencingManager::initiateSeqNoFromFile()
64 std::ifstream inputFile(m_seqFileNameWithPath.c_str());
67 if (inputFile.good()) {
68 std::string lsaOrCombinedSeqNo;
73 inputFile >> lsaOrCombinedSeqNo >> seqNo;
76 inputFile >> lsaOrCombinedSeqNo >> seqNo;
79 inputFile >> lsaOrCombinedSeqNo >> seqNo;;
85 if (m_nameLsaSeq == 0 && m_adjLsaSeq == 0 && m_corLsaSeq == 0 &&
86 lsaOrCombinedSeqNo !=
"CorLsaSeq") {
87 NLSR_LOG_DEBUG(
"Old file had combined sequence number: " << lsaOrCombinedSeqNo);
88 std::istringstream iss(lsaOrCombinedSeqNo);
90 m_adjLsaSeq = (seqNo & 0xFFFFF);
91 m_corLsaSeq = ((seqNo >> 20) & 0xFFFFF);
92 m_nameLsaSeq = ((seqNo >> 40) & 0xFFFFFF);
101 if (m_corLsaSeq != 0) {
102 NLSR_LOG_WARN(
"This router was previously configured for hyperbolic" 103 <<
" routing without clearing the seq. no. file.");
111 if (m_adjLsaSeq != 0) {
112 NLSR_LOG_WARN(
"This router was previously configured for link-state" 113 <<
" routing without clearing the seq. no. file.");
123 SequencingManager::setSeqFileDirectory(
const std::string& filePath)
125 m_seqFileNameWithPath = filePath;
127 if (m_seqFileNameWithPath.empty()) {
128 std::string homeDirPath(getpwuid(getuid())->pw_dir);
129 if (homeDirPath.empty()) {
130 homeDirPath = getenv(
"HOME");
132 m_seqFileNameWithPath = homeDirPath;
134 m_seqFileNameWithPath = m_seqFileNameWithPath +
"/nlsrSeqNo.txt";
138 SequencingManager::writeLog()
const
#define NLSR_LOG_DEBUG(x)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
#define INIT_LOGGER(name)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void writeSeqNoToFile() const
SequencingManager(std::string filePath, int hypState)