src: Discard usage of std::pair of reference type and rename functions
Refs: #1531
Change-Id: Ief2a525b8fb8addbd491d202d6b02d5db2b41ea4
diff --git a/src/communication/data-manager.cpp b/src/communication/data-manager.cpp
index e4cefe5..bcae456 100644
--- a/src/communication/data-manager.cpp
+++ b/src/communication/data-manager.cpp
@@ -17,7 +17,7 @@
using namespace ndn;
void
-DataManager::processContent(Nlsr& pnlsr, const ndn::Interest& interest,
+DataManager::processContent(const ndn::Interest& interest,
const ndn::Data& data, InterestManager& im)
{
std::cout << "I: " << interest.toUri() << std::endl;
@@ -26,24 +26,24 @@
std::string chkString("keys");
if (nt.doesTokenExist(chkString))
{
- processContentKeys(pnlsr, data);
+ processContentKeys(data);
}
else
{
- if (pnlsr.getKeyManager().verify(data))
+ if (m_nlsr.getKeyManager().verify(data))
{
std::cout << "Verified Data Content" << std::endl;
chkString = "info";
if (nt.doesTokenExist(chkString))
{
string dataContent((char*)data.getContent().value());
- processContentInfo(pnlsr, dataName, dataContent);
+ processContentInfo(dataName, dataContent);
}
chkString = "LSA";
if (nt.doesTokenExist(chkString))
{
string dataContent((char*)data.getContent().value());
- processContentLsa(pnlsr, dataName, dataContent);
+ processContentLsa(dataName, dataContent);
}
}
else
@@ -54,24 +54,24 @@
}
void
-DataManager::processContentInfo(Nlsr& pnlsr, string& dataName,
+DataManager::processContentInfo(const string& dataName,
string& dataContent)
{
Tokenizer nt(dataName, "/");
string chkString("info");
string neighbor = nt.getTokenString(0, nt.getTokenPosition(chkString) - 1);
- int oldStatus = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
- int infoIntTimedOutCount = pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+ int oldStatus = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
+ int infoIntTimedOutCount = m_nlsr.getAdl().getTimedOutInterestCount(neighbor);
//debugging purpose start
std::cout << "Before Updates: " << std::endl;
std::cout << "Neighbor : " << neighbor << std::endl;
std::cout << "Status: " << oldStatus << std::endl;
std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
//debugging purpose end
- pnlsr.getAdl().setStatusOfNeighbor(neighbor, 1);
- pnlsr.getAdl().setTimedOutInterestCount(neighbor, 0);
- int newStatus = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
- infoIntTimedOutCount = pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+ m_nlsr.getAdl().setStatusOfNeighbor(neighbor, 1);
+ m_nlsr.getAdl().setTimedOutInterestCount(neighbor, 0);
+ int newStatus = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
+ infoIntTimedOutCount = m_nlsr.getAdl().getTimedOutInterestCount(neighbor);
//debugging purpose
std::cout << "After Updates: " << std::endl;
std::cout << "Neighbor : " << neighbor << std::endl;
@@ -80,22 +80,21 @@
//debugging purpose end
if ((oldStatus - newStatus) != 0) // change in Adjacency list
{
- pnlsr.incrementAdjBuildCount();
+ m_nlsr.incrementAdjBuildCount();
/* Need to schedule event for Adjacency LSA building */
- if (pnlsr.getIsBuildAdjLsaSheduled() == 0)
+ 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
-DataManager::processContentLsa(Nlsr& pnlsr, string& dataName,
- string& dataContent)
+DataManager::processContentLsa(const string& dataName, string& dataContent)
{
Tokenizer nt(dataName, "/");
string chkString("LSA");
@@ -114,17 +113,17 @@
}
if (lsTypeString == "1") //Name Lsa
{
- processContentNameLsa(pnlsr, origRouter + "/" + lsTypeString,
+ processContentNameLsa(origRouter + "/" + lsTypeString,
interestedLsSeqNo, dataContent);
}
else if (lsTypeString == "2") //Adj Lsa
{
- processContentAdjLsa(pnlsr, origRouter + "/" + lsTypeString,
+ processContentAdjLsa(origRouter + "/" + lsTypeString,
interestedLsSeqNo, dataContent);
}
else if (lsTypeString == "3") //Cor Lsa
{
- processContentCorLsa(pnlsr, origRouter + "/" + lsTypeString,
+ processContentCorLsa(origRouter + "/" + lsTypeString,
interestedLsSeqNo, dataContent);
}
else
@@ -134,15 +133,15 @@
}
void
-DataManager::processContentNameLsa(Nlsr& pnlsr, string lsaKey,
+DataManager::processContentNameLsa(const string& lsaKey,
uint32_t lsSeqNo, string& dataContent)
{
- if (pnlsr.getLsdb().isNameLsaNew(lsaKey, lsSeqNo))
+ if (m_nlsr.getLsdb().isNameLsaNew(lsaKey, lsSeqNo))
{
NameLsa nameLsa;
if (nameLsa.initializeFromContent(dataContent))
{
- pnlsr.getLsdb().installNameLsa(pnlsr, nameLsa);
+ m_nlsr.getLsdb().installNameLsa(m_nlsr, nameLsa);
}
else
{
@@ -152,15 +151,15 @@
}
void
-DataManager::processContentAdjLsa(Nlsr& pnlsr, string lsaKey,
+DataManager::processContentAdjLsa(const string& lsaKey,
uint32_t lsSeqNo, string& dataContent)
{
- if (pnlsr.getLsdb().isAdjLsaNew(lsaKey, lsSeqNo))
+ if (m_nlsr.getLsdb().isAdjLsaNew(lsaKey, lsSeqNo))
{
AdjLsa adjLsa;
if (adjLsa.initializeFromContent(dataContent))
{
- pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
+ m_nlsr.getLsdb().installAdjLsa(m_nlsr, adjLsa);
}
else
{
@@ -170,15 +169,15 @@
}
void
-DataManager::processContentCorLsa(Nlsr& pnlsr, string lsaKey,
+DataManager::processContentCorLsa(const string& lsaKey,
uint32_t lsSeqNo, string& dataContent)
{
- if (pnlsr.getLsdb().isCorLsaNew(lsaKey, lsSeqNo))
+ if (m_nlsr.getLsdb().isCoordinateLsaNew(lsaKey, lsSeqNo))
{
- CorLsa corLsa;
+ CoordinateLsa corLsa;
if (corLsa.initializeFromContent(dataContent))
{
- pnlsr.getLsdb().installCorLsa(pnlsr, corLsa);
+ m_nlsr.getLsdb().installCoordinateLsa(m_nlsr, corLsa);
}
else
{
@@ -188,7 +187,7 @@
}
void
-DataManager::processContentKeys(Nlsr& pnlsr, const ndn::Data& data)
+DataManager::processContentKeys(const ndn::Data& data)
{
std::cout << " processContentKeys called " << std::endl;
ndn::shared_ptr<ndn::IdentityCertificate> cert =
@@ -201,15 +200,14 @@
uint32_t seqNum = boost::lexical_cast<uint32_t>(nt.getToken(
nt.getTokenNumber() - 2));
std::cout << "Cert Name: " << certName << " Seq Num: " << seqNum << std::endl;
- if (pnlsr.getKeyManager().verify(pnlsr, *(cert)))
+ if (m_nlsr.getKeyManager().verify(m_nlsr, *(cert)))
{
- pnlsr.getKeyManager().addCertificate(cert, seqNum, true);
+ m_nlsr.getKeyManager().addCertificate(cert, seqNum, true);
}
else
{
- pnlsr.getKeyManager().addCertificate(cert, seqNum, false);
+ m_nlsr.getKeyManager().addCertificate(cert, seqNum, false);
}
-
- pnlsr.getKeyManager().printCertStore();
+ m_nlsr.getKeyManager().printCertStore();
}
}//namespace nlsr
diff --git a/src/communication/data-manager.hpp b/src/communication/data-manager.hpp
index 153e0a0..ece3fca 100644
--- a/src/communication/data-manager.hpp
+++ b/src/communication/data-manager.hpp
@@ -13,32 +13,37 @@
class DataManager
{
public:
+ DataManager(Nlsr& nlsr)
+ : m_nlsr(nlsr)
+ {}
void
- processContent(Nlsr& pnlsr, const ndn::Interest& interest,
+ processContent(const ndn::Interest& interest,
const ndn::Data& data, InterestManager& im);
private:
void
- processContentInfo(Nlsr& pnlsr, std::string& dataName,
+ processContentInfo(const std::string& dataName,
std::string& dataContent);
void
- processContentLsa(Nlsr& pnlsr, std::string& dataName,
- std::string& dataContent);
+ processContentLsa(const std::string& dataName, std::string& dataContent);
void
- processContentNameLsa(Nlsr& pnlsr, std::string lsaKey,
+ processContentNameLsa(const std::string& lsaKey,
uint32_t lsSeqNo, std::string& dataContent);
void
- processContentAdjLsa(Nlsr& pnlsr, std::string lsaKey,
+ processContentAdjLsa(const std::string& lsaKey,
uint32_t lsSeqNo, std::string& dataContent);
void
- processContentCorLsa(Nlsr& pnlsr, std::string lsaKey,
+ processContentCorLsa(const std::string& lsaKey,
uint32_t lsSeqNo, std::string& dataContent);
void
- processContentKeys(Nlsr& pnlsr, const ndn::Data& data);
+ processContentKeys(const ndn::Data& data);
+
+private:
+ Nlsr& m_nlsr;
};
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));
}
diff --git a/src/communication/interest-manager.hpp b/src/communication/interest-manager.hpp
index 5975e7f..86d590b 100644
--- a/src/communication/interest-manager.hpp
+++ b/src/communication/interest-manager.hpp
@@ -12,57 +12,55 @@
class InterestManager
{
public:
- InterestManager()
+ InterestManager(Nlsr& nlsr)
+ : m_nlsr(nlsr)
{
}
void
- processInterest(Nlsr& pnlsr, const ndn::Name& name,
- const ndn::Interest& interest);
+ processInterest(const ndn::Name& name, const ndn::Interest& interest);
void
- processInterestInfo(Nlsr& pnlsr, std::string& neighbor,
- const ndn::Interest& interest);
+ processInterestInfo(const std::string& neighbor, const ndn::Interest& interest);
void
- processInterestLsa(Nlsr& pnlsr, const ndn::Interest& interest);
+ processInterestLsa(const ndn::Interest& interest);
void
- processInterestForNameLsa(Nlsr& pnlsr, const ndn::Interest& interest,
- std::string lsaKey, uint32_t interestedlsSeqNo);
+ processInterestForNameLsa(const ndn::Interest& interest,
+ const std::string& lsaKey, uint32_t interestedlsSeqNo);
void
- processInterestForAdjLsa(Nlsr& pnlsr, const ndn::Interest& interest,
- std::string lsaKey, uint32_t interestedlsSeqNo);
+ processInterestForAdjLsa(const ndn::Interest& interest,
+ const std::string& lsaKey, uint32_t interestedlsSeqNo);
void
- processInterestForCorLsa(Nlsr& pnlsr, const ndn::Interest& interest,
- std::string lsaKey, uint32_t interestedlsSeqNo);
+ processInterestForCorLsa(const ndn::Interest& interest,
+ const std::string& lsaKey, uint32_t interestedlsSeqNo);
void
- processInterestKeys(Nlsr& pnlsr, const ndn::Interest& interest);
+ processInterestKeys(const ndn::Interest& interest);
void
- processInterestTimedOut(Nlsr& pnlsr, const ndn::Interest& interest);
+ processInterestTimedOut(const ndn::Interest& interest);
void
- processInterestTimedOutInfo(Nlsr& pnlsr, std::string& neighbor,
+ processInterestTimedOutInfo(const std::string& neighbor,
const ndn::Interest& interest);
void
- processInterestTimedOutLsa(Nlsr& pnlsr, const ndn::Interest& interest);
+ processInterestTimedOutLsa(const ndn::Interest& interest);
void
- expressInterest(Nlsr& pnlsr,
- const std::string& interestNamePrefix, int scope, int seconds);
+ expressInterest(const std::string& interestNamePrefix, int scope, int seconds);
void
- sendScheduledInfoInterest(Nlsr& pnlsr, int seconds);
+ sendScheduledInfoInterest(int seconds);
void
- scheduleInfoInterest(Nlsr& pnlsr, int seconds);
+ scheduleInfoInterest(int seconds);
private:
-
+ Nlsr& m_nlsr;
};
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index a38fe98..696f06a 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -81,7 +81,7 @@
pnlsr.getConfParameter().getChronosyncLsaPrefix() +
routerName + "/1/" +
boost::lexical_cast<std::string>(sm.getNameLsaSeq());
- pnlsr.getIm().expressInterest(pnlsr, lsaPrefix, 3,
+ pnlsr.getIm().expressInterest(lsaPrefix, 3,
pnlsr.getConfParameter().getInterestResendTime());
}
if (pnlsr.getLsdb().isAdjLsaNew(routerName + "/2", sm.getAdjLsaSeq()))
@@ -91,17 +91,17 @@
pnlsr.getConfParameter().getChronosyncLsaPrefix() +
routerName + "/2/" +
boost::lexical_cast<std::string>(sm.getAdjLsaSeq());
- pnlsr.getIm().expressInterest(pnlsr, lsaPrefix, 3,
+ pnlsr.getIm().expressInterest(lsaPrefix, 3,
pnlsr.getConfParameter().getInterestResendTime());
}
- if (pnlsr.getLsdb().isCorLsaNew(routerName + "/3", sm.getCorLsaSeq()))
+ if (pnlsr.getLsdb().isCoordinateLsaNew(routerName + "/3", sm.getCorLsaSeq()))
{
std::cout << "Updated Cor LSA. Need to fetch it" << std::endl;
string lsaPrefix =
pnlsr.getConfParameter().getChronosyncLsaPrefix() +
routerName + "/3/" +
boost::lexical_cast<std::string>(sm.getCorLsaSeq());
- pnlsr.getIm().expressInterest(pnlsr, lsaPrefix, 3,
+ pnlsr.getIm().expressInterest(lsaPrefix, 3,
pnlsr.getConfParameter().getInterestResendTime());
}
}
@@ -116,7 +116,7 @@
{
string certNamePrefix = certName + "/" +
boost::lexical_cast<string>(seqNo);
- pnlsr.getIm().expressInterest(pnlsr, certNamePrefix, 3,
+ pnlsr.getIm().expressInterest(certNamePrefix, 3,
pnlsr.getConfParameter().getInterestResendTime());
}
}