Compare commits
9
Commits
NLSR-0.3.1
...
NLSR-0.3.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f023a88ec1 | ||
|
|
4c2bb361ae | ||
|
|
1de901f161 | ||
|
|
9f93666519 | ||
|
|
48daea20d7 | ||
|
|
218aaef118 | ||
|
|
87911dacd5 | ||
|
|
54e726cf5e | ||
|
|
a4cf402084 |
No files matched your search
+22
-1
@@ -1,10 +1,31 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
NLSR version 0.3.2 (changes since version 0.3.1)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: March 15, 2017
|
||||
|
||||
**Changes**
|
||||
|
||||
- NLSR constructor now accept a KeyChain argument. (:issue:`3742`)
|
||||
|
||||
- Fix security rule for /localhop LSA prefix (:issue:`3899`)
|
||||
|
||||
- Use ndn::nfd::ROUTE_ORIGIN_NLSR instead of a magic number. (:issue:`3903`)
|
||||
|
||||
- Handle "Face Already Exists" error (error code 409) in NFD. (:issue:`3976`)
|
||||
|
||||
- Enable NLSR to register localhost prefix with dispatcher before top-level prefix. (:issue:`3938`)
|
||||
|
||||
- Don't use ndn aliases provided by ndn-cxx/common.hpp. (:issue:`3983`)
|
||||
|
||||
- Remove use of deprecated code. (:issue:`3988`)
|
||||
|
||||
NLSR version 0.3.1 (changes since version 0.3.0)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: January 22, 2016
|
||||
Release date: January 22, 2017
|
||||
|
||||
**Changes**
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ security
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
|
||||
p-regex ^<localhop>([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
|
||||
p-expand \\1\\2
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -218,7 +218,7 @@ SyncLogic::onSyncRegisterFailed(const Name& prefix, const string& msg)
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogic::onSyncData(const ndn::Interest& interest, Data& data)
|
||||
SyncLogic::onSyncData(const ndn::Interest& interest, const Data& data)
|
||||
{
|
||||
OnDataValidated onValidated = bind(&SyncLogic::onSyncDataValidated, this, _1);
|
||||
OnDataValidationFailed onValidationFailed = bind(&SyncLogic::onSyncDataValidationFailed, this, _1);
|
||||
@@ -624,6 +624,7 @@ SyncLogic::sendSyncInterest ()
|
||||
|
||||
m_face->expressInterest(interest,
|
||||
bind(&SyncLogic::onSyncData, this, _1, _2),
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1), // Nack
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1));
|
||||
}
|
||||
|
||||
@@ -652,6 +653,7 @@ SyncLogic::sendSyncRecoveryInterests (DigestConstPtr digest)
|
||||
|
||||
m_face->expressInterest(interest,
|
||||
bind(&SyncLogic::onSyncData, this, _1, _2),
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1), // Nack
|
||||
bind(&SyncLogic::onSyncTimeout, this, _1));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ private:
|
||||
onSyncRegisterFailed(const ndn::Name& prefix, const std::string& msg);
|
||||
|
||||
void
|
||||
onSyncData(const ndn::Interest& interest, ndn::Data& data);
|
||||
onSyncData(const ndn::Interest& interest, const ndn::Data& data);
|
||||
|
||||
void
|
||||
onSyncTimeout(const ndn::Interest& interest);
|
||||
|
||||
@@ -112,13 +112,15 @@ SyncSocket::fetchData(const Name &prefix, const SeqNo &seq,
|
||||
m_face->expressInterest(interest,
|
||||
bind(&SyncSocket::onData, this, _1, _2,
|
||||
onValidated, onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout, this, _1, retry, // Nack
|
||||
onValidated, onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout, this, _1, retry,
|
||||
onValidated, onValidationFailed));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SyncSocket::onData(const ndn::Interest& interest, Data& data,
|
||||
SyncSocket::onData(const ndn::Interest& interest, const Data& data,
|
||||
const OnDataValidated& onValidated,
|
||||
const OnDataValidationFailed& onValidationFailed)
|
||||
{
|
||||
@@ -140,6 +142,12 @@ SyncSocket::onDataTimeout(const ndn::Interest& interest,
|
||||
_2,
|
||||
onValidated,
|
||||
onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout,
|
||||
this,
|
||||
_1,
|
||||
retry - 1,
|
||||
onValidated,
|
||||
onValidationFailed),
|
||||
bind(&SyncSocket::onDataTimeout,
|
||||
this,
|
||||
_1,
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
onData(const ndn::Interest& interest, ndn::Data& data,
|
||||
onData(const ndn::Interest& interest, const ndn::Data& data,
|
||||
const ndn::OnDataValidated& onValidated,
|
||||
const ndn::OnDataValidationFailed& onValidationFailed);
|
||||
|
||||
|
||||
@@ -235,8 +235,8 @@ AdjacencyList::find(const ndn::Name& adjName)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compare,
|
||||
_1, ndn::cref(adjName)));
|
||||
std::bind(&Adjacent::compare,
|
||||
_1, std::cref(adjName)));
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -245,8 +245,8 @@ AdjacencyList::findAdjacent(const ndn::Name& adjName)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compare,
|
||||
_1, ndn::cref(adjName)));
|
||||
std::bind(&Adjacent::compare,
|
||||
_1, std::cref(adjName)));
|
||||
if (it != m_adjList.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ AdjacencyList::findAdjacent(uint64_t faceId)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compareFaceId,
|
||||
std::bind(&Adjacent::compareFaceId,
|
||||
_1, faceId));
|
||||
if (it != m_adjList.end()) {
|
||||
return &(*it);
|
||||
@@ -273,7 +273,7 @@ AdjacencyList::getFaceId(const std::string& faceUri)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
ndn::bind(&Adjacent::compareFaceUri,
|
||||
std::bind(&Adjacent::compareFaceUri,
|
||||
_1, faceUri));
|
||||
if (it != m_adjList.end()) {
|
||||
return it->getFaceId();
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
int32_t lsaPosition = util::getNameComponentPosition(m_name, LSA_COMPONENT);
|
||||
|
||||
if (nlsrPosition < 0 || lsaPosition < 0) {
|
||||
throw Error("Cannot parse update name because expected components are missing");
|
||||
BOOST_THROW_EXCEPTION(Error("Cannot parse update name because expected components are missing"));
|
||||
}
|
||||
|
||||
ndn::Name networkName = m_name.getSubName(1, nlsrPosition-1);
|
||||
@@ -154,12 +154,12 @@ SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix)
|
||||
|
||||
// The face's lifetime is managed in main.cpp; SyncSocket should not manage the memory
|
||||
// of the object
|
||||
ndn::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
|
||||
std::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
|
||||
|
||||
m_syncSocket = ndn::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator, facePtr,
|
||||
ndn::bind(&SyncLogicHandler::onNsyncUpdate,
|
||||
m_syncSocket = std::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator, facePtr,
|
||||
std::bind(&SyncLogicHandler::onNsyncUpdate,
|
||||
this, _1, _2),
|
||||
ndn::bind(&SyncLogicHandler::onNsyncRemoval,
|
||||
std::bind(&SyncLogicHandler::onNsyncRemoval,
|
||||
this, _1));
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
|
||||
try {
|
||||
originRouter = update.getOriginRouter();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
catch (const std::exception& e) {
|
||||
_LOG_WARN("Received malformed sync update");
|
||||
return;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ SyncLogicHandler::publishRoutingUpdate()
|
||||
if (m_syncSocket == nullptr) {
|
||||
_LOG_FATAL("Cannot publish routing update; SyncSocket does not exist");
|
||||
|
||||
throw SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist");
|
||||
BOOST_THROW_EXCEPTION(SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist"));
|
||||
}
|
||||
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
@@ -90,9 +91,9 @@ private:
|
||||
publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::ValidatorNull> m_validator;
|
||||
std::shared_ptr<ndn::ValidatorNull> m_validator;
|
||||
ndn::Face& m_syncFace;
|
||||
ndn::shared_ptr<Sync::SyncSocket> m_syncSocket;
|
||||
std::shared_ptr<Sync::SyncSocket> m_syncSocket;
|
||||
ndn::Name m_syncPrefix;
|
||||
|
||||
private:
|
||||
@@ -111,4 +112,4 @@ private:
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_SYNC_LOGIC_HANDLER_HPP
|
||||
#endif // NLSR_SYNC_LOGIC_HANDLER_HPP
|
||||
@@ -45,7 +45,7 @@ template <class T>
|
||||
class ConfigurationVariable
|
||||
{
|
||||
public:
|
||||
typedef ndn::function<void(T)> ConfParameterCallback;
|
||||
typedef std::function<void(T)> ConfParameterCallback;
|
||||
typedef boost::property_tree::ptree ConfigSection;
|
||||
|
||||
ConfigurationVariable(const std::string& key, const ConfParameterCallback& setter)
|
||||
@@ -446,7 +446,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
// Event intervals
|
||||
// adj-lsa-build-interval
|
||||
ConfigurationVariable<uint32_t> adjLsaBuildInterval("adj-lsa-build-interval",
|
||||
bind(&ConfParameter::setAdjLsaBuildInterval,
|
||||
std::bind(&ConfParameter::setAdjLsaBuildInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
adjLsaBuildInterval.setMinAndMaxValue(ADJ_LSA_BUILD_INTERVAL_MIN, ADJ_LSA_BUILD_INTERVAL_MAX);
|
||||
adjLsaBuildInterval.setOptional(ADJ_LSA_BUILD_INTERVAL_DEFAULT);
|
||||
@@ -457,7 +457,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
|
||||
// first-hello-interval
|
||||
ConfigurationVariable<uint32_t> firstHelloInterval("first-hello-interval",
|
||||
bind(&ConfParameter::setFirstHelloInterval,
|
||||
std::bind(&ConfParameter::setFirstHelloInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
firstHelloInterval.setMinAndMaxValue(FIRST_HELLO_INTERVAL_MIN, FIRST_HELLO_INTERVAL_MAX);
|
||||
firstHelloInterval.setOptional(FIRST_HELLO_INTERVAL_DEFAULT);
|
||||
@@ -569,7 +569,7 @@ ConfFileProcessor::processConfSectionFib(const ConfigSection& section)
|
||||
|
||||
// routing-calc-interval
|
||||
ConfigurationVariable<uint32_t> routingCalcInterval("routing-calc-interval",
|
||||
bind(&ConfParameter::setRoutingCalcInterval,
|
||||
std::bind(&ConfParameter::setRoutingCalcInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
routingCalcInterval.setMinAndMaxValue(ROUTING_CALC_INTERVAL_MIN, ROUTING_CALC_INTERVAL_MAX);
|
||||
routingCalcInterval.setOptional(ROUTING_CALC_INTERVAL_DEFAULT);
|
||||
@@ -635,7 +635,7 @@ ConfFileProcessor::processConfSectionSecurity(const ConfigSection& section)
|
||||
|
||||
std::string file = it->second.data();
|
||||
path certfilePath = absolute(file, path(m_confFileName).parent_path());
|
||||
shared_ptr<ndn::IdentityCertificate> idCert =
|
||||
std::shared_ptr<ndn::IdentityCertificate> idCert =
|
||||
ndn::io::load<ndn::IdentityCertificate>(certfilePath.string());
|
||||
|
||||
if (idCert == nullptr) {
|
||||
|
||||
+19
-17
@@ -42,10 +42,12 @@ HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
|
||||
i.setInterestLifetime(ndn::time::seconds(seconds));
|
||||
i.setMustBeFresh(true);
|
||||
m_nlsr.getNlsrFace().expressInterest(i,
|
||||
ndn::bind(&HelloProtocol::onContent,
|
||||
std::bind(&HelloProtocol::onContent,
|
||||
this,
|
||||
_1, _2),
|
||||
ndn::bind(&HelloProtocol::processInterestTimedOut,
|
||||
std::bind(&HelloProtocol::processInterestTimedOut, // Nack
|
||||
this, _1),
|
||||
std::bind(&HelloProtocol::processInterestTimedOut,
|
||||
this, _1));
|
||||
}
|
||||
|
||||
@@ -57,7 +59,7 @@ HelloProtocol::sendScheduledInterest(uint32_t seconds)
|
||||
++it) {
|
||||
// If this adjacency has a Face, just proceed as usual.
|
||||
if((*it).getFaceId() != 0) {
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName = (*it).getName() ;
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
@@ -82,14 +84,14 @@ HelloProtocol::scheduleInterest(uint32_t seconds)
|
||||
_LOG_DEBUG("Scheduling HELLO Interests in " << ndn::time::seconds(seconds));
|
||||
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(seconds),
|
||||
ndn::bind(&HelloProtocol::sendScheduledInterest, this, seconds));
|
||||
std::bind(&HelloProtocol::sendScheduledInterest, this, seconds));
|
||||
}
|
||||
|
||||
void
|
||||
HelloProtocol::processInterest(const ndn::Name& name,
|
||||
const ndn::Interest& interest)
|
||||
{
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
const ndn::Name interestName = interest.getName();
|
||||
_LOG_DEBUG("Interest Received for Name: " << interestName);
|
||||
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
|
||||
@@ -99,7 +101,7 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
neighbor.wireDecode(interestName.get(-1).blockFromValue());
|
||||
_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) {
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
|
||||
@@ -112,7 +114,7 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_INACTIVE) {
|
||||
// We can only do that if the neighbor currently has a face.
|
||||
if(adjacent->getFaceId() != 0){
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
@@ -133,7 +135,7 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
void
|
||||
HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
{
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
const ndn::Name interestName(interest.getName());
|
||||
_LOG_DEBUG("Interest timed out for Name: " << interestName);
|
||||
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
|
||||
@@ -150,7 +152,7 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
_LOG_DEBUG("Status: " << status);
|
||||
_LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount);
|
||||
if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
@@ -179,8 +181,8 @@ HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(data,
|
||||
ndn::bind(&HelloProtocol::onContentValidated, this, _1),
|
||||
ndn::bind(&HelloProtocol::onContentValidationFailed,
|
||||
std::bind(&HelloProtocol::onContentValidated, this, _1),
|
||||
std::bind(&HelloProtocol::onContentValidationFailed,
|
||||
this, _1, _2));
|
||||
}
|
||||
|
||||
@@ -190,9 +192,9 @@ HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
// LSA. If there was a change in status, we schedule an adjacency
|
||||
// LSA build.
|
||||
void
|
||||
HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
HelloProtocol::onContentValidated(const std::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
/* data name: /<neighbor>/NLSR/INFO/<router>/<version> */
|
||||
// data name: /<neighbor>/NLSR/INFO/<router>/<version>
|
||||
ndn::Name dataName = data->getName();
|
||||
_LOG_DEBUG("Data validation successful for INFO(name): " << dataName);
|
||||
if (dataName.get(-3).toUri() == INFO_COMPONENT) {
|
||||
@@ -220,7 +222,7 @@ HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
// Simply logs a debug message that the content could not be
|
||||
// validated (and is implicitly being discarded as a result).
|
||||
void
|
||||
HelloProtocol::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
HelloProtocol::onContentValidationFailed(const std::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg)
|
||||
{
|
||||
_LOG_DEBUG("Validation Error: " << msg);
|
||||
@@ -235,9 +237,9 @@ HelloProtocol::registerPrefixes(const ndn::Name& adjName, const std::string& fac
|
||||
{
|
||||
m_nlsr.getFib().registerPrefix(adjName, faceUri, linkCost, timeout,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0,
|
||||
ndn::bind(&HelloProtocol::onRegistrationSuccess,
|
||||
std::bind(&HelloProtocol::onRegistrationSuccess,
|
||||
this, _1, adjName,timeout),
|
||||
ndn::bind(&HelloProtocol::onRegistrationFailure,
|
||||
std::bind(&HelloProtocol::onRegistrationFailure,
|
||||
this, _1, adjName));
|
||||
}
|
||||
|
||||
@@ -266,7 +268,7 @@ HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandS
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
|
||||
// Sends a Hello Interest to determine status before the next scheduled.
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
|
||||
@@ -102,11 +102,11 @@ private:
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
onContentValidated(const std::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
private:
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
onContentValidationFailed(const std::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg);
|
||||
|
||||
void
|
||||
|
||||
+22
-22
@@ -107,7 +107,7 @@ Lsdb::onFetchLsaError(uint32_t errorCode,
|
||||
void
|
||||
Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, ndn::Name& interestName)
|
||||
{
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(ndn::Name(interestName));
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(ndn::Name(interestName));
|
||||
data->setContent(bufferPtr);
|
||||
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data->getName());
|
||||
@@ -161,7 +161,7 @@ Lsdb::findNameLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
bind(nameLsaCompareByKey, _1, key));
|
||||
std::bind(nameLsaCompareByKey, _1, key));
|
||||
if (it != m_nameLsdb.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshNameLsa, this, key, seqNo));
|
||||
std::bind(&Lsdb::exprireOrRefreshNameLsa, this, key, seqNo));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -294,7 +294,7 @@ Lsdb::addNameLsa(NameLsa& nlsa)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
bind(nameLsaCompareByKey, _1,
|
||||
std::bind(nameLsaCompareByKey, _1,
|
||||
nlsa.getKey()));
|
||||
if (it == m_nameLsdb.end()) {
|
||||
m_nameLsdb.push_back(nlsa);
|
||||
@@ -308,7 +308,7 @@ Lsdb::removeNameLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
ndn::bind(nameLsaCompareByKey, _1, key));
|
||||
std::bind(nameLsaCompareByKey, _1, key));
|
||||
if (it != m_nameLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Name Lsa");
|
||||
(*it).writeLog();
|
||||
@@ -336,7 +336,7 @@ Lsdb::doesNameLsaExist(const ndn::Name& key)
|
||||
{
|
||||
std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
|
||||
m_nameLsdb.end(),
|
||||
ndn::bind(nameLsaCompareByKey, _1, key));
|
||||
std::bind(nameLsaCompareByKey, _1, key));
|
||||
if (it == m_nameLsdb.end()) {
|
||||
return false;
|
||||
}
|
||||
@@ -396,7 +396,7 @@ Lsdb::findCoordinateLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey, _1, key));
|
||||
std::bind(corLsaCompareByKey, _1, key));
|
||||
if (it != m_corLsdb.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
@@ -429,7 +429,7 @@ Lsdb::scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
|
||||
std::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
|
||||
this, key, seqNo));
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ Lsdb::addCoordinateLsa(CoordinateLsa& clsa)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey, _1,
|
||||
std::bind(corLsaCompareByKey, _1,
|
||||
clsa.getKey()));
|
||||
if (it == m_corLsdb.end()) {
|
||||
m_corLsdb.push_back(clsa);
|
||||
@@ -514,7 +514,7 @@ Lsdb::removeCoordinateLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey,
|
||||
std::bind(corLsaCompareByKey,
|
||||
_1, key));
|
||||
if (it != m_corLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
@@ -535,7 +535,7 @@ Lsdb::doesCoordinateLsaExist(const ndn::Name& key)
|
||||
{
|
||||
std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
|
||||
m_corLsdb.end(),
|
||||
ndn::bind(corLsaCompareByKey,
|
||||
std::bind(corLsaCompareByKey,
|
||||
_1, key));
|
||||
if (it == m_corLsdb.end()) {
|
||||
return false;
|
||||
@@ -584,7 +584,7 @@ Lsdb::scheduleAdjLsaBuild()
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
_LOG_DEBUG("Scheduling Adjacency LSA build in " << m_adjLsaBuildInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_adjLsaBuildInterval, ndn::bind(&Lsdb::buildAdjLsa, this));
|
||||
m_scheduler.scheduleEvent(m_adjLsaBuildInterval, std::bind(&Lsdb::buildAdjLsa, this));
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
}
|
||||
}
|
||||
@@ -611,7 +611,7 @@ Lsdb::buildAdjLsa()
|
||||
// router from refreshing the LSA, eventually causing other
|
||||
// routers to delete it, too.
|
||||
else {
|
||||
_LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors")
|
||||
_LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors");
|
||||
// Get this router's key
|
||||
ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
|
||||
key.append(AdjLsa::TYPE_STRING);
|
||||
@@ -634,7 +634,7 @@ Lsdb::buildAdjLsa()
|
||||
int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
|
||||
m_nlsr.getConfParameter().getInterestResendTime();
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(schedulingTime),
|
||||
ndn::bind(&Lsdb::buildAdjLsa, this));
|
||||
std::bind(&Lsdb::buildAdjLsa, this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,7 +643,7 @@ Lsdb::addAdjLsa(AdjLsa& alsa)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
bind(adjLsaCompareByKey, _1,
|
||||
std::bind(adjLsaCompareByKey, _1,
|
||||
alsa.getKey()));
|
||||
if (it == m_adjLsdb.end()) {
|
||||
m_adjLsdb.push_back(alsa);
|
||||
@@ -657,7 +657,7 @@ Lsdb::findAdjLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
bind(adjLsaCompareByKey, _1, key));
|
||||
std::bind(adjLsaCompareByKey, _1, key));
|
||||
if (it != m_adjLsdb.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
@@ -686,7 +686,7 @@ Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshAdjLsa, this, key, seqNo));
|
||||
std::bind(&Lsdb::exprireOrRefreshAdjLsa, this, key, seqNo));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -766,7 +766,7 @@ Lsdb::removeAdjLsa(const ndn::Name& key)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
ndn::bind(adjLsaCompareByKey, _1, key));
|
||||
std::bind(adjLsaCompareByKey, _1, key));
|
||||
if (it != m_adjLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Adj Lsa");
|
||||
(*it).writeLog();
|
||||
@@ -782,7 +782,7 @@ Lsdb::doesAdjLsaExist(const ndn::Name& key)
|
||||
{
|
||||
std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
|
||||
m_adjLsdb.end(),
|
||||
bind(adjLsaCompareByKey, _1, key));
|
||||
std::bind(adjLsaCompareByKey, _1, key));
|
||||
if (it == m_adjLsdb.end()) {
|
||||
return false;
|
||||
}
|
||||
@@ -979,8 +979,8 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
|
||||
m_nlsr.getValidator(),
|
||||
ndn::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
|
||||
ndn::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
|
||||
std::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
|
||||
std::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
|
||||
timeoutCount, deadline, lsaName, seqNo));
|
||||
}
|
||||
|
||||
@@ -1101,7 +1101,7 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
Lsdb::onContentValidated(const std::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
const ndn::Name& dataName = data->getName();
|
||||
_LOG_DEBUG("Data validation successful for LSA: " << dataName);
|
||||
|
||||
+2
-2
@@ -303,7 +303,7 @@ private:
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
onContentValidated(const std::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
void
|
||||
processContentNameLsa(const ndn::Name& lsaKey,
|
||||
@@ -387,4 +387,4 @@ private:
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_LSDB_HPP
|
||||
#endif // NLSR_LSDB_HPP
|
||||
@@ -53,8 +53,8 @@ NamePrefixList::insert(const ndn::Name& name)
|
||||
{
|
||||
std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
|
||||
m_nameList.end(),
|
||||
ndn::bind(&nameCompare, _1 ,
|
||||
ndn::cref(name)));
|
||||
std::bind(&nameCompare, _1 ,
|
||||
std::cref(name)));
|
||||
if (it != m_nameList.end()) {
|
||||
return false;
|
||||
}
|
||||
@@ -67,8 +67,8 @@ NamePrefixList::remove(const ndn::Name& name)
|
||||
{
|
||||
std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
|
||||
m_nameList.end(),
|
||||
ndn::bind(&nameCompare, _1 ,
|
||||
ndn::cref(name)));
|
||||
std::bind(&nameCompare, _1 ,
|
||||
std::cref(name)));
|
||||
if (it != m_nameList.end()) {
|
||||
m_nameList.erase(it);
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ INIT_LOGGER("NlsrRunner");
|
||||
NlsrRunner::NlsrRunner(std::string& configFileName, bool isDaemonProcess)
|
||||
: m_scheduler(m_ioService)
|
||||
, m_face(m_ioService)
|
||||
, m_nlsr(m_ioService, m_scheduler, m_face)
|
||||
, m_nlsr(m_ioService, m_scheduler, m_face, m_keyChain)
|
||||
{
|
||||
m_nlsr.setConfFileName(configFileName);
|
||||
m_nlsr.setIsDaemonProcess(isDaemonProcess);
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ private:
|
||||
boost::asio::io_service m_ioService;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::Face m_face;
|
||||
|
||||
ndn::KeyChain m_keyChain;
|
||||
Nlsr m_nlsr;
|
||||
};
|
||||
|
||||
|
||||
+27
-24
@@ -39,9 +39,10 @@ const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
|
||||
using namespace ndn;
|
||||
using namespace std;
|
||||
|
||||
Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face)
|
||||
Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face, ndn::KeyChain& keyChain)
|
||||
: m_nlsrFace(face)
|
||||
, m_scheduler(scheduler)
|
||||
, m_keyChain(keyChain)
|
||||
, m_confParam()
|
||||
, m_adjacencyList()
|
||||
, m_namePrefixList()
|
||||
@@ -75,15 +76,15 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
|
||||
, m_faceMonitor(m_nlsrFace)
|
||||
, m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
|
||||
{
|
||||
m_faceMonitor.onNotification.connect(bind(&Nlsr::onFaceEventNotification, this, _1));
|
||||
m_faceMonitor.onNotification.connect(std::bind(&Nlsr::onFaceEventNotification, this, _1));
|
||||
m_faceMonitor.start();
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registrationFailed(const ndn::Name& name)
|
||||
{
|
||||
std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << endl;
|
||||
throw Error("Error: Prefix registration failed");
|
||||
std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << std::endl;
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Prefix registration failed"));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -156,7 +157,7 @@ Nlsr::daemonize()
|
||||
process_id = fork();
|
||||
if (process_id < 0){
|
||||
std::cerr << "Daemonization failed!" << std::endl;
|
||||
throw Error("Error: Daemonization process- fork failed!");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- fork failed!"));
|
||||
}
|
||||
if (process_id > 0) {
|
||||
_LOG_DEBUG("Process daemonized. Process id: " << process_id);
|
||||
@@ -166,11 +167,11 @@ Nlsr::daemonize()
|
||||
umask(0);
|
||||
sid = setsid();
|
||||
if(sid < 0) {
|
||||
throw Error("Error: Daemonization process- setting id failed!");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- setting id failed!"));
|
||||
}
|
||||
|
||||
if (chdir("/") < 0) {
|
||||
throw Error("Error: Daemonization process-chdir failed!");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Daemonization process-chdir failed!"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,22 +189,16 @@ Nlsr::initialize()
|
||||
|
||||
m_syncLogicHandler.createSyncSocket(m_confParam.getChronosyncPrefix());
|
||||
|
||||
/* Logging start */
|
||||
// Logging start
|
||||
m_confParam.writeLog();
|
||||
m_adjacencyList.writeLog();
|
||||
m_namePrefixList.writeLog();
|
||||
/* Logging end */
|
||||
// Logging end
|
||||
initializeKey();
|
||||
setStrategies();
|
||||
_LOG_DEBUG("Default NLSR identity: " << m_signingInfo.getSignerName());
|
||||
setInfoInterestFilter();
|
||||
setLsaInterestFilter();
|
||||
try {
|
||||
m_dispatcher.addTopPrefix(LOCALHOST_PREFIX, true, m_signingInfo);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
_LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
|
||||
}
|
||||
|
||||
// Set event intervals
|
||||
setFirstHelloInterval(m_confParam.getFirstHelloInterval());
|
||||
@@ -242,15 +237,15 @@ Nlsr::initializeKey()
|
||||
try {
|
||||
m_keyChain.deleteIdentity(defaultIdentity);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
catch (const std::exception& e) {
|
||||
}
|
||||
m_signingInfo = ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID, defaultIdentity);
|
||||
|
||||
ndn::Name keyName = m_keyChain.generateRsaKeyPairAsDefault(defaultIdentity, true);
|
||||
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> certificate =
|
||||
ndn::make_shared<ndn::IdentityCertificate>();
|
||||
ndn::shared_ptr<ndn::PublicKey> pubKey = m_keyChain.getPublicKey(keyName);
|
||||
std::shared_ptr<ndn::IdentityCertificate> certificate =
|
||||
std::make_shared<ndn::IdentityCertificate>();
|
||||
std::shared_ptr<ndn::PublicKey> pubKey = m_keyChain.getPublicKey(keyName);
|
||||
Name certificateName = keyName.getPrefix(-1);
|
||||
certificateName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
|
||||
certificate->setName(certificateName);
|
||||
@@ -286,8 +281,16 @@ Nlsr::registerKeyPrefix()
|
||||
void
|
||||
Nlsr::registerLocalhostPrefix()
|
||||
{
|
||||
_LOG_TRACE("Registering prefix: " << LOCALHOST_PREFIX);
|
||||
|
||||
_LOG_TRACE("Registering prefix with dispatcher and Face: " << LOCALHOST_PREFIX);
|
||||
// All dispatcher-related sub-prefixes *must* be registered before
|
||||
// the top-level prefixes are added.
|
||||
try {
|
||||
m_dispatcher.addTopPrefix(LOCALHOST_PREFIX, false, m_signingInfo);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
_LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
|
||||
registrationFailed(LOCALHOST_PREFIX);
|
||||
}
|
||||
m_nlsrFace.registerPrefix(LOCALHOST_PREFIX,
|
||||
std::bind(&Nlsr::onLocalhostRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1));
|
||||
@@ -307,12 +310,12 @@ Nlsr::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
else if (certName[-1].toUri() != "ID-CERT")
|
||||
return; //Wrong key interest.
|
||||
|
||||
ndn::shared_ptr<const ndn::IdentityCertificate> cert = getCertificate(certName);
|
||||
std::shared_ptr<const ndn::IdentityCertificate> cert = getCertificate(certName);
|
||||
|
||||
if (!static_cast<bool>(cert))
|
||||
return; // cert is not found
|
||||
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
data->setName(interestName);
|
||||
data->setContent(cert->wireEncode());
|
||||
m_keyChain.signWithSha256(*data);
|
||||
@@ -334,7 +337,7 @@ void
|
||||
Nlsr::onDestroyFaceFailure(const ndn::nfd::ControlResponse& response)
|
||||
{
|
||||
std::cerr << response.getText() << " (code: " << response.getCode() << ")";
|
||||
throw Error("Error: Face destruction failed");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Face destruction failed"));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+10
-9
@@ -19,11 +19,12 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_HPP
|
||||
#define NLSR_HPP
|
||||
#ifndef NLSR_NLSR_HPP
|
||||
#define NLSR_NLSR_HPP
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <stdexcept>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
@@ -69,7 +70,7 @@ class Nlsr
|
||||
};
|
||||
|
||||
public:
|
||||
Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face);
|
||||
Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face, ndn::KeyChain& keyChain);
|
||||
|
||||
void
|
||||
registrationFailed(const ndn::Name& name);
|
||||
@@ -253,12 +254,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
loadCertToPublish(ndn::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
loadCertToPublish(std::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
m_certStore.insert(certificate);
|
||||
}
|
||||
|
||||
ndn::shared_ptr<const ndn::IdentityCertificate>
|
||||
std::shared_ptr<const ndn::IdentityCertificate>
|
||||
getCertificate(const ndn::Name& certificateNameWithoutVersion)
|
||||
{
|
||||
shared_ptr<const ndn::IdentityCertificate> cert =
|
||||
@@ -317,7 +318,7 @@ public:
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
addCertificateToCache(ndn::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
addCertificateToCache(std::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
if (certificate != nullptr) {
|
||||
m_certificateCache->insertCertificate(certificate);
|
||||
@@ -364,6 +365,7 @@ public:
|
||||
private:
|
||||
ndn::Face& m_nlsrFace;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
ConfParameter m_confParam;
|
||||
AdjacencyList m_adjacencyList;
|
||||
NamePrefixList m_namePrefixList;
|
||||
@@ -385,10 +387,9 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
std::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
security::CertificateStore m_certStore;
|
||||
Validator m_validator;
|
||||
ndn::KeyChain m_keyChain;
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
ndn::Name m_defaultCertName;
|
||||
update::PrefixUpdateProcessor m_prefixUpdateProcessor;
|
||||
@@ -401,4 +402,4 @@ private:
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_HPP
|
||||
#endif // NLSR_NLSR_HPP
|
||||
@@ -32,10 +32,10 @@
|
||||
namespace nlsr {
|
||||
|
||||
/*! \brief provides a publisher of Status Dataset or other segmented octet stream
|
||||
\sa http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
\sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
*/
|
||||
template <class FaceBase>
|
||||
class SegmentPublisher : ndn::noncopyable
|
||||
class SegmentPublisher : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
SegmentPublisher(FaceBase& face,
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
ndn::Name segmentName(segmentPrefix);
|
||||
segmentName.appendSegment(segmentNo);
|
||||
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(segmentName);
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(segmentName);
|
||||
data->setContent(segmentBegin, segmentEnd - segmentBegin);
|
||||
data->setFreshnessPeriod(m_freshnessPeriod);
|
||||
|
||||
@@ -113,7 +113,7 @@ protected:
|
||||
|
||||
private:
|
||||
void
|
||||
publishSegment(ndn::shared_ptr<ndn::Data>& data, const ndn::security::SigningInfo& signingInfo)
|
||||
publishSegment(std::shared_ptr<ndn::Data>& data, const ndn::security::SigningInfo& signingInfo)
|
||||
{
|
||||
m_keyChain.sign(*data, signingInfo);
|
||||
m_face.put(*data);
|
||||
|
||||
+15
-14
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
#include <ndn-cxx/encoding/nfd-constants.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
#include "common.hpp"
|
||||
@@ -52,7 +53,7 @@ Fib::scheduleEntryExpiration(const ndn::Name& name, int32_t feSeqNum,
|
||||
_LOG_DEBUG("Fib::scheduleEntryExpiration Called");
|
||||
_LOG_INFO("Name: " << name << " Seq Num: " << feSeqNum);
|
||||
|
||||
return m_scheduler.scheduleEvent(expTime, ndn::bind(&Fib::remove, this, name));
|
||||
return m_scheduler.scheduleEvent(expTime, std::bind(&Fib::remove, this, name));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -116,7 +117,7 @@ Fib::removeOldNextHopsFromFibEntryAndNfd(FibEntry& entry, const NexthopList& ins
|
||||
// See if the nexthop is installed in NFD's FIB
|
||||
NexthopList::const_iterator foundIt = std::find_if(installedHops.cbegin(),
|
||||
installedHops.cend(),
|
||||
bind(&compareFaceUri, _1, faceUri));
|
||||
std::bind(&compareFaceUri, _1, faceUri));
|
||||
|
||||
// The next hop is not installed
|
||||
if (foundIt == installedHops.cend()) {
|
||||
@@ -286,7 +287,7 @@ Fib::destroyFace(const std::string& faceUri,
|
||||
const CommandFailCallback& onFailure)
|
||||
{
|
||||
createFace(faceUri,
|
||||
ndn::bind(&Fib::destroyFaceInNfd, this, _1, onSuccess, onFailure),
|
||||
std::bind(&Fib::destroyFaceInNfd, this, _1, onSuccess, onFailure),
|
||||
onFailure);
|
||||
}
|
||||
|
||||
@@ -317,7 +318,7 @@ Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
|
||||
.setFlags(flags)
|
||||
.setCost(faceCost)
|
||||
.setExpirationPeriod(timeout)
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
|
||||
_LOG_DEBUG("Registering prefix: " << namePrefix << " Face Uri: " << faceUri
|
||||
<< " Face Id: " << faceId);
|
||||
@@ -350,9 +351,9 @@ Fib::registerPrefix(const ndn::Name& namePrefix,
|
||||
.setFlags(flags)
|
||||
.setCost(faceCost)
|
||||
.setExpirationPeriod(timeout)
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
createFace(faceUri,
|
||||
ndn::bind(static_cast<RegisterPrefixCallback>(&Fib::registerPrefixInNfd),
|
||||
std::bind(static_cast<RegisterPrefixCallback>(&Fib::registerPrefixInNfd),
|
||||
this, _1, parameters, times, onSuccess, onFailure),
|
||||
onFailure);
|
||||
}
|
||||
@@ -363,10 +364,10 @@ Fib::registerPrefixInNfd(ndn::nfd::ControlParameters& parameters,
|
||||
uint8_t times)
|
||||
{
|
||||
m_controller.start<ndn::nfd::RibRegisterCommand>(parameters,
|
||||
ndn::bind(&Fib::onRegistration, this, _1,
|
||||
std::bind(&Fib::onRegistration, this, _1,
|
||||
"Successful in name registration",
|
||||
faceUri),
|
||||
ndn::bind(&Fib::onRegistrationFailure,
|
||||
std::bind(&Fib::onRegistrationFailure,
|
||||
this, _1,
|
||||
"Failed in name registration",
|
||||
parameters,
|
||||
@@ -387,7 +388,7 @@ Fib::registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
|
||||
.setCost(parameters.getCost())
|
||||
.setFlags(parameters.getFlags())
|
||||
.setExpirationPeriod(parameters.getExpirationPeriod())
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
|
||||
onSuccess,
|
||||
onFailure);
|
||||
@@ -403,11 +404,11 @@ Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
|
||||
controlParameters
|
||||
.setName(namePrefix)
|
||||
.setFaceId(faceId)
|
||||
.setOrigin(128);
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
|
||||
ndn::bind(&Fib::onUnregistration, this, _1,
|
||||
std::bind(&Fib::onUnregistration, this, _1,
|
||||
"Successful in unregistering name"),
|
||||
ndn::bind(&Fib::onUnregistrationFailure,
|
||||
std::bind(&Fib::onUnregistrationFailure,
|
||||
this, _1,
|
||||
"Failed in unregistering name"));
|
||||
}
|
||||
@@ -422,9 +423,9 @@ Fib::setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t co
|
||||
.setStrategy(strategy);
|
||||
|
||||
m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
|
||||
bind(&Fib::onSetStrategySuccess, this, _1,
|
||||
std::bind(&Fib::onSetStrategySuccess, this, _1,
|
||||
"Successfully set strategy choice"),
|
||||
bind(&Fib::onSetStrategyFailure, this, _1,
|
||||
std::bind(&Fib::onSetStrategyFailure, this, _1,
|
||||
parameters,
|
||||
count,
|
||||
"Failed to set strategy choice"));
|
||||
|
||||
+3
-3
@@ -62,7 +62,7 @@ Map::addEntry(MapEntry& mpe)
|
||||
//cout << mpe;
|
||||
std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&mapEntryCompareByRouter,
|
||||
std::bind(&mapEntryCompareByRouter,
|
||||
_1, mpe.getRouter()));
|
||||
if (it == m_table.end()) {
|
||||
m_table.push_back(mpe);
|
||||
@@ -76,7 +76,7 @@ Map::getRouterNameByMappingNo(int32_t mn)
|
||||
{
|
||||
std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&mapEntryCompareByMappingNo,
|
||||
std::bind(&mapEntryCompareByMappingNo,
|
||||
_1, mn));
|
||||
if (it != m_table.end()) {
|
||||
return (*it).getRouter();
|
||||
@@ -89,7 +89,7 @@ Map::getMappingNoByRouterName(const ndn::Name& rName)
|
||||
{
|
||||
std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&mapEntryCompareByRouter,
|
||||
std::bind(&mapEntryCompareByRouter,
|
||||
_1, rName));
|
||||
if (it != m_table.end()) {
|
||||
return (*it).getMappingNumber();
|
||||
|
||||
@@ -43,7 +43,7 @@ NamePrefixTableEntry::generateNhlfromRteList()
|
||||
}
|
||||
|
||||
uint64_t
|
||||
NamePrefixTableEntry::removeRoutingTableEntry(shared_ptr<RoutingTablePoolEntry>
|
||||
NamePrefixTableEntry::removeRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry>
|
||||
rtpePtr)
|
||||
{
|
||||
auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
|
||||
@@ -60,7 +60,7 @@ NamePrefixTableEntry::removeRoutingTableEntry(shared_ptr<RoutingTablePoolEntry>
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::addRoutingTableEntry(shared_ptr<RoutingTablePoolEntry>
|
||||
NamePrefixTableEntry::addRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry>
|
||||
rtpePtr)
|
||||
{
|
||||
auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
|
||||
@@ -105,7 +105,7 @@ operator<<(std::ostream& os, const NamePrefixTableEntry& entry)
|
||||
{
|
||||
os << "Name: " << entry.getNamePrefix() << "\n";
|
||||
|
||||
for (const shared_ptr<RoutingTablePoolEntry> rtpePtr : entry.getRteList()) {
|
||||
for (const std::shared_ptr<RoutingTablePoolEntry> rtpePtr : entry.getRteList()) {
|
||||
os << "Destination: " << rtpePtr->getDestination() << "\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
// Ensure that the entry exists
|
||||
NptEntryList::iterator nameItr = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
std::bind(&npteCompare, _1, name));
|
||||
if (nameItr != m_table.end()) {
|
||||
_LOG_TRACE("Removing origin: " << rtpePtr->getDestination()
|
||||
<< " from prefix: " << *nameItr);
|
||||
|
||||
@@ -81,7 +81,7 @@ NexthopList::addNextHop(const NextHop& nh)
|
||||
{
|
||||
std::set<NextHop, NextHopComparator>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
m_nexthopList.end(),
|
||||
ndn::bind(&nexthopAddCompare, _1, nh));
|
||||
std::bind(&nexthopAddCompare, _1, nh));
|
||||
if (it == m_nexthopList.end()) {
|
||||
m_nexthopList.insert(nh);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ NexthopList::removeNextHop(const NextHop& nh)
|
||||
{
|
||||
std::set<NextHop, NextHopComparator>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
m_nexthopList.end(),
|
||||
ndn::bind(&nexthopRemoveCompare, _1, nh));
|
||||
std::bind(&nexthopRemoveCompare, _1, nh));
|
||||
if (it != m_nexthopList.end()) {
|
||||
m_nexthopList.erase(it);
|
||||
}
|
||||
|
||||
@@ -81,4 +81,4 @@ operator<<(std::ostream& os, const RoutingTableEntry& rte);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_ROUTING_TABLE_ENTRY_HPP
|
||||
#endif // NLSR_ROUTING_TABLE_ENTRY_HPP
|
||||
@@ -130,7 +130,7 @@ RoutingTable::calculateLsRoutingTable(Nlsr& nlsr)
|
||||
|
||||
LinkStateRoutingTableCalculator calculator(nRouters);
|
||||
|
||||
calculator.calculatePath(map, ndn::ref(*this), nlsr);
|
||||
calculator.calculatePath(map, std::ref(*this), nlsr);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -145,7 +145,7 @@ RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
|
||||
HyperbolicRoutingCalculator calculator(nRouters, false,
|
||||
nlsr.getConfParameter().getRouterPrefix());
|
||||
|
||||
calculator.calculatePaths(map, ndn::ref(*this),
|
||||
calculator.calculatePaths(map, std::ref(*this),
|
||||
nlsr.getLsdb(), nlsr.getAdjacencyList());
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ RoutingTable::calculateHypDryRoutingTable(Nlsr& nlsr)
|
||||
HyperbolicRoutingCalculator calculator(nRouters, true,
|
||||
nlsr.getConfParameter().getRouterPrefix());
|
||||
|
||||
calculator.calculatePaths(map, ndn::ref(*this),
|
||||
calculator.calculatePaths(map, std::ref(*this),
|
||||
nlsr.getLsdb(), nlsr.getAdjacencyList());
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
|
||||
_LOG_DEBUG("Scheduling routing table calculation in " << m_routingCalcInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_routingCalcInterval,
|
||||
ndn::bind(&RoutingTable::calculate, this, ndn::ref(pnlsr)));
|
||||
std::bind(&RoutingTable::calculate, this, std::ref(pnlsr)));
|
||||
|
||||
pnlsr.setIsRouteCalculationScheduled(true);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ RoutingTable::findRoutingTableEntry(const ndn::Name& destRouter)
|
||||
{
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
|
||||
m_rTable.end(),
|
||||
ndn::bind(&routingTableEntryCompare,
|
||||
std::bind(&routingTableEntryCompare,
|
||||
_1, destRouter));
|
||||
if (it != m_rTable.end()) {
|
||||
return &(*it);
|
||||
@@ -242,7 +242,7 @@ RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
|
||||
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_dryTable.begin(),
|
||||
m_dryTable.end(),
|
||||
ndn::bind(&routingTableEntryCompare,
|
||||
std::bind(&routingTableEntryCompare,
|
||||
_1, destRouter));
|
||||
if (it == m_dryTable.end()) {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "../test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/interest.hpp>
|
||||
#include <ndn-cxx/security/identity-certificate.hpp>
|
||||
#include <ndn-cxx/security/v1/identity-certificate.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace security {
|
||||
@@ -35,7 +35,7 @@ class CertificateStore
|
||||
{
|
||||
public:
|
||||
void
|
||||
insert(shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
insert(std::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
if (certificate != nullptr) {
|
||||
// Key is cert name without version
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<const ndn::IdentityCertificate>
|
||||
std::shared_ptr<const ndn::IdentityCertificate>
|
||||
find(const ndn::Name& certificateNameWithoutVersion) const
|
||||
{
|
||||
CertMap::const_iterator it = m_certificates.find(certificateNameWithoutVersion);
|
||||
@@ -63,7 +63,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::map<ndn::Name, shared_ptr<ndn::IdentityCertificate>> CertMap;
|
||||
typedef std::map<ndn::Name, std::shared_ptr<ndn::IdentityCertificate>> CertMap;
|
||||
CertMap m_certificates;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <ndn-cxx/encoding/block-helpers.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<LsaInfo>));
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<LsaInfo>));
|
||||
@@ -109,7 +109,7 @@ LsaInfo::wireDecode(const ndn::Block& wire)
|
||||
std::stringstream error;
|
||||
error << "Expected LsaInfo Block, but Block is of a different type: #"
|
||||
<< m_wire.type();
|
||||
throw Error(error.str());
|
||||
BOOST_THROW_EXCEPTION(Error(error.str()));
|
||||
}
|
||||
|
||||
m_wire.parse();
|
||||
@@ -124,13 +124,13 @@ LsaInfo::wireDecode(const ndn::Block& wire)
|
||||
m_originRouter.wireDecode(*it);
|
||||
}
|
||||
else {
|
||||
throw Error("OriginRouter: Missing required Name field");
|
||||
BOOST_THROW_EXCEPTION(Error("OriginRouter: Missing required Name field"));
|
||||
}
|
||||
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required OriginRouter field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required OriginRouter field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::SequenceNumber) {
|
||||
@@ -138,7 +138,7 @@ LsaInfo::wireDecode(const ndn::Block& wire)
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required SequenceNumber field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required SequenceNumber field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::ExpirationPeriod) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <ndn-cxx/encoding/encoding-buffer.hpp>
|
||||
#include <ndn-cxx/encoding/tlv.hpp>
|
||||
#include <ndn-cxx/name.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include "lsa.hpp"
|
||||
|
||||
@@ -41,7 +42,7 @@ namespace tlv {
|
||||
SequenceNumber
|
||||
ExpirationPeriod?
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsaInfo
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ PrefixUpdateProcessor::PrefixUpdateProcessor(ndn::Face& face,
|
||||
SyncLogicHandler& sync,
|
||||
const ndn::Name broadcastPrefix,
|
||||
ndn::KeyChain& keyChain,
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> certificateCache,
|
||||
std::shared_ptr<ndn::CertificateCacheTtl> certificateCache,
|
||||
security::CertificateStore& certStore)
|
||||
: m_face(face)
|
||||
, m_namePrefixList(namePrefixList)
|
||||
@@ -61,7 +61,7 @@ PrefixUpdateProcessor::startListening()
|
||||
{
|
||||
_LOG_DEBUG("Setting Interest filter for: " << COMMAND_PREFIX);
|
||||
|
||||
m_face.setInterestFilter(COMMAND_PREFIX, bind(&PrefixUpdateProcessor::onInterest, this, _2));
|
||||
m_face.setInterestFilter(COMMAND_PREFIX, std::bind(&PrefixUpdateProcessor::onInterest, this, _2));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -75,8 +75,8 @@ PrefixUpdateProcessor::onInterest(const ndn::Interest& request)
|
||||
}
|
||||
|
||||
m_validator.validate(request,
|
||||
bind(&PrefixUpdateProcessor::onCommandValidated, this, _1),
|
||||
bind(&PrefixUpdateProcessor::onCommandValidationFailed, this, _1, _2));
|
||||
std::bind(&PrefixUpdateProcessor::onCommandValidated, this, _1),
|
||||
std::bind(&PrefixUpdateProcessor::onCommandValidationFailed, this, _1, _2));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -197,7 +197,7 @@ PrefixUpdateProcessor::sendNack(const ndn::Interest& request)
|
||||
ndn::MetaInfo metaInfo;
|
||||
metaInfo.setType(ndn::tlv::ContentType_Nack);
|
||||
|
||||
shared_ptr<ndn::Data> responseData = std::make_shared<ndn::Data>(request.getName());
|
||||
std::shared_ptr<ndn::Data> responseData = std::make_shared<ndn::Data>(request.getName());
|
||||
responseData->setMetaInfo(metaInfo);
|
||||
|
||||
m_keyChain.sign(*responseData);
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
SyncLogicHandler& sync,
|
||||
const ndn::Name broadcastPrefix,
|
||||
ndn::KeyChain& keyChain,
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> certificateCache,
|
||||
std::shared_ptr<ndn::CertificateCacheTtl> certificateCache,
|
||||
security::CertificateStore& certStore);
|
||||
|
||||
void
|
||||
|
||||
@@ -41,8 +41,8 @@ FaceController::createFace(const std::string& request,
|
||||
FaceUri uri(request);
|
||||
|
||||
_LOG_TRACE("Converting " << uri << " to canonical form");
|
||||
uri.canonize(bind(&FaceController::onCanonizeSuccess, this, _1, onSuccess, onFailure, uri),
|
||||
bind(&FaceController::onCanonizeFailure, this, _1, onSuccess, onFailure, uri),
|
||||
uri.canonize(std::bind(&FaceController::onCanonizeSuccess, this, _1, onSuccess, onFailure, uri),
|
||||
std::bind(&FaceController::onCanonizeFailure, this, _1, onSuccess, onFailure, uri),
|
||||
m_ioService, TIME_ALLOWED_FOR_CANONIZATION);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,18 @@ FaceController::createFaceInNfd(const FaceUri& uri,
|
||||
faceParameters.setUri(uri.toString());
|
||||
|
||||
_LOG_DEBUG("Creating Face in NFD with face-uri: " << uri);
|
||||
m_controller.start<ndn::nfd::FaceCreateCommand>(faceParameters, onSuccess, onFailure);
|
||||
m_controller.start<ndn::nfd::FaceCreateCommand>(faceParameters, onSuccess,
|
||||
[onSuccess, onFailure, uri] (const ndn::nfd::ControlResponse& response) {
|
||||
ndn::nfd::ControlParameters faceParams(response.getBody());
|
||||
if (response.getCode() == 409 && faceParams.getUri() == uri.toString()) {
|
||||
_LOG_DEBUG("Got 409 - treating as success");
|
||||
onSuccess(faceParams);
|
||||
}
|
||||
else {
|
||||
onFailure(response);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+16
-12
@@ -45,7 +45,7 @@ public:
|
||||
explicit
|
||||
Validator(ndn::Face& face,
|
||||
const ndn::Name broadcastPrefix,
|
||||
const ndn::shared_ptr<ndn::CertificateCache>& cache,
|
||||
const std::shared_ptr<ndn::CertificateCache>& cache,
|
||||
security::CertificateStore& certStore,
|
||||
const int stepLimit = 10)
|
||||
: ndn::ValidatorConfig(face, cache, ndn::ValidatorConfig::DEFAULT_GRACE_INTERVAL, stepLimit)
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef std::vector<ndn::shared_ptr<ndn::ValidationRequest>> NextSteps;
|
||||
typedef std::vector<std::shared_ptr<ndn::ValidationRequest>> NextSteps;
|
||||
|
||||
virtual void
|
||||
afterCheckPolicy(const NextSteps& nextSteps,
|
||||
@@ -84,16 +84,16 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
for (const shared_ptr<ndn::ValidationRequest>& request : nextSteps) {
|
||||
for (const std::shared_ptr<ndn::ValidationRequest>& request : nextSteps) {
|
||||
|
||||
ndn::Interest& interest = request->m_interest;
|
||||
|
||||
// Look for certificate in permanent storage
|
||||
shared_ptr<const ndn::IdentityCertificate> cert = m_certStore.find(interest.getName());
|
||||
std::shared_ptr<const ndn::IdentityCertificate> cert = m_certStore.find(interest.getName());
|
||||
|
||||
if (cert != nullptr) {
|
||||
// If the certificate is found, no reason to express interest
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(interest.getName());
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(interest.getName());
|
||||
data->setContent(cert->wireEncode());
|
||||
|
||||
Validator::onData(interest, *data, request);
|
||||
@@ -106,19 +106,23 @@ protected:
|
||||
|
||||
// Attempt to fetch the certificate
|
||||
m_face->expressInterest(interest,
|
||||
bind(&Validator::onData, this, _1, _2, request),
|
||||
bind(&Validator::onTimeout,
|
||||
this, _1, request->m_nRetries,
|
||||
onFailure,
|
||||
request));
|
||||
std::bind(&Validator::onData, this, _1, _2, request),
|
||||
std::bind(&Validator::onTimeout, // Nack
|
||||
this, _1, request->m_nRetries,
|
||||
onFailure,
|
||||
request),
|
||||
std::bind(&Validator::onTimeout,
|
||||
this, _1, request->m_nRetries,
|
||||
onFailure,
|
||||
request));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual ndn::shared_ptr<const ndn::Data>
|
||||
virtual std::shared_ptr<const ndn::Data>
|
||||
preCertificateValidation(const ndn::Data& data)
|
||||
{
|
||||
ndn::shared_ptr<ndn::Data> internalData = ndn::make_shared<ndn::Data>();
|
||||
std::shared_ptr<ndn::Data> internalData = std::make_shared<ndn::Data>();
|
||||
internalData->wireDecode(data.getContent().blockFromValue());
|
||||
return internalData;
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ struct ValidatorFixture
|
||||
, m_wasValidated(false)
|
||||
{
|
||||
m_face.setInterestFilter(m_keyPrefix,
|
||||
ndn::bind(&ValidatorFixture::onKeyInterest, this, _1, _2),
|
||||
ndn::bind(&ValidatorFixture::onKeyPrefixRegSuccess, this, _1),
|
||||
ndn::bind(&ValidatorFixture::registrationFailed, this, _1, _2));
|
||||
std::bind(&ValidatorFixture::onKeyInterest, this, _1, _2),
|
||||
std::bind(&ValidatorFixture::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&ValidatorFixture::registrationFailed, this, _1, _2));
|
||||
|
||||
m_keyChain.createIdentity(m_identity);
|
||||
ndn::Name certName = m_keyChain.getDefaultCertificateNameForIdentity(m_identity);
|
||||
@@ -137,7 +137,7 @@ struct ValidatorFixture
|
||||
if (certName != m_cert->getName().getPrefix(-1))
|
||||
return; //No such a cert
|
||||
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(interestName);
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(interestName);
|
||||
data->setContent(m_cert->wireEncode());
|
||||
m_keyChain.signWithSha256(*data);
|
||||
|
||||
@@ -158,13 +158,13 @@ struct ValidatorFixture
|
||||
}
|
||||
|
||||
void
|
||||
onValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
onValidated(const std::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
m_wasValidated = true;
|
||||
}
|
||||
|
||||
void
|
||||
onValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
onValidationFailed(const std::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& failureInfo)
|
||||
{
|
||||
std::cerr << "Failure Info: " << failureInfo << std::endl;
|
||||
@@ -172,11 +172,11 @@ struct ValidatorFixture
|
||||
}
|
||||
|
||||
void
|
||||
validate(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
validate(const std::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
m_validator.validate(*data,
|
||||
bind(&ValidatorFixture::onValidated, this, _1),
|
||||
bind(&ValidatorFixture::onValidationFailed, this, _1, _2));
|
||||
std::bind(&ValidatorFixture::onValidated, this, _1),
|
||||
std::bind(&ValidatorFixture::onValidationFailed, this, _1, _2));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -190,13 +190,13 @@ protected:
|
||||
ndn::Face m_face2;
|
||||
ndn::Scheduler m_scheduler;
|
||||
const ndn::Name m_keyPrefix;
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
std::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
security::CertificateStore m_certStore;
|
||||
nlsr::Validator m_validator;
|
||||
|
||||
ndn::KeyChain m_keyChain;
|
||||
ndn::Name m_identity;
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> m_cert;
|
||||
std::shared_ptr<ndn::IdentityCertificate> m_cert;
|
||||
|
||||
bool m_wasValidated;
|
||||
};
|
||||
@@ -205,13 +205,13 @@ BOOST_FIXTURE_TEST_CASE(InfoCertFetch, ValidatorFixture)
|
||||
{
|
||||
ndn::Name dataName = m_identity;
|
||||
dataName.append("INFO").append("neighbor").append("version");
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(dataName);
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(dataName);
|
||||
m_keyChain.signByIdentity(*data, m_identity);
|
||||
|
||||
m_scheduler.scheduleEvent(ndn::time::milliseconds(200),
|
||||
ndn::bind(&ValidatorFixture::validate, this, data));
|
||||
std::bind(&ValidatorFixture::validate, this, data));
|
||||
m_scheduler.scheduleEvent(ndn::time::milliseconds(1000),
|
||||
ndn::bind(&ValidatorFixture::terminate, this));
|
||||
std::bind(&ValidatorFixture::terminate, this));
|
||||
BOOST_REQUIRE_NO_THROW(m_face.processEvents());
|
||||
|
||||
BOOST_CHECK(m_wasValidated);
|
||||
@@ -219,7 +219,7 @@ BOOST_FIXTURE_TEST_CASE(InfoCertFetch, ValidatorFixture)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(CertificateStorage, ValidatorFixture)
|
||||
{
|
||||
std::vector<ndn::CertificateSubjectDescription> subjectDescription;
|
||||
std::vector<ndn::security::v1::CertificateSubjectDescription> subjectDescription;
|
||||
|
||||
// Create an operator identity
|
||||
ndn::Name opIdentity("/TestValidator/operator/NLSR");
|
||||
@@ -227,7 +227,7 @@ BOOST_FIXTURE_TEST_CASE(CertificateStorage, ValidatorFixture)
|
||||
|
||||
// Create an operator cert signed by the trust anchor
|
||||
ndn::Name keyName = m_keyChain.generateRsaKeyPairAsDefault(opIdentity, true);
|
||||
shared_ptr<ndn::IdentityCertificate> opCert =
|
||||
std::shared_ptr<ndn::IdentityCertificate> opCert =
|
||||
m_keyChain.prepareUnsignedIdentityCertificate(keyName,
|
||||
m_identity,
|
||||
ndn::time::system_clock::now(),
|
||||
@@ -240,14 +240,14 @@ BOOST_FIXTURE_TEST_CASE(CertificateStorage, ValidatorFixture)
|
||||
// Sign data with operator cert
|
||||
ndn::Name dataName = opIdentity;
|
||||
dataName.append("INFO").append("neighbor").append("version");
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(dataName);
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(dataName);
|
||||
m_keyChain.signByIdentity(*data, opIdentity);
|
||||
|
||||
// Check without cert in CertificateStore
|
||||
m_scheduler.scheduleEvent(ndn::time::milliseconds(200),
|
||||
ndn::bind(&ValidatorFixture::validate, this, data));
|
||||
std::bind(&ValidatorFixture::validate, this, data));
|
||||
m_scheduler.scheduleEvent(ndn::time::milliseconds(1000),
|
||||
ndn::bind(&ValidatorFixture::terminate, this));
|
||||
std::bind(&ValidatorFixture::terminate, this));
|
||||
|
||||
BOOST_REQUIRE_NO_THROW(m_face.processEvents());
|
||||
BOOST_CHECK_EQUAL(m_wasValidated, false);
|
||||
@@ -256,9 +256,9 @@ BOOST_FIXTURE_TEST_CASE(CertificateStorage, ValidatorFixture)
|
||||
m_certStore.insert(opCert);
|
||||
|
||||
m_scheduler.scheduleEvent(ndn::time::milliseconds(200),
|
||||
ndn::bind(&ValidatorFixture::validate, this, data));
|
||||
std::bind(&ValidatorFixture::validate, this, data));
|
||||
m_scheduler.scheduleEvent(ndn::time::milliseconds(1000),
|
||||
ndn::bind(&ValidatorFixture::terminate, this));
|
||||
std::bind(&ValidatorFixture::terminate, this));
|
||||
|
||||
BOOST_REQUIRE_NO_THROW(m_face.processEvents());
|
||||
BOOST_CHECK(m_wasValidated);
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_PUBLISHER_FIXTURE_HPP
|
||||
#define NLSR_PUBLISHER_FIXTURE_HPP
|
||||
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include "../boost-test.hpp"
|
||||
@@ -33,8 +36,8 @@ class PublisherFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
PublisherFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, lsdb(nlsr, g_scheduler, nlsr.getSyncLogicHandler())
|
||||
{
|
||||
}
|
||||
@@ -134,7 +137,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
Lsdb lsdb;
|
||||
ndn::KeyChain keyChain;
|
||||
@@ -142,3 +145,5 @@ public:
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_PUBLISHER_FIXTURE_HPP
|
||||
@@ -31,7 +31,7 @@ namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
void
|
||||
processDatasetInterest(shared_ptr<ndn::util::DummyClientFace> face,
|
||||
processDatasetInterest(std::shared_ptr<ndn::util::DummyClientFace> face,
|
||||
std::function<bool(const ndn::Block&)> isSameType)
|
||||
{
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
@@ -50,7 +50,7 @@ processDatasetInterest(shared_ptr<ndn::util::DummyClientFace> face,
|
||||
}
|
||||
|
||||
void
|
||||
checkErrorResponse(shared_ptr<ndn::util::DummyClientFace> face, uint64_t expectedCode)
|
||||
checkErrorResponse(std::shared_ptr<ndn::util::DummyClientFace> face, uint64_t expectedCode)
|
||||
{
|
||||
BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
ndn::shared_ptr<ndn::util::DummyClientFace> m_face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> m_face;
|
||||
const ndn::time::milliseconds m_expectedFreshnessPeriod;
|
||||
TestSegmentPublisher<N> m_publisher;
|
||||
ndn::EncodingBuffer m_buffer;
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::IdentityCertificate> certificate;
|
||||
std::shared_ptr<ndn::IdentityCertificate> certificate;
|
||||
ndn::Name certificateKey;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/util/time-unit-test-clock.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -45,14 +46,15 @@ public:
|
||||
protected:
|
||||
boost::asio::io_service g_ioService;
|
||||
ndn::Scheduler g_scheduler;
|
||||
ndn::KeyChain g_keyChain;
|
||||
};
|
||||
|
||||
class UnitTestTimeFixture : public BaseFixture
|
||||
{
|
||||
protected:
|
||||
UnitTestTimeFixture()
|
||||
: steadyClock(make_shared<ndn::time::UnitTestSteadyClock>())
|
||||
, systemClock(make_shared<ndn::time::UnitTestSystemClock>())
|
||||
: steadyClock(std::make_shared<ndn::time::UnitTestSteadyClock>())
|
||||
, systemClock(std::make_shared<ndn::time::UnitTestSystemClock>())
|
||||
{
|
||||
ndn::time::setCustomClocks(steadyClock, systemClock);
|
||||
}
|
||||
@@ -78,8 +80,8 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
shared_ptr<ndn::time::UnitTestSteadyClock> steadyClock;
|
||||
shared_ptr<ndn::time::UnitTestSystemClock> systemClock;
|
||||
std::shared_ptr<ndn::time::UnitTestSteadyClock> steadyClock;
|
||||
std::shared_ptr<ndn::time::UnitTestSystemClock> systemClock;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::shared_ptr;
|
||||
using std::shared_ptr;
|
||||
|
||||
const std::string SECTION_GENERAL =
|
||||
"general\n"
|
||||
@@ -132,8 +132,8 @@ class ConfFileProcessorFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
ConfFileProcessorFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, CONFIG_FILE("unit-test-nlsr.conf")
|
||||
, m_logConfigFileName(boost::filesystem::unique_path().native())
|
||||
, m_logFileName(boost::filesystem::unique_path().native())
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
|
||||
private:
|
||||
@@ -479,7 +479,7 @@ BOOST_AUTO_TEST_CASE(LoadCertToPublish)
|
||||
ndn::KeyChain keyChain;
|
||||
keyChain.createIdentity(identity);
|
||||
ndn::Name certName = keyChain.getDefaultCertificateNameForIdentity(identity);
|
||||
shared_ptr<ndn::IdentityCertificate> certificate = keyChain.getCertificate(certName);
|
||||
std::shared_ptr<ndn::IdentityCertificate> certificate = keyChain.getCertificate(certName);
|
||||
|
||||
const boost::filesystem::path CERT_PATH =
|
||||
(boost::filesystem::current_path() / std::string("cert-to-publish.cert"));
|
||||
|
||||
+6
-6
@@ -32,13 +32,13 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::shared_ptr;
|
||||
using std::shared_ptr;
|
||||
|
||||
class FibFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
FibFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, interests(face->sentInterests)
|
||||
{
|
||||
INIT_LOGGERS("/tmp", "DEBUG");
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
|
||||
conf.setMaxFacesPerPrefix(2);
|
||||
|
||||
fib = ndn::make_shared<Fib>(ndn::ref(*face), ndn::ref(g_scheduler), ndn::ref(adjacencies),
|
||||
ndn::ref(conf), keyChain);
|
||||
fib = std::make_shared<Fib>(std::ref(*face), std::ref(g_scheduler), std::ref(adjacencies),
|
||||
std::ref(conf), keyChain);
|
||||
|
||||
fib->m_faceMap.update(router1FaceUri, router1FaceId);
|
||||
fib->m_faceMap.update(router2FaceUri, router2FaceId);
|
||||
@@ -63,9 +63,9 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
ndn::KeyChain keyChain;
|
||||
shared_ptr<Fib> fib;
|
||||
std::shared_ptr<Fib> fib;
|
||||
|
||||
AdjacencyList adjacencies;
|
||||
ConfParameter conf;
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::shared_ptr;
|
||||
using std::shared_ptr;
|
||||
using ndn::time::system_clock;
|
||||
static const system_clock::TimePoint MAX_TIME = system_clock::TimePoint::max();
|
||||
|
||||
@@ -45,8 +45,8 @@ class HyperbolicCalculatorFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
HyperbolicCalculatorFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, routingTable(nlsr.getRoutingTable())
|
||||
, adjacencies(nlsr.getAdjacencyList())
|
||||
, lsdb(nlsr.getLsdb())
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
Map map;
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ class LinkStateCalculatorFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
LinkStateCalculatorFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, routingTable(nlsr.getRoutingTable())
|
||||
, lsdb(nlsr.getLsdb())
|
||||
{
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
Map map;
|
||||
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include "test-common.hpp"
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include <ndn-cxx/interest.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
#include <ndn-cxx/security/signing-info.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/info_parser.hpp>
|
||||
|
||||
using namespace ndn;
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
class LsaRuleFixture : public nlsr::test::BaseFixture
|
||||
{
|
||||
public:
|
||||
LsaRuleFixture()
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, rootId(ndn::Name("ndn"))
|
||||
, siteIdentity(ndn::Name("/ndn/edu/test-site"))
|
||||
, opIdentity(ndn::Name(siteIdentity).append(ndn::Name("%C1.Operator/op1")))
|
||||
, routerId(ndn::Name("/ndn/edu/test-site/%C1.Router/router1"))
|
||||
, nlsr(g_ioService, g_scheduler, *face, g_keyChain)
|
||||
, ROOT_CERT_PATH(boost::filesystem::current_path() / std::string("root.cert"))
|
||||
{
|
||||
try {
|
||||
keyChain.deleteIdentity(rootId);
|
||||
keyChain.deleteIdentity(siteIdentity);
|
||||
keyChain.deleteIdentity(opIdentity);
|
||||
keyChain.deleteIdentity(routerId);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
}
|
||||
|
||||
createCert(rootId, rootCertName, rootCert, rootId);
|
||||
BOOST_REQUIRE(rootCert != nullptr);
|
||||
|
||||
createCert(siteIdentity, siteCertName, siteCert, rootId);
|
||||
BOOST_REQUIRE(siteCert != nullptr);
|
||||
|
||||
createCert(opIdentity, opCertName, opCert, siteIdentity);
|
||||
BOOST_REQUIRE(opCert != nullptr);
|
||||
|
||||
createCert(routerId, routerCertName, routerCert, opIdentity);
|
||||
BOOST_REQUIRE(routerCert != nullptr);
|
||||
|
||||
// Loading the security section's validator part into the validator
|
||||
// See conf file processor for more details
|
||||
std::ifstream inputFile;
|
||||
inputFile.open(std::string("nlsr.conf"));
|
||||
|
||||
BOOST_REQUIRE(inputFile.is_open());
|
||||
|
||||
boost::property_tree::ptree pt;
|
||||
|
||||
boost::property_tree::read_info(inputFile, pt);
|
||||
|
||||
//Loads section and file name
|
||||
for (auto tn = pt.begin(); tn != pt.end(); ++tn) {
|
||||
if (tn->first == "security") {
|
||||
auto it = tn->second.begin();
|
||||
nlsr.loadValidator(it->second, std::string("nlsr.conf"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
inputFile.close();
|
||||
|
||||
// Set the network so the LSA prefix is constructed
|
||||
// Set all so that buildRouterPrefix is set
|
||||
nlsr.getConfParameter().setNetwork("/ndn");
|
||||
nlsr.getConfParameter().setSiteName("/edu/test-site");
|
||||
nlsr.getConfParameter().setRouterName("/%C1.Router/router1");
|
||||
|
||||
// Initialize NLSR to initialize the keyChain
|
||||
nlsr.initialize();
|
||||
}
|
||||
|
||||
void
|
||||
createCert(ndn::Name& identity, ndn::Name& certName, std::shared_ptr<IdentityCertificate>& cert, const ndn::Name& signer)
|
||||
{
|
||||
ndn::Name keyName = keyChain.generateRsaKeyPairAsDefault(identity, true);
|
||||
|
||||
cert = std::make_shared<ndn::IdentityCertificate>();
|
||||
std::shared_ptr<ndn::PublicKey> pubKey = keyChain.getPublicKey(keyName);
|
||||
certName = keyName.getPrefix(-1);
|
||||
certName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
|
||||
cert->setName(certName);
|
||||
cert->setNotBefore(time::system_clock::now() - time::days(1));
|
||||
cert->setNotAfter(time::system_clock::now() + time::days(1));
|
||||
cert->setPublicKeyInfo(*pubKey);
|
||||
cert->addSubjectDescription(CertificateSubjectDescription(ndn::oid::ATTRIBUTE_NAME,
|
||||
keyName.toUri()));
|
||||
cert->encode();
|
||||
|
||||
// root is self signed and root.cert is saved
|
||||
if (signer == identity) {
|
||||
keyChain.selfSign(*cert);
|
||||
|
||||
keyChain.addCertificateAsIdentityDefault(*cert);
|
||||
|
||||
nlsr.loadCertToPublish(cert);
|
||||
|
||||
ndn::io::save(*cert, ROOT_CERT_PATH.string());
|
||||
}
|
||||
else {
|
||||
ndn::security::SigningInfo signingInfo;
|
||||
signingInfo.setSigningIdentity(signer);
|
||||
keyChain.sign(*cert, signingInfo);
|
||||
|
||||
keyChain.addCertificateAsIdentityDefault(*cert);
|
||||
|
||||
nlsr.loadCertToPublish(cert);
|
||||
}
|
||||
}
|
||||
|
||||
~LsaRuleFixture()
|
||||
{
|
||||
keyChain.deleteIdentity(rootId);
|
||||
keyChain.deleteIdentity(siteIdentity);
|
||||
keyChain.deleteIdentity(opIdentity);
|
||||
keyChain.deleteIdentity(routerId);
|
||||
|
||||
boost::filesystem::remove(ROOT_CERT_PATH);
|
||||
}
|
||||
|
||||
public:
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
ndn::KeyChain keyChain;
|
||||
|
||||
ndn::Name rootId, siteIdentity, opIdentity, routerId;
|
||||
ndn::Name rootCertName, siteCertName, opCertName, routerCertName;
|
||||
std::shared_ptr<IdentityCertificate> rootCert, siteCert, opCert, routerCert;
|
||||
|
||||
Nlsr nlsr;
|
||||
|
||||
const boost::filesystem::path ROOT_CERT_PATH;
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestLsaDataValidation, LsaRuleFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ValidateCorrectLSA)
|
||||
{
|
||||
ndn::Name lsaInterestName = nlsr.getConfParameter().getLsaPrefix();
|
||||
lsaInterestName.append(nlsr.getConfParameter().getSiteName());
|
||||
lsaInterestName.append(nlsr.getConfParameter().getRouterName());
|
||||
|
||||
// Append LSA type
|
||||
lsaInterestName.append(ndn::Name("name"));
|
||||
|
||||
// This would be the sequence number of its own NameLsa
|
||||
lsaInterestName.appendNumber(nlsr.getSequencingManager().getNameLsaSeq());
|
||||
|
||||
// Append version, segmentNo
|
||||
lsaInterestName.appendNumber(1).appendNumber(1);
|
||||
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
data->setName(lsaInterestName);
|
||||
data->setFreshnessPeriod(ndn::time::seconds(10));
|
||||
|
||||
// Sign data with NLSR's key
|
||||
nlsr.getKeyChain().sign(*data, ndn::security::signingByCertificate(nlsr.getDefaultCertName()));
|
||||
|
||||
// Make NLSR validate data signed by its own key
|
||||
nlsr.getValidator().validate(*data,
|
||||
[] (const std::shared_ptr<const Data>&) { BOOST_CHECK(true); },
|
||||
[] (const std::shared_ptr<const Data>&, const std::string&) {
|
||||
BOOST_CHECK(false);
|
||||
});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DoNotValidateIncorrectLSA)
|
||||
{
|
||||
// getSubName removes the /localhop compnonent from /localhop/ndn/NLSR/LSA
|
||||
ndn::Name lsaInterestName = nlsr.getConfParameter().getLsaPrefix().getSubName(1);
|
||||
lsaInterestName.append(nlsr.getConfParameter().getSiteName());
|
||||
lsaInterestName.append(nlsr.getConfParameter().getRouterName());
|
||||
|
||||
// Append LSA type
|
||||
lsaInterestName.append(ndn::Name("name"));
|
||||
|
||||
// This would be the sequence number of its own NameLsa
|
||||
lsaInterestName.appendNumber(nlsr.getSequencingManager().getNameLsaSeq());
|
||||
|
||||
// Append version, segmentNo
|
||||
lsaInterestName.appendNumber(1).appendNumber(1);
|
||||
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
data->setName(lsaInterestName);
|
||||
data->setFreshnessPeriod(ndn::time::seconds(10));
|
||||
nlsr.getKeyChain().sign(*data, ndn::security::signingByCertificate(nlsr.getDefaultCertName()));
|
||||
|
||||
// Make NLSR validate data signed by its own key
|
||||
nlsr.getValidator().validate(*data,
|
||||
[] (const std::shared_ptr<const Data>&) { BOOST_CHECK(false); },
|
||||
[] (const std::shared_ptr<const Data>&, const std::string&) {
|
||||
BOOST_CHECK(true);
|
||||
});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace test
|
||||
} // namespace nlsr
|
||||
+5
-5
@@ -33,14 +33,14 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::shared_ptr;
|
||||
using std::shared_ptr;
|
||||
|
||||
class LsdbFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
LsdbFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, sync(*face, nlsr.getLsdb(), nlsr.getConfParameter(), nlsr.getSequencingManager())
|
||||
, lsdb(nlsr.getLsdb())
|
||||
, conf(nlsr.getConfParameter())
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
SyncLogicHandler sync;
|
||||
|
||||
@@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(ReceiveSegmentedLsaData)
|
||||
ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/");
|
||||
interestName.appendNumber(seqNo);
|
||||
|
||||
const ndn::ConstBufferPtr bufferPtr = make_shared<ndn::Buffer>(lsa.getData().c_str(),
|
||||
const ndn::ConstBufferPtr bufferPtr = std::make_shared<ndn::Buffer>(lsa.getData().c_str(),
|
||||
lsa.getData().size());
|
||||
lsdb.afterFetchLsa(bufferPtr, interestName);
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ class NamePrefixTableFixture : public UnitTestTimeFixture
|
||||
{
|
||||
public:
|
||||
NamePrefixTableFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, lsdb(nlsr.getLsdb())
|
||||
, npt(nlsr.getNamePrefixTable())
|
||||
{
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
|
||||
Lsdb& lsdb;
|
||||
@@ -148,7 +148,7 @@ BOOST_FIXTURE_TEST_CASE(RemoveEntryFromPool, NamePrefixTableFixture)
|
||||
{
|
||||
NamePrefixTable& npt = nlsr.getNamePrefixTable();
|
||||
RoutingTablePoolEntry rtpe1("router1", 0);
|
||||
shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
|
||||
std::shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
|
||||
|
||||
npt.addRtpeToPool(rtpe1);
|
||||
|
||||
@@ -162,7 +162,7 @@ BOOST_FIXTURE_TEST_CASE(AddRoutingEntryToNptEntry, NamePrefixTableFixture)
|
||||
{
|
||||
NamePrefixTable& npt = nlsr.getNamePrefixTable();
|
||||
RoutingTablePoolEntry rtpe1("/ndn/memphis/rtr1", 0);
|
||||
shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
|
||||
std::shared_ptr<RoutingTablePoolEntry> rtpePtr = npt.addRtpeToPool(rtpe1);
|
||||
NamePrefixTableEntry npte1("/ndn/memphis/rtr2");
|
||||
|
||||
npt.addEntry("/ndn/memphis/rtr2", "/ndn/memphis/rtr1");
|
||||
@@ -172,8 +172,8 @@ BOOST_FIXTURE_TEST_CASE(AddRoutingEntryToNptEntry, NamePrefixTableFixture)
|
||||
npt.m_table.end(),
|
||||
npte1);
|
||||
|
||||
std::list<shared_ptr<RoutingTablePoolEntry>> rtpeList = nItr->getRteList();
|
||||
std::list<shared_ptr<RoutingTablePoolEntry>>::iterator rItr =
|
||||
std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = nItr->getRteList();
|
||||
std::list<std::shared_ptr<RoutingTablePoolEntry>>::iterator rItr =
|
||||
std::find(rtpeList.begin(),
|
||||
rtpeList.end(),
|
||||
rtpePtr);
|
||||
@@ -198,7 +198,7 @@ BOOST_FIXTURE_TEST_CASE(RemoveRoutingEntryFromNptEntry, NamePrefixTableFixture)
|
||||
npt.m_table.end(),
|
||||
npte1);
|
||||
|
||||
std::list<shared_ptr<RoutingTablePoolEntry>> rtpeList = nItr->getRteList();
|
||||
std::list<std::shared_ptr<RoutingTablePoolEntry>> rtpeList = nItr->getRteList();
|
||||
|
||||
BOOST_CHECK_EQUAL(rtpeList.size(), 1);
|
||||
BOOST_CHECK_EQUAL(npt.m_rtpool.size(), 1);
|
||||
|
||||
+12
-12
@@ -30,14 +30,14 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::shared_ptr;
|
||||
using std::shared_ptr;
|
||||
|
||||
class NlsrFixture : public UnitTestTimeFixture
|
||||
{
|
||||
public:
|
||||
NlsrFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, lsdb(nlsr.getLsdb())
|
||||
, neighbors(nlsr.getAdjacencyList())
|
||||
{
|
||||
@@ -49,13 +49,13 @@ public:
|
||||
ndn::Name dataName(sender);
|
||||
dataName.append("NLSR").append("INFO").append(receiver.wireEncode()).appendVersion();
|
||||
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(dataName);
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(dataName);
|
||||
|
||||
nlsr.m_helloProtocol.onContentValidated(data);
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
Lsdb& lsdb;
|
||||
AdjacencyList& neighbors;
|
||||
@@ -125,8 +125,8 @@ BOOST_AUTO_TEST_CASE(SetEventIntervals)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
{
|
||||
shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face = std::make_shared<ndn::util::DummyClientFace>(g_ioService);
|
||||
Nlsr nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain);
|
||||
Lsdb& lsdb = nlsr.getLsdb();
|
||||
|
||||
// Simulate loading configuration file
|
||||
@@ -201,7 +201,7 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
event.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
|
||||
.setFaceId(destroyFaceId);
|
||||
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>("/localhost/nfd/faces/events/%FE%00");
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>("/localhost/nfd/faces/events/%FE%00");
|
||||
data->setContent(event.wireEncode());
|
||||
nlsr.getKeyChain().sign(*data);
|
||||
|
||||
@@ -236,8 +236,8 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
// refresh will not cause RIB entries for other nodes' name prefixes to be refreshed.
|
||||
BOOST_FIXTURE_TEST_CASE(FaceDestroyEventInactive, UnitTestTimeFixture)
|
||||
{
|
||||
shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face = std::make_shared<ndn::util::DummyClientFace>(g_ioService);
|
||||
Nlsr nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain);
|
||||
Lsdb& lsdb = nlsr.getLsdb();
|
||||
|
||||
// Simulate loading configuration file
|
||||
@@ -314,7 +314,7 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEventInactive, UnitTestTimeFixture)
|
||||
event.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
|
||||
.setFaceId(destroyFaceId);
|
||||
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>("/localhost/nfd/faces/events/%FE%00");
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>("/localhost/nfd/faces/events/%FE%00");
|
||||
data->setContent(event.wireEncode());
|
||||
nlsr.getKeyChain().sign(*data);
|
||||
|
||||
@@ -348,7 +348,7 @@ BOOST_AUTO_TEST_CASE(GetCertificate)
|
||||
ndn::KeyChain keyChain;
|
||||
keyChain.createIdentity(identity);
|
||||
ndn::Name certName = keyChain.getDefaultCertificateNameForIdentity(identity);
|
||||
shared_ptr<ndn::IdentityCertificate> certificate = keyChain.getCertificate(certName);
|
||||
std::shared_ptr<ndn::IdentityCertificate> certificate = keyChain.getCertificate(certName);
|
||||
|
||||
const ndn::Name certKey = certificate->getName().getPrefix(-1);
|
||||
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::shared_ptr;
|
||||
using std::shared_ptr;
|
||||
|
||||
class SyncLogicFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
SyncLogicFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
|
||||
, sync(nlsr.getSyncLogicHandler())
|
||||
, CONFIG_NETWORK("/ndn")
|
||||
, CONFIG_SITE("/site")
|
||||
@@ -59,13 +59,13 @@ public:
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
face->sentInterests.clear();
|
||||
|
||||
p_sync.onNsyncUpdate(updates, NULL);
|
||||
p_sync.onNsyncUpdate(updates, nullptr);
|
||||
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
SyncLogicHandler& sync;
|
||||
|
||||
@@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
|
||||
{
|
||||
Nlsr nlsr_hr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
Nlsr nlsr_hr(g_ioService, g_scheduler, std::ref(*face), g_keyChain);
|
||||
SyncLogicHandler& sync_hr(nlsr_hr.getSyncLogicHandler());
|
||||
|
||||
nlsr_hr.getConfParameter().setNetwork(CONFIG_NETWORK);
|
||||
@@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
|
||||
{
|
||||
|
||||
Nlsr nlsr_hrdry(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
Nlsr nlsr_hrdry(g_ioService, g_scheduler, std::ref(*face),g_keyChain);
|
||||
SyncLogicHandler& sync_hrdry(nlsr_hrdry.getSyncLogicHandler());
|
||||
|
||||
nlsr_hrdry.getConfParameter().setNetwork(CONFIG_NETWORK);
|
||||
|
||||
@@ -43,10 +43,10 @@ class PrefixUpdateFixture : public nlsr::test::BaseFixture
|
||||
{
|
||||
public:
|
||||
PrefixUpdateFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, siteIdentity(ndn::Name("/ndn/edu/test-site").appendVersion())
|
||||
, opIdentity(ndn::Name(siteIdentity).append(ndn::Name("%C1.Operator")).appendVersion())
|
||||
, nlsr(g_ioService, g_scheduler, *face)
|
||||
, nlsr(g_ioService, g_scheduler, *face, g_keyChain)
|
||||
, keyPrefix(("/ndn/broadcast"))
|
||||
, updateProcessor(nlsr.getPrefixUpdateProcessor())
|
||||
, SITE_CERT_PATH(boost::filesystem::current_path() / std::string("site.cert"))
|
||||
@@ -138,16 +138,16 @@ public:
|
||||
// Operator cert
|
||||
ndn::Name keyName = keyChain.generateRsaKeyPairAsDefault(opIdentity, true);
|
||||
|
||||
opCert = ndn::make_shared<ndn::IdentityCertificate>();
|
||||
ndn::shared_ptr<ndn::PublicKey> pubKey = keyChain.getPublicKey(keyName);
|
||||
opCert = std::make_shared<ndn::IdentityCertificate>();
|
||||
std::shared_ptr<ndn::PublicKey> pubKey = keyChain.getPublicKey(keyName);
|
||||
opCertName = keyName.getPrefix(-1);
|
||||
opCertName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
|
||||
opCert->setName(opCertName);
|
||||
opCert->setNotBefore(time::system_clock::now() - time::days(1));
|
||||
opCert->setNotAfter(time::system_clock::now() + time::days(1));
|
||||
opCert->setPublicKeyInfo(*pubKey);
|
||||
opCert->addSubjectDescription(CertificateSubjectDescription(ndn::oid::ATTRIBUTE_NAME,
|
||||
keyName.toUri()));
|
||||
opCert->addSubjectDescription(ndn::security::v1::CertificateSubjectDescription(ndn::oid::ATTRIBUTE_NAME,
|
||||
keyName.toUri()));
|
||||
opCert->encode();
|
||||
|
||||
keyChain.signByIdentity(*opCert, siteIdentity);
|
||||
@@ -191,16 +191,16 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
ndn::KeyChain keyChain;
|
||||
|
||||
ndn::Name siteIdentity;
|
||||
ndn::Name siteCertName;
|
||||
shared_ptr<IdentityCertificate> siteCert;
|
||||
std::shared_ptr<IdentityCertificate> siteCert;
|
||||
|
||||
ndn::Name opIdentity;
|
||||
ndn::Name opCertName;
|
||||
shared_ptr<IdentityCertificate> opCert;
|
||||
std::shared_ptr<IdentityCertificate> opCert;
|
||||
|
||||
Nlsr nlsr;
|
||||
ndn::Name keyPrefix;
|
||||
@@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
|
||||
advertiseCommand.append(parameters.wireEncode());
|
||||
|
||||
shared_ptr<Interest> advertiseInterest = make_shared<Interest>(advertiseCommand);
|
||||
std::shared_ptr<Interest> advertiseInterest = std::make_shared<Interest>(advertiseCommand);
|
||||
keyChain.signByIdentity(*advertiseInterest, opIdentity);
|
||||
|
||||
face->receive(*advertiseInterest);
|
||||
@@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
ndn::Name withdrawCommand("/localhost/nlsr/prefix-update/withdraw");
|
||||
withdrawCommand.append(parameters.wireEncode());
|
||||
|
||||
shared_ptr<Interest> withdrawInterest = make_shared<Interest>(withdrawCommand);
|
||||
std::shared_ptr<Interest> withdrawInterest = std::make_shared<Interest>(withdrawCommand);
|
||||
keyChain.signByIdentity(*withdrawInterest, opIdentity);
|
||||
|
||||
face->receive(*withdrawInterest);
|
||||
@@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE(DisabledAndEnabled)
|
||||
ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
|
||||
advertiseCommand.append(parameters.wireEncode());
|
||||
|
||||
shared_ptr<Interest> advertiseInterest = make_shared<Interest>(advertiseCommand);
|
||||
std::shared_ptr<Interest> advertiseInterest = std::make_shared<Interest>(advertiseCommand);
|
||||
keyChain.signByIdentity(*advertiseInterest, opIdentity);
|
||||
|
||||
// Command should be rejected
|
||||
|
||||
@@ -31,15 +31,15 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::bind;
|
||||
using ndn::shared_ptr;
|
||||
using std::bind;
|
||||
using std::shared_ptr;
|
||||
using ndn::Interest;
|
||||
|
||||
class FaceControllerFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
FaceControllerFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
: face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, interests(face->sentInterests)
|
||||
, controller(*face, keyChain)
|
||||
, faceController(g_ioService, controller)
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> face;
|
||||
ndn::KeyChain keyChain;
|
||||
std::vector<Interest>& interests;
|
||||
ndn::nfd::Controller controller;
|
||||
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(FaceCreateCanonizeFailure)
|
||||
{
|
||||
faceController.createFace("invalid://256.0.0.1:6363",
|
||||
nullptr,
|
||||
bind(&FaceControllerFixture::onFailure, this, _1));
|
||||
std::bind(&FaceControllerFixture::onFailure, this, _1));
|
||||
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ Nlsrc::sendNamePrefixUpdate(const ndn::Name& name,
|
||||
|
||||
m_face.expressInterest(interest,
|
||||
std::bind(&Nlsrc::onControlResponse, this, info, _2),
|
||||
std::bind(&Nlsrc::onTimeout, this, ERROR_CODE_TIMEOUT, "Nack"),
|
||||
std::bind(&Nlsrc::onTimeout, this, ERROR_CODE_TIMEOUT, "Timeout"));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with
|
||||
NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
VERSION = '0.3.1'
|
||||
VERSION = '0.3.2'
|
||||
APPNAME = "nlsr"
|
||||
BUGREPORT = "http://redmine.named-data.net/projects/nlsr"
|
||||
URL = "http://named-data.net/doc/NLSR/"
|
||||
|
||||
Reference in new issue
Block a user