Indentation
diff --git a/src/nlsr_im.cpp b/src/nlsr_im.cpp
index 4e77f39..29c0fcd 100644
--- a/src/nlsr_im.cpp
+++ b/src/nlsr_im.cpp
@@ -9,150 +9,154 @@
#include "nlsr_tokenizer.hpp"
#include "nlsr_lsdb.hpp"
-namespace nlsr {
-
-using namespace std;
-using namespace ndn;
-
-void
-interestManager::processInterest( Nlsr& pnlsr,
- const ndn::Name &name,
- const ndn::Interest &interest)
+namespace nlsr
{
- cout << "<< I: " << interest << endl;
- string intName=interest.getName().toUri();
- cout << "Interest Received for Name: "<< intName <<endl;
- nlsrTokenizer nt(intName,"/");
- string chkString("info");
- if( nt.doesTokenExist(chkString) ){
- string nbr=nt.getTokenString(nt.getTokenPosition(chkString)+1);
- cout <<"Neighbor: " << nbr <<endl;
- processInterestInfo(pnlsr,nbr,interest);
- }
-
- //Data data(ndn::Name(interest->getName()).append("testApp").appendVersion());
- //data.setFreshnessPeriod(1000); // 10 sec
- //data.setContent((const uint8_t*)"HELLO KITTY", sizeof("HELLO KITTY"));
- //pnlsr.getKeyChain().sign(data);
- //cout << ">> D: " << data << endl;
- //pnlsr.getNlsrFace().put(data);
-}
+ using namespace std;
+ using namespace ndn;
-void
-interestManager::processInterestInfo(Nlsr& pnlsr, string& neighbor,
- const ndn::Interest &interest)
-{
- if ( pnlsr.getAdl().isNeighbor(neighbor) )
- {
- Data data(ndn::Name(interest.getName()).appendVersion());
- data.setFreshnessPeriod(1000); // 10 sec
- data.setContent((const uint8_t*)"info", sizeof("info"));
- pnlsr.getKeyChain().sign(data);
- cout << ">> D: " << data << endl;
- pnlsr.getNlsrFace().put(data);
+ void
+ interestManager::processInterest( Nlsr& pnlsr,
+ const ndn::Name &name,
+ const ndn::Interest &interest)
+ {
- int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
- if ( status == 0 )
- {
- string intName=neighbor +"/"+"info"+
- pnlsr.getConfParameter().getRouterPrefix();
- expressInterest( pnlsr,intName,2,
- pnlsr.getConfParameter().getInterestResendTime());
- }
- }
-}
+ cout << "<< I: " << interest << endl;
+ string intName=interest.getName().toUri();
+ cout << "Interest Received for Name: "<< intName <<endl;
+ nlsrTokenizer nt(intName,"/");
+ string chkString("info");
+ if( nt.doesTokenExist(chkString) )
+ {
+ string nbr=nt.getTokenString(nt.getTokenPosition(chkString)+1);
+ cout <<"Neighbor: " << nbr <<endl;
+ processInterestInfo(pnlsr,nbr,interest);
+ }
-void
-interestManager::processInterestTimedOut(Nlsr& pnlsr,
- const ndn::Interest &interest)
-{
- cout << "Timed out interest : " << interest.getName().toUri() << endl;
- string intName= interest.getName().toUri();
- nlsrTokenizer nt(intName,"/");
- string chkString("info");
- if( nt.doesTokenExist(chkString) ){
- string nbr="/" + nt.getFirstToken()
- +nt.getTokenString(0,nt.getTokenPosition(chkString)-1);
- processInterestTimedOutInfo( pnlsr , nbr , interest);
- }
+ //Data data(ndn::Name(interest->getName()).append("testApp").appendVersion());
+ //data.setFreshnessPeriod(1000); // 10 sec
+ //data.setContent((const uint8_t*)"HELLO KITTY", sizeof("HELLO KITTY"));
+ //pnlsr.getKeyChain().sign(data);
+ //cout << ">> D: " << data << endl;
+ //pnlsr.getNlsrFace().put(data);
+ }
-}
+ void
+ interestManager::processInterestInfo(Nlsr& pnlsr, string& neighbor,
+ const ndn::Interest &interest)
+ {
+ if ( pnlsr.getAdl().isNeighbor(neighbor) )
+ {
+ Data data(ndn::Name(interest.getName()).appendVersion());
+ data.setFreshnessPeriod(1000); // 10 sec
+ data.setContent((const uint8_t*)"info", sizeof("info"));
+ pnlsr.getKeyChain().sign(data);
+ cout << ">> D: " << data << endl;
+ pnlsr.getNlsrFace().put(data);
-void
-interestManager::processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
- const ndn::Interest &interest)
-{
- pnlsr.getAdl().incrementTimedOutInterestCount(neighbor);
- int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
- int infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
- cout<<"Neighbor: "<< neighbor << endl;
- cout<<"Status: "<< status << endl;
- cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
+ int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
+ if ( status == 0 )
+ {
+ string intName=neighbor +"/"+"info"+
+ pnlsr.getConfParameter().getRouterPrefix();
+ expressInterest( pnlsr,intName,2,
+ pnlsr.getConfParameter().getInterestResendTime());
+ }
+ }
+ }
- if((infoIntTimedOutCount < pnlsr.getConfParameter().getInterestRetryNumber()))
- {
- string intName=neighbor +"/"+"info"+
- pnlsr.getConfParameter().getRouterPrefix();
- expressInterest( pnlsr,intName,2,
- pnlsr.getConfParameter().getInterestResendTime());
- }
- else if ( (status == 1) &&
- (infoIntTimedOutCount == pnlsr.getConfParameter().getInterestRetryNumber()))
- {
- pnlsr.getAdl().setStatusOfNeighbor(neighbor,0);
- pnlsr.incrementAdjBuildCount();
- if ( pnlsr.getIsBuildAdjLsaSheduled() == 0 )
- {
- pnlsr.setIsBuildAdjLsaSheduled(1);
- // event here
- pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
- ndn::bind(&Lsdb::scheduledAdjLsaBuild,pnlsr.getLsdb(),
- boost::ref(pnlsr)));
- }
- }
-
-}
+ void
+ interestManager::processInterestTimedOut(Nlsr& pnlsr,
+ const ndn::Interest &interest)
+ {
+ cout << "Timed out interest : " << interest.getName().toUri() << endl;
+ string intName= interest.getName().toUri();
+ nlsrTokenizer nt(intName,"/");
+ string chkString("info");
+ if( nt.doesTokenExist(chkString) )
+ {
+ string nbr="/" + nt.getFirstToken()
+ +nt.getTokenString(0,nt.getTokenPosition(chkString)-1);
+ processInterestTimedOutInfo( pnlsr , nbr , interest);
+ }
-void
-interestManager::expressInterest(Nlsr& pnlsr,const string& interestNamePrefix,
- int scope, int seconds)
-{
- Interest i((ndn::Name(interestNamePrefix)));
- //i.setScope(scope);
- i.setInterestLifetime(seconds*1000);
- i.setMustBeFresh(true);
+ }
- pnlsr.getNlsrFace().expressInterest(i,
- ndn::func_lib::bind(&DataManager::processContent,
- &pnlsr.getDm(), boost::ref(pnlsr),_1, _2),
- ndn::func_lib::bind(&interestManager::processInterestTimedOut,
+ void
+ interestManager::processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
+ const ndn::Interest &interest)
+ {
+ pnlsr.getAdl().incrementTimedOutInterestCount(neighbor);
+ int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
+ int infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+ cout<<"Neighbor: "<< neighbor << endl;
+ cout<<"Status: "<< status << endl;
+ cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
+
+ if((infoIntTimedOutCount < pnlsr.getConfParameter().getInterestRetryNumber()))
+ {
+ string intName=neighbor +"/"+"info"+
+ pnlsr.getConfParameter().getRouterPrefix();
+ expressInterest( pnlsr,intName,2,
+ pnlsr.getConfParameter().getInterestResendTime());
+ }
+ else if ( (status == 1) &&
+ (infoIntTimedOutCount == pnlsr.getConfParameter().getInterestRetryNumber()))
+ {
+ pnlsr.getAdl().setStatusOfNeighbor(neighbor,0);
+ pnlsr.incrementAdjBuildCount();
+ if ( pnlsr.getIsBuildAdjLsaSheduled() == 0 )
+ {
+ pnlsr.setIsBuildAdjLsaSheduled(1);
+ // event here
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+ ndn::bind(&Lsdb::scheduledAdjLsaBuild,pnlsr.getLsdb(),
+ boost::ref(pnlsr)));
+ }
+ }
+
+ }
+
+ void
+ interestManager::expressInterest(Nlsr& pnlsr,const string& interestNamePrefix,
+ int scope, int seconds)
+ {
+ Interest i((ndn::Name(interestNamePrefix)));
+ //i.setScope(scope);
+ i.setInterestLifetime(seconds*1000);
+ i.setMustBeFresh(true);
+
+ pnlsr.getNlsrFace().expressInterest(i,
+ ndn::func_lib::bind(&DataManager::processContent,
+ &pnlsr.getDm(), boost::ref(pnlsr),_1, _2),
+ ndn::func_lib::bind(&interestManager::processInterestTimedOut,
this,boost::ref(pnlsr),_1));
-}
+ }
-void
-interestManager::sendScheduledInfoInterest(Nlsr& pnlsr, int seconds)
-{
- std::list<Adjacent> adjList=pnlsr.getAdl().getAdjList();
- for(std::list<Adjacent>::iterator it=adjList.begin(); it!=adjList.end();++it)
- {
- string adjName=(*it).getAdjacentName()+"/"+"info"+
- pnlsr.getConfParameter().getRouterPrefix();
- expressInterest( pnlsr,adjName,2,pnlsr.getConfParameter().getInterestResendTime());
- }
+ void
+ interestManager::sendScheduledInfoInterest(Nlsr& pnlsr, int seconds)
+ {
+ std::list<Adjacent> adjList=pnlsr.getAdl().getAdjList();
+ for(std::list<Adjacent>::iterator it=adjList.begin(); it!=adjList.end(); ++it)
+ {
+ string adjName=(*it).getAdjacentName()+"/"+"info"+
+ pnlsr.getConfParameter().getRouterPrefix();
+ expressInterest( pnlsr,adjName,2,
+ pnlsr.getConfParameter().getInterestResendTime());
+ }
- scheduleInfoInterest(pnlsr, pnlsr.getConfParameter().getInfoInterestInterval());
+ scheduleInfoInterest(pnlsr, pnlsr.getConfParameter().getInfoInterestInterval());
-}
+ }
-void
-interestManager::scheduleInfoInterest(Nlsr& pnlsr, int seconds)
-{
- EventId eid=pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
- ndn::bind(&interestManager::sendScheduledInfoInterest, this,
- boost::ref(pnlsr),seconds));
-}
+ void
+ interestManager::scheduleInfoInterest(Nlsr& pnlsr, int seconds)
+ {
+ EventId eid=pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
+ ndn::bind(&interestManager::sendScheduledInfoInterest, this,
+ boost::ref(pnlsr),seconds));
+ }
} //namespace nlsr