fw: UnsolicitedDataPolicy

The decision of whether to cache or drop an unsolicited Data is moved from
Data unsolicited pipeline to UnsolicitedDataPolicy.

refs #2181

Change-Id: Iba3e72c2214e0ac5f6f305c2c1c0ed182b008e85
This commit is contained in:
Junxiao Shi
2016-08-22 16:02:30 +00:00
parent 2e526d70d2
commit fbe8efea55
4 changed files with 145 additions and 8 deletions
+5 -6
View File
@@ -35,10 +35,9 @@ namespace nfd {
NFD_LOG_INIT("Forwarder");
using fw::Strategy;
Forwarder::Forwarder()
: m_fib(m_nameTree)
: m_unsolicitedDataPolicy(new fw::AdmitLocalUnsolicitedDataPolicy())
, m_fib(m_nameTree)
, m_pit(m_nameTree)
, m_measurements(m_nameTree)
, m_strategyChoice(m_nameTree, fw::makeDefaultStrategy(*this))
@@ -389,15 +388,15 @@ void
Forwarder::onDataUnsolicited(Face& inFace, const Data& data)
{
// accept to cache?
bool acceptToCache = inFace.getScope() == ndn::nfd::FACE_SCOPE_LOCAL;
if (acceptToCache) {
fw::UnsolicitedDataDecision decision = m_unsolicitedDataPolicy->decide(inFace, data);
if (decision == fw::UnsolicitedDataDecision::CACHE) {
// CS insert
m_cs.insert(data, true);
}
NFD_LOG_DEBUG("onDataUnsolicited face=" << inFace.getId() <<
" data=" << data.getName() <<
(acceptToCache ? " cached" : " not cached"));
" decision=" << decision);
}
void