src: Discard usage of std::pair of reference type and rename functions
Refs: #1531
Change-Id: Ief2a525b8fb8addbd491d202d6b02d5db2b41ea4
diff --git a/src/communication/interest-manager.cpp b/src/communication/interest-manager.cpp
index 73a43e9..226efaf 100644
--- a/src/communication/interest-manager.cpp
+++ b/src/communication/interest-manager.cpp
@@ -17,8 +17,7 @@
using namespace ndn;
void
-InterestManager::processInterest(Nlsr& pnlsr,
- const ndn::Name& name,
+InterestManager::processInterest(const ndn::Name& name,
const ndn::Interest& interest)
{
cout << "<< I: " << interest << endl;
@@ -30,45 +29,45 @@
{
string nbr = nt.getTokenString(nt.getTokenPosition(chkString) + 1);
cout << "Neighbor: " << nbr << endl;
- processInterestInfo(pnlsr, nbr, interest);
+ processInterestInfo(nbr, interest);
}
chkString = "LSA";
if (nt.doesTokenExist(chkString))
{
- processInterestLsa(pnlsr, interest);
+ processInterestLsa(interest);
}
chkString = "keys";
if (nt.doesTokenExist(chkString))
{
- processInterestKeys(pnlsr, interest);
+ processInterestKeys(interest);
}
}
void
-InterestManager::processInterestInfo(Nlsr& pnlsr, string& neighbor,
+InterestManager::processInterestInfo(const string& neighbor,
const ndn::Interest& interest)
{
- if (pnlsr.getAdl().isNeighbor(neighbor))
+ if (m_nlsr.getAdl().isNeighbor(neighbor))
{
Data data(ndn::Name(interest.getName()).appendVersion());
data.setFreshnessPeriod(time::seconds(10)); // 10 sec
data.setContent((const uint8_t*)"info", sizeof("info"));
- pnlsr.getKeyManager().signData(data);
+ m_nlsr.getKeyManager().signData(data);
cout << ">> D: " << data << endl;
- pnlsr.getNlsrFace()->put(data);
- int status = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
+ m_nlsr.getNlsrFace()->put(data);
+ int status = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
if (status == 0)
{
string intName = neighbor + "/" + "info" +
- pnlsr.getConfParameter().getRouterPrefix();
- expressInterest(pnlsr, intName, 2,
- pnlsr.getConfParameter().getInterestResendTime());
+ m_nlsr.getConfParameter().getRouterPrefix();
+ expressInterest(intName, 2,
+ m_nlsr.getConfParameter().getInterestResendTime());
}
}
}
void
-InterestManager::processInterestLsa(Nlsr& pnlsr, const ndn::Interest& interest)
+InterestManager::processInterestLsa(const ndn::Interest& interest)
{
string intName = interest.getName().toUri();
Tokenizer nt(intName, "/");
@@ -94,17 +93,17 @@
std::cout << "Ls Type: " << interestedLsType << std::endl;
if (lsTypeString == "1") //Name Lsa
{
- processInterestForNameLsa(pnlsr, interest,
+ processInterestForNameLsa(interest,
origRouter + "/" + lsTypeString, interestedLsSeqNo);
}
else if (lsTypeString == "2") //Adj Lsa
{
- processInterestForAdjLsa(pnlsr, interest,
+ processInterestForAdjLsa(interest,
origRouter + "/" + lsTypeString, interestedLsSeqNo);
}
else if (lsTypeString == "3") //Cor Lsa
{
- processInterestForCorLsa(pnlsr, interest,
+ processInterestForCorLsa(interest,
origRouter + "/" + lsTypeString, interestedLsSeqNo);
}
else
@@ -114,70 +113,67 @@
}
void
-InterestManager::processInterestForNameLsa(Nlsr& pnlsr,
- const ndn::Interest& interest,
- string lsaKey, uint32_t interestedlsSeqNo)
+InterestManager::processInterestForNameLsa(const ndn::Interest& interest,
+ const string& lsaKey, uint32_t interestedlsSeqNo)
{
- std::pair<NameLsa&, bool> nameLsa = pnlsr.getLsdb().getNameLsa(lsaKey);
- if (nameLsa.second)
+ NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
+ if (nameLsa != 0)
{
- if (nameLsa.first.getLsSeqNo() >= interestedlsSeqNo)
+ if (nameLsa->getLsSeqNo() >= interestedlsSeqNo)
{
Data data(ndn::Name(interest.getName()).appendVersion());
data.setFreshnessPeriod(time::seconds(10)); // 10 sec
- string content = nameLsa.first.getData();
+ string content = nameLsa->getData();
data.setContent((const uint8_t*)content.c_str(), content.size());
- pnlsr.getKeyManager().signData(data);
+ m_nlsr.getKeyManager().signData(data);
std::cout << ">> D: " << data << std::endl;
- pnlsr.getNlsrFace()->put(data);
+ m_nlsr.getNlsrFace()->put(data);
}
}
}
void
-InterestManager::processInterestForAdjLsa(Nlsr& pnlsr,
- const ndn::Interest& interest,
- string lsaKey, uint32_t interestedlsSeqNo)
+InterestManager::processInterestForAdjLsa(const ndn::Interest& interest,
+ const string& lsaKey, uint32_t interestedlsSeqNo)
{
- std::pair<AdjLsa&, bool> adjLsa = pnlsr.getLsdb().getAdjLsa(lsaKey);
- if (adjLsa.second)
+ AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
+ if (adjLsa != 0)
{
- if (adjLsa.first.getLsSeqNo() >= interestedlsSeqNo)
+ if (adjLsa->getLsSeqNo() >= interestedlsSeqNo)
{
Data data(ndn::Name(interest.getName()).appendVersion());
data.setFreshnessPeriod(time::seconds(10)); // 10 sec
- string content = adjLsa.first.getData();
+ string content = adjLsa->getData();
data.setContent((const uint8_t*)content.c_str(), content.size());
- pnlsr.getKeyManager().signData(data);
+ m_nlsr.getKeyManager().signData(data);
std::cout << ">> D: " << data << std::endl;
- pnlsr.getNlsrFace()->put(data);
+ m_nlsr.getNlsrFace()->put(data);
}
}
}
void
-InterestManager::processInterestForCorLsa(Nlsr& pnlsr,
- const ndn::Interest& interest,
- string lsaKey, uint32_t interestedlsSeqNo)
+InterestManager::processInterestForCorLsa(const ndn::Interest& interest,
+ const string& lsaKey, uint32_t interestedlsSeqNo)
{
- std::pair<CorLsa&, bool> corLsa = pnlsr.getLsdb().getCorLsa(lsaKey);
- if (corLsa.second)
+ CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
+ if (corLsa != 0)
{
- if (corLsa.first.getLsSeqNo() >= interestedlsSeqNo)
+ if (corLsa->getLsSeqNo() >= interestedlsSeqNo)
{
Data data(ndn::Name(interest.getName()).appendVersion());
data.setFreshnessPeriod(time::seconds(10)); // 10 sec
- string content = corLsa.first.getData();
+ string content = corLsa->getData();
data.setContent((const uint8_t*)content.c_str(), content.size());
- pnlsr.getKeyManager().signData(data);
+ m_nlsr.getKeyManager().signData(data);
std::cout << ">> D: " << data << std::endl;
- pnlsr.getNlsrFace()->put(data);
+ m_nlsr.getNlsrFace()->put(data);
}
}
}
void
-InterestManager::processInterestKeys(Nlsr& pnlsr, const ndn::Interest& interest)
+InterestManager::processInterestKeys(const ndn::Interest& interest)
{
std::cout << "processInterestKeys called " << std::endl;
string intName = interest.getName().toUri();
@@ -192,14 +188,14 @@
{
certName = nt.getTokenString(0, nt.getTokenNumber() - 1);
cout << "Cert Name: " << certName << std::endl;
- chkCert = pnlsr.getKeyManager().getCertificateFromStore(certName);
+ chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName);
}
else
{
certName = nt.getTokenString(0, nt.getTokenNumber() - 2);
seqNum = boost::lexical_cast<uint32_t>(nt.getToken(nt.getTokenNumber() - 1));
std::cout << "Cert Name: " << certName << " Seq Num: " << seqNum << std::endl;
- chkCert = pnlsr.getKeyManager().getCertificateFromStore(certName, seqNum);
+ chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName, seqNum);
}
if (chkCert.second)
{
@@ -208,7 +204,7 @@
std::string dn;
dataName = ndn::Name(interest.getName()).appendVersion();
std::pair<uint32_t, bool> seqChk =
- pnlsr.getKeyManager().getCertificateSeqNum(certName);
+ m_nlsr.getKeyManager().getCertificateSeqNum(certName);
if (seqChk.second)
{
dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(seqChk.first);
@@ -219,7 +215,6 @@
dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(10);
dataName = ndn::Name(dn);
}
-
}
else
{
@@ -228,15 +223,14 @@
Data data(dataName.appendVersion());
data.setFreshnessPeriod(time::seconds(10)); //10 sec
data.setContent(chkCert.first->wireEncode());
- pnlsr.getKeyManager().signData(data);
- pnlsr.getNlsrFace()->put(data);
+ m_nlsr.getKeyManager().signData(data);
+ m_nlsr.getNlsrFace()->put(data);
}
}
void
-InterestManager::processInterestTimedOut(Nlsr& pnlsr,
- const ndn::Interest& interest)
+InterestManager::processInterestTimedOut(const ndn::Interest& interest)
{
std::cout << "Timed out interest : " << interest.getName().toUri() << std::endl;
string intName = interest.getName().toUri();
@@ -245,94 +239,92 @@
if (nt.doesTokenExist(chkString))
{
string nbr = nt.getTokenString(0, nt.getTokenPosition(chkString) - 1);
- processInterestTimedOutInfo(pnlsr , nbr , interest);
+ processInterestTimedOutInfo(nbr , interest);
}
chkString = "LSA";
if (nt.doesTokenExist(chkString))
{
- processInterestTimedOutLsa(pnlsr, interest);
+ processInterestTimedOutLsa(interest);
}
}
void
-InterestManager::processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
+InterestManager::processInterestTimedOutInfo(const string& neighbor,
const ndn::Interest& interest)
{
- pnlsr.getAdl().incrementTimedOutInterestCount(neighbor);
- int status = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
- int infoIntTimedOutCount = pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+ m_nlsr.getAdl().incrementTimedOutInterestCount(neighbor);
+ int status = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
+ int infoIntTimedOutCount = m_nlsr.getAdl().getTimedOutInterestCount(neighbor);
std::cout << "Neighbor: " << neighbor << std::endl;
std::cout << "Status: " << status << std::endl;
std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
- if ((infoIntTimedOutCount < pnlsr.getConfParameter().getInterestRetryNumber()))
+ if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber()))
{
string intName = neighbor + "/" + "info" +
- pnlsr.getConfParameter().getRouterPrefix();
- expressInterest(pnlsr, intName, 2,
- pnlsr.getConfParameter().getInterestResendTime());
+ m_nlsr.getConfParameter().getRouterPrefix();
+ expressInterest(intName, 2,
+ m_nlsr.getConfParameter().getInterestResendTime());
}
else if ((status == 1) &&
- (infoIntTimedOutCount == pnlsr.getConfParameter().getInterestRetryNumber()))
+ (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()))
{
- pnlsr.getAdl().setStatusOfNeighbor(neighbor, 0);
- pnlsr.incrementAdjBuildCount();
- if (pnlsr.getIsBuildAdjLsaSheduled() == 0)
+ m_nlsr.getAdl().setStatusOfNeighbor(neighbor, 0);
+ m_nlsr.incrementAdjBuildCount();
+ if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
{
- pnlsr.setIsBuildAdjLsaSheduled(1);
+ m_nlsr.setIsBuildAdjLsaSheduled(1);
// event here
- pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
- ndn::bind(&Lsdb::scheduledAdjLsaBuild,
- &pnlsr.getLsdb(),
- boost::ref(pnlsr)));
+ m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+ ndn::bind(&Lsdb::scheduledAdjLsaBuild,
+ &m_nlsr.getLsdb(),
+ boost::ref(m_nlsr)));
}
}
}
void
-InterestManager::processInterestTimedOutLsa(Nlsr& pnlsr,
- const ndn::Interest& interest)
+InterestManager::processInterestTimedOutLsa(const ndn::Interest& interest)
{
}
void
-InterestManager::expressInterest(Nlsr& pnlsr, const string& interestNamePrefix,
+InterestManager::expressInterest(const string& interestNamePrefix,
int scope, int seconds)
{
std::cout << "Expressing Interest :" << interestNamePrefix << std::endl;
ndn::Interest i((ndn::Name(interestNamePrefix)));
i.setInterestLifetime(time::seconds(seconds));
i.setMustBeFresh(true);
- pnlsr.getNlsrFace()->expressInterest(i,
- ndn::func_lib::bind(&DataManager::processContent,
- &pnlsr.getDm(),
- boost::ref(pnlsr), _1,
- _2, boost::ref(*this)),
- ndn::func_lib::bind(&InterestManager::processInterestTimedOut,
- this, boost::ref(pnlsr), _1));
+ m_nlsr.getNlsrFace()->expressInterest(i,
+ ndn::bind(&DataManager::processContent,
+ &m_nlsr.getDm(),
+ _1, _2, boost::ref(*this)),
+ ndn::bind(&InterestManager::processInterestTimedOut,
+ this, _1));
}
void
-InterestManager::sendScheduledInfoInterest(Nlsr& pnlsr, int seconds)
+InterestManager::sendScheduledInfoInterest(int seconds)
{
- std::list<Adjacent> adjList = pnlsr.getAdl().getAdjList();
+ std::list<Adjacent> adjList = m_nlsr.getAdl().getAdjList();
for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
++it)
{
string adjName = (*it).getName() + "/" + "info" +
- pnlsr.getConfParameter().getRouterPrefix();
- expressInterest(pnlsr, adjName, 2,
- pnlsr.getConfParameter().getInterestResendTime());
+ m_nlsr.getConfParameter().getRouterPrefix();
+ expressInterest(adjName, 2,
+ m_nlsr.getConfParameter().getInterestResendTime());
}
- scheduleInfoInterest(pnlsr, pnlsr.getConfParameter().getInfoInterestInterval());
+ scheduleInfoInterest(m_nlsr.getConfParameter().getInfoInterestInterval());
}
void
-InterestManager::scheduleInfoInterest(Nlsr& pnlsr, int seconds)
+InterestManager::scheduleInfoInterest(int seconds)
{
- EventId eid = pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
- ndn::bind(&InterestManager::sendScheduledInfoInterest, this,
- boost::ref(pnlsr), seconds));
+ EventId eid = m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
+ ndn::bind(&InterestManager::sendScheduledInfoInterest, this,
+ seconds));
}