Fixing Coding Style
diff --git a/CertTool/cert_tool.cpp b/CertTool/cert_tool.cpp
index d88394c..d28340f 100644
--- a/CertTool/cert_tool.cpp
+++ b/CertTool/cert_tool.cpp
@@ -86,8 +86,8 @@
certificateName.append("KEY").append(
keyName.get(-1)).append("ID-CERT").appendVersion();
certificate->setName(certificateName);
- certificate->setNotBefore(ndn::getNow());
- certificate->setNotAfter(ndn::getNow() + 63072000 /* 2 years*/);
+ certificate->setNotBefore(ndn::time::system_clock::now());
+ certificate->setNotAfter(ndn::time::system_clock::now() + ndn::time::days(730) /* 2 years*/);
certificate->setPublicKeyInfo(*pubKey);
certificate->addSubjectDescription(
ndn::CertificateSubjectDescription("2.5.4.41",
@@ -110,7 +110,7 @@
}
return identityName;
}
- ndn::KeyChain::addCertificate(*(certificate));
+ ndn::KeyChain::addCertificateAsIdentityDefault(*(certificate));
}
certName=certificate->getName();
@@ -135,7 +135,7 @@
try
{
ndn::KeyChain::deleteCertificate(cert->getName());
- ndn::KeyChain::addCertificate(*(cert));
+ ndn::KeyChain::addCertificateAsIdentityDefault(*(cert));
return true;
}
catch(InfoError& e)
diff --git a/nsync/src/sync-full-state.cc b/nsync/src/sync-full-state.cc
index eb9ca4c..7000606 100644
--- a/nsync/src/sync-full-state.cc
+++ b/nsync/src/sync-full-state.cc
@@ -45,10 +45,10 @@
{
}
-ndn::time::Duration
+ndn::time::system_clock::Duration
FullState::getTimeFromLastUpdate () const
{
- return ndn::time::now() - m_lastUpdated;
+ return ndn::time::system_clock::now() - m_lastUpdated;
}
DigestConstPtr
@@ -81,7 +81,7 @@
boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
FullState::update (NameInfoConstPtr info, const SeqNo &seq)
{
- m_lastUpdated = ndn::time::now();
+ m_lastUpdated = ndn::time::system_clock::now();
m_digest.reset ();
@@ -109,7 +109,7 @@
bool
FullState::remove (NameInfoConstPtr info)
{
- m_lastUpdated = ndn::time::now();
+ m_lastUpdated = ndn::time::system_clock::now();
m_digest.reset ();
diff --git a/nsync/src/sync-full-state.h b/nsync/src/sync-full-state.h
index 28e0078..028c41e 100644
--- a/nsync/src/sync-full-state.h
+++ b/nsync/src/sync-full-state.h
@@ -51,7 +51,7 @@
*
* This value can be used to randomize reconciliation waiting time in SyncApp
*/
- ndn::time::Duration
+ ndn::time::system_clock::Duration
getTimeFromLastUpdate () const;
/**
@@ -70,7 +70,7 @@
remove (NameInfoConstPtr info);
private:
- ndn::time::Point m_lastUpdated; ///< @brief Time when state was updated last time
+ ndn::time::system_clock::TimePoint m_lastUpdated; ///< @brief Time when state was updated last time
DigestPtr m_digest;
};
diff --git a/nsync/src/sync-interest-container.h b/nsync/src/sync-interest-container.h
index 742f053..f674d05 100644
--- a/nsync/src/sync-interest-container.h
+++ b/nsync/src/sync-interest-container.h
@@ -47,14 +47,14 @@
Interest (DigestConstPtr digest, const std::string &name, bool unknown=false)
: m_digest (digest)
, m_name (name)
- , m_time (ndn::time::now())
+ , m_time (ndn::time::system_clock::now())
, m_unknown (unknown)
{
}
DigestConstPtr m_digest;
std::string m_name;
- ndn::time::Point m_time;
+ ndn::time::system_clock::TimePoint m_time;
bool m_unknown;
};
@@ -87,7 +87,7 @@
mi::ordered_non_unique<
mi::tag<timed>,
- BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::Point, m_time)
+ BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::system_clock::TimePoint, m_time)
>
>
>
diff --git a/nsync/src/sync-interest-table.cc b/nsync/src/sync-interest-table.cc
index a378950..415b641 100644
--- a/nsync/src/sync-interest-table.cc
+++ b/nsync/src/sync-interest-table.cc
@@ -29,7 +29,7 @@
namespace Sync
{
-SyncInterestTable::SyncInterestTable (boost::asio::io_service& io, ndn::time::Duration lifetime)
+SyncInterestTable::SyncInterestTable (boost::asio::io_service& io, ndn::time::system_clock::Duration lifetime)
: m_entryLifetime (lifetime)
, m_scheduler(io)
{
@@ -103,7 +103,7 @@
void SyncInterestTable::expireInterests ()
{
uint32_t count = 0;
- ndn::time::Point expireTime = ndn::time::now() - m_entryLifetime;
+ ndn::time::system_clock::TimePoint expireTime = ndn::time::system_clock::now() - m_entryLifetime;
while (m_table.size () > 0)
{
diff --git a/nsync/src/sync-interest-table.h b/nsync/src/sync-interest-table.h
index 9b7c46b..4810c41 100644
--- a/nsync/src/sync-interest-table.h
+++ b/nsync/src/sync-interest-table.h
@@ -42,7 +42,7 @@
class SyncInterestTable
{
public:
- SyncInterestTable (boost::asio::io_service& io, ndn::time::Duration lifetime);
+ SyncInterestTable (boost::asio::io_service& io, ndn::time::system_clock::Duration lifetime);
~SyncInterestTable ();
/**
@@ -81,7 +81,7 @@
expireInterests ();
private:
- ndn::time::Duration m_entryLifetime;
+ ndn::time::system_clock::Duration m_entryLifetime;
InterestContainer m_table;
ndn::Scheduler m_scheduler;
diff --git a/nsync/src/sync-logic.cc b/nsync/src/sync-logic.cc
index ec4d63e..c915718 100644
--- a/nsync/src/sync-logic.cc
+++ b/nsync/src/sync-logic.cc
@@ -63,6 +63,10 @@
LogicUpdateCallback onUpdate,
LogicRemoveCallback onRemove)
: m_state (new FullState)
+ , m_unknownDigestStoreTime(10)
+ , m_syncResponseFreshness(1000)
+ , m_syncInterestReexpress(4)
+ , m_defaultRecoveryRetransmitInterval(200)
, m_syncInterestTable (*face->ioService(), time::seconds(m_syncInterestReexpress))
, m_syncPrefix (syncPrefix)
, m_onUpdate (onUpdate)
@@ -424,7 +428,7 @@
// satisfyPendingSyncInterests (diffLog); // if there are interests in PIT, there is a point to satisfy them using new state
// if state has changed, then it is safe to express a new interest
- time::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
+ time::system_clock::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
// cout << "------------ reexpress interest after: " << after << endl;
EventId eventId = m_scheduler.scheduleEvent (after,
bind (&SyncLogic::sendSyncInterest, this));
@@ -596,7 +600,7 @@
Name interestName = m_syncPrefix;
interestName.append("recovery").append(os.str());
- time::Duration nextRetransmission = time::milliseconds (m_recoveryRetransmissionInterval + GET_RANDOM (m_reexpressionJitter));
+ time::system_clock::Duration nextRetransmission = time::milliseconds (m_recoveryRetransmissionInterval + GET_RANDOM (m_reexpressionJitter));
m_recoveryRetransmissionInterval <<= 1;
@@ -634,7 +638,7 @@
Data syncData(name);
syncData.setContent(reinterpret_cast<const uint8_t*>(wireData), size);
- syncData.setFreshnessPeriod(m_syncResponseFreshness);
+ syncData.setFreshnessPeriod(time::seconds(m_syncResponseFreshness));
m_keyChain->sign(syncData);
@@ -652,7 +656,7 @@
{
_LOG_DEBUG_ID ("Satisfied our own Interest. Re-expressing (hopefully with a new digest)");
- time::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
+ time::system_clock::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
// cout << "------------ reexpress interest after: " << after << endl;
EventId eventId = m_scheduler.scheduleEvent (after,
bind (&SyncLogic::sendSyncInterest, this));
diff --git a/nsync/src/sync-logic.h b/nsync/src/sync-logic.h
index fc63fca..25d7c5c 100644
--- a/nsync/src/sync-logic.h
+++ b/nsync/src/sync-logic.h
@@ -176,6 +176,12 @@
private:
FullStatePtr m_state;
+
+ int m_unknownDigestStoreTime;
+ int m_syncResponseFreshness;
+ int m_syncInterestReexpress;
+ int m_defaultRecoveryRetransmitInterval;
+
DiffStateContainer m_log;
ndn::Name m_outstandingInterestName;
@@ -197,11 +203,14 @@
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > m_rangeUniformRandom;
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > m_reexpressionJitter;
+ /*
static const int m_unknownDigestStoreTime = 10; // seconds
static const int m_syncResponseFreshness = 1000; // MUST BE dividable by 1000!!!
static const int m_syncInterestReexpress = 4; // seconds
static const int m_defaultRecoveryRetransmitInterval = 200; // milliseconds
+ */
+
uint32_t m_recoveryRetransmissionInterval; // milliseconds
ndn::EventId m_delayedInterestProcessingId;
diff --git a/nsync/src/sync-socket.cc b/nsync/src/sync-socket.cc
index db51ce2..bd4c0e4 100644
--- a/nsync/src/sync-socket.cc
+++ b/nsync/src/sync-socket.cc
@@ -56,7 +56,7 @@
{
shared_ptr<Data> data = make_shared<Data>();
data->setContent(reinterpret_cast<const uint8_t*>(buf), len);
- data->setFreshnessPeriod(1000*freshness);
+ data->setFreshnessPeriod(time::seconds(freshness));
m_ioService->post(bind(&SyncSocket::publishDataInternal, this, data, prefix, session,seq));
diff --git a/src/communication/nlsr_dm.cpp b/src/communication/nlsr_dm.cpp
index ffb85e3..249b5e7 100644
--- a/src/communication/nlsr_dm.cpp
+++ b/src/communication/nlsr_dm.cpp
@@ -10,6 +10,9 @@
#include "utility/nlsr_tokenizer.hpp"
#include "nlsr_lsdb.hpp"
#include "security/nlsr_km.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_dm.cpp"
namespace nlsr
{
@@ -19,7 +22,7 @@
void
DataManager::processContent(Nlsr& pnlsr, const ndn::Interest &interest,
- const ndn::Data & data, interestManager& im)
+ const ndn::Data & data, InterestManager& im)
{
cout << "I: " << interest.toUri() << endl;
string dataName(data.getName().toUri());
@@ -141,7 +144,7 @@
if ( pnlsr.getLsdb().isNameLsaNew(lsaKey,lsSeqNo))
{
NameLsa nameLsa;
- if( nameLsa.initNameLsaFromContent(dataContent) )
+ if( nameLsa.initializeFromContent(dataContent) )
{
pnlsr.getLsdb().installNameLsa(pnlsr, nameLsa);
}
@@ -159,7 +162,7 @@
if ( pnlsr.getLsdb().isAdjLsaNew(lsaKey,lsSeqNo))
{
AdjLsa adjLsa;
- if( adjLsa.initAdjLsaFromContent(dataContent) )
+ if( adjLsa.initializeFromContent(dataContent) )
{
pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
}
@@ -177,7 +180,7 @@
if ( pnlsr.getLsdb().isCorLsaNew(lsaKey,lsSeqNo))
{
CorLsa corLsa;
- if( corLsa.initCorLsaFromContent(dataContent) )
+ if( corLsa.initializeFromContent(dataContent) )
{
pnlsr.getLsdb().installCorLsa(pnlsr, corLsa);
}
diff --git a/src/communication/nlsr_dm.hpp b/src/communication/nlsr_dm.hpp
index 4a807f2..fc231d3 100644
--- a/src/communication/nlsr_dm.hpp
+++ b/src/communication/nlsr_dm.hpp
@@ -18,8 +18,8 @@
class DataManager
{
public:
- void processContent(Nlsr& pnlsr, const ndn::Interest &interest,
- const ndn::Data& data, interestManager& im);
+ void processContent(Nlsr& pnlsr, const ndn::Interest& interest,
+ const ndn::Data& data, InterestManager& im);
private:
void processContentInfo(Nlsr& pnlsr, string& dataName,
string& dataContent);
diff --git a/src/communication/nlsr_im.cpp b/src/communication/nlsr_im.cpp
index 16d0c72..d708812 100644
--- a/src/communication/nlsr_im.cpp
+++ b/src/communication/nlsr_im.cpp
@@ -10,6 +10,9 @@
#include "nlsr_dm.hpp"
#include "utility/nlsr_tokenizer.hpp"
#include "nlsr_lsdb.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_im.cpp"
namespace nlsr
{
@@ -18,9 +21,9 @@
using namespace ndn;
void
- interestManager::processInterest( Nlsr& pnlsr,
- const ndn::Name &name,
- const ndn::Interest &interest)
+ InterestManager::processInterest( Nlsr& pnlsr,
+ const ndn::Name& name,
+ const ndn::Interest& interest)
{
cout << "<< I: " << interest << endl;
string intName=interest.getName().toUri();
@@ -46,13 +49,13 @@
}
void
- interestManager::processInterestInfo(Nlsr& pnlsr, string& neighbor,
- const ndn::Interest &interest)
+ 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.setFreshnessPeriod(time::seconds(10)); // 10 sec
data.setContent((const uint8_t*)"info", sizeof("info"));
pnlsr.getKeyManager().signData(data);
cout << ">> D: " << data << endl;
@@ -69,7 +72,7 @@
}
void
- interestManager::processInterestLsa(Nlsr& pnlsr,const ndn::Interest &interest)
+ InterestManager::processInterestLsa(Nlsr& pnlsr,const ndn::Interest& interest)
{
string intName=interest.getName().toUri();
nlsrTokenizer nt(intName,"/");
@@ -115,8 +118,8 @@
}
void
- interestManager::processInterestForNameLsa(Nlsr& pnlsr,
- const ndn::Interest &interest,
+ InterestManager::processInterestForNameLsa(Nlsr& pnlsr,
+ const ndn::Interest& interest,
string lsaKey, uint32_t interestedlsSeqNo)
{
std::pair<NameLsa&, bool> nameLsa=pnlsr.getLsdb().getNameLsa(lsaKey);
@@ -125,8 +128,8 @@
if ( nameLsa.first.getLsSeqNo() >= interestedlsSeqNo )
{
Data data(ndn::Name(interest.getName()).appendVersion());
- data.setFreshnessPeriod(1000); // 10 sec
- string content=nameLsa.first.getNameLsaData();
+ data.setFreshnessPeriod(time::seconds(10)); // 10 sec
+ string content=nameLsa.first.getData();
data.setContent((const uint8_t*)content.c_str(),content.size());
pnlsr.getKeyManager().signData(data);
cout << ">> D: " << data << endl;
@@ -136,8 +139,8 @@
}
void
- interestManager::processInterestForAdjLsa(Nlsr& pnlsr,
- const ndn::Interest &interest,
+ InterestManager::processInterestForAdjLsa(Nlsr& pnlsr,
+ const ndn::Interest& interest,
string lsaKey, uint32_t interestedlsSeqNo)
{
std::pair<AdjLsa&, bool> adjLsa=pnlsr.getLsdb().getAdjLsa(lsaKey);
@@ -146,8 +149,8 @@
if ( adjLsa.first.getLsSeqNo() >= interestedlsSeqNo )
{
Data data(ndn::Name(interest.getName()).appendVersion());
- data.setFreshnessPeriod(1000); // 10 sec
- string content=adjLsa.first.getAdjLsaData();
+ data.setFreshnessPeriod(time::seconds(10)); // 10 sec
+ string content=adjLsa.first.getData();
data.setContent((const uint8_t*)content.c_str(),content.size());
pnlsr.getKeyManager().signData(data);
cout << ">> D: " << data << endl;
@@ -157,8 +160,8 @@
}
void
- interestManager::processInterestForCorLsa(Nlsr& pnlsr,
- const ndn::Interest &interest,
+ InterestManager::processInterestForCorLsa(Nlsr& pnlsr,
+ const ndn::Interest& interest,
string lsaKey, uint32_t interestedlsSeqNo)
{
std::pair<CorLsa&, bool> corLsa=pnlsr.getLsdb().getCorLsa(lsaKey);
@@ -167,8 +170,8 @@
if ( corLsa.first.getLsSeqNo() >= interestedlsSeqNo )
{
Data data(ndn::Name(interest.getName()).appendVersion());
- data.setFreshnessPeriod(1000); // 10 sec
- string content=corLsa.first.getCorLsaData();
+ data.setFreshnessPeriod(time::seconds(10)); // 10 sec
+ string content=corLsa.first.getData();
data.setContent((const uint8_t*)content.c_str(),content.size());
pnlsr.getKeyManager().signData(data);
cout << ">> D: " << data << endl;
@@ -178,7 +181,7 @@
}
void
- interestManager::processInterestKeys(Nlsr& pnlsr,const ndn::Interest &interest)
+ InterestManager::processInterestKeys(Nlsr& pnlsr,const ndn::Interest& interest)
{
cout<<"processInterestKeys called "<<endl;
string intName=interest.getName().toUri();
@@ -227,7 +230,7 @@
dataName=ndn::Name(interest.getName());
}
Data data(dataName.appendVersion());
- data.setFreshnessPeriod(1000); //10 sec
+ data.setFreshnessPeriod(time::seconds(10)); //10 sec
data.setContent(chkCert.first->wireEncode());
pnlsr.getKeyManager().signData(data);
pnlsr.getNlsrFace()->put(data);
@@ -236,8 +239,8 @@
void
- interestManager::processInterestTimedOut(Nlsr& pnlsr,
- const ndn::Interest &interest)
+ InterestManager::processInterestTimedOut(Nlsr& pnlsr,
+ const ndn::Interest& interest)
{
cout << "Timed out interest : " << interest.getName().toUri() << endl;
string intName= interest.getName().toUri();
@@ -256,8 +259,8 @@
}
void
- interestManager::processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
- const ndn::Interest &interest)
+ InterestManager::processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
+ const ndn::Interest& interest)
{
pnlsr.getAdl().incrementTimedOutInterestCount(neighbor);
int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
@@ -289,35 +292,35 @@
}
void
- interestManager::processInterestTimedOutLsa(Nlsr& pnlsr,
- const ndn::Interest &interest)
+ InterestManager::processInterestTimedOutLsa(Nlsr& pnlsr,
+ const ndn::Interest& interest)
{
}
void
- interestManager::expressInterest(Nlsr& pnlsr,const string& interestNamePrefix,
+ InterestManager::expressInterest(Nlsr& pnlsr,const string& interestNamePrefix,
int scope, int seconds)
{
cout<<"Expressing Interest :"<<interestNamePrefix<<endl;
ndn::Interest i((ndn::Name(interestNamePrefix)));
//i.setScope(scope);
- i.setInterestLifetime(seconds*1000);
+ 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,
+ ndn::func_lib::bind(&InterestManager::processInterestTimedOut,
this,boost::ref(pnlsr),_1));
}
void
- interestManager::sendScheduledInfoInterest(Nlsr& pnlsr, int seconds)
+ 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"+
+ string adjName=(*it).getName()+"/"+"info"+
pnlsr.getConfParameter().getRouterPrefix();
expressInterest( pnlsr,adjName,2,
pnlsr.getConfParameter().getInterestResendTime());
@@ -326,10 +329,10 @@
}
void
- interestManager::scheduleInfoInterest(Nlsr& pnlsr, int seconds)
+ InterestManager::scheduleInfoInterest(Nlsr& pnlsr, int seconds)
{
EventId eid=pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
- ndn::bind(&interestManager::sendScheduledInfoInterest, this,
+ ndn::bind(&InterestManager::sendScheduledInfoInterest, this,
boost::ref(pnlsr),seconds));
}
diff --git a/src/communication/nlsr_im.hpp b/src/communication/nlsr_im.hpp
index c150e8f..5b74174 100644
--- a/src/communication/nlsr_im.hpp
+++ b/src/communication/nlsr_im.hpp
@@ -13,30 +13,30 @@
class Nlsr;
- class interestManager
+ class InterestManager
{
public:
- interestManager()
+ InterestManager()
{
}
- void processInterest(Nlsr& pnlsr, const ndn::Name &name,
- const ndn::Interest &interest);
+ void processInterest(Nlsr& pnlsr, const ndn::Name& name,
+ const ndn::Interest& interest);
void processInterestInfo(Nlsr& pnlsr, string& neighbor,
- const ndn::Interest &interest);
- void processInterestLsa(Nlsr& pnlsr,const ndn::Interest &interest);
- void processInterestForNameLsa(Nlsr& pnlsr, const ndn::Interest &interest,
+ const ndn::Interest& interest);
+ void processInterestLsa(Nlsr& pnlsr,const ndn::Interest& interest);
+ void processInterestForNameLsa(Nlsr& pnlsr, const ndn::Interest& interest,
string lsaKey, uint32_t interestedlsSeqNo);
- void processInterestForAdjLsa(Nlsr& pnlsr, const ndn::Interest &interest,
+ void processInterestForAdjLsa(Nlsr& pnlsr, const ndn::Interest& interest,
string lsaKey, uint32_t interestedlsSeqNo);
- void processInterestForCorLsa(Nlsr& pnlsr, const ndn::Interest &interest,
+ void processInterestForCorLsa(Nlsr& pnlsr, const ndn::Interest& interest,
string lsaKey, uint32_t interestedlsSeqNo);
- void processInterestKeys(Nlsr& pnlsr,const ndn::Interest &interest);
+ void processInterestKeys(Nlsr& pnlsr,const ndn::Interest& interest);
- void processInterestTimedOut(Nlsr& pnlsr, const ndn::Interest &interest);
+ void processInterestTimedOut(Nlsr& pnlsr, const ndn::Interest& interest);
void processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
- const ndn::Interest &interest);
- void processInterestTimedOutLsa(Nlsr& pnlsr,const ndn::Interest &interest);
+ const ndn::Interest& interest);
+ void processInterestTimedOutLsa(Nlsr& pnlsr,const ndn::Interest& interest);
void expressInterest(Nlsr& pnlsr,const string& interestNamePrefix, int scope,
int seconds);
void sendScheduledInfoInterest(Nlsr& pnlsr, int seconds);
diff --git a/src/communication/nlsr_slh.cpp b/src/communication/nlsr_slh.cpp
index 189612a..70295aa 100644
--- a/src/communication/nlsr_slh.cpp
+++ b/src/communication/nlsr_slh.cpp
@@ -2,16 +2,19 @@
#include "nlsr_slh.hpp"
#include "security/nlsr_km.hpp"
#include "utility/nlsr_tokenizer.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_slh.cpp"
namespace nlsr
{
void
- SyncLogicHandler::createSyncSocket(Nlsr &pnlsr )
+ SyncLogicHandler::createSyncSocket(Nlsr& pnlsr )
{
cout<<"Creating Sync socket ......"<<endl;
- cout<<"Sync prefix: "<<syncPrefix.toUri()<<endl;
- syncSocket=make_shared<SyncSocket>(syncPrefix, validator, syncFace,
+ cout<<"Sync prefix: "<<m_syncPrefix.toUri()<<endl;
+ m_syncSocket=make_shared<SyncSocket>(m_syncPrefix, m_validator, m_syncFace,
bind(&SyncLogicHandler::nsyncUpdateCallBack,this,
_1, _2,boost::ref(pnlsr)),
bind(&SyncLogicHandler::nsyncRemoveCallBack, this,
@@ -130,10 +133,6 @@
void
SyncLogicHandler::publishKeyUpdate(KeyManager& km)
{
- //publishSyncUpdate(km.getRootCertName().toUri(), 10);
- //publishSyncUpdate(km.getSiteCertName().toUri(), 10);
- //publishSyncUpdate(km.getOperatorCertName().toUri(), 10);
- //publishSyncUpdate(km.getRouterCertName().toUri(), km.getCertSeqNo());
publishSyncUpdate(km.getProcessCertName().toUri(),km.getCertSeqNo());
}
@@ -151,7 +150,7 @@
cout<<"Seq No: "<<seqNo<<endl;
ndn::Name updateName(updatePrefix);
string data("NoData");
- syncSocket->publishData(updateName,0,data.c_str(),data.size(),1000,seqNo);
+ m_syncSocket->publishData(updateName,0,data.c_str(),data.size(),1000,seqNo);
}
}
diff --git a/src/communication/nlsr_slh.hpp b/src/communication/nlsr_slh.hpp
index 420210d..4f90fd6 100644
--- a/src/communication/nlsr_slh.hpp
+++ b/src/communication/nlsr_slh.hpp
@@ -20,7 +20,7 @@
using namespace Sync;
using namespace std;
-class interestManager;
+class InterestManager;
class ConfParameter;
namespace nlsr
@@ -29,23 +29,23 @@
{
public:
SyncLogicHandler(ndn::shared_ptr<boost::asio::io_service> ioService)
- : validator(new ndn::ValidatorNull())
- , syncFace(new ndn::Face(ioService))
+ : m_validator(new ndn::ValidatorNull())
+ , m_syncFace(new ndn::Face(ioService))
{}
void createSyncSocket(Nlsr& pnlsr);
- void nsyncUpdateCallBack(const vector<MissingDataInfo> &v,
+ void nsyncUpdateCallBack(const vector<MissingDataInfo>& v,
SyncSocket *socket, Nlsr& pnlsr );
- void nsyncRemoveCallBack(const string& prefix, Nlsr &pnlsr);
+ void nsyncRemoveCallBack(const string& prefix, Nlsr& pnlsr);
void removeRouterFromSyncing(string& routerPrefix);
void publishRoutingUpdate(SequencingManager& sm, string updatePrefix);
void publishKeyUpdate(KeyManager& km);
void publishIdentityUpdate(string identityName);
void setSyncPrefix(string sp)
{
- syncPrefix.clear();
- syncPrefix.set(sp);
+ m_syncPrefix.clear();
+ m_syncPrefix.set(sp);
}
private:
void processUpdateFromSync(std::string updateName, uint64_t seqNo,
@@ -56,10 +56,10 @@
Nlsr& pnlsr);
void publishSyncUpdate(string updatePrefix, uint64_t seqNo);
private:
- ndn::shared_ptr<ndn::ValidatorNull> validator;
- ndn::shared_ptr<ndn::Face> syncFace;
- ndn::shared_ptr<SyncSocket> syncSocket;
- ndn::Name syncPrefix;
+ ndn::shared_ptr<ndn::ValidatorNull> m_validator;
+ ndn::shared_ptr<ndn::Face> m_syncFace;
+ ndn::shared_ptr<SyncSocket> m_syncSocket;
+ ndn::Name m_syncPrefix;
};
}
#endif
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 08338f2..13e7906 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -1,6 +1,7 @@
#include <cstdlib>
#include <string>
#include <sstream>
+#include <cstdio>
#include <ndn-cpp-dev/face.hpp>
#include <ndn-cpp-dev/security/key-chain.hpp>
#include <ndn-cpp-dev/security/identity-certificate.hpp>
@@ -14,6 +15,7 @@
#include "security/nlsr_cert_store.hpp"
#include "security/nlsr_cse.hpp"
+#define THIS_FILE "nlsr.cpp"
namespace nlsr
{
@@ -33,46 +35,49 @@
Nlsr::setInterestFilterNlsr(const string& name)
{
getNlsrFace()->setInterestFilter(name,
- func_lib::bind(&interestManager::processInterest, &im,
+ func_lib::bind(&InterestManager::processInterest, &m_im,
boost::ref(*this), _1, _2),
func_lib::bind(&Nlsr::nlsrRegistrationFailed, this, _1));
}
void
- Nlsr::initNlsr()
+ Nlsr::initialize()
{
- confParam.buildRouterPrefix();
- nlsrLogger.initNlsrLogger(confParam.getLogDir());
- nlsrLsdb.setLsaRefreshTime(confParam.getLsaRefreshTime());
- nlsrLsdb.setThisRouterPrefix(confParam.getRouterPrefix());
- fib.setFibEntryRefreshTime(2*confParam.getLsaRefreshTime());
- if( ! km.initKeyManager(confParam) )
+ src::logger lg;
+ m_confParam.buildRouterPrefix();
+ m_nlsrLogger.initNlsrLogger(m_confParam.getLogDir());
+ m_nlsrLsdb.setLsaRefreshTime(m_confParam.getLsaRefreshTime());
+ m_nlsrLsdb.setThisRouterPrefix(m_confParam.getRouterPrefix());
+ m_fib.setEntryRefreshTime(2*m_confParam.getLsaRefreshTime());
+ if( ! m_km.initialize(m_confParam) )
{
std::cerr<<"Can not initiate/load certificate"<<endl;
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Certificate initiation"
+ <<" error";
}
- sm.setSeqFileName(confParam.getSeqFileDir());
- sm.initiateSeqNoFromFile();
+ m_sm.setSeqFileName(m_confParam.getSeqFileDir());
+ m_sm.initiateSeqNoFromFile();
/* debugging purpose start */
- cout << confParam;
- adl.printAdl();
- npl.printNpl();
+ cout << m_confParam;
+ m_adl.printAdl();
+ m_npl.print();
/* debugging purpose end */
- nlsrLsdb.buildAndInstallOwnNameLsa(boost::ref(*this));
- nlsrLsdb.buildAndInstallOwnCorLsa(boost::ref(*this));
- setInterestFilterNlsr(confParam.getRouterPrefix());
- setInterestFilterNlsr(confParam.getChronosyncLsaPrefix()+
- confParam.getRouterPrefix());
- setInterestFilterNlsr(confParam.getRootKeyPrefix());
- slh.setSyncPrefix(confParam.getChronosyncSyncPrefix());
- slh.createSyncSocket(boost::ref(*this));
- slh.publishKeyUpdate(km);
- im.scheduleInfoInterest(boost::ref(*this),10);
+ m_nlsrLsdb.buildAndInstallOwnNameLsa(boost::ref(*this));
+ m_nlsrLsdb.buildAndInstallOwnCorLsa(boost::ref(*this));
+ setInterestFilterNlsr(m_confParam.getRouterPrefix());
+ setInterestFilterNlsr(m_confParam.getChronosyncLsaPrefix()+
+ m_confParam.getRouterPrefix());
+ setInterestFilterNlsr(m_confParam.getRootKeyPrefix());
+ m_slh.setSyncPrefix(m_confParam.getChronosyncSyncPrefix());
+ m_slh.createSyncSocket(boost::ref(*this));
+ m_slh.publishKeyUpdate(m_km);
+ m_im.scheduleInfoInterest(boost::ref(*this),10);
}
void
Nlsr::startEventLoop()
{
- io->run();
+ m_io->run();
}
int
@@ -95,6 +100,7 @@
int
main(int argc, char **argv)
{
+ src::logger lg;
nlsr::Nlsr nlsr_;
string programName(argv[0]);
nlsr_.setConfFileName("nlsr.conf");
@@ -102,7 +108,7 @@
while ((opt = getopt(argc, argv, "df:p:h")) != -1)
{
switch (opt)
- {
+ {
case 'f':
nlsr_.setConfFileName(optarg);
break;
@@ -121,15 +127,16 @@
default:
nlsr_.usage(programName);
return EXIT_FAILURE;
- }
+ }
}
ConfFileProcessor cfp(nlsr_.getConfFileName());
int res=cfp.processConfFile(nlsr_);
if ( res < 0 )
{
+ std::cerr<<"Error in configuration file processing! Exiting from NLSR"<<std::endl;
return EXIT_FAILURE;
}
- nlsr_.initNlsr();
+ nlsr_.initialize();
try
{
nlsr_.startEventLoop();
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index 9a580f3..0c406ac 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -30,28 +30,28 @@
{
public:
Nlsr()
- : io(ndn::make_shared<boost::asio::io_service>())
- , nlsrFace(make_shared<ndn::Face>(io))
- , scheduler(*io)
- , confParam()
- , adl()
- , npl()
- , im()
- , dm()
- , sm()
- , km()
+ : m_io(ndn::make_shared<boost::asio::io_service>())
+ , m_nlsrFace(make_shared<ndn::Face>(m_io))
+ , m_scheduler(*m_io)
+ , m_confParam()
+ , m_adl()
+ , m_npl()
+ , m_im()
+ , m_dm()
+ , m_sm()
+ , m_km()
, isDaemonProcess(false)
- , configFileName("nlsr.conf")
- , nlsrLsdb()
- , adjBuildCount(0)
+ , m_configFileName("nlsr.conf")
+ , m_nlsrLsdb()
+ , m_adjBuildCount(0)
, isBuildAdjLsaSheduled(0)
, isRouteCalculationScheduled(0)
, isRoutingTableCalculating(0)
- , routingTable()
- , npt()
- , fib()
- , slh(io)
- , nlsrLogger()
+ , m_routingTable()
+ , m_npt()
+ , m_fib()
+ , m_slh(m_io)
+ , m_nlsrLogger()
{}
void nlsrRegistrationFailed(const ndn::Name& name);
@@ -63,15 +63,15 @@
string getConfFileName()
{
- return configFileName;
+ return m_configFileName;
}
void setConfFileName(const string& fileName)
{
- configFileName=fileName;
+ m_configFileName=fileName;
}
- bool isSetDaemonProcess()
+ bool getIsSetDaemonProcess()
{
return isDaemonProcess;
}
@@ -83,88 +83,88 @@
ConfParameter& getConfParameter()
{
- return confParam;
+ return m_confParam;
}
Adl& getAdl()
{
- return adl;
+ return m_adl;
}
Npl& getNpl()
{
- return npl;
+ return m_npl;
}
ndn::shared_ptr<boost::asio::io_service>& getIo()
{
- return io;
+ return m_io;
}
ndn::Scheduler& getScheduler()
{
- return scheduler;
+ return m_scheduler;
}
ndn::shared_ptr<ndn::Face> getNlsrFace()
{
- return nlsrFace;
+ return m_nlsrFace;
}
KeyManager& getKeyManager()
{
- return km;
+ return m_km;
}
- interestManager& getIm()
+ InterestManager& getIm()
{
- return im;
+ return m_im;
}
DataManager& getDm()
{
- return dm;
+ return m_dm;
}
SequencingManager& getSm()
{
- return sm;
+ return m_sm;
}
Lsdb& getLsdb()
{
- return nlsrLsdb;
+ return m_nlsrLsdb;
}
RoutingTable& getRoutingTable()
{
- return routingTable;
+ return m_routingTable;
}
Npt& getNpt()
{
- return npt;
+ return m_npt;
}
Fib& getFib()
{
- return fib;
+ return m_fib;
}
long int getAdjBuildCount()
{
- return adjBuildCount;
+ return m_adjBuildCount;
}
void incrementAdjBuildCount()
{
- adjBuildCount++;
+ m_adjBuildCount++;
}
void setAdjBuildCount(long int abc)
{
- adjBuildCount=abc;
+ m_adjBuildCount=abc;
}
int getIsBuildAdjLsaSheduled()
@@ -172,7 +172,7 @@
return isBuildAdjLsaSheduled;
}
- void setIsBuildAdjLsaSheduled(int iabls)
+ void setIsBuildAdjLsaSheduled(bool iabls)
{
isBuildAdjLsaSheduled=iabls;
}
@@ -180,72 +180,72 @@
void setApiPort(int ap)
{
- apiPort=ap;
+ m_apiPort=ap;
}
int getApiPort()
{
- return apiPort;
+ return m_apiPort;
}
- int getIsRoutingTableCalculating()
+ bool getIsRoutingTableCalculating()
{
return isRoutingTableCalculating;
}
- void setIsRoutingTableCalculating(int irtc)
+ void setIsRoutingTableCalculating(bool irtc)
{
isRoutingTableCalculating=irtc;
}
- int getIsRouteCalculationScheduled()
+ bool getIsRouteCalculationScheduled()
{
return isRouteCalculationScheduled;
}
- void setIsRouteCalculationScheduled(int ircs)
+ void setIsRouteCalculationScheduled(bool ircs)
{
isRouteCalculationScheduled=ircs;
}
SyncLogicHandler& getSlh()
{
- return slh;
+ return m_slh;
}
NlsrLogger& getNlsrLogger()
{
- return nlsrLogger;
+ return m_nlsrLogger;
}
- void initNlsr();
+ void initialize();
private:
- ConfParameter confParam;
- Adl adl;
- Npl npl;
- ndn::shared_ptr<boost::asio::io_service> io;
- ndn::Scheduler scheduler;
- ndn::shared_ptr<ndn::Face> nlsrFace;
- interestManager im;
- DataManager dm;
- SequencingManager sm;
- KeyManager km;
+ ConfParameter m_confParam;
+ Adl m_adl;
+ Npl m_npl;
+ ndn::shared_ptr<boost::asio::io_service> m_io;
+ ndn::Scheduler m_scheduler;
+ ndn::shared_ptr<ndn::Face> m_nlsrFace;
+ InterestManager m_im;
+ DataManager m_dm;
+ SequencingManager m_sm;
+ KeyManager m_km;
bool isDaemonProcess;
- string configFileName;
- int apiPort;
+ string m_configFileName;
+ int m_apiPort;
- Lsdb nlsrLsdb;
- RoutingTable routingTable;
- Npt npt;
- Fib fib;
- SyncLogicHandler slh;
- NlsrLogger nlsrLogger;
+ Lsdb m_nlsrLsdb;
+ RoutingTable m_routingTable;
+ Npt m_npt;
+ Fib m_fib;
+ SyncLogicHandler m_slh;
+ NlsrLogger m_nlsrLogger;
- long int adjBuildCount;
- int isBuildAdjLsaSheduled;
- int isRouteCalculationScheduled;
- int isRoutingTableCalculating;
+ long int m_adjBuildCount;
+ bool isBuildAdjLsaSheduled;
+ bool isRouteCalculationScheduled;
+ bool isRoutingTableCalculating;
diff --git a/src/nlsr_adjacent.cpp b/src/nlsr_adjacent.cpp
index f636e5c..6ef9c0b 100644
--- a/src/nlsr_adjacent.cpp
+++ b/src/nlsr_adjacent.cpp
@@ -2,8 +2,10 @@
#include<string>
#include<cmath>
#include<limits>
-
#include "nlsr_adjacent.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_adjacent.cpp"
namespace nlsr
{
@@ -12,26 +14,26 @@
Adjacent::Adjacent(const string& an, int cf, double lc, int s, int iton)
{
- adjacentName=an;
- connectingFace=cf;
- linkCost=lc;
- status=s;
- interestTimedOutNo=iton;
+ m_name=an;
+ m_connectingFace=cf;
+ m_linkCost=lc;
+ m_status=s;
+ m_interestTimedOutNo=iton;
}
bool
- Adjacent::isAdjacentEqual(Adjacent& adj)
+ Adjacent::isEqual(Adjacent& adj)
{
- return ( adjacentName == adj.getAdjacentName() ) &&
- ( connectingFace == adj.getConnectingFace() ) &&
- (std::abs(linkCost - adj.getLinkCost()) <
+ return ( m_name == adj.getName() ) &&
+ ( m_connectingFace == adj.getConnectingFace() ) &&
+ (std::abs(m_linkCost - adj.getLinkCost()) <
std::numeric_limits<double>::epsilon()) ;
}
std::ostream&
operator << (std::ostream &os, Adjacent &adj)
{
- cout<<"Adjacent : "<< adj.getAdjacentName() << endl;
+ cout<<"Adjacent : "<< adj.getName() << endl;
cout<<"Connecting Face: "<<adj.getConnectingFace()<<endl;
cout<<"Link Cost: "<<adj.getLinkCost()<<endl;
cout<<"Status: "<<adj.getStatus()<<endl;
diff --git a/src/nlsr_adjacent.hpp b/src/nlsr_adjacent.hpp
index 23f334c..f9a789a 100644
--- a/src/nlsr_adjacent.hpp
+++ b/src/nlsr_adjacent.hpp
@@ -11,82 +11,82 @@
public:
Adjacent()
- :adjacentName()
- ,connectingFace(0)
- ,linkCost(10.0)
- ,status(0)
- ,interestTimedOutNo(0)
+ :m_name()
+ ,m_connectingFace(0)
+ ,m_linkCost(10.0)
+ ,m_status(0)
+ ,m_interestTimedOutNo(0)
{
}
Adjacent(const string& an)
- :connectingFace(0)
- ,linkCost(0.0)
- ,status(0)
- ,interestTimedOutNo(0)
+ :m_connectingFace(0)
+ ,m_linkCost(0.0)
+ ,m_status(0)
+ ,m_interestTimedOutNo(0)
{
- adjacentName=an;
+ m_name=an;
}
Adjacent(const string& an, int cf, double lc, int s, int iton);
- string getAdjacentName()
+ string getName()
{
- return adjacentName;
+ return m_name;
}
- void setAdjacentName(const string& an)
+ void setName(const string& an)
{
- adjacentName=an;
+ m_name=an;
}
int getConnectingFace()
{
- return connectingFace;
+ return m_connectingFace;
}
void setConnectingFace(int cf)
{
- connectingFace=cf;
+ m_connectingFace=cf;
}
double getLinkCost()
{
- return linkCost;
+ return m_linkCost;
}
void setLinkCost(double lc)
{
- linkCost=lc;
+ m_linkCost=lc;
}
int getStatus()
{
- return status;
+ return m_status;
}
void setStatus(int s)
{
- status=s;
+ m_status=s;
}
int getInterestTimedOutNo()
{
- return interestTimedOutNo;
+ return m_interestTimedOutNo;
}
void setInterestTimedOutNo(int iton)
{
- interestTimedOutNo=iton;
+ m_interestTimedOutNo=iton;
}
- bool isAdjacentEqual(Adjacent& adj);
+ bool isEqual(Adjacent& adj);
private:
- string adjacentName;
- int connectingFace;
- double linkCost;
- int status;
- int interestTimedOutNo;
+ string m_name;
+ int m_connectingFace;
+ double m_linkCost;
+ int m_status;
+ int m_interestTimedOutNo;
};
std::ostream&
diff --git a/src/nlsr_adl.cpp b/src/nlsr_adl.cpp
index ab5db84..fd84f9e 100644
--- a/src/nlsr_adl.cpp
+++ b/src/nlsr_adl.cpp
@@ -4,6 +4,9 @@
#include "nlsr_adl.hpp"
#include "nlsr_adjacent.hpp"
#include "nlsr.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_adl.cpp"
namespace nlsr
{
@@ -19,20 +22,20 @@
static bool
adjacent_compare(Adjacent& adj1, Adjacent& adj2)
{
- return adj1.getAdjacentName()==adj2.getAdjacentName();
+ return adj1.getName()==adj2.getName();
}
int
Adl::insert(Adjacent& adj)
{
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if ( it != adjList.end() )
+ if ( it != m_adjList.end() )
{
return -1;
}
- adjList.push_back(adj);
+ m_adjList.push_back(adj);
return 0;
}
@@ -50,10 +53,10 @@
Adl::updateAdjacentStatus(string adjName, int s)
{
Adjacent adj(adjName);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it == adjList.end())
+ if( it == m_adjList.end())
{
return -1;
}
@@ -65,10 +68,10 @@
Adl::getAdjacent(string adjName)
{
Adjacent adj(adjName);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it != adjList.end())
+ if( it != m_adjList.end())
{
return (*it);
}
@@ -77,28 +80,28 @@
bool
- Adl::isAdlEqual(Adl &adl)
+ Adl::isEqual(Adl& adl)
{
- if ( getAdlSize() != adl.getAdlSize() )
+ if ( getSize() != adl.getSize() )
{
return false;
}
- adjList.sort(adjacent_compare);
+ m_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() ;
- it1!=adjList.end(); it1++,it2++)
+ for(it1=m_adjList.begin() , it2=adjList2.begin() ;
+ it1!=m_adjList.end(); it1++,it2++)
{
- if ( !(*it1).isAdjacentEqual((*it2)) )
+ if ( !(*it1).isEqual((*it2)) )
{
break;
}
equalAdjCount++;
}
- return equalAdjCount==getAdlSize();
+ return equalAdjCount==getSize();
}
@@ -106,10 +109,10 @@
Adl::updateAdjacentLinkCost(string adjName, double lc)
{
Adjacent adj(adjName);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it == adjList.end())
+ if( it == m_adjList.end())
{
return -1;
}
@@ -121,10 +124,10 @@
Adl::isNeighbor(string adjName)
{
Adjacent adj(adjName);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it == adjList.end())
+ if( it == m_adjList.end())
{
return false;
}
@@ -135,10 +138,10 @@
Adl::incrementTimedOutInterestCount(string& neighbor)
{
Adjacent adj(neighbor);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it == adjList.end())
+ if( it == m_adjList.end())
{
return ;
}
@@ -149,10 +152,10 @@
Adl::setTimedOutInterestCount(string& neighbor, int count)
{
Adjacent adj(neighbor);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it != adjList.end())
+ if( it != m_adjList.end())
{
(*it).setInterestTimedOutNo(count);
}
@@ -162,10 +165,10 @@
Adl::getTimedOutInterestCount(string& neighbor)
{
Adjacent adj(neighbor);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it == adjList.end())
+ if( it == m_adjList.end())
{
return -1;
}
@@ -176,10 +179,10 @@
Adl::getStatusOfNeighbor(string& neighbor)
{
Adjacent adj(neighbor);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it == adjList.end())
+ if( it == m_adjList.end())
{
return -1;
}
@@ -190,10 +193,10 @@
Adl::setStatusOfNeighbor(string& neighbor, int status)
{
Adjacent adj(neighbor);
- std::list<Adjacent >::iterator it = std::find_if( adjList.begin(),
- adjList.end(),
+ std::list<Adjacent >::iterator it = std::find_if( m_adjList.begin(),
+ m_adjList.end(),
bind(&adjacent_compare, _1, adj));
- if( it != adjList.end())
+ if( it != m_adjList.end())
{
(*it).setStatus(status);
}
@@ -202,15 +205,15 @@
std::list<Adjacent>&
Adl::getAdjList()
{
- return adjList;
+ return m_adjList;
}
bool
Adl::isAdjLsaBuildable(Nlsr& pnlsr)
{
int nbrCount=0;
- for( std::list<Adjacent>::iterator it=adjList.begin();
- it!= adjList.end() ; it++)
+ for( std::list<Adjacent>::iterator it=m_adjList.begin();
+ it!= m_adjList.end() ; it++)
{
if ( ((*it).getStatus() == 1 ) )
{
@@ -225,7 +228,7 @@
}
}
}
- if( nbrCount == adjList.size())
+ if( nbrCount == m_adjList.size())
{
return true;
}
@@ -236,8 +239,8 @@
Adl::getNumOfActiveNeighbor()
{
int actNbrCount=0;
- for( std::list<Adjacent>::iterator it=adjList.begin();
- it!= adjList.end() ; it++)
+ for( std::list<Adjacent>::iterator it=m_adjList.begin();
+ it!= m_adjList.end() ; it++)
{
if ( ((*it).getStatus() == 1 ) )
{
@@ -251,7 +254,7 @@
void
Adl::printAdl()
{
- for( std::list<Adjacent>::iterator it=adjList.begin(); it!= adjList.end() ;
+ for( std::list<Adjacent>::iterator it=m_adjList.begin(); it!= m_adjList.end() ;
it++)
{
cout<< (*it) <<endl;
diff --git a/src/nlsr_adl.hpp b/src/nlsr_adl.hpp
index 82edaf0..ad85f01 100644
--- a/src/nlsr_adl.hpp
+++ b/src/nlsr_adl.hpp
@@ -34,25 +34,25 @@
int getNumOfActiveNeighbor();
Adjacent getAdjacent(string adjName);
- bool isAdlEqual(Adl &adl);
+ bool isEqual(Adl& adl);
- int getAdlSize()
+ int getSize()
{
- return adjList.size();
+ return m_adjList.size();
}
- void resetAdl()
+ void reset()
{
- if( adjList.size() > 0 )
+ if( m_adjList.size() > 0 )
{
- adjList.clear();
+ m_adjList.clear();
}
}
void printAdl();
private:
- std::list< Adjacent > adjList;
+ std::list< Adjacent > m_adjList;
};
} //namespace nlsr
diff --git a/src/nlsr_conf_param.cpp b/src/nlsr_conf_param.cpp
index 4f879e3..84f0f74 100644
--- a/src/nlsr_conf_param.cpp
+++ b/src/nlsr_conf_param.cpp
@@ -1,5 +1,7 @@
#include<iostream>
#include "nlsr_conf_param.hpp"
+#include "utility/nlsr_logger.hpp"
+#define THIS_FILE "nlsr_conf_param.cpp"
namespace nlsr
{
@@ -7,7 +9,7 @@
using namespace std;
ostream&
- operator << (ostream &os, ConfParameter& cfp)
+ operator << (ostream& os, ConfParameter& cfp)
{
os <<"Router Name: "<< cfp.getRouterName()<<endl;
os <<"Site Name: "<< cfp.getSiteName()<<endl;
diff --git a/src/nlsr_conf_param.hpp b/src/nlsr_conf_param.hpp
index 9446009..ddfa1a0 100644
--- a/src/nlsr_conf_param.hpp
+++ b/src/nlsr_conf_param.hpp
@@ -13,285 +13,285 @@
public:
ConfParameter()
- : chronosyncSyncPrefix("ndn/nlsr/sync")
- , chronosyncLsaPrefix("/ndn/nlsr/LSA")
- , rootKeyPrefix("/ndn/keys")
+ : m_chronosyncSyncPrefix("ndn/nlsr/sync")
+ , m_chronosyncLsaPrefix("/ndn/nlsr/LSA")
+ , m_rootKeyPrefix("/ndn/keys")
, isStrictHierchicalKeyCheck(0)
- , interestRetryNumber(3)
- , interestResendTime(5)
- , infoInterestInterval(60)
- , lsaRefreshTime(1800)
- , routerDeadInterval(3600)
- , maxFacesPerPrefix(0)
- , tunnelType(0)
- , detailedLogging(0)
- , certDir()
- , debugging(0)
+ , m_interestRetryNumber(3)
+ , m_interestResendTime(5)
+ , m_infoInterestInterval(60)
+ , m_lsaRefreshTime(1800)
+ , m_routerDeadInterval(3600)
+ , m_maxFacesPerPrefix(0)
+ , m_tunnelType(0)
+ , m_detailedLogging(0)
+ , m_certDir()
+ , m_debugging(0)
, isHyperbolicCalc(0)
- , seqFileDir()
- , corR(0)
- , corTheta(0)
+ , m_seqFileDir()
+ , m_corR(0)
+ , m_corTheta(0)
{}
void setRouterName(const string& rn)
{
- routerName=rn;
+ m_routerName=rn;
}
string getRouterName()
{
- return routerName;
+ return m_routerName;
}
void setSiteName(const string& sn)
{
- siteName=sn;
+ m_siteName=sn;
}
string getSiteName()
{
- return siteName;
+ return m_siteName;
}
void setNetwork(const string& nn)
{
- network=nn;
+ m_network=nn;
}
string getNetwork()
{
- return network;
+ return m_network;
}
void buildRouterPrefix()
{
- routerPrefix="/"+network+"/"+siteName+"/"+routerName;
+ m_routerPrefix="/"+m_network+"/"+m_siteName+"/"+m_routerName;
}
string getRouterPrefix()
{
- return routerPrefix;
+ return m_routerPrefix;
}
string getRootKeyPrefix()
{
- return rootKeyPrefix;
+ return m_rootKeyPrefix;
}
void setRootKeyPrefix(string rkp)
{
- rootKeyPrefix=rkp;
+ m_rootKeyPrefix=rkp;
}
void setInterestRetryNumber(int irn)
{
- interestRetryNumber=irn;
+ m_interestRetryNumber=irn;
}
int getInterestRetryNumber()
{
- return interestRetryNumber;
+ return m_interestRetryNumber;
}
void setInterestResendTime(int irt)
{
- interestResendTime=irt;
+ m_interestResendTime=irt;
}
int getInterestResendTime()
{
- return interestResendTime;
+ return m_interestResendTime;
}
void setLsaRefreshTime(int lrt)
{
- lsaRefreshTime=lrt;
- routerDeadInterval=2*lsaRefreshTime;
+ m_lsaRefreshTime=lrt;
+ m_routerDeadInterval=2*m_lsaRefreshTime;
}
int getLsaRefreshTime()
{
- return lsaRefreshTime;
+ return m_lsaRefreshTime;
}
void setRouterDeadInterval(int rdt)
{
- routerDeadInterval=rdt;
+ m_routerDeadInterval=rdt;
}
long int getRouterDeadInterval()
{
- return routerDeadInterval;
+ return m_routerDeadInterval;
}
void setMaxFacesPerPrefix(int mfpp)
{
- maxFacesPerPrefix=mfpp;
+ m_maxFacesPerPrefix=mfpp;
}
int getMaxFacesPerPrefix()
{
- return maxFacesPerPrefix;
+ return m_maxFacesPerPrefix;
}
void setLogDir(string ld)
{
- logDir=ld;
+ m_logDir=ld;
}
string getLogDir()
{
- return logDir;
+ return m_logDir;
}
void setCertDir(std::string cd)
{
- certDir=cd;
+ m_certDir=cd;
}
std::string getCertDir()
{
- return certDir;
+ return m_certDir;
}
void setSeqFileDir(string ssfd)
{
- seqFileDir=ssfd;
+ m_seqFileDir=ssfd;
}
string getSeqFileDir()
{
- return seqFileDir;
+ return m_seqFileDir;
}
void setDetailedLogging(int dl)
{
- detailedLogging=dl;
+ m_detailedLogging=dl;
}
int getDetailedLogging()
{
- return detailedLogging;
+ return m_detailedLogging;
}
void setDebugging(int d)
{
- debugging=d;
+ m_debugging=d;
}
int getDebugging()
{
- return debugging;
+ return m_debugging;
}
- void setIsHyperbolicCalc(int ihc)
+ void setIsHyperbolicCalc(bool ihc)
{
isHyperbolicCalc=ihc;
}
- int getIsHyperbolicCalc()
+ bool getIsHyperbolicCalc()
{
return isHyperbolicCalc;
}
void setCorR(double cr)
{
- corR=cr;
+ m_corR=cr;
}
double getCorR()
{
- return corR;
+ return m_corR;
}
void setCorTheta(double ct)
{
- corTheta=ct;
+ m_corTheta=ct;
}
double getCorTheta()
{
- return corTheta;
+ return m_corTheta;
}
void setTunnelType(int tt)
{
- tunnelType=tt;
+ m_tunnelType=tt;
}
int getTunnelType()
{
- return tunnelType;
+ return m_tunnelType;
}
void setChronosyncSyncPrefix(const string& csp)
{
- chronosyncSyncPrefix=csp;
+ m_chronosyncSyncPrefix=csp;
}
string getChronosyncSyncPrefix()
{
- return chronosyncSyncPrefix;
+ return m_chronosyncSyncPrefix;
}
void setChronosyncLsaPrefix(string clp)
{
- chronosyncLsaPrefix=clp;
+ m_chronosyncLsaPrefix=clp;
}
string getChronosyncLsaPrefix()
{
- return chronosyncLsaPrefix;
+ return m_chronosyncLsaPrefix;
}
int getInfoInterestInterval()
{
- return infoInterestInterval;
+ return m_infoInterestInterval;
}
void setInfoInterestInterval(int iii)
{
- infoInterestInterval=iii;
+ m_infoInterestInterval=iii;
}
private:
- string routerName;
- string siteName;
- string network;
+ string m_routerName;
+ string m_siteName;
+ string m_network;
- string routerPrefix;
- string lsaRouterPrefix;
+ string m_routerPrefix;
+ string m_lsaRouterPrefix;
- string chronosyncSyncPrefix;
- string chronosyncLsaPrefix;
+ string m_chronosyncSyncPrefix;
+ string m_chronosyncLsaPrefix;
- string rootKeyPrefix;
+ string m_rootKeyPrefix;
- int interestRetryNumber;
- int interestResendTime;
- int infoInterestInterval;
- int lsaRefreshTime;
- int routerDeadInterval;
+ int m_interestRetryNumber;
+ int m_interestResendTime;
+ int m_infoInterestInterval;
+ int m_lsaRefreshTime;
+ int m_routerDeadInterval;
- int maxFacesPerPrefix;
- string logDir;
- string certDir;
- string seqFileDir;
- string logFile;
- int detailedLogging;
- int debugging;
+ int m_maxFacesPerPrefix;
+ string m_logDir;
+ string m_certDir;
+ string m_seqFileDir;
+ string m_logFile;
+ int m_detailedLogging;
+ int m_debugging;
- int isHyperbolicCalc;
- double corR;
- double corTheta;
+ bool isHyperbolicCalc;
+ double m_corR;
+ double m_corTheta;
- int tunnelType;
- int isStrictHierchicalKeyCheck;
+ int m_tunnelType;
+ bool isStrictHierchicalKeyCheck;
};
std::ostream&
- operator << (std::ostream &os, ConfParameter &cfp);
+ operator << (std::ostream& os, ConfParameter& cfp);
} // namespace nlsr
diff --git a/src/nlsr_conf_processor.cpp b/src/nlsr_conf_processor.cpp
index 627be79..fd3c9ef 100644
--- a/src/nlsr_conf_processor.cpp
+++ b/src/nlsr_conf_processor.cpp
@@ -8,6 +8,9 @@
#include "nlsr_conf_param.hpp"
#include "utility/nlsr_tokenizer.hpp"
#include "nlsr_adjacent.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_conf_processor.cpp"
namespace nlsr
@@ -19,9 +22,9 @@
ConfFileProcessor::processConfFile(Nlsr& pnlsr)
{
int ret=0;
- if ( !confFileName.empty())
+ if ( !m_confFileName.empty())
{
- std::ifstream inputFile(confFileName.c_str());
+ std::ifstream inputFile(m_confFileName.c_str());
if ( inputFile.is_open())
{
for( string line; getline( inputFile, line ); )
@@ -41,7 +44,7 @@
}
else
{
- std::cerr <<"Configuration file: ("<<confFileName<<") does not exist :(";
+ std::cerr <<"Configuration file: ("<<m_confFileName<<") does not exist :(";
std::cerr <<endl;
ret=-1;
}
@@ -527,7 +530,7 @@
}
else
{
- pnlsr.getNpl().insertIntoNpl(command);
+ pnlsr.getNpl().insert(command);
}
return 0;
}
diff --git a/src/nlsr_conf_processor.hpp b/src/nlsr_conf_processor.hpp
index 25861a2..8448823 100644
--- a/src/nlsr_conf_processor.hpp
+++ b/src/nlsr_conf_processor.hpp
@@ -12,12 +12,12 @@
{
public:
ConfFileProcessor()
- :confFileName()
+ :m_confFileName()
{
}
ConfFileProcessor(const string& cfile)
{
- confFileName=cfile;
+ m_confFileName=cfile;
}
int processConfFile(Nlsr& pnlsr);
@@ -49,7 +49,7 @@
private:
- string confFileName;
+ string m_confFileName;
};
} //namespace nlsr
diff --git a/src/nlsr_lsa.cpp b/src/nlsr_lsa.cpp
index 4354393..0f97568 100644
--- a/src/nlsr_lsa.cpp
+++ b/src/nlsr_lsa.cpp
@@ -10,7 +10,9 @@
#include "nlsr_npl.hpp"
#include "nlsr_adjacent.hpp"
#include "utility/nlsr_tokenizer.hpp"
+#include "utility/nlsr_logger.hpp"
+#define THIS_FILE "nlsr_lsa.cpp"
namespace nlsr
{
@@ -19,36 +21,36 @@
string
- NameLsa::getNameLsaKey()
+ NameLsa::getKey()
{
string key;
- key=origRouter + "/" + boost::lexical_cast<std::string>(1);
+ key=m_origRouter + "/" + boost::lexical_cast<std::string>(1);
return key;
}
NameLsa::NameLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt, Npl npl)
{
- origRouter=origR;
- lsType=lst;
- lsSeqNo=lsn;
- lifeTime=lt;
+ m_origRouter=origR;
+ m_lsType=lst;
+ m_lsSeqNo=lsn;
+ m_lifeTime=lt;
std::list<string> nl=npl.getNameList();
for( std::list<string>::iterator it=nl.begin(); it != nl.end(); it++)
{
- addNameToLsa((*it));
+ addName((*it));
}
}
string
- NameLsa::getNameLsaData()
+ NameLsa::getData()
{
string nameLsaData;
- nameLsaData=origRouter + "|" + boost::lexical_cast<std::string>(1) + "|"
- + boost::lexical_cast<std::string>(lsSeqNo) + "|"
- + boost::lexical_cast<std::string>(lifeTime);
+ nameLsaData=m_origRouter + "|" + boost::lexical_cast<std::string>(1) + "|"
+ + boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
+ + boost::lexical_cast<std::string>(m_lifeTime);
nameLsaData+="|";
- nameLsaData+=boost::lexical_cast<std::string>(npl.getNplSize());
- std::list<string> nl=npl.getNameList();
+ nameLsaData+=boost::lexical_cast<std::string>(m_npl.getSize());
+ std::list<string> nl=m_npl.getNameList();
for( std::list<string>::iterator it=nl.begin(); it != nl.end(); it++)
{
nameLsaData+="|";
@@ -58,20 +60,20 @@
}
bool
- NameLsa::initNameLsaFromContent(string content)
+ NameLsa::initializeFromContent(string content)
{
uint32_t numName=0;
nlsrTokenizer nt(content, "|");
- origRouter=nt.getNextToken();
- if(origRouter.empty())
+ m_origRouter=nt.getNextToken();
+ if(m_origRouter.empty())
{
return false;
}
try
{
- lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
- lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
- lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
+ m_lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
+ m_lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
+ m_lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
numName=boost::lexical_cast<uint32_t>(nt.getNextToken());
}
catch(std::exception &e)
@@ -81,10 +83,30 @@
for(int i=0; i<numName; i++)
{
string name=nt.getNextToken();
- addNameToLsa(name);
+ addName(name);
}
return true;
}
+
+ void
+ NameLsa::writeLog()
+ {
+ src::logger lg;
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Name-LSA";
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<" Origination Router: "
+ <<m_origRouter;
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<" LS Type: "<<m_lsType;
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<" LS Seq: "<<m_lsSeqNo;
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<" LS Lifetime: "<<m_lifeTime;
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<" LS Data: ";
+ int i=1;
+ std::list<string> nl=m_npl.getNameList();
+ for( std::list<string>::iterator it=nl.begin(); it != nl.end(); it++)
+ {
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<" Name "<<i<<": "<<(*it);
+ }
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"name_lsa_end";
+ }
std::ostream&
operator<<(std::ostream& os, NameLsa& nLsa)
@@ -109,60 +131,60 @@
CorLsa::CorLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt
, double r, double theta)
{
- origRouter=origR;
- lsType=lst;
- lsSeqNo=lsn;
- lifeTime=lt;
- corRad=r;
- corTheta=theta;
+ m_origRouter=origR;
+ m_lsType=lst;
+ m_lsSeqNo=lsn;
+ m_lifeTime=lt;
+ m_corRad=r;
+ m_corTheta=theta;
}
string
- CorLsa::getCorLsaKey()
+ CorLsa::getKey()
{
string key;
- key=origRouter + "/" + boost::lexical_cast<std::string>(3);
+ key=m_origRouter + "/" + boost::lexical_cast<std::string>(3);
return key;
}
bool
- CorLsa::isLsaContentEqual(CorLsa& clsa)
+ CorLsa::isEqual(CorLsa& clsa)
{
- return (std::abs(corRad - clsa.getCorRadius()) <
+ return (std::abs(m_corRad - clsa.getCorRadius()) <
std::numeric_limits<double>::epsilon()) &&
- (std::abs(corTheta - clsa.getCorTheta()) <
+ (std::abs(m_corTheta - clsa.getCorTheta()) <
std::numeric_limits<double>::epsilon());
}
string
- CorLsa::getCorLsaData()
+ CorLsa::getData()
{
string corLsaData;
- corLsaData=origRouter + "|";
+ corLsaData=m_origRouter + "|";
corLsaData+=(boost::lexical_cast<std::string>(3) + "|");
- corLsaData+=(boost::lexical_cast<std::string>(lsSeqNo) + "|");
- corLsaData+=(boost::lexical_cast<std::string>(lifeTime) + "|");
- corLsaData+=(boost::lexical_cast<std::string>(corRad) + "|");
- corLsaData+=(boost::lexical_cast<std::string>(corTheta) + "|");
+ corLsaData+=(boost::lexical_cast<std::string>(m_lsSeqNo) + "|");
+ corLsaData+=(boost::lexical_cast<std::string>(m_lifeTime) + "|");
+ corLsaData+=(boost::lexical_cast<std::string>(m_corRad) + "|");
+ corLsaData+=(boost::lexical_cast<std::string>(m_corTheta) + "|");
return corLsaData;
}
bool
- CorLsa::initCorLsaFromContent(string content)
+ CorLsa::initializeFromContent(string content)
{
nlsrTokenizer nt(content, "|");
- origRouter=nt.getNextToken();
- if(origRouter.empty())
+ m_origRouter=nt.getNextToken();
+ if(m_origRouter.empty())
{
return false;
}
try
{
- lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
- lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
- lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
- corRad=boost::lexical_cast<double>(nt.getNextToken());
- corTheta=boost::lexical_cast<double>(nt.getNextToken());
+ m_lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
+ m_lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
+ m_lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
+ m_corRad=boost::lexical_cast<double>(nt.getNextToken());
+ m_corTheta=boost::lexical_cast<double>(nt.getNextToken());
}
catch(std::exception &e)
{
@@ -188,50 +210,50 @@
AdjLsa::AdjLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt,
uint32_t nl ,Adl padl)
{
- origRouter=origR;
- lsType=lst;
- lsSeqNo=lsn;
- lifeTime=lt;
- noLink=nl;
+ m_origRouter=origR;
+ m_lsType=lst;
+ m_lsSeqNo=lsn;
+ m_lifeTime=lt;
+ m_noLink=nl;
std::list<Adjacent> al=padl.getAdjList();
for( std::list<Adjacent>::iterator it=al.begin(); it != al.end(); it++)
{
if((*it).getStatus()==1)
{
- addAdjacentToLsa((*it));
+ addAdjacent((*it));
}
}
}
string
- AdjLsa::getAdjLsaKey()
+ AdjLsa::getKey()
{
string key;
- key=origRouter + "/" + boost::lexical_cast<std::string>(2);
+ key=m_origRouter + "/" + boost::lexical_cast<std::string>(2);
return key;
}
bool
- AdjLsa::isLsaContentEqual(AdjLsa& alsa)
+ AdjLsa::isEqual(AdjLsa& alsa)
{
- return adl.isAdlEqual(alsa.getAdl());
+ return m_adl.isEqual(alsa.getAdl());
}
string
- AdjLsa::getAdjLsaData()
+ AdjLsa::getData()
{
string adjLsaData;
- adjLsaData=origRouter + "|" + boost::lexical_cast<std::string>(2) + "|"
- + boost::lexical_cast<std::string>(lsSeqNo) + "|"
- + boost::lexical_cast<std::string>(lifeTime);
+ adjLsaData=m_origRouter + "|" + boost::lexical_cast<std::string>(2) + "|"
+ + boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
+ + boost::lexical_cast<std::string>(m_lifeTime);
adjLsaData+="|";
- adjLsaData+=boost::lexical_cast<std::string>(adl.getAdlSize());
- std::list<Adjacent> al=adl.getAdjList();
+ adjLsaData+=boost::lexical_cast<std::string>(m_adl.getSize());
+ std::list<Adjacent> al=m_adl.getAdjList();
for( std::list<Adjacent>::iterator it=al.begin(); it != al.end(); it++)
{
adjLsaData+="|";
- adjLsaData+=(*it).getAdjacentName();
+ adjLsaData+=(*it).getName();
adjLsaData+="|";
adjLsaData+=boost::lexical_cast<std::string>((*it).getConnectingFace());
adjLsaData+="|";
@@ -241,20 +263,20 @@
}
bool
- AdjLsa::initAdjLsaFromContent(string content)
+ AdjLsa::initializeFromContent(string content)
{
uint32_t numLink=0;
nlsrTokenizer nt(content, "|");
- origRouter=nt.getNextToken();
- if(origRouter.empty())
+ m_origRouter=nt.getNextToken();
+ if(m_origRouter.empty())
{
return false;
}
try
{
- lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
- lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
- lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
+ m_lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
+ m_lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
+ m_lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
numLink=boost::lexical_cast<uint32_t>(nt.getNextToken());
}
catch(std::exception &e)
@@ -269,7 +291,7 @@
int connectingFace=boost::lexical_cast<int>(nt.getNextToken());
double linkCost=boost::lexical_cast<double>(nt.getNextToken());
Adjacent adjacent(adjName, connectingFace, linkCost, 0, 0);
- addAdjacentToLsa(adjacent);
+ addAdjacent(adjacent);
}
catch( std::exception &e )
{
@@ -281,7 +303,7 @@
void
- AdjLsa::addNptEntriesForAdjLsa(Nlsr& pnlsr)
+ AdjLsa::addNptEntries(Nlsr& pnlsr)
{
if ( getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
@@ -291,7 +313,7 @@
void
- AdjLsa::removeNptEntriesForAdjLsa(Nlsr& pnlsr)
+ AdjLsa::removeNptEntries(Nlsr& pnlsr)
{
if ( getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
@@ -316,7 +338,7 @@
for( std::list<Adjacent>::iterator it=al.begin(); it != al.end(); it++)
{
os<<" Adjacent "<<i<<": "<<endl;
- os<<" Adjacent Name: "<<(*it).getAdjacentName()<<endl;
+ os<<" Adjacent Name: "<<(*it).getName()<<endl;
os<<" Connecting Face: "<<(*it).getConnectingFace()<<endl;
os<<" Link Cost: "<<(*it).getLinkCost()<<endl;
}
diff --git a/src/nlsr_lsa.hpp b/src/nlsr_lsa.hpp
index 06dcbc6..878d688 100644
--- a/src/nlsr_lsa.hpp
+++ b/src/nlsr_lsa.hpp
@@ -16,71 +16,70 @@
{
public:
Lsa()
- : origRouter()
- , lsSeqNo()
- , lifeTime()
- , lsaExpiringEventId()
+ : m_origRouter()
+ , m_lsSeqNo()
+ , m_lifeTime()
+ , m_expiringEventId()
{
}
void setLsType(uint8_t lst)
{
- lsType=lst;
+ m_lsType=lst;
}
uint8_t getLsType()
{
- return lsType;
+ return m_lsType;
}
void setLsSeqNo(uint32_t lsn)
{
- lsSeqNo=lsn;
+ m_lsSeqNo=lsn;
}
uint32_t getLsSeqNo()
{
- return lsSeqNo;
+ return m_lsSeqNo;
}
string& getOrigRouter()
{
- return origRouter;
+ return m_origRouter;
}
void setOrigRouter(string& org)
{
- origRouter=org;
+ m_origRouter=org;
}
uint32_t getLifeTime()
{
- return lifeTime;
+ return m_lifeTime;
}
void setLifeTime(uint32_t lt)
{
- lifeTime=lt;
+ m_lifeTime=lt;
}
- void setLsaExpiringEventId(ndn::EventId leei)
+ void setExpiringEventId(ndn::EventId leei)
{
- lsaExpiringEventId=leei;
+ m_expiringEventId=leei;
}
- ndn::EventId getLsaExpiringEventId()
+ ndn::EventId getExpiringEventId()
{
- return lsaExpiringEventId;
+ return m_expiringEventId;
}
-
protected:
- string origRouter;
- uint8_t lsType;
- uint32_t lsSeqNo;
- uint32_t lifeTime;
- ndn::EventId lsaExpiringEventId;
+ string m_origRouter;
+ uint8_t m_lsType;
+ uint32_t m_lsSeqNo;
+ uint32_t m_lifeTime;
+ ndn::EventId m_expiringEventId;
};
class NameLsa:public Lsa
@@ -88,7 +87,7 @@
public:
NameLsa()
: Lsa()
- , npl()
+ , m_npl()
{
setLsType(1);
}
@@ -97,26 +96,27 @@
Npl& getNpl()
{
- return npl;
+ return m_npl;
}
- void addNameToLsa(string& name)
+ void addName(string& name)
{
- npl.insertIntoNpl(name);
+ m_npl.insert(name);
}
- void removeNameFromLsa(string& name)
+ void removeName(string& name)
{
- npl.removeFromNpl(name);
+ m_npl.remove(name);
}
- string getNameLsaKey();
+ string getKey();
- string getNameLsaData();
- bool initNameLsaFromContent(string content);
+ string getData();
+ bool initializeFromContent(string content);
+ void writeLog();
private:
- Npl npl;
+ Npl m_npl;
};
@@ -128,7 +128,7 @@
public:
AdjLsa()
: Lsa()
- , adl()
+ , m_adl()
{
setLsType(2);
}
@@ -137,28 +137,28 @@
uint32_t nl ,Adl padl);
Adl& getAdl()
{
- return adl;
+ return m_adl;
}
- void addAdjacentToLsa(Adjacent adj)
+ void addAdjacent(Adjacent adj)
{
- adl.insert(adj);
+ m_adl.insert(adj);
}
- string getAdjLsaKey();
- string getAdjLsaData();
- bool initAdjLsaFromContent(string content);
+ string getKey();
+ string getData();
+ bool initializeFromContent(string content);
uint32_t getNoLink()
{
- return noLink;
+ return m_noLink;
}
- bool isLsaContentEqual(AdjLsa& alsa);
- void addNptEntriesForAdjLsa(Nlsr& pnlsr);
- void removeNptEntriesForAdjLsa(Nlsr& pnlsr);
+ bool isEqual(AdjLsa& alsa);
+ void addNptEntries(Nlsr& pnlsr);
+ void removeNptEntries(Nlsr& pnlsr);
private:
- uint32_t noLink;
- Adl adl;
+ uint32_t m_noLink;
+ Adl m_adl;
};
std::ostream&
@@ -169,22 +169,22 @@
public:
CorLsa()
: Lsa()
- , corRad(0)
- , corTheta(0)
+ , m_corRad(0)
+ , m_corTheta(0)
{
setLsType(3);
}
CorLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt
, double r, double theta);
- string getCorLsaKey();
- string getCorLsaData();
- bool initCorLsaFromContent(string content);
+ string getKey();
+ string getData();
+ bool initializeFromContent(string content);
double getCorRadius()
{
- if ( corRad >= 0 )
+ if ( m_corRad >= 0 )
{
- return corRad;
+ return m_corRad;
}
else
{
@@ -194,23 +194,23 @@
void setCorRadius(double cr)
{
- corRad=cr;
+ m_corRad=cr;
}
double getCorTheta()
{
- return corTheta;
+ return m_corTheta;
}
void setCorTheta(double ct)
{
- corTheta=ct;
+ m_corTheta=ct;
}
- bool isLsaContentEqual(CorLsa& clsa);
+ bool isEqual(CorLsa& clsa);
private:
- double corRad;
- double corTheta;
+ double m_corRad;
+ double m_corTheta;
};
diff --git a/src/nlsr_lsdb.cpp b/src/nlsr_lsdb.cpp
index 3da115a..7b662e2 100644
--- a/src/nlsr_lsdb.cpp
+++ b/src/nlsr_lsdb.cpp
@@ -2,6 +2,9 @@
#include<utility>
#include "nlsr_lsdb.hpp"
#include "nlsr.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_lsdb.cpp"
namespace nlsr
{
@@ -17,7 +20,7 @@
static bool
nameLsaCompareByKey(NameLsa& nlsa1, string& key)
{
- return nlsa1.getNameLsaKey()==key;
+ return nlsa1.getKey()==key;
}
@@ -76,11 +79,14 @@
bool
Lsdb::installNameLsa(Nlsr& pnlsr, NameLsa &nlsa)
{
+ src::logger lg;
int timeToExpire=lsaRefreshTime;
- std::pair<NameLsa& , bool> chkNameLsa=getNameLsa(nlsa.getNameLsaKey());
+ std::pair<NameLsa& , bool> chkNameLsa=getNameLsa(nlsa.getKey());
if ( !chkNameLsa.second )
{
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Adding name lsa";
addNameLsa(nlsa);
+ nlsa.writeLog();
printNameLsdb();
if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
@@ -99,17 +105,19 @@
{
timeToExpire=nlsa.getLifeTime();
}
- nlsa.setLsaExpiringEventId(scheduleNameLsaExpiration( pnlsr,
- nlsa.getNameLsaKey(), nlsa.getLsSeqNo(), timeToExpire));
+ nlsa.setExpiringEventId(scheduleNameLsaExpiration( pnlsr,
+ nlsa.getKey(), nlsa.getLsSeqNo(), timeToExpire));
}
else
{
if ( chkNameLsa.first.getLsSeqNo() < nlsa.getLsSeqNo() )
{
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Deleting name lsa";
+ chkNameLsa.first.writeLog();
chkNameLsa.first.setLsSeqNo(nlsa.getLsSeqNo());
chkNameLsa.first.setLifeTime(nlsa.getLifeTime());
- chkNameLsa.first.getNpl().sortNpl();
- nlsa.getNpl().sortNpl();
+ chkNameLsa.first.getNpl().sort();
+ nlsa.getNpl().sort();
std::list<string> nameToAdd;
std::set_difference(nlsa.getNpl().getNameList().begin(),
nlsa.getNpl().getNameList().end(),
@@ -119,7 +127,7 @@
for(std::list<string>::iterator it=nameToAdd.begin(); it!=nameToAdd.end();
++it)
{
- chkNameLsa.first.addNameToLsa((*it));
+ chkNameLsa.first.addName((*it));
if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
@@ -137,7 +145,7 @@
for(std::list<string>::iterator it=nameToRemove.begin();
it!=nameToRemove.end(); ++it)
{
- chkNameLsa.first.removeNameFromLsa((*it));
+ chkNameLsa.first.removeName((*it));
if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
@@ -151,9 +159,11 @@
timeToExpire=nlsa.getLifeTime();
}
cancelScheduleLsaExpiringEvent(pnlsr,
- chkNameLsa.first.getLsaExpiringEventId());
- chkNameLsa.first.setLsaExpiringEventId(scheduleNameLsaExpiration( pnlsr,
- nlsa.getNameLsaKey(), nlsa.getLsSeqNo(), timeToExpire));
+ chkNameLsa.first.getExpiringEventId());
+ chkNameLsa.first.setExpiringEventId(scheduleNameLsaExpiration( pnlsr,
+ nlsa.getKey(), nlsa.getLsSeqNo(), timeToExpire));
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Adding name lsa";
+ chkNameLsa.first.writeLog();
}
}
return true;
@@ -163,7 +173,7 @@
Lsdb::addNameLsa(NameLsa &nlsa)
{
std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
- nameLsdb.end(), bind(nameLsaCompareByKey, _1, nlsa.getNameLsaKey()));
+ nameLsdb.end(), bind(nameLsaCompareByKey, _1, nlsa.getKey()));
if( it == nameLsdb.end())
{
nameLsdb.push_back(nlsa);
@@ -175,11 +185,14 @@
bool
Lsdb::removeNameLsa(Nlsr& pnlsr, string& key)
{
+ src::logger lg;
std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
nameLsdb.end(),
bind(nameLsaCompareByKey, _1, key));
if ( it != nameLsdb.end() )
{
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Deleting name lsa";
+ (*it).writeLog();
if ( (*it).getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix() )
{
pnlsr.getNpt().removeNpte((*it).getOrigRouter(),(*it).getOrigRouter(),pnlsr);
@@ -228,7 +241,7 @@
static bool
corLsaCompareByKey(CorLsa& clsa, string& key)
{
- return clsa.getCorLsaKey()==key;
+ return clsa.getKey()==key;
}
bool
@@ -289,7 +302,7 @@
Lsdb::installCorLsa(Nlsr& pnlsr, CorLsa &clsa)
{
int timeToExpire=lsaRefreshTime;
- std::pair<CorLsa& , bool> chkCorLsa=getCorLsa(clsa.getCorLsaKey());
+ std::pair<CorLsa& , bool> chkCorLsa=getCorLsa(clsa.getKey());
if ( !chkCorLsa.second )
{
addCorLsa(clsa);
@@ -307,7 +320,7 @@
{
timeToExpire=clsa.getLifeTime();
}
- scheduleCorLsaExpiration(pnlsr,clsa.getCorLsaKey(),
+ scheduleCorLsaExpiration(pnlsr,clsa.getKey(),
clsa.getLsSeqNo(), timeToExpire);
}
else
@@ -316,7 +329,7 @@
{
chkCorLsa.first.setLsSeqNo(clsa.getLsSeqNo());
chkCorLsa.first.setLifeTime(clsa.getLifeTime());
- if ( !chkCorLsa.first.isLsaContentEqual(clsa) )
+ if ( !chkCorLsa.first.isEqual(clsa) )
{
chkCorLsa.first.setCorRadius(clsa.getCorRadius());
chkCorLsa.first.setCorTheta(clsa.getCorTheta());
@@ -330,9 +343,9 @@
timeToExpire=clsa.getLifeTime();
}
cancelScheduleLsaExpiringEvent(pnlsr,
- chkCorLsa.first.getLsaExpiringEventId());
- chkCorLsa.first.setLsaExpiringEventId(scheduleCorLsaExpiration(pnlsr,
- clsa.getCorLsaKey(),
+ chkCorLsa.first.getExpiringEventId());
+ chkCorLsa.first.setExpiringEventId(scheduleCorLsaExpiration(pnlsr,
+ clsa.getKey(),
clsa.getLsSeqNo(), timeToExpire));
}
}
@@ -344,7 +357,7 @@
{
std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(),
corLsdb.end(),
- bind(corLsaCompareByKey, _1, clsa.getCorLsaKey()));
+ bind(corLsaCompareByKey, _1, clsa.getKey()));
if( it == corLsdb.end())
{
corLsdb.push_back(clsa);
@@ -401,7 +414,7 @@
static bool
adjLsaCompareByKey(AdjLsa& alsa, string& key)
{
- return alsa.getAdjLsaKey()==key;
+ return alsa.getKey()==key;
}
@@ -445,7 +458,7 @@
{
std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
adjLsdb.end(),
- bind(adjLsaCompareByKey, _1, alsa.getAdjLsaKey()));
+ bind(adjLsaCompareByKey, _1, alsa.getKey()));
if( it == adjLsdb.end())
{
adjLsdb.push_back(alsa);
@@ -500,17 +513,17 @@
Lsdb::installAdjLsa(Nlsr& pnlsr, AdjLsa &alsa)
{
int timeToExpire=lsaRefreshTime;
- std::pair<AdjLsa& , bool> chkAdjLsa=getAdjLsa(alsa.getAdjLsaKey());
+ std::pair<AdjLsa& , bool> chkAdjLsa=getAdjLsa(alsa.getKey());
if ( !chkAdjLsa.second )
{
addAdjLsa(alsa);
- alsa.addNptEntriesForAdjLsa(pnlsr);
+ alsa.addNptEntries(pnlsr);
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
if(alsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
{
timeToExpire=alsa.getLifeTime();
}
- scheduleAdjLsaExpiration(pnlsr,alsa.getAdjLsaKey(),
+ scheduleAdjLsaExpiration(pnlsr,alsa.getKey(),
alsa.getLsSeqNo(),timeToExpire);
}
else
@@ -519,9 +532,9 @@
{
chkAdjLsa.first.setLsSeqNo(alsa.getLsSeqNo());
chkAdjLsa.first.setLifeTime(alsa.getLifeTime());
- if ( ! chkAdjLsa.first.isLsaContentEqual(alsa))
+ if ( ! chkAdjLsa.first.isEqual(alsa))
{
- chkAdjLsa.first.getAdl().resetAdl();
+ chkAdjLsa.first.getAdl().reset();
chkAdjLsa.first.getAdl().addAdjacentsFromAdl(alsa.getAdl());
pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
}
@@ -530,9 +543,9 @@
timeToExpire=alsa.getLifeTime();
}
cancelScheduleLsaExpiringEvent(pnlsr,
- chkAdjLsa.first.getLsaExpiringEventId());
- chkAdjLsa.first.setLsaExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
- alsa.getAdjLsaKey(), alsa.getLsSeqNo(),timeToExpire));
+ chkAdjLsa.first.getExpiringEventId());
+ chkAdjLsa.first.setExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
+ alsa.getKey(), alsa.getLsSeqNo(),timeToExpire));
}
}
return true;
@@ -562,7 +575,7 @@
bind(adjLsaCompareByKey, _1, key));
if ( it != adjLsdb.end() )
{
- (*it).removeNptEntriesForAdjLsa(pnlsr);
+ (*it).removeNptEntries(pnlsr);
adjLsdb.erase(it);
return true;
}
@@ -613,9 +626,14 @@
{
if(chkNameLsa.first.getOrigRouter() == thisRouterPrefix )
{
+ src::logger lg;
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Deleting name lsa";
+ chkNameLsa.first.writeLog();
cout<<"Own Name LSA, so refreshing name LSA"<<endl;
chkNameLsa.first.setLsSeqNo(chkNameLsa.first.getLsSeqNo()+1);
pnlsr.getSm().setNameLsaSeq(chkNameLsa.first.getLsSeqNo());
+ BOOST_LOG(lg)<<" "<<THIS_FILE<<" "<<__LINE__<<": "<<"Adding name lsa";
+ chkNameLsa.first.writeLog();
// publish routing update
string lsaPrefix=pnlsr.getConfParameter().getChronosyncLsaPrefix()
+ pnlsr.getConfParameter().getRouterPrefix();
diff --git a/src/nlsr_npl.cpp b/src/nlsr_npl.cpp
index d8b2087..e6cd819 100644
--- a/src/nlsr_npl.cpp
+++ b/src/nlsr_npl.cpp
@@ -2,6 +2,9 @@
#include<algorithm>
#include "nlsr_npl.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_npl.cpp"
namespace nlsr
{
@@ -23,43 +26,43 @@
}
int
- Npl::insertIntoNpl(string& name)
+ Npl::insert(string& name)
{
- std::list<string >::iterator it = std::find_if( nameList.begin(),
- nameList.end(),
+ std::list<string >::iterator it = std::find_if( m_nameList.begin(),
+ m_nameList.end(),
bind(&nameCompare, _1 , name));
- if( it != nameList.end() )
+ if( it != m_nameList.end() )
{
return -1;
}
- nameList.push_back(name);
+ m_nameList.push_back(name);
return 0;
}
int
- Npl::removeFromNpl(string& name)
+ Npl::remove(string& name)
{
- std::list<string >::iterator it = std::find_if( nameList.begin(),
- nameList.end(),
+ std::list<string >::iterator it = std::find_if( m_nameList.begin(),
+ m_nameList.end(),
bind(&nameCompare, _1 , name));
- if( it != nameList.end() )
+ if( it != m_nameList.end() )
{
- nameList.erase(it);
+ m_nameList.erase(it);
}
return -1;
}
void
- Npl::sortNpl()
+ Npl::sort()
{
- nameList.sort();
+ m_nameList.sort();
}
void
- Npl::printNpl()
+ Npl::print()
{
int i=1;
- for( std::list<string>::iterator it=nameList.begin(); it != nameList.end();
+ for( std::list<string>::iterator it=m_nameList.begin(); it != m_nameList.end();
it++)
{
cout<<"Name "<<i<<" : "<<(*it)<<endl;
diff --git a/src/nlsr_npl.hpp b/src/nlsr_npl.hpp
index dd1bafa..b69b352 100644
--- a/src/nlsr_npl.hpp
+++ b/src/nlsr_npl.hpp
@@ -17,21 +17,21 @@
Npl();
~Npl();
- int insertIntoNpl(string& name);
- int removeFromNpl(string& name);
- void sortNpl();
- int getNplSize()
+ int insert(string& name);
+ int remove(string& name);
+ void sort();
+ int getSize()
{
- return nameList.size();
+ return m_nameList.size();
}
std::list<string>& getNameList()
{
- return nameList;
+ return m_nameList;
}
- void printNpl();
+ void print();
private:
- std::list<string> nameList;
+ std::list<string> m_nameList;
};
diff --git a/src/nlsr_sm.cpp b/src/nlsr_sm.cpp
index efc7614..e44c433 100644
--- a/src/nlsr_sm.cpp
+++ b/src/nlsr_sm.cpp
@@ -6,6 +6,9 @@
#include <unistd.h>
#include "nlsr_sm.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_sm.cpp"
namespace nlsr
{
@@ -15,41 +18,41 @@
void
SequencingManager::splittSequenceNo(uint64_t seqNo)
{
- combinedSeqNo=seqNo;
- adjLsaSeq = (combinedSeqNo & 0xFFFFF);
- corLsaSeq = ((combinedSeqNo >> 20) & 0xFFFFF);
- nameLsaSeq = ((combinedSeqNo >> 40) & 0xFFFFF);
+ m_combinedSeqNo=seqNo;
+ m_adjLsaSeq = (m_combinedSeqNo & 0xFFFFF);
+ m_corLsaSeq = ((m_combinedSeqNo >> 20) & 0xFFFFF);
+ m_nameLsaSeq = ((m_combinedSeqNo >> 40) & 0xFFFFF);
}
void
SequencingManager::combineSequenceNo()
{
- combinedSeqNo=0;
- combinedSeqNo = combinedSeqNo | adjLsaSeq;
- combinedSeqNo = combinedSeqNo | (corLsaSeq<<20);
- combinedSeqNo = combinedSeqNo | (nameLsaSeq<<40);
+ m_combinedSeqNo=0;
+ m_combinedSeqNo = m_combinedSeqNo | m_adjLsaSeq;
+ m_combinedSeqNo = m_combinedSeqNo | (m_corLsaSeq<<20);
+ m_combinedSeqNo = m_combinedSeqNo | (m_nameLsaSeq<<40);
}
void
SequencingManager::writeSeqNoToFile()
{
- std::ofstream outputFile(seqFileNameWithPath.c_str(),ios::binary);
- outputFile<<combinedSeqNo;
+ std::ofstream outputFile(m_seqFileNameWithPath.c_str(),ios::binary);
+ outputFile<<m_combinedSeqNo;
outputFile.close();
}
void
SequencingManager::initiateSeqNoFromFile()
{
- cout<<"Seq File Name: "<< seqFileNameWithPath<<endl;
- std::ifstream inputFile(seqFileNameWithPath.c_str(),ios::binary);
+ cout<<"Seq File Name: "<< m_seqFileNameWithPath<<endl;
+ std::ifstream inputFile(m_seqFileNameWithPath.c_str(),ios::binary);
if ( inputFile.good() )
{
- inputFile>>combinedSeqNo;
- splittSequenceNo(combinedSeqNo);
- adjLsaSeq+=10;
- corLsaSeq+=10;
- nameLsaSeq+=10;
+ inputFile>>m_combinedSeqNo;
+ splittSequenceNo(m_combinedSeqNo);
+ m_adjLsaSeq+=10;
+ m_corLsaSeq+=10;
+ m_nameLsaSeq+=10;
combineSequenceNo();
inputFile.close();
}
@@ -62,12 +65,12 @@
void
SequencingManager::setSeqFileName(string filePath)
{
- seqFileNameWithPath=filePath;
- if( seqFileNameWithPath.empty() )
+ m_seqFileNameWithPath=filePath;
+ if( m_seqFileNameWithPath.empty() )
{
- seqFileNameWithPath=getUserHomeDirectory();
+ m_seqFileNameWithPath=getUserHomeDirectory();
}
- seqFileNameWithPath=seqFileNameWithPath+"/nlsrSeqNo.txt";
+ m_seqFileNameWithPath=m_seqFileNameWithPath+"/nlsrSeqNo.txt";
}
string
diff --git a/src/nlsr_sm.hpp b/src/nlsr_sm.hpp
index d1cbb23..4861009 100644
--- a/src/nlsr_sm.hpp
+++ b/src/nlsr_sm.hpp
@@ -14,11 +14,11 @@
{
public:
SequencingManager()
- : nameLsaSeq(0)
- , adjLsaSeq(0)
- , corLsaSeq(0)
- , combinedSeqNo(0)
- , seqFileNameWithPath()
+ : m_nameLsaSeq(0)
+ , m_adjLsaSeq(0)
+ , m_corLsaSeq(0)
+ , m_combinedSeqNo(0)
+ , m_seqFileNameWithPath()
{
}
@@ -29,48 +29,48 @@
SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn)
{
- nameLsaSeq=nlsn;
- adjLsaSeq=alsn;
- corLsaSeq=clsn;
+ m_nameLsaSeq=nlsn;
+ m_adjLsaSeq=alsn;
+ m_corLsaSeq=clsn;
combineSequenceNo();
}
uint64_t getNameLsaSeq() const
{
- return nameLsaSeq;
+ return m_nameLsaSeq;
}
void setNameLsaSeq(uint64_t nlsn)
{
- nameLsaSeq=nlsn;
+ m_nameLsaSeq=nlsn;
combineSequenceNo();
}
uint64_t getAdjLsaSeq() const
{
- return adjLsaSeq;
+ return m_adjLsaSeq;
}
void setAdjLsaSeq(uint64_t alsn)
{
- adjLsaSeq=alsn;
+ m_adjLsaSeq=alsn;
combineSequenceNo();
}
uint64_t getCorLsaSeq() const
{
- return corLsaSeq;
+ return m_corLsaSeq;
}
void setCorLsaSeq(uint64_t clsn)
{
- corLsaSeq=clsn;
+ m_corLsaSeq=clsn;
combineSequenceNo();
}
uint64_t getCombinedSeqNo() const
{
- return combinedSeqNo;
+ return m_combinedSeqNo;
}
void writeSeqNoToFile();
@@ -84,11 +84,11 @@
private:
- uint64_t nameLsaSeq;
- uint64_t adjLsaSeq;
- uint64_t corLsaSeq;
- uint64_t combinedSeqNo;
- string seqFileNameWithPath;
+ uint64_t m_nameLsaSeq;
+ uint64_t m_adjLsaSeq;
+ uint64_t m_corLsaSeq;
+ uint64_t m_combinedSeqNo;
+ string m_seqFileNameWithPath;
};
diff --git a/src/route/nlsr_fe.cpp b/src/route/nlsr_fe.cpp
index 9464f63..cc724fe 100644
--- a/src/route/nlsr_fe.cpp
+++ b/src/route/nlsr_fe.cpp
@@ -1,6 +1,9 @@
#include <list>
#include "nlsr_fe.hpp"
#include "nlsr_nexthop.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_fe.cpp"
namespace nlsr
{
@@ -8,9 +11,9 @@
using namespace std;
bool
- FibEntry::isEqualNextHops(Nhl &nhlOther)
+ FibEntry::isEqualNextHops(Nhl& nhlOther)
{
- if ( nhl.getNhlSize() != nhlOther.getNhlSize() )
+ if ( m_nhl.getSize() != nhlOther.getSize() )
{
return false;
}
@@ -18,9 +21,9 @@
{
int nhCount=0;
std::list<NextHop>::iterator it1, it2;
- for ( it1=nhl.getNextHopList().begin(),
+ for ( it1=m_nhl.getNextHopList().begin(),
it2 = nhlOther.getNextHopList().begin() ;
- it1 != nhl.getNextHopList().end() ; it1++, it2++)
+ it1 != m_nhl.getNextHopList().end() ; it1++, it2++)
{
if (it1->getConnectingFace() == it2->getConnectingFace() )
{
@@ -32,7 +35,7 @@
break;
}
}
- return nhCount == nhl.getNhlSize();
+ return nhCount == m_nhl.getSize();
}
}
diff --git a/src/route/nlsr_fe.hpp b/src/route/nlsr_fe.hpp
index edd77ab..3cac2fc 100644
--- a/src/route/nlsr_fe.hpp
+++ b/src/route/nlsr_fe.hpp
@@ -17,69 +17,69 @@
{
public:
FibEntry()
- : name()
- , timeToRefresh(0)
- , feSeqNo(0)
- , nhl()
+ : m_name()
+ , m_timeToRefresh(0)
+ , m_seqNo(0)
+ , m_nhl()
{
}
FibEntry(string n)
- : timeToRefresh(0)
- , feSeqNo(0)
- , nhl()
+ : m_timeToRefresh(0)
+ , m_seqNo(0)
+ , m_nhl()
{
- name=n;
+ m_name=n;
}
string getName()
{
- return name;
+ return m_name;
}
Nhl& getNhl()
{
- return nhl;
+ return m_nhl;
}
int getTimeToRefresh()
{
- return timeToRefresh;
+ return m_timeToRefresh;
}
void setTimeToRefresh(int ttr)
{
- timeToRefresh=ttr;
+ m_timeToRefresh=ttr;
}
- void setFeExpiringEventId(ndn::EventId feid)
+ void setExpiringEventId(ndn::EventId feid)
{
- feExpiringEventId=feid;
+ m_expiringEventId=feid;
}
- ndn::EventId getFeExpiringEventId()
+ ndn::EventId getExpiringEventId()
{
- return feExpiringEventId;
+ return m_expiringEventId;
}
- void setFeSeqNo(int fsn)
+ void setSeqNo(int fsn)
{
- feSeqNo=fsn;
+ m_seqNo=fsn;
}
- int getFeSeqNo()
+ int getSeqNo()
{
- return feSeqNo;
+ return m_seqNo;
}
- bool isEqualNextHops(Nhl &nhlOther);
+ bool isEqualNextHops(Nhl& nhlOther);
private:
- string name;
- int timeToRefresh;
- ndn::EventId feExpiringEventId;
- int feSeqNo;
- Nhl nhl;
+ string m_name;
+ int m_timeToRefresh;
+ ndn::EventId m_expiringEventId;
+ int m_seqNo;
+ Nhl m_nhl;
};
ostream& operator<<(ostream& os,FibEntry fe);
diff --git a/src/route/nlsr_fib.cpp b/src/route/nlsr_fib.cpp
index 8b03409..141bf3a 100644
--- a/src/route/nlsr_fib.cpp
+++ b/src/route/nlsr_fib.cpp
@@ -3,6 +3,9 @@
#include "nlsr_fib.hpp"
#include "nlsr_nhl.hpp"
#include "nlsr.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_fib.cpp"
namespace nlsr
{
@@ -17,58 +20,58 @@
}
void
- Fib::cancelScheduledFeExpiringEvent(Nlsr& pnlsr, EventId eid)
+ Fib::cancelScheduledExpiringEvent(Nlsr& pnlsr, EventId eid)
{
pnlsr.getScheduler().cancelEvent(eid);
}
ndn::EventId
- Fib::scheduleFibEntryRefreshing(Nlsr& pnlsr, string name, int feSeqNum,
+ Fib::scheduleEntryRefreshing(Nlsr& pnlsr, string name, int feSeqNum,
int refreshTime)
{
return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
- ndn::bind(&Fib::refreshFibEntry,this,name,feSeqNum));
+ ndn::bind(&Fib::refreshEntry,this,name,feSeqNum));
}
void
- Fib::refreshFibEntry(string name, int feSeqNum)
+ Fib::refreshEntry(string name, int feSeqNum)
{
}
void
- Fib::removeFromFib(Nlsr& pnlsr, string name)
+ Fib::remove(Nlsr& pnlsr, string name)
{
- std::list<FibEntry >::iterator it = std::find_if( fibTable.begin(),
- fibTable.end(), bind(&fibEntryNameCompare, _1, name));
- if( it != fibTable.end() )
+ std::list<FibEntry >::iterator it = std::find_if( m_table.begin(),
+ m_table.end(), bind(&fibEntryNameCompare, _1, name));
+ if( it != m_table.end() )
{
for(std::list<NextHop>::iterator nhit=(*it).getNhl().getNextHopList().begin();
nhit != (*it).getNhl().getNextHopList().begin(); nhit++)
{
//remove entry from NDN-FIB
}
- cancelScheduledFeExpiringEvent(pnlsr, (*it).getFeExpiringEventId());
- fibTable.erase(it);
+ cancelScheduledExpiringEvent(pnlsr, (*it).getExpiringEventId());
+ m_table.erase(it);
}
}
void
- Fib::updateFib(Nlsr& pnlsr,string name, Nhl& nextHopList)
+ Fib::update(Nlsr& pnlsr,string name, Nhl& nextHopList)
{
std::cout<<"Fib::updateFib Called"<<std::endl;
int startFace=0;
int endFace=getNumberOfFacesForName(nextHopList,
pnlsr.getConfParameter().getMaxFacesPerPrefix());
- std::list<FibEntry >::iterator it = std::find_if( fibTable.begin(),
- fibTable.end(),
+ std::list<FibEntry >::iterator it = std::find_if( m_table.begin(),
+ m_table.end(),
bind(&fibEntryNameCompare, _1, name));
- if( it == fibTable.end() )
+ if( it == m_table.end() )
{
- if( nextHopList.getNhlSize() > 0 )
+ if( nextHopList.getSize() > 0 )
{
- nextHopList.sortNhl();
+ nextHopList.sort();
FibEntry newEntry(name);
std::list<NextHop> nhl=nextHopList.getNextHopList();
std::list<NextHop>::iterator nhit=nhl.begin();
@@ -77,27 +80,27 @@
newEntry.getNhl().addNextHop((*nhit));
//Add entry to NDN-FIB
}
- newEntry.getNhl().sortNhl();
- newEntry.setTimeToRefresh(fibEntryRefreshTime);
- newEntry.setFeSeqNo(1);
- newEntry.setFeExpiringEventId(scheduleFibEntryRefreshing(pnlsr,
- name ,1,fibEntryRefreshTime));
- fibTable.push_back(newEntry);
+ newEntry.getNhl().sort();
+ newEntry.setTimeToRefresh(m_refreshTime);
+ newEntry.setSeqNo(1);
+ newEntry.setExpiringEventId(scheduleEntryRefreshing(pnlsr,
+ name ,1,m_refreshTime));
+ m_table.push_back(newEntry);
}
}
else
{
std::cout<<"Old FIB Entry"<<std::endl;
- if( nextHopList.getNhlSize() > 0 )
+ if( nextHopList.getSize() > 0 )
{
- nextHopList.sortNhl();
+ nextHopList.sort();
if ( !it->isEqualNextHops(nextHopList) )
{
std::list<NextHop> nhl=nextHopList.getNextHopList();
std::list<NextHop>::iterator nhit=nhl.begin();
// Add first Entry to NDN-FIB
- removeFibEntryHop(pnlsr, it->getNhl(),nhit->getConnectingFace());
- it->getNhl().resetNhl();
+ removeHop(pnlsr, it->getNhl(),nhit->getConnectingFace());
+ it->getNhl().reset();
it->getNhl().addNextHop((*nhit));
++startFace;
++nhit;
@@ -107,37 +110,37 @@
//Add Entry to NDN_FIB
}
}
- it->setTimeToRefresh(fibEntryRefreshTime);
- cancelScheduledFeExpiringEvent(pnlsr, it->getFeExpiringEventId());
- it->setFeSeqNo(it->getFeSeqNo()+1);
- (*it).setFeExpiringEventId(scheduleFibEntryRefreshing(pnlsr,
+ it->setTimeToRefresh(m_refreshTime);
+ cancelScheduledExpiringEvent(pnlsr, it->getExpiringEventId());
+ it->setSeqNo(it->getSeqNo()+1);
+ (*it).setExpiringEventId(scheduleEntryRefreshing(pnlsr,
it->getName() ,
- it->getFeSeqNo(),fibEntryRefreshTime));
+ it->getSeqNo(),m_refreshTime));
}
else
{
- removeFromFib(pnlsr,name);
+ remove(pnlsr,name);
}
}
}
- void Fib::cleanFib(Nlsr& pnlsr)
+ void Fib::clean(Nlsr& pnlsr)
{
- for( std::list<FibEntry >::iterator it=fibTable.begin(); it != fibTable.end();
+ for( std::list<FibEntry >::iterator it=m_table.begin(); it != m_table.end();
++it)
{
for(std::list<NextHop>::iterator nhit=(*it).getNhl().getNextHopList().begin();
nhit != (*it).getNhl().getNextHopList().begin(); nhit++)
{
- cancelScheduledFeExpiringEvent(pnlsr,(*it).getFeExpiringEventId());
+ cancelScheduledExpiringEvent(pnlsr,(*it).getExpiringEventId());
//Remove entry from NDN-FIB
}
}
- if ( fibTable.size() > 0 )
+ if ( m_table.size() > 0 )
{
- fibTable.clear();
+ m_table.clear();
}
}
@@ -145,9 +148,9 @@
Fib::getNumberOfFacesForName(Nhl& nextHopList, int maxFacesPerPrefix)
{
int endFace=0;
- if((maxFacesPerPrefix == 0) || (nextHopList.getNhlSize() <= maxFacesPerPrefix))
+ if((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix))
{
- return nextHopList.getNhlSize();
+ return nextHopList.getSize();
}
else
{
@@ -157,7 +160,7 @@
}
void
- Fib::removeFibEntryHop(Nlsr& pnlsr, Nhl& nl, int doNotRemoveHopFaceId)
+ Fib::removeHop(Nlsr& pnlsr, Nhl& nl, int doNotRemoveHopFaceId)
{
for( std::list<NextHop >::iterator it=nl.getNextHopList().begin();
it != nl.getNextHopList().end(); ++it)
@@ -170,10 +173,10 @@
}
void
- Fib::printFib()
+ Fib::print()
{
cout<<"-------------------FIB-----------------------------"<<endl;
- for(std::list<FibEntry>::iterator it = fibTable.begin(); it!=fibTable.end();
+ for(std::list<FibEntry>::iterator it = m_table.begin(); it!=m_table.end();
++it)
{
cout<<(*it);
diff --git a/src/route/nlsr_fib.hpp b/src/route/nlsr_fib.hpp
index 50369d4..b36d0d8 100644
--- a/src/route/nlsr_fib.hpp
+++ b/src/route/nlsr_fib.hpp
@@ -16,33 +16,33 @@
{
public:
Fib()
- : fibTable()
- , fibEntryRefreshTime(0)
+ : m_table()
+ , m_refreshTime(0)
{
}
- void removeFromFib(Nlsr& pnlsr, string name);
- void updateFib(Nlsr& pnlsr, string name, Nhl& nextHopList);
- void cleanFib(Nlsr& pnlsr);
- void setFibEntryRefreshTime(int fert)
+ void remove(Nlsr& pnlsr, string name);
+ void update(Nlsr& pnlsr, string name, Nhl& nextHopList);
+ void clean(Nlsr& pnlsr);
+ void setEntryRefreshTime(int fert)
{
- fibEntryRefreshTime=fert;
+ m_refreshTime=fert;
}
- void printFib();
+ void print();
private:
- void removeFibEntryHop(Nlsr& pnlsr, Nhl& nl, int doNotRemoveHopFaceId);
+ void removeHop(Nlsr& pnlsr, Nhl& nl, int doNotRemoveHopFaceId);
int getNumberOfFacesForName(Nhl& nextHopList, int maxFacesPerPrefix);
ndn::EventId
- scheduleFibEntryRefreshing(Nlsr& pnlsr, string name, int feSeqNum,
+ scheduleEntryRefreshing(Nlsr& pnlsr, string name, int feSeqNum,
int refreshTime);
- void cancelScheduledFeExpiringEvent(Nlsr& pnlsr, EventId eid);
- void refreshFibEntry(string name, int feSeqNum);
+ void cancelScheduledExpiringEvent(Nlsr& pnlsr, EventId eid);
+ void refreshEntry(string name, int feSeqNum);
private:
- std::list<FibEntry> fibTable;
- int fibEntryRefreshTime;
+ std::list<FibEntry> m_table;
+ int m_refreshTime;
};
}//namespace nlsr
diff --git a/src/route/nlsr_map.cpp b/src/route/nlsr_map.cpp
index 19c57c1..f08f1ae 100644
--- a/src/route/nlsr_map.cpp
+++ b/src/route/nlsr_map.cpp
@@ -6,6 +6,9 @@
#include "nlsr_lsa.hpp"
#include "nlsr_lsdb.hpp"
#include "nlsr_map.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_map.cpp"
namespace nlsr
{
@@ -33,25 +36,25 @@
}
void
- Map::addMapElement(string& rtrName)
+ Map::addElement(string& rtrName)
{
- MapEntry me(rtrName,mappingIndex);
- if ( addMapElement(me) )
+ MapEntry me(rtrName,m_mappingIndex);
+ if ( addElement(me) )
{
- mappingIndex++;
+ m_mappingIndex++;
}
}
bool
- Map::addMapElement(MapEntry& mpe)
+ Map::addElement(MapEntry& mpe)
{
//cout << mpe;
- std::list<MapEntry >::iterator it = std::find_if( rMap.begin(),
- rMap.end(),
+ std::list<MapEntry >::iterator it = std::find_if( m_table.begin(),
+ m_table.end(),
bind(&mapEntryCompareByRouter, _1, mpe.getRouter()));
- if ( it == rMap.end() )
+ if ( it == m_table.end() )
{
- rMap.push_back(mpe);
+ m_table.push_back(mpe);
return true;
}
return false;
@@ -60,10 +63,10 @@
string
Map::getRouterNameByMappingNo(int mn)
{
- std::list<MapEntry >::iterator it = std::find_if( rMap.begin(),
- rMap.end(),
+ std::list<MapEntry >::iterator it = std::find_if( m_table.begin(),
+ m_table.end(),
bind(&mapEntryCompareByMappingNo, _1, mn));
- if ( it != rMap.end() )
+ if ( it != m_table.end() )
{
return (*it).getRouter();
}
@@ -73,10 +76,10 @@
int
Map::getMappingNoByRouterName(string& rName)
{
- std::list<MapEntry >::iterator it = std::find_if( rMap.begin(),
- rMap.end(),
+ std::list<MapEntry >::iterator it = std::find_if( m_table.begin(),
+ m_table.end(),
bind(&mapEntryCompareByRouter, _1, rName));
- if ( it != rMap.end() )
+ if ( it != m_table.end() )
{
return (*it).getMappingNumber();
}
@@ -84,36 +87,36 @@
}
void
- Map::createMapFromAdjLsdb(Nlsr& pnlsr)
+ Map::createFromAdjLsdb(Nlsr& pnlsr)
{
std::list<AdjLsa> adjLsdb=pnlsr.getLsdb().getAdjLsdb();
for( std::list<AdjLsa>::iterator it=adjLsdb.begin();
it!= adjLsdb.end() ; it++)
{
string linkStartRouter=(*it).getOrigRouter();
- addMapElement(linkStartRouter);
+ addElement(linkStartRouter);
std::list<Adjacent> adl=(*it).getAdl().getAdjList();
for( std::list<Adjacent>::iterator itAdl=adl.begin();
itAdl!= adl.end() ; itAdl++)
{
- string linkEndRouter=(*itAdl).getAdjacentName();
- addMapElement(linkEndRouter);
+ string linkEndRouter=(*itAdl).getName();
+ addElement(linkEndRouter);
}
}
}
void
- Map::resetMap()
+ Map::reset()
{
- rMap.clear();
- mappingIndex=0;
+ m_table.clear();
+ m_mappingIndex=0;
}
ostream&
- operator<<(ostream& os, Map& rMap)
+ operator<<(ostream& os, Map& map)
{
os<<"---------------Map----------------------"<<endl;
- std::list< MapEntry > ml=rMap.getMapList();
+ std::list< MapEntry > ml=map.getMapList();
for( std::list<MapEntry>::iterator it=ml.begin(); it!= ml.end() ; it++)
{
os<< (*it);
diff --git a/src/route/nlsr_map.hpp b/src/route/nlsr_map.hpp
index c362706..bf50aac 100644
--- a/src/route/nlsr_map.hpp
+++ b/src/route/nlsr_map.hpp
@@ -17,8 +17,8 @@
{
public:
MapEntry()
- : router()
- , mappingNumber(-1)
+ : m_router()
+ , m_mappingNumber(-1)
{
}
@@ -28,22 +28,22 @@
MapEntry(string rtr, int mn)
{
- router=rtr;
- mappingNumber=mn;
+ m_router=rtr;
+ m_mappingNumber=mn;
}
string getRouter()
{
- return router;
+ return m_router;
}
int getMappingNumber()
{
- return mappingNumber;
+ return m_mappingNumber;
}
private:
- string router;
- int mappingNumber;
+ string m_router;
+ int m_mappingNumber;
};
ostream&
@@ -53,36 +53,36 @@
{
public:
Map()
- : mappingIndex(0)
+ : m_mappingIndex(0)
{
}
- void addMapElement(string& rtrName);
- void createMapFromAdjLsdb(Nlsr& pnlsr);
+ void addElement(string& rtrName);
+ void createFromAdjLsdb(Nlsr& pnlsr);
string getRouterNameByMappingNo(int mn);
int getMappingNoByRouterName(string& rName);
- void resetMap();
+ void reset();
std::list< MapEntry >& getMapList()
{
- return rMap;
+ return m_table;
}
int getMapSize()
{
- return rMap.size();
+ return m_table.size();
}
private:
- bool addMapElement(MapEntry& mpe);
+ bool addElement(MapEntry& mpe);
- int mappingIndex;
- std::list< MapEntry > rMap;
+ int m_mappingIndex;
+ std::list< MapEntry > m_table;
};
ostream&
- operator<<(ostream& os, Map& rMap);
+ operator<<(ostream& os, Map& map);
} // namespace nlsr
#endif
diff --git a/src/route/nlsr_nexthop.cpp b/src/route/nlsr_nexthop.cpp
index 1c7257b..08dfe62 100644
--- a/src/route/nlsr_nexthop.cpp
+++ b/src/route/nlsr_nexthop.cpp
@@ -1,4 +1,6 @@
#include "nlsr_nexthop.hpp"
+#include "utility/nlsr_logger.hpp"
+#define THIS_FILE "nlsr_nexthop.cpp"
namespace nlsr
{
diff --git a/src/route/nlsr_nexthop.hpp b/src/route/nlsr_nexthop.hpp
index b8a0af0..0105fb6 100644
--- a/src/route/nlsr_nexthop.hpp
+++ b/src/route/nlsr_nexthop.hpp
@@ -12,39 +12,39 @@
{
public:
NextHop()
- : connectingFace(0)
- , routeCost(0)
+ : m_connectingFace(0)
+ , m_routeCost(0)
{
}
NextHop(int cf, double rc)
{
- connectingFace=cf;
- routeCost=rc;
+ m_connectingFace=cf;
+ m_routeCost=rc;
}
int getConnectingFace() const
{
- return connectingFace;
+ return m_connectingFace;
}
void setConnectingFace(int cf)
{
- connectingFace=cf;
+ m_connectingFace=cf;
}
double getRouteCost() const
{
- return routeCost;
+ return m_routeCost;
}
void setRouteCost(double rc)
{
- routeCost=rc;
+ m_routeCost=rc;
}
private:
- int connectingFace;
- double routeCost;
+ int m_connectingFace;
+ double m_routeCost;
};
diff --git a/src/route/nlsr_nhl.cpp b/src/route/nlsr_nhl.cpp
index 953a0b6..ed769c9 100644
--- a/src/route/nlsr_nhl.cpp
+++ b/src/route/nlsr_nhl.cpp
@@ -1,8 +1,10 @@
#include <iostream>
-
+#include "utility/nlsr_logger.hpp"
#include "nlsr_nhl.hpp"
#include "nlsr_nexthop.hpp"
+#define THIS_FILE "nlsr_nhl.cpp"
+
namespace nlsr
{
@@ -38,12 +40,12 @@
void
Nhl::addNextHop(NextHop& nh)
{
- std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(),
- nexthopList.end(),
+ std::list<NextHop >::iterator it = std::find_if( m_nexthopList.begin(),
+ m_nexthopList.end(),
bind(&nexthopCompare, _1, nh));
- if ( it == nexthopList.end() )
+ if ( it == m_nexthopList.end() )
{
- nexthopList.push_back(nh);
+ m_nexthopList.push_back(nh);
}
if ( (*it).getRouteCost() > nh.getRouteCost() )
{
@@ -59,19 +61,19 @@
void
Nhl::removeNextHop(NextHop &nh)
{
- std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(),
- nexthopList.end(),
+ std::list<NextHop >::iterator it = std::find_if( m_nexthopList.begin(),
+ m_nexthopList.end(),
bind(&nexthopRemoveCompare, _1, nh));
- if ( it != nexthopList.end() )
+ if ( it != m_nexthopList.end() )
{
- nexthopList.erase(it);
+ m_nexthopList.erase(it);
}
}
void
- Nhl::sortNhl()
+ Nhl::sort()
{
- nexthopList.sort(nextHopSortingComparator);
+ m_nexthopList.sort(nextHopSortingComparator);
}
ostream&
diff --git a/src/route/nlsr_nhl.hpp b/src/route/nlsr_nhl.hpp
index f82d37e..fd8b4ca 100644
--- a/src/route/nlsr_nhl.hpp
+++ b/src/route/nlsr_nhl.hpp
@@ -17,7 +17,7 @@
{
public:
Nhl()
- : nexthopList()
+ : m_nexthopList()
{
}
@@ -26,25 +26,25 @@
}
void addNextHop(NextHop &nh);
void removeNextHop(NextHop &nh);
- void sortNhl();
- int getNhlSize()
+ void sort();
+ int getSize()
{
- return nexthopList.size();
+ return m_nexthopList.size();
}
- void resetNhl()
+ void reset()
{
- if (nexthopList.size() > 0 )
+ if (m_nexthopList.size() > 0 )
{
- nexthopList.clear();
+ m_nexthopList.clear();
}
}
std::list< NextHop >& getNextHopList()
{
- return nexthopList;
+ return m_nexthopList;
}
private:
- std::list< NextHop > nexthopList;
+ std::list< NextHop > m_nexthopList;
};
ostream&
diff --git a/src/route/nlsr_npt.cpp b/src/route/nlsr_npt.cpp
index 2dfa311..89eba30 100644
--- a/src/route/nlsr_npt.cpp
+++ b/src/route/nlsr_npt.cpp
@@ -1,11 +1,13 @@
#include <list>
#include <utility>
#include <algorithm>
-
+#include "utility/nlsr_logger.hpp"
#include "nlsr_npt.hpp"
#include "nlsr_npte.hpp"
#include "nlsr.hpp"
+#define THIS_FILE "nlsr_npt.cpp"
+
namespace nlsr
{
@@ -22,34 +24,34 @@
void
Npt::addNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
{
- std::list<Npte >::iterator it = std::find_if( npteList.begin(),
- npteList.end(), bind(&npteCompare, _1, name));
- if ( it == npteList.end() )
+ std::list<Npte >::iterator it = std::find_if( m_npteList.begin(),
+ m_npteList.end(), bind(&npteCompare, _1, name));
+ if ( it == m_npteList.end() )
{
Npte newEntry(name);
newEntry.addRoutingTableEntry(rte);
newEntry.generateNhlfromRteList();
- newEntry.getNhl().sortNhl();
- npteList.push_back(newEntry);
- if(rte.getNhl().getNhlSize()> 0)
+ newEntry.getNhl().sort();
+ m_npteList.push_back(newEntry);
+ if(rte.getNhl().getSize()> 0)
{
- pnlsr.getFib().updateFib(pnlsr, name,newEntry.getNhl());
+ pnlsr.getFib().update(pnlsr, name,newEntry.getNhl());
}
}
else
{
- if ( rte.getNhl().getNhlSize()> 0 )
+ if ( rte.getNhl().getSize()> 0 )
{
(*it).addRoutingTableEntry(rte);
(*it).generateNhlfromRteList();
- (*it).getNhl().sortNhl();
- pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl());
+ (*it).getNhl().sort();
+ pnlsr.getFib().update(pnlsr, name,(*it).getNhl());
}
else
{
(*it).resetRteListNextHop();
- (*it).getNhl().resetNhl();
- pnlsr.getFib().removeFromFib(pnlsr,name);
+ (*it).getNhl().reset();
+ pnlsr.getFib().remove(pnlsr,name);
}
}
}
@@ -57,9 +59,9 @@
void
Npt::removeNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
{
- std::list<Npte >::iterator it = std::find_if( npteList.begin(),
- npteList.end(), bind(&npteCompare, _1, name));
- if ( it != npteList.end() )
+ std::list<Npte >::iterator it = std::find_if( m_npteList.begin(),
+ m_npteList.end(), bind(&npteCompare, _1, name));
+ if ( it != m_npteList.end() )
{
string destRouter=rte.getDestination();
(*it).removeRoutingTableEntry(rte);
@@ -68,13 +70,13 @@
(!pnlsr.getLsdb().doesLsaExist(destRouter+"/2",2) ) &&
(!pnlsr.getLsdb().doesLsaExist(destRouter+"/3",3) ) )
{
- npteList.erase(it);
- pnlsr.getFib().removeFromFib(pnlsr,name);
+ m_npteList.erase(it);
+ pnlsr.getFib().remove(pnlsr,name);
}
else
{
(*it).generateNhlfromRteList();
- pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl());
+ pnlsr.getFib().update(pnlsr, name,(*it).getNhl());
}
}
}
@@ -113,9 +115,9 @@
}
void
- Npt::updateNptWithNewRoute(Nlsr& pnlsr)
+ Npt::updateWithNewRoute(Nlsr& pnlsr)
{
- for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
+ for(std::list<Npte >::iterator it=m_npteList.begin(); it!=m_npteList.end(); ++it)
{
std::list<RoutingTableEntry> rteList=(*it).getRteList();
for(std::list<RoutingTableEntry >::iterator rteit=rteList.begin();
@@ -137,10 +139,10 @@
}
void
- Npt::printNpt()
+ Npt::print()
{
cout<<"----------------NPT----------------------"<<endl;
- for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
+ for(std::list<Npte >::iterator it=m_npteList.begin(); it!=m_npteList.end(); ++it)
{
cout <<(*it)<<endl;
}
diff --git a/src/route/nlsr_npt.hpp b/src/route/nlsr_npt.hpp
index 8e6a98c..89af33d 100644
--- a/src/route/nlsr_npt.hpp
+++ b/src/route/nlsr_npt.hpp
@@ -20,13 +20,13 @@
}
void addNpteByDestName(string name, string destRouter, Nlsr& pnlsr);
void removeNpte(string name, string destRouter, Nlsr& pnlsr);
- void updateNptWithNewRoute(Nlsr& pnlsr);
- void printNpt();
+ void updateWithNewRoute(Nlsr& pnlsr);
+ void print();
private:
void addNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr);
void removeNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr);
private:
- std::list<Npte> npteList;
+ std::list<Npte> m_npteList;
};
}//namespace nlsr
diff --git a/src/route/nlsr_npte.cpp b/src/route/nlsr_npte.cpp
index c342a21..d8e83c3 100644
--- a/src/route/nlsr_npte.cpp
+++ b/src/route/nlsr_npte.cpp
@@ -3,6 +3,9 @@
#include "nlsr_npte.hpp"
#include "nlsr_rte.hpp"
#include "nlsr_nexthop.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_npte.cpp"
namespace nlsr
{
@@ -12,14 +15,14 @@
void
Npte::generateNhlfromRteList()
{
- nhl.resetNhl();
- for( std::list<RoutingTableEntry>::iterator it=rteList.begin();
- it != rteList.end(); ++it )
+ m_nhl.reset();
+ for( std::list<RoutingTableEntry>::iterator it=m_rteList.begin();
+ it != m_rteList.end(); ++it )
{
for(std::list< NextHop >::iterator nhit=(*it).getNhl().getNextHopList().begin();
nhit != (*it).getNhl().getNextHopList().end(); ++nhit)
{
- nhl.addNextHop((*nhit));
+ m_nhl.addNextHop((*nhit));
}
}
}
@@ -35,28 +38,28 @@
void
Npte::removeRoutingTableEntry(RoutingTableEntry& rte)
{
- std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
- rteList.end(),
+ std::list<RoutingTableEntry >::iterator it = std::find_if( m_rteList.begin(),
+ m_rteList.end(),
bind(&rteCompare, _1, rte.getDestination()));
- if ( it != rteList.end() )
+ if ( it != m_rteList.end() )
{
- rteList.erase(it);
+ m_rteList.erase(it);
}
}
void
Npte::addRoutingTableEntry(RoutingTableEntry &rte)
{
- std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
- rteList.end(),
+ std::list<RoutingTableEntry >::iterator it = std::find_if( m_rteList.begin(),
+ m_rteList.end(),
bind(&rteCompare, _1, rte.getDestination()));
- if ( it == rteList.end() )
+ if ( it == m_rteList.end() )
{
- rteList.push_back(rte);
+ m_rteList.push_back(rte);
}
else
{
- (*it).getNhl().resetNhl(); // reseting existing routing table's next hop
+ (*it).getNhl().reset(); // reseting existing routing table's next hop
for(std::list< NextHop >::iterator nhit=rte.getNhl().getNextHopList().begin();
nhit != rte.getNhl().getNextHopList().end(); ++nhit)
{
diff --git a/src/route/nlsr_npte.hpp b/src/route/nlsr_npte.hpp
index 3dfa04a..bb4b1c8 100644
--- a/src/route/nlsr_npte.hpp
+++ b/src/route/nlsr_npte.hpp
@@ -14,55 +14,55 @@
{
public:
Npte()
- : namePrefix()
- , nhl()
+ : m_namePrefix()
+ , m_nhl()
{
}
Npte(string np)
- : nhl()
+ : m_nhl()
{
- namePrefix=np;
+ m_namePrefix=np;
}
string getNamePrefix()
{
- return namePrefix;
+ return m_namePrefix;
}
std::list<RoutingTableEntry>& getRteList()
{
- return rteList;
+ return m_rteList;
}
void resetRteListNextHop()
{
- if (rteList.size() > 0 )
+ if (m_rteList.size() > 0 )
{
- for( std::list<RoutingTableEntry>::iterator it=rteList.begin();
- it != rteList.end(); ++it )
+ for( std::list<RoutingTableEntry>::iterator it=m_rteList.begin();
+ it != m_rteList.end(); ++it )
{
- (*it).getNhl().resetNhl();
+ (*it).getNhl().reset();
}
}
}
int getRteListSize()
{
- return rteList.size();
+ return m_rteList.size();
}
Nhl& getNhl()
{
- return nhl;
+ return m_nhl;
}
void generateNhlfromRteList();
void removeRoutingTableEntry(RoutingTableEntry& rte);
void addRoutingTableEntry(RoutingTableEntry &rte);
private:
- string namePrefix;
- std::list<RoutingTableEntry> rteList;
- Nhl nhl;
+ string m_namePrefix;
+ std::list<RoutingTableEntry> m_rteList;
+ Nhl m_nhl;
};
ostream&
diff --git a/src/route/nlsr_rt.cpp b/src/route/nlsr_rt.cpp
index 2cd9b28..8267930 100644
--- a/src/route/nlsr_rt.cpp
+++ b/src/route/nlsr_rt.cpp
@@ -8,6 +8,9 @@
#include "nlsr_rtc.hpp"
#include "nlsr_rte.hpp"
#include "nlsr_npt.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_rt.cpp"
namespace nlsr
{
@@ -19,7 +22,7 @@
{
//debugging purpose
std::cout<<pnlsr.getConfParameter()<<std::endl;
- pnlsr.getNpt().printNpt();
+ pnlsr.getNpt().print();
pnlsr.getLsdb().printAdjLsdb();
pnlsr.getLsdb().printCorLsdb();
pnlsr.getLsdb().printNameLsdb();
@@ -51,11 +54,11 @@
calculateHypDryRoutingTable(pnlsr);
}
//need to update NPT here
- pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
+ pnlsr.getNpt().updateWithNewRoute(pnlsr);
//debugging purpose
printRoutingTable();
- pnlsr.getNpt().printNpt();
- pnlsr.getFib().printFib();
+ pnlsr.getNpt().print();
+ pnlsr.getFib().print();
//debugging purpose end
}
else
@@ -72,11 +75,11 @@
clearDryRoutingTable(); // for dry run options
// need to update NPT here
std::cout<<"Calling Update NPT With new Route"<<std::endl;
- pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
+ pnlsr.getNpt().updateWithNewRoute(pnlsr);
//debugging purpose
printRoutingTable();
- pnlsr.getNpt().printNpt();
- pnlsr.getFib().printFib();
+ pnlsr.getNpt().print();
+ pnlsr.getFib().print();
//debugging purpose end
}
pnlsr.setIsRouteCalculationScheduled(0); //clear scheduled flag
@@ -94,7 +97,7 @@
{
cout<<"RoutingTable::calculateLsRoutingTable Called"<<endl;
Map vMap;
- vMap.createMapFromAdjLsdb(pnlsr);
+ vMap.createFromAdjLsdb(pnlsr);
int numOfRouter=vMap.getMapSize();
LinkStateRoutingTableCalculator lsrtc(numOfRouter);
lsrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
@@ -104,7 +107,7 @@
RoutingTable::calculateHypRoutingTable(Nlsr& pnlsr)
{
Map vMap;
- vMap.createMapFromAdjLsdb(pnlsr);
+ vMap.createFromAdjLsdb(pnlsr);
int numOfRouter=vMap.getMapSize();
HypRoutingTableCalculator hrtc(numOfRouter,0);
hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
@@ -114,7 +117,7 @@
RoutingTable::calculateHypDryRoutingTable(Nlsr& pnlsr)
{
Map vMap;
- vMap.createMapFromAdjLsdb(pnlsr);
+ vMap.createFromAdjLsdb(pnlsr);
int numOfRouter=vMap.getMapSize();
HypRoutingTableCalculator hrtc(numOfRouter,1);
hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
@@ -146,7 +149,7 @@
{
RoutingTableEntry rte(destRouter);
rte.getNhl().addNextHop(nh);
- rTable.push_back(rte);
+ m_rTable.push_back(rte);
}
else
{
@@ -157,10 +160,10 @@
std::pair<RoutingTableEntry&, bool>
RoutingTable::findRoutingTableEntry(string destRouter)
{
- std::list<RoutingTableEntry >::iterator it = std::find_if( rTable.begin(),
- rTable.end(),
+ std::list<RoutingTableEntry >::iterator it = std::find_if( m_rTable.begin(),
+ m_rTable.end(),
bind(&routingTableEntryCompare, _1, destRouter));
- if ( it != rTable.end() )
+ if ( it != m_rTable.end() )
{
return std::make_pair(boost::ref((*it)),true);
}
@@ -172,8 +175,8 @@
RoutingTable::printRoutingTable()
{
cout<<"---------------Routing Table------------------"<<endl;
- for(std::list<RoutingTableEntry>::iterator it=rTable.begin() ;
- it != rTable.end(); ++it)
+ for(std::list<RoutingTableEntry>::iterator it=m_rTable.begin() ;
+ it != m_rTable.end(); ++it)
{
cout<<(*it)<<endl;
}
@@ -184,14 +187,14 @@
void
RoutingTable::addNextHopToDryTable(string destRouter, NextHop& nh)
{
- std::list<RoutingTableEntry >::iterator it = std::find_if( dryTable.begin(),
- dryTable.end(),
+ std::list<RoutingTableEntry >::iterator it = std::find_if( m_dryTable.begin(),
+ m_dryTable.end(),
bind(&routingTableEntryCompare, _1, destRouter));
- if ( it == dryTable.end() )
+ if ( it == m_dryTable.end() )
{
RoutingTableEntry rte(destRouter);
rte.getNhl().addNextHop(nh);
- dryTable.push_back(rte);
+ m_dryTable.push_back(rte);
}
else
{
@@ -203,8 +206,8 @@
RoutingTable::printDryRoutingTable()
{
cout<<"--------Dry Run's Routing Table--------------"<<endl;
- for(std::list<RoutingTableEntry>::iterator it=dryTable.begin() ;
- it != dryTable.end(); ++it)
+ for(std::list<RoutingTableEntry>::iterator it=m_dryTable.begin() ;
+ it != m_dryTable.end(); ++it)
{
cout<<(*it)<<endl;
}
@@ -214,18 +217,18 @@
void
RoutingTable::clearRoutingTable()
{
- if( rTable.size() > 0 )
+ if( m_rTable.size() > 0 )
{
- rTable.clear();
+ m_rTable.clear();
}
}
void
RoutingTable::clearDryRoutingTable()
{
- if (dryTable.size()>0 )
+ if (m_dryTable.size()>0 )
{
- dryTable.clear();
+ m_dryTable.clear();
}
}
diff --git a/src/route/nlsr_rt.hpp b/src/route/nlsr_rt.hpp
index bf4e489..e382b8b 100644
--- a/src/route/nlsr_rt.hpp
+++ b/src/route/nlsr_rt.hpp
@@ -34,15 +34,15 @@
private:
void calculateLsRoutingTable(Nlsr& pnlsr);
void calculateHypRoutingTable(Nlsr& pnlsr);
- void calculateHypDryRoutingTable(Nlsr&pnlsr);
+ void calculateHypDryRoutingTable(Nlsr& pnlsr);
void clearRoutingTable();
void clearDryRoutingTable();
const int NO_NEXT_HOP;
- std::list< RoutingTableEntry > rTable;
- std::list< RoutingTableEntry > dryTable;
+ std::list< RoutingTableEntry > m_rTable;
+ std::list< RoutingTableEntry > m_dryTable;
};
}//namespace nlsr
diff --git a/src/route/nlsr_rtc.cpp b/src/route/nlsr_rtc.cpp
index 90200e5..c6499f7 100644
--- a/src/route/nlsr_rtc.cpp
+++ b/src/route/nlsr_rtc.cpp
@@ -6,6 +6,9 @@
#include "nlsr_lsa.hpp"
#include "nlsr_nexthop.hpp"
#include "nlsr.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_rtc.cpp"
namespace nlsr
{
@@ -45,7 +48,7 @@
for( std::list<Adjacent>::iterator itAdl=adl.begin();
itAdl!= adl.end() ; itAdl++)
{
- string linkEndRouter=(*itAdl).getAdjacentName();
+ string linkEndRouter=(*itAdl).getName();
int col=pMap.getMappingNoByRouterName(linkEndRouter);
double cost=(*itAdl).getLinkCost();
if ( (row >= 0 && row<numOfRouter) && (col >= 0 && col<numOfRouter) )
@@ -206,18 +209,18 @@
/* Initiate the Parent */
for (i = 0 ; i < numOfRouter; i++)
{
- parent[i]=EMPTY_PARENT;
- distance[i]=INF_DISTANCE;
+ m_parent[i]=EMPTY_PARENT;
+ m_distance[i]=INF_DISTANCE;
Q[i]=i;
}
if ( sourceRouter != NO_MAPPING_NUM )
{
- distance[sourceRouter]=0;
- sortQueueByDistance(Q,distance,head,numOfRouter);
+ m_distance[sourceRouter]=0;
+ sortQueueByDistance(Q,m_distance,head,numOfRouter);
while (head < numOfRouter )
{
u=Q[head];
- if(distance[u] == INF_DISTANCE)
+ if(m_distance[u] == INF_DISTANCE)
{
break;
}
@@ -227,16 +230,16 @@
{
if ( isNotExplored(Q,v,head+1,numOfRouter) )
{
- if( distance[u] + adjMatrix[u][v] < distance[v])
+ if( m_distance[u] + adjMatrix[u][v] < m_distance[v])
{
- distance[v]=distance[u] + adjMatrix[u][v] ;
- parent[v]=u;
+ m_distance[v]=m_distance[u] + adjMatrix[u][v] ;
+ m_parent[v]=u;
}
}
}
}
head++;
- sortQueueByDistance(Q,distance,head,numOfRouter);
+ sortQueueByDistance(Q,m_distance,head,numOfRouter);
}
}
delete [] Q;
@@ -255,7 +258,7 @@
int nextHopRouter=getLsNextHop(i,sourceRouter);
if ( nextHopRouter != NO_NEXT_HOP )
{
- double routeCost=distance[i];
+ double routeCost=m_distance[i];
string nextHopRouterName=
pMap.getRouterNameByMappingNo(nextHopRouter);
int nxtHopFace=
@@ -277,10 +280,10 @@
LinkStateRoutingTableCalculator::getLsNextHop(int dest, int source)
{
int nextHop;
- while ( parent[dest] != EMPTY_PARENT )
+ while ( m_parent[dest] != EMPTY_PARENT )
{
nextHop=dest;
- dest=parent[dest];
+ dest=m_parent[dest];
}
if ( dest != source )
{
@@ -307,9 +310,9 @@
void
LinkStateRoutingTableCalculator::printLsPath(int destRouter)
{
- if (parent[destRouter] != EMPTY_PARENT )
+ if (m_parent[destRouter] != EMPTY_PARENT )
{
- printLsPath(parent[destRouter]);
+ printLsPath(m_parent[destRouter]);
}
cout<<" "<<destRouter;
}
@@ -351,24 +354,24 @@
void
LinkStateRoutingTableCalculator::allocateParent()
{
- parent=new int[numOfRouter];
+ m_parent=new int[numOfRouter];
}
void
LinkStateRoutingTableCalculator::allocateDistance()
{
- distance= new double[numOfRouter];
+ m_distance= new double[numOfRouter];
}
void
LinkStateRoutingTableCalculator::freeParent()
{
- delete [] parent;
+ delete [] m_parent;
}
void LinkStateRoutingTableCalculator::freeDistance()
{
- delete [] distance;
+ delete [] m_distance;
}
@@ -404,9 +407,9 @@
pMap,links[j],i);
if ( distToDestFromNbr >= 0 )
{
- linkFaces[k] = nextHopFace;
- distanceToNeighbor[k] = distToNbr;
- distFromNbrToDest[k] = distToDestFromNbr;
+ m_linkFaces[k] = nextHopFace;
+ m_distanceToNeighbor[k] = distToNbr;
+ m_distFromNbrToDest[k] = distToDestFromNbr;
k++;
}
}
@@ -428,9 +431,9 @@
for(int i=0 ; i < noFaces ; ++i)
{
string destRouter=pMap.getRouterNameByMappingNo(dest);
- NextHop nh(linkFaces[i],distFromNbrToDest[i]);
+ NextHop nh(m_linkFaces[i],m_distFromNbrToDest[i]);
rt.addNextHop(destRouter,nh);
- if( isDryRun == 1 )
+ if( m_isDryRun)
{
rt.addNextHopToDryTable(destRouter,nh);
}
@@ -472,37 +475,37 @@
void
HypRoutingTableCalculator::allocateLinkFaces()
{
- linkFaces=new int[vNoLink];
+ m_linkFaces=new int[vNoLink];
}
void
HypRoutingTableCalculator::allocateDistanceToNeighbor()
{
- distanceToNeighbor=new double[vNoLink];
+ m_distanceToNeighbor=new double[vNoLink];
}
void
HypRoutingTableCalculator::allocateDistFromNbrToDest()
{
- distFromNbrToDest=new double[vNoLink];
+ m_distFromNbrToDest=new double[vNoLink];
}
void
HypRoutingTableCalculator::freeLinkFaces()
{
- delete [] linkFaces;
+ delete [] m_linkFaces;
}
void
HypRoutingTableCalculator::freeDistanceToNeighbor()
{
- delete [] distanceToNeighbor;
+ delete [] m_distanceToNeighbor;
}
void
HypRoutingTableCalculator::freeDistFromNbrToDest()
{
- delete [] distFromNbrToDest;
+ delete [] m_distFromNbrToDest;
}
}//namespace nlsr
diff --git a/src/route/nlsr_rtc.hpp b/src/route/nlsr_rtc.hpp
index 730612c..dba45ca 100644
--- a/src/route/nlsr_rtc.hpp
+++ b/src/route/nlsr_rtc.hpp
@@ -45,12 +45,12 @@
}
protected:
- double ** adjMatrix;
+ double** adjMatrix;
int numOfRouter;
int vNoLink;
- int *links;
- double *linkCosts;
+ int* links;
+ double* linkCosts;
};
class LinkStateRoutingTableCalculator: public RoutingTableCalculator
@@ -71,8 +71,8 @@
private:
void doDijkstraPathCalculation(int sourceRouter);
- void sortQueueByDistance(int *Q, double *dist,int start,int element);
- int isNotExplored(int *Q, int u,int start, int element);
+ void sortQueueByDistance(int* Q, double* dist,int start,int element);
+ int isNotExplored(int* Q, int u,int start, int element);
void printAllLsPath(int sourceRouter);
void printLsPath(int destRouter);
void addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
@@ -88,8 +88,8 @@
private:
- int *parent;
- double *distance;
+ int* m_parent;
+ double* m_distance;
const int EMPTY_PARENT;
@@ -106,13 +106,13 @@
: MATH_PI(3.141592654)
{
numOfRouter=rn;
- isDryRun=0;
+ m_isDryRun=0;
}
HypRoutingTableCalculator(int rn, int idr)
: MATH_PI(3.141592654)
{
numOfRouter=rn;
- isDryRun=idr;
+ m_isDryRun=idr;
}
void calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);
@@ -130,11 +130,11 @@
RoutingTable& rt, int noFaces,int dest);
private:
- int isDryRun;
+ bool m_isDryRun;
- int *linkFaces;
- double *distanceToNeighbor;
- double *distFromNbrToDest;
+ int* m_linkFaces;
+ double* m_distanceToNeighbor;
+ double* m_distFromNbrToDest;
const double MATH_PI;
diff --git a/src/route/nlsr_rte.cpp b/src/route/nlsr_rte.cpp
index 129ab8a..7c06b03 100644
--- a/src/route/nlsr_rte.cpp
+++ b/src/route/nlsr_rte.cpp
@@ -2,6 +2,9 @@
#include <string>
#include "nlsr_rte.hpp"
+#include "utility/nlsr_logger.hpp"
+
+#define THIS_FILE "nlsr_rte.cpp"
namespace nlsr
{
@@ -9,7 +12,7 @@
using namespace std;
ostream&
- operator<<(ostream& os, RoutingTableEntry &rte)
+ operator<<(ostream& os, RoutingTableEntry& rte)
{
os<<"Destination: "<<rte.getDestination()<<endl;
os<<"Nexthops: "<<endl;
diff --git a/src/route/nlsr_rte.hpp b/src/route/nlsr_rte.hpp
index 736909b..484edab 100644
--- a/src/route/nlsr_rte.hpp
+++ b/src/route/nlsr_rte.hpp
@@ -14,8 +14,8 @@
{
public:
RoutingTableEntry()
- : destination()
- , nhl()
+ : m_destination()
+ , m_nhl()
{
}
@@ -24,28 +24,28 @@
}
RoutingTableEntry(string dest)
- : nhl()
+ : m_nhl()
{
- destination=dest;
+ m_destination=dest;
}
string getDestination()
{
- return destination;
+ return m_destination;
}
Nhl& getNhl()
{
- return nhl;
+ return m_nhl;
}
private:
- string destination;
- Nhl nhl;
+ string m_destination;
+ Nhl m_nhl;
};
ostream&
- operator<<(ostream& os, RoutingTableEntry &rte);
+ operator<<(ostream& os, RoutingTableEntry& rte);
}
diff --git a/src/security/nlsr_cert_store.cpp b/src/security/nlsr_cert_store.cpp
index 897d44a..fa84ad9 100644
--- a/src/security/nlsr_cert_store.cpp
+++ b/src/security/nlsr_cert_store.cpp
@@ -4,6 +4,8 @@
#include "nlsr_wle.hpp"
#include "nlsr_km.hpp"
+#define THIS_FILE "nlsr_cert_store.cpp"
+
namespace nlsr
{
static bool
@@ -36,7 +38,7 @@
ndn::Name tmpName(respCertName);
respCertName=tmpName.getPrefix(-1).toUri();
std::pair<WaitingListEntry, bool> chkWle=
- waitingList.getWaitingListEntry(respCertName);
+ m_waitingList.getWaitingListEntry(respCertName);
if( chkWle.second )
{
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> sc=
@@ -62,7 +64,7 @@
}
//remove that entry from waiting list
- waitingList.removeFromWaitingList(respCertName);
+ m_waitingList.remove(respCertName);
}
void
@@ -75,7 +77,7 @@
else
{
ndn::SignatureSha256WithRsa signature(ncse.getCert()->getSignature());
- waitingList.addtoWaitingList(signature.getKeyLocator().getName().toUri(),
+ m_waitingList.add(signature.getKeyLocator().getName().toUri(),
ncse.getCert()->getName().toUri());
}
}
@@ -84,20 +86,20 @@
NlsrCertificateStore::addCertificate(NlsrCertificateStoreEntry & ncse)
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompare, _1, ncse));
- if(it == certTable.end())
+ if(it == m_certTable.end())
{
- certTable.push_back(ncse);
+ m_certTable.push_back(ncse);
updateWaitingList(ncse);
return true;
}
- else if( it != certTable.end() )
+ else if( it != m_certTable.end() )
{
if ( (*it).getCertSeqNum() < ncse.getCertSeqNum() )
{
- certTable.erase(it);
- certTable.push_back(ncse);
+ m_certTable.erase(it);
+ m_certTable.push_back(ncse);
updateWaitingList(ncse);
return true;
}
@@ -117,9 +119,9 @@
NlsrCertificateStore::getCertificateSeqNum(std::string certName)
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
- if(it == certTable.end())
+ if(it == m_certTable.end())
{
return std::make_pair(0,false);
}
@@ -133,9 +135,9 @@
bool isVerified)
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
- if(it != certTable.end())
+ if(it != m_certTable.end())
{
it->setIsSignerVerified(true);
}
@@ -145,9 +147,9 @@
NlsrCertificateStore::getCertificateIsVerified( std::string certName )
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
- if(it != certTable.end())
+ if(it != m_certTable.end())
{
return it->getIsSignerVerified();
}
@@ -159,9 +161,9 @@
NlsrCertificateStore::getCertificateFromStore(const std::string certName)
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
- if(it == certTable.end())
+ if(it == m_certTable.end())
{
ndn::shared_ptr<ndn::IdentityCertificate> cert=
ndn::make_shared<ndn::IdentityCertificate>();
@@ -175,9 +177,9 @@
const std::string certName, int checkSeqNum)
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
- if(it == certTable.end())
+ if(it == m_certTable.end())
{
ndn::shared_ptr<ndn::IdentityCertificate> cert=
ndn::make_shared<ndn::IdentityCertificate>();
@@ -198,9 +200,9 @@
int checkSeqNo)
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
- if(it != certTable.end())
+ if(it != m_certTable.end())
{
return (*it).getCertSeqNum() < checkSeqNo ;
}
@@ -211,24 +213,24 @@
NlsrCertificateStore::removeCertificateFromStroe(const std::string certName)
{
std::list<NlsrCertificateStoreEntry>::iterator it =
- std::find_if( certTable.begin(), certTable.end(),
+ std::find_if( m_certTable.begin(), m_certTable.end(),
bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
- if(it != certTable.end())
+ if(it != m_certTable.end())
{
- certTable.erase(it);
+ m_certTable.erase(it);
return true;
}
return false;
}
void
- NlsrCertificateStore::printCertStore()
+ NlsrCertificateStore::print()
{
std::list<NlsrCertificateStoreEntry>::iterator it;
- for(it=certTable.begin(); it!=certTable.end(); ++it)
+ for(it=m_certTable.begin(); it!=m_certTable.end(); ++it)
{
std::cout<<(*it)<<std::endl;
}
- std::cout<<waitingList<<std::endl;
+ std::cout<<m_waitingList<<std::endl;
}
}
diff --git a/src/security/nlsr_cert_store.hpp b/src/security/nlsr_cert_store.hpp
index d9c9b64..2ef4513 100644
--- a/src/security/nlsr_cert_store.hpp
+++ b/src/security/nlsr_cert_store.hpp
@@ -12,11 +12,11 @@
{
public:
NlsrCertificateStore()
- : certTable()
- , waitingList()
+ : m_certTable()
+ , m_waitingList()
{}
- bool addCertificate(NlsrCertificateStoreEntry & ncse);
+ bool addCertificate(NlsrCertificateStoreEntry& ncse);
bool addCertificate(ndn::shared_ptr<ndn::IdentityCertificate> pcert
, uint32_t csn, bool isv);
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
@@ -26,7 +26,7 @@
bool removeCertificateFromStroe(const std::string certName);
bool isCertificateNewInStore(const std::string certName, int checkSeqNo);
std::pair<uint32_t, bool> getCertificateSeqNum(std::string certName);
- void printCertStore();
+ void print();
void setCertificateIsVerified(std::string certName, bool isVerified);
bool getCertificateIsVerified(std::string certName);
private:
@@ -34,8 +34,8 @@
void updateWaitingList(std::string respCertName);
private:
- std::list<NlsrCertificateStoreEntry> certTable;
- WaitingList waitingList;
+ std::list<NlsrCertificateStoreEntry> m_certTable;
+ WaitingList m_waitingList;
};
}
diff --git a/src/security/nlsr_cse.cpp b/src/security/nlsr_cse.cpp
index f2f5f06..91c0150 100644
--- a/src/security/nlsr_cse.cpp
+++ b/src/security/nlsr_cse.cpp
@@ -1,6 +1,8 @@
#include <ndn-cpp-dev/security/signature-sha256-with-rsa.hpp>
#include "nlsr_cse.hpp"
+#define THIS_FILE "nlsr_cse.cpp"
+
namespace nlsr
{
std::ostream&
diff --git a/src/security/nlsr_cse.hpp b/src/security/nlsr_cse.hpp
index f91e9e2..238d511 100644
--- a/src/security/nlsr_cse.hpp
+++ b/src/security/nlsr_cse.hpp
@@ -11,52 +11,52 @@
{
public:
NlsrCertificateStoreEntry()
- : cert(ndn::make_shared<ndn::IdentityCertificate>())
- , certSeqNum(0)
- , isSignerVerified(false)
+ : m_cert(ndn::make_shared<ndn::IdentityCertificate>())
+ , m_certSeqNum(0)
+ , m_isSignerVerified(false)
{}
NlsrCertificateStoreEntry(ndn::shared_ptr<ndn::IdentityCertificate> pcert
, uint32_t csn, bool isv)
- : cert(pcert)
- , certSeqNum(csn)
- , isSignerVerified(isv)
+ : m_cert(pcert)
+ , m_certSeqNum(csn)
+ , m_isSignerVerified(isv)
{}
ndn::shared_ptr<ndn::IdentityCertificate> getCert() const
{
- return cert;
+ return m_cert;
}
void setCert(ndn::shared_ptr<ndn::IdentityCertificate> pcert)
{
- cert=pcert;
+ m_cert=pcert;
}
uint32_t getCertSeqNum() const
{
- return certSeqNum;
+ return m_certSeqNum;
}
void setCertSeqNum(uint32_t csn)
{
- certSeqNum=csn;
+ m_certSeqNum=csn;
}
bool getIsSignerVerified() const
{
- return isSignerVerified;
+ return m_isSignerVerified;
}
void setIsSignerVerified(bool isv)
{
- isSignerVerified=isv;
+ m_isSignerVerified=isv;
}
private:
- ndn::shared_ptr<ndn::IdentityCertificate> cert;
- uint32_t certSeqNum;
- bool isSignerVerified;
+ ndn::shared_ptr<ndn::IdentityCertificate> m_cert;
+ uint32_t m_certSeqNum;
+ bool m_isSignerVerified;
};
/* Debugging Purpose */
std::ostream&
diff --git a/src/security/nlsr_km.cpp b/src/security/nlsr_km.cpp
index 183e934..d357795 100644
--- a/src/security/nlsr_km.cpp
+++ b/src/security/nlsr_km.cpp
@@ -6,17 +6,19 @@
#include "nlsr_km.hpp"
#include "nlsr.hpp"
+#define THIS_FILE "nlsr_km.cpp"
+
namespace nlsr
{
bool
- KeyManager::initKeyManager(ConfParameter &cp)
+ KeyManager::initialize(ConfParameter &cp)
{
initCertSeqFromFile(cp.getSeqFileDir());
if( !loadAllCertificates(cp.getCertDir()) )
{
return false;
}
- nlsrRootKeyPrefix=cp.getRootKeyPrefix();
+ m_nlsrRootKeyPrefix=cp.getRootKeyPrefix();
string processIdentityName(cp.getRootKeyPrefix());
processIdentityName += "/";
processIdentityName += cp.getSiteName();
@@ -26,22 +28,22 @@
processIdentityName += cp.getRouterName();
ndn::Name ri(processIdentityName);
std::cout<<"Router Identity: "<<ri.toUri()<<std::endl;
- routerIdentity=ri;
+ m_routerIdentity=ri;
processIdentityName += "/";
processIdentityName += "nlsr";
cout<<"Proces Identity Name: "<<processIdentityName<<endl;
ndn::Name identityName(processIdentityName);
- processIdentity=identityName;
- ndn::KeyChain::deleteIdentity(processIdentity);
- processCertName = ndn::KeyChain::createIdentity(processIdentity);
- cout<<"Certificate Name: "<<processCertName.toUri()<<endl;
- processKeyName=processCertName.getPrefix(-2);
- cout<<"Key Name: "<<processKeyName.toUri()<<endl;
+ m_processIdentity=identityName;
+ ndn::KeyChain::deleteIdentity(m_processIdentity);
+ m_processCertName = ndn::KeyChain::createIdentity(m_processIdentity);
+ cout<<"Certificate Name: "<<m_processCertName.toUri()<<endl;
+ m_processKeyName=m_processCertName.getPrefix(-2);
+ cout<<"Key Name: "<<m_processKeyName.toUri()<<endl;
ndn::shared_ptr<ndn::IdentityCertificate> cert =
- getCertificate(processCertName);
- signByIdentity(*(cert),routerIdentity);
- certStore.addCertificate(cert, certSeqNo, true);
- certStore.printCertStore();
+ getCertificate(m_processCertName);
+ signByIdentity(*(cert),m_routerIdentity);
+ m_certStore.addCertificate(cert, m_certSeqNo, true);
+ m_certStore.print();
return true;
}
@@ -70,35 +72,35 @@
ndn::io::load<ndn::IdentityCertificate>(inputFile, ndn::io::BASE_64);
ndn::Name certName=cert->getName();
switch(keyType)
- {
+ {
case KEY_TYPE_ROOT:
- certStore.addCertificate(cert, 10, true);
- rootCertName=certName;
- std::cout<<"Root Cert: "<<rootCertName<<std::endl;
+ m_certStore.addCertificate(cert, 10, true);
+ m_rootCertName=certName;
+ std::cout<<"Root Cert: "<<m_rootCertName<<std::endl;
break;
case KEY_TYPE_SITE:
- certStore.addCertificate(cert, 10, true);
- siteCertName=certName;
- std::cout<<"Site Cert: "<<siteCertName<<std::endl;
+ m_certStore.addCertificate(cert, 10, true);
+ m_siteCertName=certName;
+ std::cout<<"Site Cert: "<<m_siteCertName<<std::endl;
break;
case KEY_TYPE_OPERATOR:
- certStore.addCertificate(cert, 10, true);
- opCertName=certName;
- std::cout<<"Operator Cert: "<<opCertName<<std::endl;
+ m_certStore.addCertificate(cert, 10, true);
+ m_opCertName=certName;
+ std::cout<<"Operator Cert: "<<m_opCertName<<std::endl;
break;
case KEY_TYPE_ROUTER:
- certStore.addCertificate(cert, certSeqNo, true);
- routerCertName=certName;
- std::cout<<"Router Cert: "<<routerCertName<<std::endl;
+ m_certStore.addCertificate(cert, m_certSeqNo, true);
+ m_routerCertName=certName;
+ std::cout<<"Router Cert: "<<m_routerCertName<<std::endl;
break;
case KEY_TYPE_PROCESS:
- certStore.addCertificate(cert, certSeqNo, true);
- processCertName=certName;
- std::cout<<"Process Cert: "<<processCertName<<std::endl;
+ m_certStore.addCertificate(cert, m_certSeqNo, true);
+ m_processCertName=certName;
+ std::cout<<"Process Cert: "<<m_processCertName<<std::endl;
break;
default:
break;
- }
+ }
return true;
}
catch(std::exception& e)
@@ -111,65 +113,65 @@
ndn::Name
KeyManager::getProcessCertName()
{
- return processCertName;
+ return m_processCertName;
}
ndn::Name
KeyManager::getRouterCertName()
{
- return routerCertName;
+ return m_routerCertName;
}
ndn::Name
KeyManager::getOperatorCertName()
{
- return opCertName;
+ return m_opCertName;
}
ndn::Name
KeyManager::getSiteCertName()
{
- return siteCertName;
+ return m_siteCertName;
}
ndn::Name
KeyManager::getRootCertName()
{
- return rootCertName;
+ return m_rootCertName;
}
uint32_t
KeyManager::getCertSeqNo()
{
- return certSeqNo;
+ return m_certSeqNo;
}
void
KeyManager::setCerSeqNo(uint32_t csn)
{
- certSeqNo=csn;
+ m_certSeqNo=csn;
}
void
KeyManager::initCertSeqFromFile(string certSeqFileDir)
{
- certSeqFileNameWithPath=certSeqFileDir;
- if( certSeqFileNameWithPath.empty() )
+ m_certSeqFileNameWithPath=certSeqFileDir;
+ if( m_certSeqFileNameWithPath.empty() )
{
SequencingManager sm;
- certSeqFileNameWithPath=sm.getUserHomeDirectory();
+ m_certSeqFileNameWithPath=sm.getUserHomeDirectory();
}
- certSeqFileNameWithPath += "/nlsrCertSeqNo.txt";
- cout<<"Key Seq File Name: "<< certSeqFileNameWithPath<<endl;
- std::ifstream inputFile(certSeqFileNameWithPath.c_str(),ios::binary);
+ m_certSeqFileNameWithPath += "/nlsrCertSeqNo.txt";
+ cout<<"Key Seq File Name: "<< m_certSeqFileNameWithPath<<endl;
+ std::ifstream inputFile(m_certSeqFileNameWithPath.c_str(),ios::binary);
if ( inputFile.good() )
{
- inputFile>>certSeqNo;
- certSeqNo++;
+ inputFile>>m_certSeqNo;
+ m_certSeqNo++;
}
else
{
- certSeqNo=1;
+ m_certSeqNo=1;
}
writeCertSeqToFile();
}
@@ -177,40 +179,40 @@
void
KeyManager::writeCertSeqToFile()
{
- std::ofstream outputFile(certSeqFileNameWithPath.c_str(),ios::binary);
- outputFile<<certSeqNo;
+ std::ofstream outputFile(m_certSeqFileNameWithPath.c_str(),ios::binary);
+ outputFile<<m_certSeqNo;
outputFile.close();
}
bool
KeyManager::isNewCertificate(std::string certName, int checkSeqNum)
{
- return certStore.isCertificateNewInStore(certName,checkSeqNum);
+ return m_certStore.isCertificateNewInStore(certName,checkSeqNum);
}
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
KeyManager::getCertificateFromStore(const std::string certName, int checkSeqNum)
{
- return certStore.getCertificateFromStore(certName, checkSeqNum);
+ return m_certStore.getCertificateFromStore(certName, checkSeqNum);
}
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
KeyManager::getCertificateFromStore(const std::string certName)
{
- return certStore.getCertificateFromStore(certName);
+ return m_certStore.getCertificateFromStore(certName);
}
bool
KeyManager::addCertificate(ndn::shared_ptr<ndn::IdentityCertificate> pcert
, uint32_t csn, bool isv)
{
- return certStore.addCertificate(pcert, csn, isv);
+ return m_certStore.addCertificate(pcert, csn, isv);
}
std::pair<uint32_t, bool>
KeyManager::getCertificateSeqNum(std::string certName)
{
- return certStore.getCertificateSeqNum(certName);
+ return m_certStore.getCertificateSeqNum(certName);
}
nlsrKeyType
@@ -221,7 +223,7 @@
std::string opHandle("O.Start");
std::string routerHandle("R.Start");
std::string processHandle("nlsr");
- if ( nt.getTokenString(0,nt.getTokenPosition(KEY)-1) == nlsrRootKeyPrefix)
+ if ( nt.getTokenString(0,nt.getTokenPosition(KEY)-1) == m_nlsrRootKeyPrefix)
{
return KEY_TYPE_ROOT;
}
@@ -249,7 +251,7 @@
KeyManager::getRouterName(const std::string name)
{
std::string routerName;
- std::string rkp(nlsrRootKeyPrefix);
+ std::string rkp(m_nlsrRootKeyPrefix);
nlsrTokenizer ntRkp(rkp,"/");
nlsrTokenizer nt(name,"/");
std::string KEY("KEY");
@@ -295,7 +297,7 @@
{
std::string siteName;
std::string routerName;
- std::string rkp(nlsrRootKeyPrefix);
+ std::string rkp(m_nlsrRootKeyPrefix);
nlsrTokenizer ntRkp(rkp,"/");
nlsrTokenizer nt(name,"/");
std::string KEY("KEY");
@@ -324,7 +326,7 @@
{
std::string rName;
nlsrTokenizer nt(name,"/");
- std::string rkp(nlsrRootKeyPrefix);
+ std::string rkp(m_nlsrRootKeyPrefix);
nlsrTokenizer ntRkp(rkp,"/");
rName=nt.getTokenString(0,ntRkp.getTokenNumber()-1);
return rName;
@@ -356,37 +358,37 @@
}
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> signee=
- certStore.getCertificateFromStore(signingCertName);
+ m_certStore.getCertificateFromStore(signingCertName);
if( signee.second )
{
switch(paketCertType)
- {
+ {
case KEY_TYPE_ROOT:
- return ((getRootName(packetName) == nlsrRootKeyPrefix) &&
+ return ((getRootName(packetName) == m_nlsrRootKeyPrefix) &&
verifySignature(packet,signee.first->getPublicKeyInfo()));
break;
case KEY_TYPE_SITE:
return ((getRootName(packetName) == getRootName(signingCertName)) &&
verifySignature(packet,signee.first->getPublicKeyInfo()) &&
- certStore.getCertificateIsVerified(signingCertName));
+ m_certStore.getCertificateIsVerified(signingCertName));
break;
case KEY_TYPE_OPERATOR:
return ((getSiteName(packetName) == getSiteName(signingCertName)) &&
verifySignature(packet,signee.first->getPublicKeyInfo()) &&
- certStore.getCertificateIsVerified(signingCertName));
+ m_certStore.getCertificateIsVerified(signingCertName));
break;
case KEY_TYPE_ROUTER:
return ((getSiteName(packetName) == getSiteName(signingCertName)) &&
verifySignature(packet,signee.first->getPublicKeyInfo()) &&
- certStore.getCertificateIsVerified(signingCertName));
+ m_certStore.getCertificateIsVerified(signingCertName));
break;
case KEY_TYPE_PROCESS:
return ((getRouterName(packetName) == getRouterName(signingCertName)) &&
verifySignature(packet,signee.first->getPublicKeyInfo()) &&
- certStore.getCertificateIsVerified(signingCertName));
+ m_certStore.getCertificateIsVerified(signingCertName));
break;
- }
+ }
}
else
{
diff --git a/src/security/nlsr_km.hpp b/src/security/nlsr_km.hpp
index 7d75fb2..291d55c 100644
--- a/src/security/nlsr_km.hpp
+++ b/src/security/nlsr_km.hpp
@@ -37,35 +37,35 @@
typedef SecTpm::Error TpmError;
public:
KeyManager()
- : certSeqNo(1)
- , certStore()
- , nlsrRootKeyPrefix()
+ : m_certSeqNo(1)
+ , m_certStore()
+ , m_nlsrRootKeyPrefix()
{
}
- bool initKeyManager(ConfParameter &cp);
+ bool initialize(ConfParameter &cp);
void
checkPolicy (const ndn::Data& data,
int stepCount,
- const ndn::OnDataValidated &onValidated,
- const ndn::OnDataValidationFailed &onValidationFailed,
- std::vector<ndn::shared_ptr<ndn::ValidationRequest> > &nextSteps)
+ const ndn::OnDataValidated& onValidated,
+ const ndn::OnDataValidationFailed& onValidationFailed,
+ std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps)
{}
void
checkPolicy (const ndn::Interest& interest,
int stepCount,
- const ndn::OnInterestValidated &onValidated,
- const ndn::OnInterestValidationFailed &onValidationFailed,
- std::vector<ndn::shared_ptr<ndn::ValidationRequest> > &nextSteps)
+ const ndn::OnInterestValidated& onValidated,
+ const ndn::OnInterestValidationFailed& onValidationFailed,
+ std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps)
{}
void signData(ndn::Data& data)
{
- ndn::KeyChain::signByIdentity(data,processIdentity);
+ ndn::KeyChain::signByIdentity(data,m_processIdentity);
}
template<typename T>
@@ -83,7 +83,7 @@
ndn::shared_ptr<ndn::IdentityCertificate>
getCertificate()
{
- return getCertificate(processCertName);
+ return getCertificate(m_processCertName);
}
ndn::Name
@@ -127,8 +127,8 @@
certificateName.append("KEY").append(
keyName.get(-1)).append("ID-CERT").appendVersion();
certificate->setName(certificateName);
- certificate->setNotBefore(ndn::getNow());
- certificate->setNotAfter(ndn::getNow() + 31536000 /* 1 year*/);
+ certificate->setNotBefore(ndn::time::system_clock::now());
+ certificate->setNotAfter(ndn::time::system_clock::now() + ndn::time::days(7300) /* 1 year*/);
certificate->setPublicKeyInfo(*pubKey);
certificate->addSubjectDescription(
ndn::CertificateSubjectDescription("2.5.4.41",
@@ -156,7 +156,7 @@
void printCertStore()
{
- certStore.printCertStore();
+ m_certStore.print();
}
private:
@@ -168,14 +168,14 @@
std::string signingCertName=signature.getKeyLocator().getName().toUri();
std::string packetName=packet.getName().toUri();
std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> signee=
- certStore.getCertificateFromStore(signingCertName);
+ m_certStore.getCertificateFromStore(signingCertName);
if( signee.second )
{
std::string routerNameFromPacketName=getRouterName(packetName);
std::string routerNameFromCertName=getRouterName(signingCertName);
return ( (routerNameFromPacketName== routerNameFromCertName) &&
verifySignature(packet, signee.first->getPublicKeyInfo()) &&
- certStore.getCertificateIsVerified(signingCertName));
+ m_certStore.getCertificateIsVerified(signingCertName));
}
return false;
}
@@ -230,18 +230,18 @@
std::string getRootName(const std::string name);
private:
- ndn::Name processIdentity;
- ndn::Name routerIdentity;
- ndn::Name processCertName;
- ndn::Name routerCertName;
- ndn::Name opCertName;
- ndn::Name siteCertName;
- ndn::Name rootCertName;
- ndn::Name processKeyName;
- uint32_t certSeqNo;
- string certSeqFileNameWithPath;
- string nlsrRootKeyPrefix;
- NlsrCertificateStore certStore;
+ ndn::Name m_processIdentity;
+ ndn::Name m_routerIdentity;
+ ndn::Name m_processCertName;
+ ndn::Name m_routerCertName;
+ ndn::Name m_opCertName;
+ ndn::Name m_siteCertName;
+ ndn::Name m_rootCertName;
+ ndn::Name m_processKeyName;
+ uint32_t m_certSeqNo;
+ string m_certSeqFileNameWithPath;
+ string m_nlsrRootKeyPrefix;
+ NlsrCertificateStore m_certStore;
};
}
diff --git a/src/security/nlsr_wl.cpp b/src/security/nlsr_wl.cpp
index 39ddfe3..442afe3 100644
--- a/src/security/nlsr_wl.cpp
+++ b/src/security/nlsr_wl.cpp
@@ -1,6 +1,8 @@
#include <ndn-cpp-dev/face.hpp>
#include "nlsr_wl.hpp"
+#define THIS_FILE "nlsr_wl.cpp"
+
namespace nlsr
{
static bool
@@ -12,9 +14,9 @@
std::pair<WaitingListEntry, bool>
WaitingList::getWaitingListEntry(std::string respCert)
{
- std::list<WaitingListEntry>::iterator it = std::find_if( waitingTable.begin(),
- waitingTable.end(),ndn::bind(&waitingListCompare, _1, respCert));
- if( it != waitingTable.end() )
+ std::list<WaitingListEntry>::iterator it = std::find_if( m_waitingTable.begin(),
+ m_waitingTable.end(),ndn::bind(&waitingListCompare, _1, respCert));
+ if( it != m_waitingTable.end() )
{
return std::make_pair(*(it),true);
}
@@ -25,15 +27,15 @@
}
bool
- WaitingList::addtoWaitingList(std::string respCert, std::string waitee)
+ WaitingList::add(std::string respCert, std::string waitee)
{
- std::list<WaitingListEntry>::iterator it = std::find_if( waitingTable.begin(),
- waitingTable.end(),ndn::bind(&waitingListCompare, _1, respCert));
- if( it == waitingTable.end() )
+ std::list<WaitingListEntry>::iterator it = std::find_if( m_waitingTable.begin(),
+ m_waitingTable.end(),ndn::bind(&waitingListCompare, _1, respCert));
+ if( it == m_waitingTable.end() )
{
WaitingListEntry newWle(respCert);
newWle.addWaitee(waitee);
- waitingTable.push_back(newWle);
+ m_waitingTable.push_back(newWle);
return true;
}
else
@@ -44,17 +46,17 @@
}
bool
- WaitingList::removeFromWaitingList(std::string respCert)
+ WaitingList::remove(std::string respCert)
{
- std::list<WaitingListEntry>::iterator it = std::find_if( waitingTable.begin(),
- waitingTable.end(),ndn::bind(&waitingListCompare, _1, respCert));
- if( it == waitingTable.end() )
+ std::list<WaitingListEntry>::iterator it = std::find_if( m_waitingTable.begin(),
+ m_waitingTable.end(),ndn::bind(&waitingListCompare, _1, respCert));
+ if( it == m_waitingTable.end() )
{
return false;
}
else
{
- waitingTable.erase(it);
+ m_waitingTable.erase(it);
return true;
}
return false;
diff --git a/src/security/nlsr_wl.hpp b/src/security/nlsr_wl.hpp
index c287842..1a752ca 100644
--- a/src/security/nlsr_wl.hpp
+++ b/src/security/nlsr_wl.hpp
@@ -9,20 +9,20 @@
{
public:
WaitingList()
- : waitingTable()
+ : m_waitingTable()
{}
std::list<WaitingListEntry>& getWaitingTable()
{
- return waitingTable;
+ return m_waitingTable;
}
- bool addtoWaitingList(std::string respCert, std::string waitee);
+ bool add(std::string respCert, std::string waitee);
std::pair<WaitingListEntry, bool> getWaitingListEntry(std::string respCert);
- bool removeFromWaitingList(std::string respCert);
+ bool remove(std::string respCert);
private:
- std::list<WaitingListEntry> waitingTable;
+ std::list<WaitingListEntry> m_waitingTable;
};
std::ostream& operator<<(std::ostream& os, WaitingList wl);
diff --git a/src/security/nlsr_wle.cpp b/src/security/nlsr_wle.cpp
index df83544..37caf6d 100644
--- a/src/security/nlsr_wle.cpp
+++ b/src/security/nlsr_wle.cpp
@@ -3,6 +3,8 @@
#include <ndn-cpp-dev/face.hpp>
#include "nlsr_wle.hpp"
+#define THIS_FILE "nlsr_wle.cpp"
+
namespace nlsr
{
static bool
@@ -14,11 +16,11 @@
bool
WaitingListEntry::addWaitee(std::string waiteeName)
{
- std::list<std::string>::iterator it = std::find_if( waitingCerts.begin(),
- waitingCerts.end(),ndn::bind(&waiteeCompare, _1, waiteeName));
- if( it == waitingCerts.end() )
+ std::list<std::string>::iterator it = std::find_if( m_waitingCerts.begin(),
+ m_waitingCerts.end(),ndn::bind(&waiteeCompare, _1, waiteeName));
+ if( it == m_waitingCerts.end() )
{
- waitingCerts.push_back(waiteeName);
+ m_waitingCerts.push_back(waiteeName);
return true;
}
diff --git a/src/security/nlsr_wle.hpp b/src/security/nlsr_wle.hpp
index c8e6fd6..0647382 100644
--- a/src/security/nlsr_wle.hpp
+++ b/src/security/nlsr_wle.hpp
@@ -10,35 +10,35 @@
{
public:
WaitingListEntry()
- : responsibleCert()
- , waitingCerts()
+ : m_responsibleCert()
+ , m_waitingCerts()
{}
WaitingListEntry(std::string resCert)
- : responsibleCert(resCert)
- , waitingCerts()
+ : m_responsibleCert(resCert)
+ , m_waitingCerts()
{}
std::string getResponsibleCert() const
{
- return responsibleCert;
+ return m_responsibleCert;
}
void setResponsibleCert(std::string resCert)
{
- responsibleCert=resCert;
+ m_responsibleCert=resCert;
}
std::list<std::string> getWaitingCerts() const
{
- return waitingCerts;
+ return m_waitingCerts;
}
bool addWaitee(std::string waiteeName);
private:
- std::string responsibleCert;
- std::list<std::string> waitingCerts;
+ std::string m_responsibleCert;
+ std::list<std::string> m_waitingCerts;
};
std::ostream& operator<<(std::ostream& os, const WaitingListEntry& we);
diff --git a/src/utility/nlsr_logger.cpp b/src/utility/nlsr_logger.cpp
index 82b6e75..f214c6a 100644
--- a/src/utility/nlsr_logger.cpp
+++ b/src/utility/nlsr_logger.cpp
@@ -49,7 +49,7 @@
keywords::min_free_space = 64 * 1024 * 1024
));
sink->set_formatter(
- expr::format("%1%: %2%")
+ expr::format("%1% %2%")
% getEpochTime()
% expr::smessage
);
diff --git a/src/utility/nlsr_tokenizer.cpp b/src/utility/nlsr_tokenizer.cpp
index 35d6625..a1ed2bd 100644
--- a/src/utility/nlsr_tokenizer.cpp
+++ b/src/utility/nlsr_tokenizer.cpp
@@ -15,8 +15,8 @@
void
nlsrTokenizer::makeToken()
{
- char_separator<char> sep(seps.c_str());
- tokenizer< char_separator<char> >tokens(originalString, sep);
+ char_separator<char> sep(m_seps.c_str());
+ tokenizer< char_separator<char> >tokens(m_originalString, sep);
tokenizer< char_separator<char> >::iterator tok_iter = tokens.begin();
for ( ; tok_iter != tokens.end(); ++tok_iter)
{
@@ -27,15 +27,15 @@
insertToken(oneToken);
}
}
- firstToken=vTokenList[0];
+ m_firstToken=m_vTokenList[0];
makeRestOfTheLine();
}
void
nlsrTokenizer::insertToken(const string& token)
{
- tokenList.push_back(token);
- vTokenList.push_back(token);
+ m_tokenList.push_back(token);
+ m_vTokenList.push_back(token);
}
int
@@ -43,8 +43,8 @@
{
int pos=-1;
int i=0;
- for(std::list<string>::iterator it=tokenList.begin();
- it!=tokenList.end(); it++)
+ for(std::list<string>::iterator it=m_tokenList.begin();
+ it!=m_tokenList.end(); it++)
{
if( (*it) == token )
{
@@ -52,7 +52,7 @@
}
i++;
}
- if( i < tokenList.size() )
+ if( i < m_tokenList.size() )
{
pos=i;
}
@@ -63,13 +63,13 @@
nlsrTokenizer::getTokenString(int from , int to)
{
string returnString="";
- if((from>=0 && to<tokenList.size()) &&
- (to>=from && to <tokenList.size()))
+ if((from>=0 && to<m_tokenList.size()) &&
+ (to>=from && to <m_tokenList.size()))
{
for(int i=from; i<=to; i++)
{
- returnString+=seps;
- returnString+=vTokenList[i];
+ returnString+=m_seps;
+ returnString+=m_vTokenList[i];
}
}
trim(returnString);
@@ -79,7 +79,7 @@
string
nlsrTokenizer::getTokenString(int from)
{
- return getTokenString(from,tokenList.size()-1);
+ return getTokenString(from,m_tokenList.size()-1);
}
static bool
@@ -91,16 +91,16 @@
void
nlsrTokenizer::makeRestOfTheLine()
{
- restOfTheLine=getTokenString(1);
+ m_restOfTheLine=getTokenString(1);
}
bool
nlsrTokenizer::doesTokenExist(string token)
{
- std::list<string >::iterator it = std::find_if( tokenList.begin(),
- tokenList.end(),
+ std::list<string >::iterator it = std::find_if( m_tokenList.begin(),
+ m_tokenList.end(),
bind(&tokenCompare, _1 , token));
- if( it != tokenList.end() )
+ if( it != m_tokenList.end() )
{
return true;
}
diff --git a/src/utility/nlsr_tokenizer.hpp b/src/utility/nlsr_tokenizer.hpp
index 4b84d8b..02d6eea 100644
--- a/src/utility/nlsr_tokenizer.hpp
+++ b/src/utility/nlsr_tokenizer.hpp
@@ -19,62 +19,62 @@
{
public:
nlsrTokenizer(const string& inputString)
- : firstToken()
- , restOfTheLine()
- , currentPosition(0)
+ : m_firstToken()
+ , m_restOfTheLine()
+ , m_currentPosition(0)
{
- seps = " ";
- originalString = inputString;
+ m_seps = " ";
+ m_originalString = inputString;
makeToken();
}
nlsrTokenizer(const string& inputString, const string& separator)
- : firstToken()
- , restOfTheLine()
- , currentPosition(0)
+ : m_firstToken()
+ , m_restOfTheLine()
+ , m_currentPosition(0)
{
- seps = separator;
- originalString = inputString;
+ m_seps = separator;
+ m_originalString = inputString;
makeToken();
}
string getFirstToken()
{
- return firstToken;
+ return m_firstToken;
}
string getRestOfLine()
{
- return restOfTheLine;
+ return m_restOfTheLine;
}
void resetCurrentPosition(uint32_t cp=0)
{
- if( cp >=0 && cp <= vTokenList.size() )
+ if( cp >=0 && cp <= m_vTokenList.size() )
{
- currentPosition=cp;
+ m_currentPosition=cp;
}
}
string getNextToken()
{
- if(currentPosition >= 0 && currentPosition <= (vTokenList.size()-1))
+ if(m_currentPosition >= 0 && m_currentPosition <= (m_vTokenList.size()-1))
{
- return vTokenList[currentPosition++];
+ return m_vTokenList[m_currentPosition++];
}
return "";
}
uint32_t getTokenNumber()
{
- return tokenList.size();
+ return m_tokenList.size();
}
string getToken(int position)
{
- if( position >=0 && position <vTokenList.size() )
+ if( position >=0 && position <m_vTokenList.size() )
{
- return vTokenList[position];
+ return m_vTokenList[position];
}
return "";
}
@@ -91,13 +91,13 @@
void insertToken(const string& token);
void makeRestOfTheLine();
- string seps;
- string originalString;
- string firstToken;
- string restOfTheLine;
- std::list<string> tokenList;
- std::vector<string> vTokenList;
- uint32_t currentPosition;
+ string m_seps;
+ string m_originalString;
+ string m_firstToken;
+ string m_restOfTheLine;
+ std::list<string> m_tokenList;
+ std::vector<string> m_vTokenList;
+ uint32_t m_currentPosition;
};
}//namespace nlsr
diff --git a/waf-tools/openssl.py b/waf-tools/openssl.py
new file mode 100644
index 0000000..7f599a9
--- /dev/null
+++ b/waf-tools/openssl.py
@@ -0,0 +1,59 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+'''
+
+When using this tool, the wscript will look like:
+
+ def options(opt):
+ opt.tool_options('openssl')
+
+ def configure(conf):
+ conf.load('compiler_c openssl')
+
+ conf.check_openssl()
+
+ def build(bld):
+ bld(source='main.cpp', target='app', use='OPENSSL')
+
+'''
+
+from waflib import Options
+from waflib.Configure import conf
+
+@conf
+def check_openssl(self,*k,**kw):
+ root = k and k[0] or kw.get('path',None) or Options.options.with_openssl
+ mandatory = kw.get('mandatory', True)
+ var = kw.get('var', 'OPENSSL')
+
+ CODE = """
+#include <openssl/crypto.h>
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ (void)argc;
+ printf ("%s", argv[0]);
+
+ return 0;
+}
+"""
+ if root:
+ libcrypto = self.check_cc (lib=['ssl', 'crypto'],
+ header_name='openssl/crypto.h',
+ define_name='HAVE_%s' % var,
+ uselib_store=var,
+ mandatory = mandatory,
+ cflags="-I%s/include" % root,
+ linkflags="-L%s/lib" % root,
+ execute = True, fragment = CODE, define_ret = True)
+ else:
+ libcrypto = self.check_cc (lib=['ssl', 'crypto'],
+ header_name='openssl/crypto.h',
+ define_name='HAVE_%s' % var,
+ uselib_store=var,
+ mandatory = mandatory,
+ execute = True, fragment = CODE, define_ret = True)
+
+def options(opt):
+ opt.add_option('--with-openssl',type='string',default='',dest='with_openssl',help='''Path to OpenSSL''')
diff --git a/wscript b/wscript
index 061fb26..200ccbf 100644
--- a/wscript
+++ b/wscript
@@ -1,16 +1,23 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+VERSION='1.0'
+NAME="NLSR"
from waflib import Build, Logs, Utils, Task, TaskGen, Configure
+from waflib.Tools import c_preproc
def options(opt):
opt.load('compiler_c compiler_cxx gnu_dirs c_osx')
- opt.load('boost cryptopp', tooldir=['waf-tools'])
+ opt.load('boost openssl cryptopp', tooldir=['waf-tools'])
- opt = opt.add_option_group('Options')
+ opt = opt.add_option_group('NLSR Options')
+
opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
+
def configure(conf):
- conf.load("compiler_c compiler_cxx boost gnu_dirs c_osx cryptopp")
+ conf.load("compiler_c compiler_cxx boost gnu_dirs c_osx openssl cryptopp")
+
+ conf.check_openssl()
if conf.options.debug:
conf.define ('_DEBUG', 1)
@@ -30,15 +37,22 @@
conf.add_supported_cxxflags (cxxflags = flags)
else:
- flags = ['-O3', '-g','-Wno-unused-variable', '-Wno-tautological-compare',
- '-Wno-unused-function', '-Wno-deprecated-declarations']
+ flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations']
conf.add_supported_cxxflags (cxxflags = flags)
+
conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True)
- conf.check_boost(lib='system iostreams thread unit_test_framework log', uselib_store='BOOST', version='1_55', mandatory=True)
conf.check_cfg(package='nsync', args=['--cflags', '--libs'], uselib_store='nsync', mandatory=True)
conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
conf.check_cryptopp(path=conf.options.cryptopp_dir, mandatory=True)
+ conf.check_boost(lib='system iostreams thread unit_test_framework log', uselib_store='BOOST', mandatory=True)
+ if conf.env.BOOST_VERSION_NUMBER < 105400:
+ Logs.error ("Minimum required boost version is 1.54.0")
+ Logs.error ("Please upgrade your distribution or install custom boost libraries")
+ return
+
+
+
def build (bld):
bld (