31 #include <boost/algorithm/string.hpp> 41 std::ofstream outputFile(m_seqFileNameWithPath.c_str());
42 std::ostringstream os;
43 os <<
"NameLsaSeq " << std::to_string(m_nameLsaSeq) <<
"\n" 44 <<
"AdjLsaSeq " << std::to_string(m_adjLsaSeq) <<
"\n" 45 <<
"CorLsaSeq " << std::to_string(m_corLsaSeq);
46 outputFile << os.str();
54 std::ifstream inputFile(m_seqFileNameWithPath.c_str());
57 if (inputFile.good()) {
58 std::string lsaOrCombinedSeqNo;
63 inputFile >> lsaOrCombinedSeqNo >> seqNo;
66 inputFile >> lsaOrCombinedSeqNo >> seqNo;
69 inputFile >> lsaOrCombinedSeqNo >> seqNo;;
75 if (m_nameLsaSeq == 0 && m_adjLsaSeq == 0 && m_corLsaSeq == 0 &&
76 lsaOrCombinedSeqNo !=
"CorLsaSeq") {
77 NLSR_LOG_DEBUG(
"Old file had combined sequence number: " << lsaOrCombinedSeqNo);
78 std::istringstream iss(lsaOrCombinedSeqNo);
80 m_adjLsaSeq = (seqNo & 0xFFFFF);
81 m_corLsaSeq = ((seqNo >> 20) & 0xFFFFF);
82 m_nameLsaSeq = ((seqNo >> 40) & 0xFFFFFF);
91 if (m_corLsaSeq != 0) {
92 NLSR_LOG_WARN(
"This router was previously configured for hyperbolic" 93 <<
" routing without clearing the seq. no. file.");
101 if (m_adjLsaSeq != 0) {
102 NLSR_LOG_WARN(
"This router was previously configured for link-state" 103 <<
" routing without clearing the seq. no. file.");
115 m_seqFileNameWithPath = filePath;
117 if (m_seqFileNameWithPath.empty()) {
118 std::string homeDirPath(getpwuid(getuid())->pw_dir);
119 if (homeDirPath.empty()) {
120 homeDirPath = getenv(
"HOME");
122 m_seqFileNameWithPath = homeDirPath;
124 m_seqFileNameWithPath = m_seqFileNameWithPath +
"/nlsrSeqNo.txt";
#define NLSR_LOG_DEBUG(x)
void initiateSeqNoFromFile(int hypState)
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
void setSeqFileDirectory(std::string filePath)
Set the sequence file directory.