fw: /localhop scope control on outgoing Interests
refs #1253
Change-Id: I359747688568934070d1583995957835ac690f28
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index e6d3438..a723a17 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -15,6 +15,7 @@
const ndn::Milliseconds Forwarder::DEFAULT_INTEREST_LIFETIME(static_cast<ndn::Milliseconds>(4000));
const Name Forwarder::LOCALHOST_NAME("ndn:/localhost");
+const Name Forwarder::LOCALHOP_NAME("ndn:/localhop");
Forwarder::Forwarder()
: m_faceTable(*this)
@@ -140,6 +141,16 @@
return;
}
+ // /localhop scope control
+ bool isViolatingLocalhop = !outFace.isLocal() &&
+ LOCALHOP_NAME.isPrefixOf(pitEntry->getName()) &&
+ !pitEntry->hasLocalInRecord();
+ if (isViolatingLocalhop) {
+ NFD_LOG_DEBUG("onOutgoingInterest face=" << outFace.getId() <<
+ " interest=" << pitEntry->getName() << " violates /localhop");
+ return;
+ }
+
// pick Interest
const pit::InRecordCollection& inRecords = pitEntry->getInRecords();
pit::InRecordCollection::const_iterator pickedInRecord = std::max_element(
diff --git a/daemon/fw/forwarder.hpp b/daemon/fw/forwarder.hpp
index c6e3529..e229dcf 100644
--- a/daemon/fw/forwarder.hpp
+++ b/daemon/fw/forwarder.hpp
@@ -159,6 +159,7 @@
static const ndn::Milliseconds DEFAULT_INTEREST_LIFETIME;
static const Name LOCALHOST_NAME;
+ static const Name LOCALHOP_NAME;
// allow Strategy (base class) to enter pipelines
friend class fw::Strategy;