[ndnSIM] fw: Add beforeSatisfyInterest and beforeExpirePendingInterest signals
The beforeExpirePendingInterest signal, in addition to actually timed out
interests, also includes NACKed interests.
Change-Id: I01b3a6e9f6090673c864d29065fd6d182fc251c4
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 5c529a8..1fc674d 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -34,6 +34,8 @@
#include <ndn-cxx/lp/tags.hpp>
+#include "face/null-face.hpp"
+
namespace nfd {
NFD_LOG_INIT(Forwarder);
@@ -51,7 +53,10 @@
, m_pit(m_nameTree)
, m_measurements(m_nameTree)
, m_strategyChoice(*this)
+ , m_csFace(face::makeNullFace(FaceUri("contentstore://")))
{
+ getFaceTable().addReserved(m_csFace, face::FACEID_CONTENT_STORE);
+
m_faceTable.afterAdd.connect([this] (const Face& face) {
face.afterReceiveInterest.connect(
[this, &face] (const Interest& interest, const EndpointId& endpointId) {
@@ -221,6 +226,10 @@
// set PIT expiry timer to now
this->setExpiryTimer(pitEntry, 0_ms);
+ beforeSatisfyInterest(*pitEntry, *m_csFace, data);
+ this->dispatchToStrategy(*pitEntry,
+ [&] (fw::Strategy& strategy) { strategy.beforeSatisfyInterest(pitEntry, FaceEndpoint(*m_csFace, 0), data); });
+
// dispatch to strategy: after Content Store hit
this->dispatchToStrategy(*pitEntry,
[&] (fw::Strategy& strategy) { strategy.afterContentStoreHit(pitEntry, ingress, data); });
@@ -246,6 +255,10 @@
NFD_LOG_DEBUG("onInterestFinalize interest=" << pitEntry->getName()
<< (pitEntry->isSatisfied ? " satisfied" : " unsatisfied"));
+ if (!pitEntry->isSatisfied) {
+ beforeExpirePendingInterest(*pitEntry);
+ }
+
// Dead Nonce List insert if necessary
this->insertDeadNonceList(*pitEntry, nullptr);
@@ -299,6 +312,7 @@
// set PIT expiry timer to now
this->setExpiryTimer(pitEntry, 0_ms);
+ beforeSatisfyInterest(*pitEntry, ingress.face, data);
// trigger strategy: after receive Data
this->dispatchToStrategy(*pitEntry,
[&] (fw::Strategy& strategy) { strategy.afterReceiveData(pitEntry, ingress, data); });
@@ -333,6 +347,7 @@
this->setExpiryTimer(pitEntry, 0_ms);
// invoke PIT satisfy callback
+ beforeSatisfyInterest(*pitEntry, ingress.face, data);
this->dispatchToStrategy(*pitEntry,
[&] (fw::Strategy& strategy) { strategy.beforeSatisfyInterest(pitEntry, ingress, data); });