Directory Structuring
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 3ca2279..84b5e6d 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -6,12 +6,9 @@
#include <sstream>
#include "nlsr.hpp"
-#include "nlsr_conf_param.hpp"
#include "nlsr_conf_processor.hpp"
-#include "nlsr_lsdb.hpp"
-#include "nlsr_logger.hpp"
-//test purpose of NLSR
-#include "nlsr_test.hpp"
+#include "utility/nlsr_logger.hpp"
+
namespace nlsr
{
@@ -23,24 +20,37 @@
Nlsr::nlsrRegistrationFailed(const ndn::Name& name)
{
cerr << "ERROR: Failed to register prefix in local hub's daemon" << endl;
- getNlsrFace().shutdown();
+ getNlsrFace()->shutdown();
}
void
Nlsr::setInterestFilterNlsr(const string& name)
{
- getNlsrFace().setInterestFilter(name,
- func_lib::bind(&interestManager::processInterest, &im,
- boost::ref(*this), _1, _2),
- func_lib::bind(&Nlsr::nlsrRegistrationFailed, this, _1));
+ getNlsrFace()->setInterestFilter(name,
+ func_lib::bind(&interestManager::processInterest, &im,
+ boost::ref(*this), _1, _2),
+ func_lib::bind(&Nlsr::nlsrRegistrationFailed, this, _1));
}
+ void
+ Nlsr::initNlsr()
+ {
+ confParam.buildRouterPrefix();
+ nlsrLogger.initNlsrLogger(confParam.getLogDir());
+ nlsrLsdb.setLsaRefreshTime(confParam.getLsaRefreshTime());
+ nlsrLsdb.setThisRouterPrefix(confParam.getRouterPrefix());
+ fib.setFibEntryRefreshTime(2*confParam.getLsaRefreshTime());
+ km.initKeyManager(confParam);
+ sm.setSeqFileName(confParam.getSeqFileDir());
+ sm.initiateSeqNoFromFile();
+ slh.setSyncPrefix(confParam.getChronosyncSyncPrefix());
+ }
void
Nlsr::startEventLoop()
{
- getNlsrFace().processEvents();
+ io->run();
}
int
@@ -97,19 +107,7 @@
{
return EXIT_FAILURE;
}
- nlsr_.getConfParameter().buildRouterPrefix();
- nlsr_.getNlsrLogger().initNlsrLogger(nlsr_.getConfParameter().getLogDir());
- //src::logger lg;
- //BOOST_LOG(lg) << "Some log record from nlsr.cpp";
- //for(int j=0; j< 1000; j++)
- //{
- // BOOST_LOG(lg) << "Some log record from nlsr.cpp "<<j;
- //}
- nlsr_.getLsdb().setLsaRefreshTime(nlsr_.getConfParameter().getLsaRefreshTime());
- nlsr_.getFib().setFibEntryRefreshTime(
- 2*nlsr_.getConfParameter().getLsaRefreshTime());
- nlsr_.getLsdb().setThisRouterPrefix(nlsr_.getConfParameter().getRouterPrefix());
- nlsr_.getKeyManager().initKeyManager(nlsr_.getConfParameter());
+ nlsr_.initNlsr();
/* debugging purpose start */
cout << nlsr_.getConfParameter();
nlsr_.getAdl().printAdl();
@@ -118,9 +116,15 @@
nlsr_.getLsdb().buildAndInstallOwnNameLsa(nlsr_);
nlsr_.getLsdb().buildAndInstallOwnCorLsa(nlsr_);
nlsr_.setInterestFilterNlsr(nlsr_.getConfParameter().getRouterPrefix());
+ nlsr_.setInterestFilterNlsr(nlsr_.getConfParameter().getChronosyncLsaPrefix()+
+ nlsr_.getConfParameter().getRouterPrefix());
+ nlsr_.setInterestFilterNlsr(nlsr_.getConfParameter().getRootKeyPrefix());
+ nlsr_.getSlh().createSyncSocket(nlsr_);
+ nlsr_.getSlh().publishKeyUpdate(nlsr_.getKeyManager());
+ nlsr_.getSlh().publishRoutingUpdate(nlsr_.getSm(),
+ nlsr_.getConfParameter().getChronosyncLsaPrefix()
+ + nlsr_.getConfParameter().getRouterPrefix());
nlsr_.getIm().scheduleInfoInterest(nlsr_,1);
- //testing purpose
- nlsr_.getNlsrTesting().schedlueAddingLsas(nlsr_);
try
{
nlsr_.startEventLoop();