fw: make strategies understand scope

refs #1253

Change-Id: I57f7a6008e6f08c9817e58f480020eb9219a4aec
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index a723a17..4ab852e 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -13,9 +13,7 @@
 
 using fw::Strategy;
 
-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)
@@ -35,9 +33,6 @@
   NFD_LOG_DEBUG("onIncomingInterest face=" << inFace.getId() <<
                 " interest=" << interest.getName());
   const_cast<Interest&>(interest).setIncomingFaceId(inFace.getId());
-  if (interest.getInterestLifetime() < 0) {
-    const_cast<Interest&>(interest).setInterestLifetime(DEFAULT_INTEREST_LIFETIME);
-  }
   m_counters.getInInterest() ++;
 
   // /localhost scope control
@@ -132,22 +127,10 @@
   NFD_LOG_DEBUG("onOutgoingInterest face=" << outFace.getId() <<
                 " interest=" << pitEntry->getName());
 
-  // /localhost scope control
-  bool isViolatingLocalhost = !outFace.isLocal() &&
-                              LOCALHOST_NAME.isPrefixOf(pitEntry->getName());
-  if (isViolatingLocalhost) {
+  // scope control
+  if (pitEntry->violatesScope(outFace)) {
     NFD_LOG_DEBUG("onOutgoingInterest face=" << outFace.getId() <<
-                  " interest=" << pitEntry->getName() << " violates /localhost");
-    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");
+                  " interest=" << pitEntry->getName() << " violates scope");
     return;
   }
 
@@ -323,6 +306,12 @@
 void
 Forwarder::setStragglerTimer(shared_ptr<pit::Entry> pitEntry)
 {
+  if (pitEntry->hasUnexpiredOutRecords()) {
+    NFD_LOG_DEBUG("setStragglerTimer " << pitEntry->getName() <<
+                  " cannot set StragglerTimer when an OutRecord is pending");
+    return;
+  }
+
   time::Duration stragglerTime = time::milliseconds(100);
 
   pitEntry->m_stragglerTimer = scheduler::schedule(stragglerTime,