Indentation Final
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 49886e0..fe4ba01 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -47,14 +47,12 @@
int
Nlsr::usage(const string& progname)
{
-
cout << "Usage: " << progname << " [OPTIONS...]"<<endl;
cout << " NDN routing...." << endl;
cout << " -d, --daemon Run in daemon mode" << endl;
cout << " -f, --config_file Specify configuration file name" <<endl;
cout << " -p, --api_port port where api client will connect" <<endl;
cout << " -h, --help Display this help message" << endl;
-
exit(EXIT_FAILURE);
}
@@ -69,7 +67,6 @@
nlsr::Nlsr nlsr_;
string programName(argv[0]);
nlsr_.setConfFileName("nlsr.conf");
-
int opt;
while ((opt = getopt(argc, argv, "df:p:h")) != -1)
{
@@ -95,15 +92,12 @@
return EXIT_FAILURE;
}
}
-
-
ConfFileProcessor cfp(nlsr_.getConfFileName());
int res=cfp.processConfFile(nlsr_);
if ( res < 0 )
{
return EXIT_FAILURE;
}
-
nlsr_.getConfParameter().buildRouterPrefix();
nlsr_.getNlsrLogger().initNlsrLogger(nlsr_.getConfParameter().getLogDir());
//src::logger lg;
@@ -116,27 +110,17 @@
nlsr_.getFib().setFibEntryRefreshTime(
2*nlsr_.getConfParameter().getLsaRefreshTime());
nlsr_.getLsdb().setThisRouterPrefix(nlsr_.getConfParameter().getRouterPrefix());
-
/* debugging purpose start */
cout << nlsr_.getConfParameter();
nlsr_.getAdl().printAdl();
nlsr_.getNpl().printNpl();
/* debugging purpose end */
-
nlsr_.getLsdb().buildAndInstallOwnNameLsa(nlsr_);
nlsr_.getLsdb().buildAndInstallOwnCorLsa(nlsr_);
-
-
-
-
nlsr_.setInterestFilterNlsr(nlsr_.getConfParameter().getRouterPrefix());
nlsr_.getIm().scheduleInfoInterest(nlsr_,1);
//testing purpose
nlsr_.getNlsrTesting().schedlueAddingLsas(nlsr_);
-
-
-
-
try
{
nlsr_.startEventLoop();
@@ -145,6 +129,5 @@
{
std::cerr << "ERROR: " << e.what() << std::endl;
}
-
return EXIT_SUCCESS;
}
diff --git a/src/nlsr_adl.cpp b/src/nlsr_adl.cpp
index 64976d7..0d47e67 100644
--- a/src/nlsr_adl.cpp
+++ b/src/nlsr_adl.cpp
@@ -14,7 +14,6 @@
Adl::~Adl()
{
-
}
static bool
@@ -51,36 +50,28 @@
Adl::updateAdjacentStatus(string adjName, int s)
{
Adjacent adj(adjName);
-
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it == adjList.end())
{
return -1;
}
-
(*it).setStatus(s);
return 0;
-
-
}
Adjacent
Adl::getAdjacent(string adjName)
{
Adjacent adj(adjName);
-
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it != adjList.end())
{
return (*it);
}
-
return adj;
}
@@ -92,13 +83,10 @@
{
return false;
}
-
adjList.sort(adjacent_compare);
adl.getAdjList().sort(adjacent_compare);
int equalAdjCount=0;
-
std::list< Adjacent > adjList2=adl.getAdjList();
-
std::list<Adjacent>::iterator it1;
std::list<Adjacent>::iterator it2;
for(it1=adjList.begin() , it2=adjList2.begin() ;
@@ -110,7 +98,6 @@
}
equalAdjCount++;
}
-
return equalAdjCount==getAdlSize();
}
@@ -119,19 +106,15 @@
Adl::updateAdjacentLinkCost(string adjName, double lc)
{
Adjacent adj(adjName);
-
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it == adjList.end())
{
return -1;
}
-
(*it).setLinkCost(lc);
return 0;
-
}
bool
@@ -141,12 +124,10 @@
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it == adjList.end())
{
return false;
}
-
return true;
}
@@ -157,14 +138,11 @@
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it == adjList.end())
{
return ;
}
-
(*it).setInterestTimedOutNo((*it).getInterestTimedOutNo()+1);
-
}
void
@@ -174,7 +152,6 @@
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it != adjList.end())
{
(*it).setInterestTimedOutNo(count);
@@ -188,12 +165,10 @@
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it == adjList.end())
{
return -1;
}
-
return (*it).getInterestTimedOutNo();
}
@@ -204,12 +179,10 @@
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it == adjList.end())
{
return -1;
}
-
return (*it).getStatus();
}
@@ -220,7 +193,6 @@
std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
adjList.end(),
bind(&adjacent_compare, _1, adj));
-
if( it != adjList.end())
{
(*it).setStatus(status);
@@ -253,12 +225,10 @@
}
}
}
-
if( nbrCount == adjList.size())
{
return true;
}
-
return false;
}
@@ -274,7 +244,6 @@
actNbrCount++;
}
}
-
return actNbrCount;
}
diff --git a/src/nlsr_conf_param.cpp b/src/nlsr_conf_param.cpp
index d307b83..1fc0e41 100644
--- a/src/nlsr_conf_param.cpp
+++ b/src/nlsr_conf_param.cpp
@@ -26,7 +26,6 @@
os <<"Hyp R: "<< cfp.getCorR()<<endl;
os <<"Hyp theta: "<< cfp.getCorTheta()<<endl;
os <<"Tunnel Type: "<< cfp.getTunnelType()<<endl;
-
return os;
}
diff --git a/src/nlsr_conf_param.hpp b/src/nlsr_conf_param.hpp
index 61b7e42..b2413ba 100644
--- a/src/nlsr_conf_param.hpp
+++ b/src/nlsr_conf_param.hpp
@@ -17,7 +17,6 @@
,chronosyncLsaPrefix("/ndn/nlsr/LSA")
{
isStrictHierchicalKeyCheck=0;
-
interestRetryNumber=3;
interestResendTime=5;
infoInterestInterval=60;
diff --git a/src/nlsr_conf_processor.cpp b/src/nlsr_conf_processor.cpp
index 8fc7419..fd9e217 100644
--- a/src/nlsr_conf_processor.cpp
+++ b/src/nlsr_conf_processor.cpp
@@ -19,7 +19,6 @@
ConfFileProcessor::processConfFile(Nlsr& pnlsr)
{
int ret=0;
-
if ( !confFileName.empty())
{
std::ifstream inputFile(confFileName.c_str());
@@ -47,7 +46,6 @@
ret=-1;
}
}
-
return ret;
}
@@ -129,7 +127,6 @@
{
cout << "Wrong configuration Command: "<< nt.getFirstToken()<<endl;
}
-
return ret;
}
@@ -438,11 +435,9 @@
nlsrTokenizer nt(command," ");
stringstream ssr(nt.getFirstToken().c_str());
stringstream sst(nt.getRestOfLine().c_str());
-
double r,theta;
ssr>>r;
sst>>theta;
-
pnlsr.getConfParameter().setCorR(r);
pnlsr.getConfParameter().setCorTheta(theta);
}
@@ -507,10 +502,8 @@
{
nlsrTokenizer nt(command," ");
stringstream sst(nt.getRestOfLine().c_str());
-
double cost;
sst>>cost;
-
pnlsr.getAdl().updateAdjacentLinkCost(nt.getFirstToken(),cost);
}
return 0;
diff --git a/src/nlsr_dm.cpp b/src/nlsr_dm.cpp
index 8252423..a88951b 100644
--- a/src/nlsr_dm.cpp
+++ b/src/nlsr_dm.cpp
@@ -16,22 +16,17 @@
DataManager::processContent(Nlsr& pnlsr, const ndn::Interest &interest,
const ndn::Data & data)
{
-
cout << "I: " << interest.toUri() << endl;
-
string dataName(data.getName().toUri());
string dataContent((char *)data.getContent().value());
-
cout << "D: " << dataName << endl;
cout << "Data Content: " << dataContent << endl;
-
nlsrTokenizer nt(dataName,"/");
string chkString("info");
if( nt.doesTokenExist(chkString) )
{
processContentInfo(pnlsr,dataName,dataContent);
}
-
}
void
@@ -50,20 +45,16 @@
cout<<"Status: "<< oldStatus << endl;
cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<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);
-
//debugging purpose
cout <<"After Updates: " <<endl;
cout <<"Neighbor : "<<neighbor<<endl;
cout<<"Status: "<< newStatus << endl;
cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
//debugging purpose end
-
if ( ( oldStatus-newStatus)!= 0 ) // change in Adjacency list
{
pnlsr.incrementAdjBuildCount();
@@ -76,7 +67,6 @@
ndn::bind(&Lsdb::scheduledAdjLsaBuild, pnlsr.getLsdb(),
boost::ref(pnlsr)));
}
-
}
}
diff --git a/src/nlsr_fe.cpp b/src/nlsr_fe.cpp
index f0f9d06..5f4811c 100644
--- a/src/nlsr_fe.cpp
+++ b/src/nlsr_fe.cpp
@@ -18,7 +18,6 @@
{
int nhCount=0;
std::list<NextHop>::iterator it1, it2;
-
for ( it1=nhl.getNextHopList().begin(),
it2 = nhlOther.getNextHopList().begin() ;
it1 != nhl.getNextHopList().end() ; it1++, it2++)
@@ -33,7 +32,6 @@
break;
}
}
-
return nhCount == nhl.getNhlSize();
}
}
diff --git a/src/nlsr_fib.cpp b/src/nlsr_fib.cpp
index 4ff49b2..8fb7928 100644
--- a/src/nlsr_fib.cpp
+++ b/src/nlsr_fib.cpp
@@ -34,7 +34,6 @@
void
Fib::refreshFibEntry(string name, int feSeqNum)
{
-
}
void
@@ -76,7 +75,6 @@
{
(*it).getNhl().addNextHop((*nhit));
}
-
(*it).setTimeToRefresh(fibEntryRefreshTime);
}
(*it).getNhl().sortNhl();
@@ -101,9 +99,7 @@
newEntry.setTimeToRefresh(fibEntryRefreshTime);
newEntry.setFeSeqNo(1);
fibTable.push_back(newEntry);
-
//cancelScheduledFeExpiringEvent(pnlsr, newEntry().getFeExpiringEventId());
-
//Update NDN-FIB
}
}
@@ -122,7 +118,6 @@
//remove entry from NDN-FIB
}
}
-
if ( fibTable.size() > 0 )
{
fibTable.clear();
@@ -156,7 +151,6 @@
{
return maxFacesPerPrefix;
}
-
return endFace;
}
diff --git a/src/nlsr_im.cpp b/src/nlsr_im.cpp
index 29c0fcd..23a56cc 100644
--- a/src/nlsr_im.cpp
+++ b/src/nlsr_im.cpp
@@ -20,7 +20,6 @@
const ndn::Name &name,
const ndn::Interest &interest)
{
-
cout << "<< I: " << interest << endl;
string intName=interest.getName().toUri();
cout << "Interest Received for Name: "<< intName <<endl;
@@ -32,7 +31,6 @@
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"));
@@ -53,7 +51,6 @@
pnlsr.getKeyChain().sign(data);
cout << ">> D: " << data << endl;
pnlsr.getNlsrFace().put(data);
-
int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
if ( status == 0 )
{
@@ -79,7 +76,6 @@
+nt.getTokenString(0,nt.getTokenPosition(chkString)-1);
processInterestTimedOutInfo( pnlsr , nbr , interest);
}
-
}
void
@@ -92,7 +88,6 @@
cout<<"Neighbor: "<< neighbor << endl;
cout<<"Status: "<< status << endl;
cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
-
if((infoIntTimedOutCount < pnlsr.getConfParameter().getInterestRetryNumber()))
{
string intName=neighbor +"/"+"info"+
@@ -114,7 +109,6 @@
boost::ref(pnlsr)));
}
}
-
}
void
@@ -125,7 +119,6 @@
//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),
@@ -145,9 +138,7 @@
expressInterest( pnlsr,adjName,2,
pnlsr.getConfParameter().getInterestResendTime());
}
-
scheduleInfoInterest(pnlsr, pnlsr.getConfParameter().getInfoInterestInterval());
-
}
void
diff --git a/src/nlsr_logger.cpp b/src/nlsr_logger.cpp
index 5b97ac4..804ef98 100644
--- a/src/nlsr_logger.cpp
+++ b/src/nlsr_logger.cpp
@@ -23,7 +23,6 @@
{
homeDirPath = getenv("HOME");
}
-
return homeDirPath;
}
@@ -36,7 +35,6 @@
logDirPath=getUserHomeDirectory()+"/nlsrLog";
}
cout<<"Log Dir Path: "<< logDirPath<<endl;
-
typedef sinks::synchronous_sink< sinks::text_file_backend > file_sink;
shared_ptr< file_sink > sink(new file_sink(
keywords::file_name = logDirPath
@@ -50,13 +48,11 @@
keywords::max_size = 16 * 1024 * 1024 * 1024,
keywords::min_free_space = 128 * 1024 * 1024
));
-
sink->set_formatter(
expr::format("%1%: %2%")
% getEpochTime()
% expr::smessage
);
-
logging::core::get()->add_sink(sink);
}
diff --git a/src/nlsr_lsa.cpp b/src/nlsr_lsa.cpp
index 5adb854..f238bce 100644
--- a/src/nlsr_lsa.cpp
+++ b/src/nlsr_lsa.cpp
@@ -29,14 +29,11 @@
lsType=lst;
lsSeqNo=lsn;
lifeTime=lt;
-
std::list<string> nl=npl.getNameList();
for( std::list<string>::iterator it=nl.begin(); it != nl.end(); it++)
{
addNameToLsa((*it));
}
-
-
}
string
@@ -48,14 +45,12 @@
+ boost::lexical_cast<std::string>(lifeTime);
nameLsaData+="|";
nameLsaData+=boost::lexical_cast<std::string>(npl.getNplSize());
-
std::list<string> nl=npl.getNameList();
for( std::list<string>::iterator it=nl.begin(); it != nl.end(); it++)
{
nameLsaData+="|";
nameLsaData+=(*it);
}
-
return nameLsaData;
}
@@ -74,7 +69,6 @@
{
os<<" Name "<<i<<": "<<(*it)<<endl;
}
-
return os;
}
@@ -118,7 +112,6 @@
corLsaData+=(boost::lexical_cast<std::string>(lifeTime) + "|");
corLsaData+=(boost::lexical_cast<std::string>(corRad) + "|");
corLsaData+=(boost::lexical_cast<std::string>(corTheta) + "|");
-
return corLsaData;
}
@@ -132,7 +125,6 @@
os<<" Ls Lifetime: "<<(unsigned int)cLsa.getLifeTime()<<endl;
os<<" Hyperbolic Radius: "<<cLsa.getCorRadius()<<endl;
os<<" Hyperbolic Theta: "<<cLsa.getCorTheta()<<endl;
-
return os;
}
@@ -145,7 +137,6 @@
lsSeqNo=lsn;
lifeTime=lt;
noLink=nl;
-
std::list<Adjacent> al=padl.getAdjList();
for( std::list<Adjacent>::iterator it=al.begin(); it != al.end(); it++)
{
@@ -180,7 +171,6 @@
+ boost::lexical_cast<std::string>(lifeTime);
adjLsaData+="|";
adjLsaData+=boost::lexical_cast<std::string>(adl.getAdlSize());
-
std::list<Adjacent> al=adl.getAdjList();
for( std::list<Adjacent>::iterator it=al.begin(); it != al.end(); it++)
{
@@ -190,7 +180,6 @@
adjLsaData+=boost::lexical_cast<std::string>((*it).getConnectingFace());
adjLsaData+="|";
adjLsaData+=boost::lexical_cast<std::string>((*it).getLinkCost());
-
}
return adjLsaData;
}
@@ -203,7 +192,6 @@
{
pnlsr.getNpt().addNpte(getOrigRouter(), getOrigRouter(),pnlsr);
}
-
}
@@ -237,7 +225,6 @@
os<<" Connecting Face: "<<(*it).getConnectingFace()<<endl;
os<<" Link Cost: "<<(*it).getLinkCost()<<endl;
}
-
return os;
}
diff --git a/src/nlsr_lsdb.cpp b/src/nlsr_lsdb.cpp
index dbe5b86..cd80809 100644
--- a/src/nlsr_lsdb.cpp
+++ b/src/nlsr_lsdb.cpp
@@ -31,7 +31,6 @@
, pnlsr.getNpl() );
pnlsr.getSm().setNameLsaSeq(pnlsr.getSm().getNameLsaSeq()+1);
return installNameLsa(pnlsr,nameLsa);
-
}
std::pair<NameLsa&, bool>
@@ -40,15 +39,12 @@
std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
nameLsdb.end(),
bind(nameLsaCompareByKey, _1, key));
-
if( it != nameLsdb.end())
{
return std::make_pair(boost::ref((*it)),true);
}
-
NameLsa nlsa;
return std::make_pair(boost::ref(nlsa),false);
-
}
@@ -81,7 +77,6 @@
}
}
}
-
if(nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
timeToExpire=nlsa.getLifeTime();
@@ -95,10 +90,8 @@
{
chkNameLsa.first.setLsSeqNo(nlsa.getLsSeqNo());
chkNameLsa.first.setLifeTime(nlsa.getLifeTime());
-
chkNameLsa.first.getNpl().sortNpl();
nlsa.getNpl().sortNpl();
-
std::list<string> nameToAdd;
std::set_difference(nlsa.getNpl().getNameList().begin(),
nlsa.getNpl().getNameList().end(),
@@ -117,7 +110,6 @@
}
}
}
-
std::list<string> nameToRemove;
std::set_difference(chkNameLsa.first.getNpl().getNameList().begin(),
chkNameLsa.first.getNpl().getNameList().end(),
@@ -136,7 +128,6 @@
}
}
}
-
if(nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
timeToExpire=nlsa.getLifeTime();
@@ -147,7 +138,6 @@
nlsa.getNameLsaKey(), nlsa.getLsSeqNo(), timeToExpire));
}
}
-
return true;
}
@@ -156,7 +146,6 @@
{
std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
nameLsdb.end(), bind(nameLsaCompareByKey, _1, nlsa.getNameLsaKey()));
-
if( it == nameLsdb.end())
{
nameLsdb.push_back(nlsa);
@@ -184,7 +173,6 @@
pnlsr.getNpt().removeNpte((*nit),(*it).getOrigRouter(),pnlsr);
}
}
-
}
nameLsdb.erase(it);
return true;
@@ -198,12 +186,10 @@
std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
nameLsdb.end(),
bind(nameLsaCompareByKey, _1, key));
-
if( it == nameLsdb.end())
{
return false;
}
-
return true;
}
@@ -238,7 +224,6 @@
, pnlsr.getConfParameter().getCorTheta() );
pnlsr.getSm().setCorLsaSeq(pnlsr.getSm().getCorLsaSeq()+1);
installCorLsa(pnlsr, corLsa);
-
return true;
}
@@ -248,12 +233,10 @@
std::list< CorLsa >::iterator it = std::find_if( corLsdb.begin(),
corLsdb.end(),
bind(corLsaCompareByKey, _1, key));
-
if( it != corLsdb.end())
{
return std::make_pair(boost::ref((*it)), true);
}
-
CorLsa clsa;
return std::make_pair(boost::ref(clsa),false);
}
@@ -283,14 +266,12 @@
{
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
}
-
if(clsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
timeToExpire=clsa.getLifeTime();
}
scheduleCorLsaExpiration(pnlsr,clsa.getCorLsaKey(),
clsa.getLsSeqNo(), timeToExpire);
-
}
else
{
@@ -302,14 +283,11 @@
{
chkCorLsa.first.setCorRadius(clsa.getCorRadius());
chkCorLsa.first.setCorTheta(clsa.getCorTheta());
-
if (pnlsr.getConfParameter().getIsHyperbolicCalc() >=1 )
{
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
}
-
}
-
if(clsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
timeToExpire=clsa.getLifeTime();
@@ -320,9 +298,7 @@
clsa.getCorLsaKey(),
clsa.getLsSeqNo(), timeToExpire));
}
-
}
-
return true;
}
@@ -332,7 +308,6 @@
std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(),
corLsdb.end(),
bind(corLsaCompareByKey, _1, clsa.getCorLsaKey()));
-
if( it == corLsdb.end())
{
corLsdb.push_back(clsa);
@@ -357,7 +332,6 @@
return true;
}
return false;
-
}
bool
@@ -366,12 +340,10 @@
std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(),
corLsdb.end(),
bind(corLsaCompareByKey, _1, key));
-
if( it == corLsdb.end())
{
return false;
}
-
return true;
}
@@ -401,7 +373,6 @@
{
cout<<"scheduledAdjLsaBuild Called"<<endl;
pnlsr.setIsBuildAdjLsaSheduled(0);
-
if( pnlsr.getAdl().isAdjLsaBuildable(pnlsr))
{
int adjBuildCount=pnlsr.getAdjBuildCount();
@@ -429,7 +400,6 @@
ndn::bind(&Lsdb::scheduledAdjLsaBuild, pnlsr.getLsdb(),
boost::ref(pnlsr)));
}
-
}
@@ -439,14 +409,12 @@
std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
adjLsdb.end(),
bind(adjLsaCompareByKey, _1, alsa.getAdjLsaKey()));
-
if( it == adjLsdb.end())
{
adjLsdb.push_back(alsa);
return true;
}
return false;
-
}
std::pair<AdjLsa& , bool>
@@ -455,12 +423,10 @@
std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
adjLsdb.end(),
bind(adjLsaCompareByKey, _1, key));
-
if( it != adjLsdb.end())
{
return std::make_pair(boost::ref((*it)),true);
}
-
AdjLsa alsa;
return std::make_pair(boost::ref(alsa),false);
}
@@ -485,14 +451,12 @@
addAdjLsa(alsa);
alsa.addNptEntriesForAdjLsa(pnlsr);
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
-
if(alsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
timeToExpire=alsa.getLifeTime();
}
scheduleAdjLsaExpiration(pnlsr,alsa.getAdjLsaKey(),
alsa.getLsSeqNo(),timeToExpire);
-
}
else
{
@@ -500,14 +464,12 @@
{
chkAdjLsa.first.setLsSeqNo(alsa.getLsSeqNo());
chkAdjLsa.first.setLifeTime(alsa.getLifeTime());
-
if ( ! chkAdjLsa.first.isLsaContentEqual(alsa))
{
chkAdjLsa.first.getAdl().resetAdl();
chkAdjLsa.first.getAdl().addAdjacentsFromAdl(alsa.getAdl());
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
}
-
if(alsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
timeToExpire=alsa.getLifeTime();
@@ -517,11 +479,8 @@
chkAdjLsa.first.setLsaExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
alsa.getAdjLsaKey(), alsa.getLsSeqNo(),timeToExpire));
}
-
}
-
printAdjLsdb();
-
return true;
}
@@ -551,7 +510,6 @@
return true;
}
return false;
-
}
bool
@@ -560,12 +518,10 @@
std::list< AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
adjLsdb.end(),
bind(adjLsaCompareByKey, _1, key));
-
if( it == adjLsdb.end())
{
return false;
}
-
return true;
}
@@ -637,7 +593,6 @@
cout<<"Other's Adj LSA, so removing form LSDB"<<endl;
removeAdjLsa(pnlsr, lsaKey);
}
-
// schedule Routing table calculaiton
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
}
@@ -667,7 +622,6 @@
cout<<"Other's Cor LSA, so removing form LSDB"<<endl;
removeCorLsa(pnlsr, lsaKey);
}
-
if (pnlsr.getConfParameter().getIsHyperbolicCalc() >=1 )
{
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
@@ -704,7 +658,6 @@
{
return doesCorLsaExist(key);
}
-
return false;
}
diff --git a/src/nlsr_map.cpp b/src/nlsr_map.cpp
index b879889..47b02ec 100644
--- a/src/nlsr_map.cpp
+++ b/src/nlsr_map.cpp
@@ -17,7 +17,6 @@
{
os<<"MapEntry: ( Router: "<<mpe.getRouter()<<" Mapping No: ";
os<<mpe.getMappingNumber()<<" )"<<endl;
-
return os;
}
@@ -100,7 +99,6 @@
string linkEndRouter=(*itAdl).getAdjacentName();
addMapElement(linkEndRouter);
}
-
}
}
@@ -120,7 +118,6 @@
{
os<< (*it);
}
-
return os;
}
diff --git a/src/nlsr_npl.cpp b/src/nlsr_npl.cpp
index 326b001..e8356cb 100644
--- a/src/nlsr_npl.cpp
+++ b/src/nlsr_npl.cpp
@@ -10,12 +10,10 @@
Npl::Npl()
{
-
}
Npl::~Npl()
{
-
}
static bool
@@ -30,15 +28,12 @@
std::list<string >::iterator it = std::find_if( nameList.begin(),
nameList.end(),
bind(&nameCompare, _1 , name));
-
if( it != nameList.end() )
{
return -1;
}
-
nameList.push_back(name);
return 0;
-
}
int
@@ -47,12 +42,10 @@
std::list<string >::iterator it = std::find_if( nameList.begin(),
nameList.end(),
bind(&nameCompare, _1 , name));
-
if( it != nameList.end() )
{
nameList.erase(it);
}
-
return -1;
}
diff --git a/src/nlsr_npt.cpp b/src/nlsr_npt.cpp
index 5f4ea43..9c4d4cb 100644
--- a/src/nlsr_npt.cpp
+++ b/src/nlsr_npt.cpp
@@ -24,7 +24,6 @@
{
std::list<Npte >::iterator it = std::find_if( npteList.begin(),
npteList.end(), bind(&npteCompare, _1, name));
-
if ( it == npteList.end() )
{
Npte newEntry( name);
@@ -53,7 +52,6 @@
if ( it != npteList.end() )
{
string destRouter=rte.getDestination();
-
(*it).removeRoutingTableEntry(rte);
if ( ((*it).getRteListSize() == 0 ) &&
(!pnlsr.getLsdb().doesLsaExist(destRouter+"/1",1) ) &&
@@ -63,7 +61,6 @@
npteList.erase(it); // remove entry from NPT
// remove FIB entry with this name
pnlsr.getFib().removeFromFib(pnlsr,name);
-
}
else
{
@@ -90,7 +87,6 @@
RoutingTableEntry rte(destRouter);
addNpte(name, rte,pnlsr);
}
-
}
void
diff --git a/src/nlsr_npte.cpp b/src/nlsr_npte.cpp
index d2d1d8a..60013ff 100644
--- a/src/nlsr_npte.cpp
+++ b/src/nlsr_npte.cpp
@@ -77,7 +77,6 @@
cout<<(*it);
}
os<<npte.getNhl();
-
return os;
}
diff --git a/src/nlsr_rt.cpp b/src/nlsr_rt.cpp
index 734a85e..87dcd26 100644
--- a/src/nlsr_rt.cpp
+++ b/src/nlsr_rt.cpp
@@ -19,11 +19,9 @@
{
//debugging purpose
pnlsr.getNpt().printNpt();
-
if ( pnlsr.getIsRoutingTableCalculating() == 0 )
{
pnlsr.setIsRoutingTableCalculating(1); //setting routing table calculation
-
if ( pnlsr.getLsdb().doesLsaExist(
pnlsr.getConfParameter().getRouterPrefix()+"/"+"2",2) )
{
@@ -48,7 +46,6 @@
{
calculateHypDryRoutingTable(pnlsr);
}
-
//need to update NPT here
pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
//debugging purpose
@@ -77,8 +74,6 @@
pnlsr.getFib().printFib();
//debugging purpose end
}
-
-
pnlsr.setIsRouteCalculationScheduled(0); //clear scheduled flag
pnlsr.setIsRoutingTableCalculating(0); //unsetting routing table calculation
}
@@ -86,7 +81,6 @@
{
scheduleRoutingTableCalculation(pnlsr);
}
-
}
@@ -97,7 +91,6 @@
Map vMap;
vMap.createMapFromAdjLsdb(pnlsr);
int numOfRouter=vMap.getMapSize();
-
LinkStateRoutingTableCalculator lsrtc(numOfRouter);
lsrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
}
@@ -199,7 +192,6 @@
{
(*it).getNhl().addNextHop(nh);
}
-
}
void
diff --git a/src/nlsr_rtc.cpp b/src/nlsr_rtc.cpp
index e594794..acdf6d5 100644
--- a/src/nlsr_rtc.cpp
+++ b/src/nlsr_rtc.cpp
@@ -53,7 +53,6 @@
adjMatrix[row][col]=cost;
}
}
-
}
}
@@ -163,7 +162,6 @@
int noLink=getNumOfLinkfromAdjMatrix(sourceRouter);
allocateParent();
allocateDistance();
-
if ( pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1 )
{
// Single Path
@@ -179,11 +177,9 @@
setNoLink(getNumOfLinkfromAdjMatrix(sourceRouter));
allocateLinks();
allocateLinkCosts();
-
getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
for (int i=0 ; i < vNoLink; i++)
{
-
adjustAdMatrix(sourceRouter,links[i], linkCosts[i]);
printAdjMatrix();
doDijkstraPathCalculation(sourceRouter);
@@ -192,11 +188,9 @@
//update routing table
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
}
-
freeLinks();
freeLinksCosts();
}
-
freeParent();
freeDistance();
freeAdjMatrix();
@@ -216,12 +210,10 @@
distance[i]=INF_DISTANCE;
Q[i]=i;
}
-
if ( sourceRouter != NO_MAPPING_NUM )
{
distance[sourceRouter]=0;
sortQueueByDistance(Q,distance,head,numOfRouter);
-
while (head < numOfRouter )
{
u=Q[head];
@@ -229,7 +221,6 @@
{
break;
}
-
for(v=0 ; v <numOfRouter; v++)
{
if( adjMatrix[u][v] > 0 )
@@ -241,13 +232,9 @@
distance[v]=distance[u] + adjMatrix[u][v] ;
parent[v]=u;
}
-
}
-
}
-
}
-
head++;
sortQueueByDistance(Q,distance,head,numOfRouter);
}
@@ -278,7 +265,6 @@
// Add next hop to routing table
NextHop nh(nxtHopFace,routeCost);
rt.addNextHop(pMap.getRouterNameByMappingNo(i),nh);
-
}
}
}
@@ -291,14 +277,11 @@
{
nextHop=dest;
dest=parent[dest];
-
}
-
if ( dest != source )
{
nextHop=NO_NEXT_HOP;
}
-
return nextHop;
}
@@ -324,7 +307,6 @@
{
printLsPath(parent[destRouter]);
}
-
cout<<" "<<destRouter;
}
@@ -344,7 +326,6 @@
}
}
}
-
}
int
@@ -399,9 +380,7 @@
setNoLink(noLink);
allocateLinks();
allocateLinkCosts();
-
getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
-
for(int i=0 ; i < numOfRouter ; ++i)
{
int k=0;
@@ -410,7 +389,6 @@
allocateLinkFaces();
allocateDistanceToNeighbor();
allocateDistFromNbrToDest();
-
for(int j=0; j<vNoLink; j++)
{
string nextHopRouterName=pMap.getRouterNameByMappingNo(links[j]);
@@ -428,15 +406,12 @@
k++;
}
}
-
addHypNextHopsToRoutingTable(pnlsr,pMap,rt,k,i);
-
freeLinkFaces();
freeDistanceToNeighbor();
freeDistFromNbrToDest();
}
}
-
freeLinks();
freeLinksCosts();
freeAdjMatrix();
@@ -456,7 +431,6 @@
rt.addNextHopToDryTable(destRouter,nh);
}
}
-
}
double
@@ -464,25 +438,18 @@
Map& pMap, int src, int dest)
{
double distance=0.0;
-
string srcRouterKey=pMap.getRouterNameByMappingNo(src)+"/3";
string destRouterKey=pMap.getRouterNameByMappingNo(dest)+"/3";
-
double srcRadius=(pnlsr.getLsdb().getCorLsa(srcRouterKey).first).getCorRadius();
double srcTheta=(pnlsr.getLsdb().getCorLsa(srcRouterKey).first).getCorTheta();
-
double destRadius=(pnlsr.getLsdb().getCorLsa(
destRouterKey).first).getCorRadius();
double destTheta=(pnlsr.getLsdb().getCorLsa(destRouterKey).first).getCorTheta();
-
-
double diffTheta = fabs (srcTheta - destTheta);
-
if (diffTheta > MATH_PI)
{
diffTheta = 2 * MATH_PI - diffTheta;
}
-
if ( srcRadius != -1 && destRadius != -1 )
{
if (diffTheta == 0)
@@ -495,7 +462,6 @@
{
distance = -1;
}
-
return distance;
}
diff --git a/src/nlsr_rte.hpp b/src/nlsr_rte.hpp
index 25bc7ce..27d3601 100644
--- a/src/nlsr_rte.hpp
+++ b/src/nlsr_rte.hpp
@@ -17,7 +17,6 @@
: destination()
, nhl()
{
-
}
~RoutingTableEntry()
diff --git a/src/nlsr_test.cpp b/src/nlsr_test.cpp
index f7d8d13..c04fd77 100644
--- a/src/nlsr_test.cpp
+++ b/src/nlsr_test.cpp
@@ -15,7 +15,6 @@
NlsrTest::schedlueAddingLsas(Nlsr& pnlsr)
{
// scheduling adding two name lsas, two Cor Lsas and three Adj LSAs
-
//Scheduling Adding LSAs for router altair
string router("/ndn/memphis.edu/cs/altair");
string name1("/ndn/memphis.edu/cs/altair/name1");
@@ -23,7 +22,6 @@
string name3("/ndn/memphis.edu/cs/broadcast");
Adjacent adj1("/ndn/memphis.edu/cs/pollux",7,17,1,0);
Adjacent adj2("/ndn/memphis.edu/cs/maia",15,27,1,0);
-
pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(30),
ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
boost::ref(pnlsr)
@@ -36,7 +34,6 @@
ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
boost::ref(pnlsr)
,router,adj1,adj2));
-
//Scheduling Adding LSAs for router Maia
string routerMaia("/ndn/memphis.edu/cs/maia");
string maiaName1("/ndn/memphis.edu/maia/name1");
@@ -44,7 +41,6 @@
string maiaName3("/ndn/memphis.edu/cs/broadcast");
Adjacent maiaAdj1("/ndn/memphis.edu/cs/pollux",8,25,1,0);
Adjacent maiaAdj2("/ndn/memphis.edu/cs/altair",11,15,1,0);
-
pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(55),
ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
boost::ref(pnlsr)
@@ -57,18 +53,14 @@
ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
boost::ref(pnlsr)
,routerMaia,maiaAdj1,maiaAdj2));
-
//sheduling Adding LSAs for Router itself
string routerPollux("/ndn/memphis.edu/cs/pollux");
Adjacent polluxAdj1("/ndn/memphis.edu/cs/maia",9,13,1,0);
Adjacent polluxAdj2("/ndn/memphis.edu/cs/altair",12,23,1,0);
-
pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(90),
ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
boost::ref(pnlsr)
,routerPollux,polluxAdj1,polluxAdj2));
-
-
}
@@ -83,7 +75,6 @@
npl.insertIntoNpl(name3);
NameLsa nameLsa(router,1,1,3600,npl);
pnlsr.getLsdb().installNameLsa(pnlsr, nameLsa);
-
}
void
@@ -102,7 +93,6 @@
adl.insert(adj2);
AdjLsa adjLsa(router,2,1,3600,2,adl);
pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
-
}
}//namespace nlsr
diff --git a/src/nlsr_tokenizer.cpp b/src/nlsr_tokenizer.cpp
index 3c49f8c..d64a600 100644
--- a/src/nlsr_tokenizer.cpp
+++ b/src/nlsr_tokenizer.cpp
@@ -18,11 +18,9 @@
char_separator<char> sep(seps.c_str());
tokenizer< char_separator<char> >tokens(originalString, sep);
tokenizer< char_separator<char> >::iterator tok_iter = tokens.begin();
-
string ft(*tok_iter);
firstToken=ft;
++tok_iter;
-
for ( ; tok_iter != tokens.end(); ++tok_iter)
{
string oneToken(*tok_iter);
@@ -30,7 +28,6 @@
restOfTheLine+=oneToken;
restOfTheLine+=seps;
}
-
trim(restOfTheLine);
}
@@ -45,7 +42,6 @@
{
int pos=-1;
int i=1;
-
for(std::list<string>::iterator it=tokenList.begin(); it!=tokenList.end(); it++)
{
if( (*it) == token )
@@ -54,12 +50,10 @@
}
i++;
}
-
if( i < tokenList.size() )
{
pos=i;
}
-
return pos;
}
@@ -79,12 +73,9 @@
string oneToken((*it));
returnString+=seps;
returnString+=oneToken;
-
}
-
}
}
-
trim(returnString);
return returnString;
}
@@ -105,12 +96,9 @@
string oneToken((*it));
returnString+=seps;
returnString+=oneToken;
-
}
-
}
}
-
trim(returnString);
return returnString;
}
@@ -127,12 +115,10 @@
std::list<string >::iterator it = std::find_if( tokenList.begin(),
tokenList.end(),
bind(&tokenCompare, _1 , token));
-
if( it != tokenList.end() )
{
return true;
}
-
return false;
}