fw+table: use Interest::Nonce instead of uint32_t
Change-Id: I2a4b83696db80d2d0b675121da53a73c309e059c
diff --git a/daemon/fw/algorithm.cpp b/daemon/fw/algorithm.cpp
index 1ed699b..7dada21 100644
--- a/daemon/fw/algorithm.cpp
+++ b/daemon/fw/algorithm.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -75,7 +75,7 @@
}
int
-findDuplicateNonce(const pit::Entry& pitEntry, uint32_t nonce, const Face& face)
+findDuplicateNonce(const pit::Entry& pitEntry, Interest::Nonce nonce, const Face& face)
{
int dnw = DUPLICATE_NONCE_NONE;
diff --git a/daemon/fw/algorithm.hpp b/daemon/fw/algorithm.hpp
index 07a0e01..68d9f14 100644
--- a/daemon/fw/algorithm.hpp
+++ b/daemon/fw/algorithm.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -70,7 +70,7 @@
* \return OR'ed DuplicateNonceWhere
*/
int
-findDuplicateNonce(const pit::Entry& pitEntry, uint32_t nonce, const Face& face);
+findDuplicateNonce(const pit::Entry& pitEntry, Interest::Nonce nonce, const Face& face);
/** \brief determine whether \p pitEntry has any pending out-records
* \return true if there is at least one out-record waiting for Data
diff --git a/daemon/table/dead-nonce-list.cpp b/daemon/table/dead-nonce-list.cpp
index 3521b51..142ddea 100644
--- a/daemon/table/dead-nonce-list.cpp
+++ b/daemon/table/dead-nonce-list.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -87,14 +87,14 @@
}
bool
-DeadNonceList::has(const Name& name, uint32_t nonce) const
+DeadNonceList::has(const Name& name, Interest::Nonce nonce) const
{
Entry entry = DeadNonceList::makeEntry(name, nonce);
return m_ht.find(entry) != m_ht.end();
}
void
-DeadNonceList::add(const Name& name, uint32_t nonce)
+DeadNonceList::add(const Name& name, Interest::Nonce nonce)
{
Entry entry = DeadNonceList::makeEntry(name, nonce);
m_queue.push_back(entry);
@@ -103,11 +103,12 @@
}
DeadNonceList::Entry
-DeadNonceList::makeEntry(const Name& name, uint32_t nonce)
+DeadNonceList::makeEntry(const Name& name, Interest::Nonce nonce)
{
Block nameWire = name.wireEncode();
- return CityHash64WithSeed(reinterpret_cast<const char*>(nameWire.wire()), nameWire.size(),
- static_cast<uint64_t>(nonce));
+ uint32_t n;
+ std::memcpy(&n, nonce.data(), sizeof(n));
+ return CityHash64WithSeed(reinterpret_cast<const char*>(nameWire.wire()), nameWire.size(), n);
}
size_t
diff --git a/daemon/table/dead-nonce-list.hpp b/daemon/table/dead-nonce-list.hpp
index dea1d51..5b49143 100644
--- a/daemon/table/dead-nonce-list.hpp
+++ b/daemon/table/dead-nonce-list.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -67,15 +67,15 @@
~DeadNonceList();
/** \brief Determines if name+nonce exists
- * \return true if name+nonce exists
+ * \return true if name+nonce exists, false otherwise
*/
bool
- has(const Name& name, uint32_t nonce) const;
+ has(const Name& name, Interest::Nonce nonce) const;
/** \brief Records name+nonce
*/
void
- add(const Name& name, uint32_t nonce);
+ add(const Name& name, Interest::Nonce nonce);
/** \return number of stored Nonces
* \note The return value does not contain non-Nonce entries in the index, if any.
@@ -95,7 +95,7 @@
typedef uint64_t Entry;
static Entry
- makeEntry(const Name& name, uint32_t nonce);
+ makeEntry(const Name& name, Interest::Nonce nonce);
typedef boost::multi_index_container<
Entry,
diff --git a/daemon/table/pit-face-record.hpp b/daemon/table/pit-face-record.hpp
index 7c36ab6..1a68a51 100644
--- a/daemon/table/pit-face-record.hpp
+++ b/daemon/table/pit-face-record.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -51,7 +51,7 @@
return m_face;
}
- uint32_t
+ Interest::Nonce
getLastNonce() const
{
return m_lastNonce;
@@ -79,7 +79,7 @@
private:
Face& m_face;
- uint32_t m_lastNonce = 0;
+ Interest::Nonce m_lastNonce{0, 0, 0, 0};
time::steady_clock::TimePoint m_lastRenewed = time::steady_clock::TimePoint::min();
time::steady_clock::TimePoint m_expiry = time::steady_clock::TimePoint::min();
};