Allow override of the session number (required by NLSR)
Change-Id: Ifb08868d6a640518aa826d3bec4546dc4e001dfa
diff --git a/src/logic.cpp b/src/logic.cpp
index 81d84c8..c987109 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -110,7 +110,8 @@
const time::milliseconds& resetInterestLifetime,
const time::milliseconds& syncInterestLifetime,
const time::milliseconds& syncReplyFreshness,
- const time::milliseconds& recoveryInterestLifetime)
+ const time::milliseconds& recoveryInterestLifetime,
+ const name::Component& session)
: m_face(face)
, m_syncPrefix(syncPrefix)
, m_defaultUserPrefix(defaultUserPrefix)
@@ -134,7 +135,7 @@
{
_LOG_DEBUG_ID(">> Logic::Logic");
- addUserNode(m_defaultUserPrefix, defaultSigningId);
+ addUserNode(m_defaultUserPrefix, defaultSigningId, session);
m_syncReset = m_syncPrefix;
m_syncReset.append("reset");
@@ -194,7 +195,7 @@
}
void
-Logic::addUserNode(const Name& userPrefix, const Name& signingId)
+Logic::addUserNode(const Name& userPrefix, const Name& signingId, const name::Component& session)
{
if (userPrefix == EMPTY_NAME)
return;
@@ -205,7 +206,12 @@
m_nodeList[userPrefix].userPrefix = userPrefix;
m_nodeList[userPrefix].signingId = signingId;
Name sessionName = userPrefix;
- sessionName.appendNumber(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count());
+ if (!session.empty()) {
+ sessionName.append(session);
+ }
+ else {
+ sessionName.appendNumber(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count());
+ }
m_nodeList[userPrefix].sessionName = sessionName;
m_nodeList[userPrefix].seqNo = 0;
reset(false);
diff --git a/src/logic.hpp b/src/logic.hpp
index 1aef992..a2fec3b 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -117,6 +117,7 @@
* @param syncInterestLifetime The lifetime of sync interest
* @param syncReplyFreshness The FreshnessPeriod of sync reply
* @param recoveryInterestLifetime The lifetime of recovery interest
+ * @param session Manually defined session ID
*/
Logic(ndn::Face& face,
const Name& syncPrefix,
@@ -129,7 +130,8 @@
const time::milliseconds& resetInterestLifetime = DEFAULT_RESET_INTEREST_LIFETIME,
const time::milliseconds& syncInterestLifetime = DEFAULT_SYNC_INTEREST_LIFETIME,
const time::milliseconds& syncReplyFreshness = DEFAULT_SYNC_REPLY_FRESHNESS,
- const time::milliseconds& recoveryInterestLifetime = DEFAULT_RECOVERY_INTEREST_LIFETIME);
+ const time::milliseconds& recoveryInterestLifetime = DEFAULT_RECOVERY_INTEREST_LIFETIME,
+ const name::Component& session = {});
~Logic();
@@ -165,9 +167,10 @@
*
* @param userPrefix prefix of the added node
* @param signingId signing Id of the added node
+ * @param session manually defined session ID
*/
void
- addUserNode(const Name& userPrefix, const Name& signingId = DEFAULT_NAME);
+ addUserNode(const Name& userPrefix, const Name& signingId = DEFAULT_NAME, const name::Component& session = {});
/// @brief remove the node from the local session
void
diff --git a/src/socket.cpp b/src/socket.cpp
index a4c1673..4468fb7 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -39,12 +39,14 @@
const UpdateCallback& updateCallback,
const Name& signingId,
std::shared_ptr<Validator> validator,
- const time::milliseconds& syncInterestLifetime)
+ const time::milliseconds& syncInterestLifetime,
+ const name::Component& session)
: m_userPrefix(userPrefix)
, m_face(face)
, m_logic(face, syncPrefix, userPrefix, updateCallback, Logic::DEFAULT_NAME, Logic::DEFAULT_VALIDATOR,
Logic::DEFAULT_RESET_TIMER, Logic::DEFAULT_CANCEL_RESET_TIMER, Logic::DEFAULT_RESET_INTEREST_LIFETIME,
- syncInterestLifetime)
+ syncInterestLifetime, Logic::DEFAULT_SYNC_REPLY_FRESHNESS, Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME,
+ session)
, m_signingId(signingId)
, m_validator(validator)
{
@@ -67,7 +69,7 @@
}
void
-Socket::addSyncNode(const Name& prefix, const Name& signingId)
+Socket::addSyncNode(const Name& prefix, const Name& signingId, const name::Component& session)
{
if (prefix == DEFAULT_NAME)
return;
@@ -80,7 +82,7 @@
if (m_userPrefix == DEFAULT_NAME)
m_userPrefix = prefix;
- m_logic.addUserNode(prefix, signingId);
+ m_logic.addUserNode(prefix, signingId, session);
m_registeredPrefixList[prefix] =
m_face.setInterestFilter(prefix,
bind(&Socket::onInterest, this, _1, _2),
@@ -103,7 +105,6 @@
m_ims.erase(prefix);
m_logic.removeUserNode(prefix);
-
}
void
diff --git a/src/socket.hpp b/src/socket.hpp
index b7b0858..81fc806 100644
--- a/src/socket.hpp
+++ b/src/socket.hpp
@@ -65,7 +65,8 @@
const UpdateCallback& updateCallback,
const Name& signingId = DEFAULT_NAME,
std::shared_ptr<Validator> validator = DEFAULT_VALIDATOR,
- const time::milliseconds& syncInterestLifetime = Logic::DEFAULT_SYNC_INTEREST_LIFETIME);
+ const time::milliseconds& syncInterestLifetime = Logic::DEFAULT_SYNC_INTEREST_LIFETIME,
+ const name::Component& session = {});
~Socket();
@@ -82,9 +83,10 @@
*
* @param prefix Prefix of the new node
* @param signingId Signing ID for the packet sent out by the new node
+ * @param session Manually defined session number
*/
void
- addSyncNode(const Name& prefix, const Name& signingId = DEFAULT_NAME);
+ addSyncNode(const Name& prefix, const Name& signingId = DEFAULT_NAME, const name::Component& session = {});
/**
* @brief Remove a sync node under same logic