[exprimental] Add strategies more control over satisfying Data
With this patch, strategies now selectively decide not to satisfy some
(all) of the incoming interests listed in PIT. However, if there are
multiple PIT entries being satisfied with the same Data packet, the
decision may not be honored (e.g., when another PIT entry/strategy
decided to satisfy a specific downstream).
Change-Id: I2edf19ae5bdeab0b69c57c7af7bb292db05885bb
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index da83f14..7cf73ad 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -160,13 +160,46 @@
}
void
+Strategy::beforeSatisfyInterest(const Data& data, const FaceEndpoint& ingress,
+ const shared_ptr<pit::Entry>& pitEntry)
+{
+ NFD_LOG_DEBUG("beforeSatisfyInterest pitEntry=" << pitEntry->getName()
+ << " in=" << ingress << " data=" << data.getName());
+}
+
+void
+Strategy::satisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
+ const FaceEndpoint& ingress, const Data& data,
+ std::set<std::pair<Face*, EndpointId>>& satisfiedDownstreams,
+ std::set<std::pair<Face*, EndpointId>>& unsatisfiedDownstreams)
+{
+ NFD_LOG_DEBUG("satisfyInterest pitEntry=" << pitEntry->getName()
+ << " in=" << ingress << " data=" << data.getName());
+
+ NFD_LOG_DEBUG("onIncomingData matching=" << pitEntry->getName());
+
+ auto now = time::steady_clock::now();
+
+ // remember pending downstreams
+ for (const pit::InRecord& inRecord : pitEntry->getInRecords()) {
+ if (inRecord.getExpiry() > now) {
+ satisfiedDownstreams.emplace(&inRecord.getFace(), 0);
+ }
+ }
+
+ // invoke PIT satisfy callback
+ beforeSatisfyInterest(pitEntry, ingress, data);
+}
+
+
+void
Strategy::afterContentStoreHit(const Data& data, const FaceEndpoint& ingress,
const shared_ptr<pit::Entry>& pitEntry)
{
- NFD_LOG_DEBUG("afterContentStoreHit pitEntry=" << pitEntry->getName()
- << " in=" << ingress << " data=" << data.getName());
+ NFD_LOG_DEBUG("afterContentStoreHit pitEntry=" << pitEntry->getName()
+ << " in=" << ingress << " data=" << data.getName());
- this->sendData(data, ingress.face, pitEntry);
+ this->sendData(data, ingress.face, pitEntry);
}
void