table+fw: move forwarding semantics out of PIT entry
refs #3546
Change-Id: I1e6f87fd81176c116b6d758156da1cf96ea03608
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index 22df4a4..21e4c53 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,9 +29,6 @@
namespace nfd {
namespace pit {
-const Name Entry::LOCALHOST_NAME("ndn:/localhost");
-const Name Entry::LOCALHOP_NAME("ndn:/localhop");
-
Entry::Entry(const Interest& interest)
: m_interest(interest.shared_from_this())
{
@@ -43,90 +40,6 @@
return m_interest->getName();
}
-bool
-Entry::hasLocalInRecord() const
-{
- return std::any_of(m_inRecords.begin(), m_inRecords.end(),
- [] (const InRecord& inRecord) { return inRecord.getFace()->getScope() == ndn::nfd::FACE_SCOPE_LOCAL; });
-}
-
-bool
-Entry::canForwardTo(const Face& face) const
-{
- time::steady_clock::TimePoint now = time::steady_clock::now();
-
- bool hasUnexpiredOutRecord = std::any_of(m_outRecords.begin(), m_outRecords.end(),
- [&face, &now] (const OutRecord& outRecord) {
- return outRecord.getFace().get() == &face && outRecord.getExpiry() >= now;
- });
- if (hasUnexpiredOutRecord) {
- return false;
- }
-
- bool hasUnexpiredOtherInRecord = std::any_of(m_inRecords.begin(), m_inRecords.end(),
- [&face, &now] (const InRecord& inRecord) {
- return inRecord.getFace().get() != &face && inRecord.getExpiry() >= now;
- });
- if (!hasUnexpiredOtherInRecord) {
- return false;
- }
-
- return !this->violatesScope(face);
-}
-
-bool
-Entry::violatesScope(const Face& face) const
-{
- // /localhost scope
- bool isViolatingLocalhost = face.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL &&
- LOCALHOST_NAME.isPrefixOf(this->getName());
- if (isViolatingLocalhost) {
- return true;
- }
-
- // /localhop scope
- bool isViolatingLocalhop = face.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL &&
- LOCALHOP_NAME.isPrefixOf(this->getName()) &&
- !this->hasLocalInRecord();
- if (isViolatingLocalhop) {
- return true;
- }
-
- return false;
-}
-
-int
-Entry::findNonce(uint32_t nonce, const Face& face) const
-{
- // TODO should we ignore expired in/out records?
-
- int dnw = DUPLICATE_NONCE_NONE;
-
- for (const InRecord& inRecord : m_inRecords) {
- if (inRecord.getLastNonce() == nonce) {
- if (inRecord.getFace().get() == &face) {
- dnw |= DUPLICATE_NONCE_IN_SAME;
- }
- else {
- dnw |= DUPLICATE_NONCE_IN_OTHER;
- }
- }
- }
-
- for (const OutRecord& outRecord : m_outRecords) {
- if (outRecord.getLastNonce() == nonce) {
- if (outRecord.getFace().get() == &face) {
- dnw |= DUPLICATE_NONCE_OUT_SAME;
- }
- else {
- dnw |= DUPLICATE_NONCE_OUT_OTHER;
- }
- }
- }
-
- return dnw;
-}
-
InRecordCollection::iterator
Entry::insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest)
{
@@ -195,14 +108,5 @@
}
}
-bool
-Entry::hasUnexpiredOutRecords() const
-{
- time::steady_clock::TimePoint now = time::steady_clock::now();
-
- return std::any_of(m_outRecords.begin(), m_outRecords.end(),
- [&now] (const OutRecord& outRecord) { return outRecord.getExpiry() >= now; });
-}
-
} // namespace pit
} // namespace nfd