src: ConfParameter variables should be consistent with their min and max values
refs: #2084 Change-Id: Iae71da80ae47fca44ec46f4a3f0d4d86c77e5094
This commit is contained in:
1 parent
c11cc20948
commit
5a45495e3e
3 files changed
+36
-19
No files matched your search
@@ -256,7 +256,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
|
||||
// lsa-refresh-time
|
||||
int32_t lsaRefreshTime = section.get<int32_t>("lsa-refresh-time", LSA_REFRESH_TIME_DEFAULT);
|
||||
uint32_t lsaRefreshTime = section.get<uint32_t>("lsa-refresh-time", LSA_REFRESH_TIME_DEFAULT);
|
||||
|
||||
if (lsaRefreshTime >= LSA_REFRESH_TIME_MIN && lsaRefreshTime <= LSA_REFRESH_TIME_MAX) {
|
||||
m_nlsr.getConfParameter().setLsaRefreshTime(lsaRefreshTime);
|
||||
@@ -270,7 +270,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
|
||||
// router-dead-interval
|
||||
int32_t routerDeadInterval = section.get<int32_t>("router-dead-interval", (2*lsaRefreshTime));
|
||||
uint32_t routerDeadInterval = section.get<uint32_t>("router-dead-interval", (2*lsaRefreshTime));
|
||||
|
||||
if (routerDeadInterval > m_nlsr.getConfParameter().getLsaRefreshTime()) {
|
||||
m_nlsr.getConfParameter().setRouterDeadInterval(routerDeadInterval);
|
||||
@@ -422,7 +422,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
}
|
||||
|
||||
// hello-timeout
|
||||
int timeOut = section.get<int>("hello-timeout", HELLO_TIMEOUT_DEFAULT);
|
||||
uint32_t timeOut = section.get<uint32_t>("hello-timeout", HELLO_TIMEOUT_DEFAULT);
|
||||
|
||||
if (timeOut >= HELLO_TIMEOUT_MIN && timeOut <= HELLO_TIMEOUT_MAX) {
|
||||
m_nlsr.getConfParameter().setInterestResendTime(timeOut);
|
||||
@@ -436,7 +436,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
}
|
||||
|
||||
// hello-interval
|
||||
int interval = section.get<int>("hello-interval", HELLO_INTERVAL_DEFAULT);
|
||||
uint32_t interval = section.get<uint32_t>("hello-interval", HELLO_INTERVAL_DEFAULT);
|
||||
|
||||
if (interval >= HELLO_INTERVAL_MIN && interval <= HELLO_INTERVAL_MAX) {
|
||||
m_nlsr.getConfParameter().setInfoInterestInterval(interval);
|
||||
|
||||
+12
-12
@@ -188,12 +188,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setLsaRefreshTime(int32_t lrt)
|
||||
setLsaRefreshTime(uint32_t lrt)
|
||||
{
|
||||
m_lsaRefreshTime = lrt;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getLsaRefreshTime() const
|
||||
{
|
||||
return m_lsaRefreshTime;
|
||||
@@ -248,12 +248,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setRouterDeadInterval(int32_t rdt)
|
||||
setRouterDeadInterval(uint32_t rdt)
|
||||
{
|
||||
m_routerDeadInterval = rdt;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getRouterDeadInterval() const
|
||||
{
|
||||
return m_routerDeadInterval;
|
||||
@@ -284,25 +284,25 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setInterestResendTime(int32_t irt)
|
||||
setInterestResendTime(uint32_t irt)
|
||||
{
|
||||
m_interestResendTime = irt;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getInterestResendTime() const
|
||||
{
|
||||
return m_interestResendTime;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getInfoInterestInterval() const
|
||||
{
|
||||
return m_infoInterestInterval;
|
||||
}
|
||||
|
||||
void
|
||||
setInfoInterestInterval(int32_t iii)
|
||||
setInfoInterestInterval(uint32_t iii)
|
||||
{
|
||||
m_infoInterestInterval = iii;
|
||||
}
|
||||
@@ -416,20 +416,20 @@ private:
|
||||
ndn::Name m_chronosyncPrefix;
|
||||
ndn::Name m_lsaPrefix;
|
||||
|
||||
int32_t m_lsaRefreshTime;
|
||||
uint32_t m_lsaRefreshTime;
|
||||
|
||||
uint32_t m_adjLsaBuildInterval;
|
||||
uint32_t m_firstHelloInterval;
|
||||
uint32_t m_routingCalcInterval;
|
||||
|
||||
ndn::time::seconds m_lsaInterestLifetime;
|
||||
int32_t m_routerDeadInterval;
|
||||
uint32_t m_routerDeadInterval;
|
||||
std::string m_logLevel;
|
||||
|
||||
uint32_t m_interestRetryNumber;
|
||||
int32_t m_interestResendTime;
|
||||
uint32_t m_interestResendTime;
|
||||
|
||||
int32_t m_infoInterestInterval;
|
||||
uint32_t m_infoInterestInterval;
|
||||
|
||||
int32_t m_hyperbolicState;
|
||||
double m_corR;
|
||||
|
||||
@@ -382,7 +382,7 @@ BOOST_AUTO_TEST_CASE(DefaultValuesGeneral)
|
||||
|
||||
ConfParameter& conf = nlsr.getConfParameter();
|
||||
|
||||
BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), static_cast<int32_t>(LSA_REFRESH_TIME_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), static_cast<uint32_t>(LSA_REFRESH_TIME_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(),
|
||||
static_cast<ndn::time::seconds>(LSA_INTEREST_LIFETIME_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), (2*conf.getLsaRefreshTime()));
|
||||
@@ -403,8 +403,8 @@ BOOST_AUTO_TEST_CASE(DefaultValuesNeighbors)
|
||||
ConfParameter& conf = nlsr.getConfParameter();
|
||||
|
||||
BOOST_CHECK_EQUAL(conf.getInterestRetryNumber(), static_cast<uint32_t>(HELLO_RETRIES_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getInterestResendTime(), static_cast<int32_t>(HELLO_TIMEOUT_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getInfoInterestInterval(), static_cast<int32_t>(HELLO_INTERVAL_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getInterestResendTime(), static_cast<uint32_t>(HELLO_TIMEOUT_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getInfoInterestInterval(), static_cast<uint32_t>(HELLO_INTERVAL_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getFirstHelloInterval(),
|
||||
static_cast<uint32_t>(FIRST_HELLO_INTERVAL_DEFAULT));
|
||||
BOOST_CHECK_EQUAL(conf.getAdjLsaBuildInterval(),
|
||||
@@ -454,6 +454,23 @@ BOOST_AUTO_TEST_CASE(OutOfRangeValue)
|
||||
BOOST_CHECK_EQUAL(processConfigurationString(SECTION_FIB_OUT_OF_RANGE), false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NegativeValue)
|
||||
{
|
||||
const std::string SECTION_GENERAL_NEGATIVE_VALUE =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" network /ndn/\n"
|
||||
" site /memphis.edu/\n"
|
||||
" router /cs/pollux/\n"
|
||||
" lsa-refresh-time -1800\n"
|
||||
" lsa-interest-lifetime -3\n"
|
||||
" router-dead-interval -86400\n"
|
||||
"}\n\n";
|
||||
|
||||
// Processing should fail due to negative value
|
||||
BOOST_CHECK_EQUAL(processConfigurationString(SECTION_GENERAL_NEGATIVE_VALUE), false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} //namespace test
|
||||
|
||||
Reference in new issue
Block a user