routing: Add routable prefix support
Change-Id: I31c860adf7aa985b96063dbf5444f308e5ea0b21
diff --git a/src/sync-socket.h b/src/sync-socket.h
index 19fac0d..8013635 100644
--- a/src/sync-socket.h
+++ b/src/sync-socket.h
@@ -49,24 +49,34 @@
typedef ndn::function< void (const std::vector<MissingDataInfo> &, SyncSocket * ) > NewDataCallback;
typedef ndn::function< void (const std::string &/*prefix*/ ) > RemoveCallback;
- SyncSocket (const ndn::Name& syncPrefix,
- const ndn::Name& dataPrefix,
- uint64_t dataSession,
- ndn::shared_ptr<ndn::Face> face,
- const ndn::IdentityCertificate& myCertificate,
- ndn::shared_ptr<ndn::SecRuleRelative> dataRule,
- NewDataCallback dataCallback,
- RemoveCallback rmCallback);
+ static const ndn::Name EMPTY_NAME;
- ~SyncSocket ();
+ SyncSocket(const ndn::Name& syncPrefix,
+ const ndn::Name& dataPrefix,
+ uint64_t dataSession,
+ bool withRoutingPrefix,
+ const ndn::Name& routingPrefix,
+ ndn::shared_ptr<ndn::Face> face,
+ const ndn::IdentityCertificate& myCertificate,
+ ndn::shared_ptr<ndn::SecRuleRelative> dataRule,
+ NewDataCallback dataCallback,
+ RemoveCallback rmCallback);
+
+ ~SyncSocket();
void
publishData(const uint8_t* buf, size_t len, int freshness, bool isCert = false);
void
- remove (const ndn::Name &prefix)
+ leave()
{
- m_syncLogic->remove(prefix);
+ m_syncLogic->remove(m_withRoutingPrefix ? m_routableDataPrefix : m_dataPrefix);
+ }
+
+ void
+ remove(const ndn::Name& prefix)
+ {
+ m_syncLogic->remove(prefix);
}
void
@@ -79,21 +89,22 @@
}
uint64_t
- getNextSeq (const ndn::Name &prefix, uint64_t session)
+ getNextSeq()
{
- SequenceLog::iterator i = m_sequenceLog.find (prefix);
+ // If DNS works, we should use pure m_dataprefix rather than the one with routing prefix.
+ SequenceLog::iterator i = m_sequenceLog.find (m_withRoutingPrefix ? m_routableDataPrefix : m_dataPrefix);
if (i != m_sequenceLog.end ())
{
SeqNo s = i->second;
- if (s.getSession() == session)
+ if (s.getSession() == m_dataSession)
return s.getSeq();
}
return 0;
}
SyncLogic &
- getLogic ()
+ getLogic()
{
return *m_syncLogic;
}
@@ -142,10 +153,7 @@
private:
void
- publishDataInternal(ndn::shared_ptr<ndn::Data> data,
- const ndn::Name &prefix,
- uint64_t session,
- bool isCert);
+ publishDataInternal(ndn::shared_ptr<ndn::Data> data, bool isCert);
void
passCallback(const std::vector<MissingDataInfo> &v)
@@ -154,15 +162,11 @@
}
void
- onData(const ndn::Interest& interest, ndn::Data& data,
- const ndn::OnDataValidated& onValidated,
- const ndn::OnDataValidationFailed& onValidationFailed);
+ onData(const ndn::Interest& interest, ndn::Data& data, const ndn::OnDataValidated& dataCallback);
void
- onDataTimeout(const ndn::Interest& interest,
- int retry,
- const ndn::OnDataValidated& onValidated,
- const ndn::OnDataValidationFailed& onValidationFailed);
+ onDataTimeout(const ndn::Interest& interest, int retry, const ndn::OnDataValidated& dataCallback);
+
void
onDataValidated(const ndn::shared_ptr<const ndn::Data>& data,
@@ -178,6 +182,8 @@
ndn::Name m_dataPrefix;
uint64_t m_dataSession;
+ ndn::Name m_routableDataPrefix;
+ bool m_withRoutingPrefix;
NewDataCallback m_newDataCallback;
SequenceLog m_sequenceLog;
ndn::IdentityCertificate m_myCertificate;