Fix some bugs
diff --git a/src/ccnx/sync-socket.cc b/src/ccnx/sync-socket.cc
index 48d4ad0..3ef1c96 100644
--- a/src/ccnx/sync-socket.cc
+++ b/src/ccnx/sync-socket.cc
@@ -31,13 +31,18 @@
RemoveCallback rmCallback )
: m_newDataCallback(dataCallback)
, m_syncPolicyManager(syncPolicyManager)
+ , m_handler(Ptr<Wrapper>(new Wrapper(Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(),
+ m_syncPolicyManager,
+ NULL)))))
, m_syncLogic (syncPrefix,
syncPolicyManager,
+ m_handler,
bind(&SyncSocket::passCallback, this, _1),
rmCallback)
{
- Ptr<security::Keychain> keychain = Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(), m_syncPolicyManager, NULL));
- m_handler = Ptr<Wrapper>(new Wrapper(keychain));
+ // Ptr<security::Keychain> keychain = Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(), m_syncPolicyManager, NULL));
+ // m_handler = Ptr<Wrapper>(new Wrapper(keychain));
+ m_syncPolicyManager->setWrapper(m_handler);
}
SyncSocket::~SyncSocket()
diff --git a/src/sync-intro-certificate.cc b/src/sync-intro-certificate.cc
index 9d77cca..5c966c8 100644
--- a/src/sync-intro-certificate.cc
+++ b/src/sync-intro-certificate.cc
@@ -44,11 +44,12 @@
}
certificateName.appendVersion();
- setName(certificateName);
+ Data::setName(certificateName);
setNotBefore(notBefore);
setNotAfter(notAfter);
setPublicKeyInfo(key);
addSubjectDescription(CertificateSubDescrypt("2.5.4.41", keyName.toUri()));
+ encode();
}
SyncIntroCertificate::SyncIntroCertificate (const Name& nameSpace,
diff --git a/src/sync-logic.cc b/src/sync-logic.cc
index ef96a86..f40a36c 100644
--- a/src/sync-logic.cc
+++ b/src/sync-logic.cc
@@ -60,6 +60,7 @@
SyncLogic::SyncLogic (const Name& syncPrefix,
Ptr<SyncPolicyManager> syncPolicyManager,
+ Ptr<Wrapper> handler,
LogicUpdateCallback onUpdate,
LogicRemoveCallback onRemove)
: m_state (new FullState)
@@ -69,6 +70,7 @@
, m_onRemove (onRemove)
, m_perBranch (false)
, m_policyManager(syncPolicyManager)
+ , m_handler (handler)
#ifndef NS3_MODULE
, m_randomGenerator (static_cast<unsigned int> (std::time (0)))
, m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,1000))
@@ -82,10 +84,6 @@
#ifndef NS3_MODULE
// In NS3 module these functions are moved to StartApplication method
- Ptr<security::Keychain> keychain = Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(),
- m_policyManager,
- NULL));
- m_handler = Ptr<Wrapper>(new Wrapper(keychain));
m_handler->setInterestFilter (m_syncPrefix,
bind (&SyncLogic::respondSyncInterest, this, _1));
@@ -97,6 +95,7 @@
SyncLogic::SyncLogic (const Name& syncPrefix,
Ptr<SyncPolicyManager> syncPolicyManager,
+ Ptr<Wrapper> handler,
LogicPerBranchCallback onUpdateBranch)
: m_state (new FullState)
, m_syncInterestTable (TIME_SECONDS (m_syncInterestReexpress))
@@ -104,6 +103,7 @@
, m_onUpdateBranch (onUpdateBranch)
, m_perBranch(true)
, m_policyManager(syncPolicyManager)
+ , m_handler (handler)
#ifndef NS3_MODULE
, m_randomGenerator (static_cast<unsigned int> (std::time (0)))
, m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,1000))
@@ -116,14 +116,9 @@
{
#ifndef NS3_MODULE
// In NS3 module these functions are moved to StartApplication method
-
- Ptr<security::Keychain> keychain = Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(),
- m_policyManager,
- NULL));
- m_handler = Ptr<Wrapper>(new Wrapper(keychain));
m_handler->setInterestFilter (m_syncPrefix,
- bind (&SyncLogic::respondSyncInterest, this, _1));
+ bind (&SyncLogic::respondSyncInterest, this, _1));
m_scheduler.schedule (TIME_SECONDS (0), // no need to add jitter
bind (&SyncLogic::sendSyncInterest, this),
diff --git a/src/sync-logic.h b/src/sync-logic.h
index b7152cc..e18a01b 100644
--- a/src/sync-logic.h
+++ b/src/sync-logic.h
@@ -85,11 +85,13 @@
*/
SyncLogic (const ndn::Name& syncPrefix,
ndn::Ptr<SyncPolicyManager> syncPolicyManager,
+ ndn::Ptr<ndn::Wrapper> handler,
LogicUpdateCallback onUpdate,
LogicRemoveCallback onRemove);
SyncLogic (const ndn::Name& syncPrefix,
ndn::Ptr<SyncPolicyManager> syncPolicyManager,
+ ndn::Ptr<ndn::Wrapper> handler,
LogicPerBranchCallback onUpdateBranch);
~SyncLogic ();