fw: make strategies understand scope

refs #1253

Change-Id: I57f7a6008e6f08c9817e58f480020eb9219a4aec
diff --git a/daemon/fw/best-route-strategy.cpp b/daemon/fw/best-route-strategy.cpp
index 8f87270..ac865d0 100644
--- a/daemon/fw/best-route-strategy.cpp
+++ b/daemon/fw/best-route-strategy.cpp
@@ -20,19 +20,34 @@
 {
 }
 
+static inline bool
+predicate_PitEntry_canForwardTo_NextHop(shared_ptr<pit::Entry> pitEntry,
+                                        const fib::NextHop& nexthop)
+{
+  return pitEntry->canForwardTo(*nexthop.getFace());
+}
+
 void
 BestRouteStrategy::afterReceiveInterest(const Face& inFace,
                    const Interest& interest,
                    shared_ptr<fib::Entry> fibEntry,
                    shared_ptr<pit::Entry> pitEntry)
 {
+  if (pitEntry->hasUnexpiredOutRecords()) {
+    // not a new Interest, don't forward
+    return;
+  }
+
   const fib::NextHopList& nexthops = fibEntry->getNextHops();
-  if (nexthops.size() == 0) {
+  fib::NextHopList::const_iterator it = std::find_if(nexthops.begin(), nexthops.end(),
+    bind(&predicate_PitEntry_canForwardTo_NextHop, pitEntry, _1));
+
+  if (it == nexthops.end()) {
     this->rejectPendingInterest(pitEntry);
     return;
   }
-  
-  shared_ptr<Face> outFace = nexthops.begin()->getFace();
+
+  shared_ptr<Face> outFace = it->getFace();
   this->sendInterest(pitEntry, outFace);
 }