fw: NccStrategy

refs #1242

Change-Id: I21f870728b7b361547adbde9d64357c93aeb1ed9
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index 7a719df..2d016ca 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -33,6 +33,38 @@
   return m_outRecords;
 }
 
+static inline bool
+predicate_FaceRecord_Face(const FaceRecord& faceRecord, shared_ptr<Face> face)
+{
+  return faceRecord.getFace() == face;
+}
+
+static inline bool
+predicate_FaceRecord_ne_Face_and_unexpired(const FaceRecord& faceRecord,
+  shared_ptr<Face> face, time::Point now)
+{
+  return faceRecord.getFace() != face && faceRecord.getExpiry() >= now;
+}
+
+bool
+Entry::canForwardTo(shared_ptr<Face> face) const
+{
+  OutRecordCollection::const_iterator outIt = std::find_if(
+    m_outRecords.begin(), m_outRecords.end(),
+    bind(&predicate_FaceRecord_Face, _1, face));
+  bool hasUnexpiredOutRecord = outIt != m_outRecords.end() &&
+                               outIt->getExpiry() >= time::now();
+  if (hasUnexpiredOutRecord) {
+    return false;
+  }
+  
+  InRecordCollection::const_iterator inIt = std::find_if(
+    m_inRecords.begin(), m_inRecords.end(),
+    bind(&predicate_FaceRecord_ne_Face_and_unexpired, _1, face, time::now()));
+  bool hasUnexpiredOtherInRecord = inIt != m_inRecords.end();
+  return hasUnexpiredOtherInRecord;
+}
+
 bool
 Entry::addNonce(uint32_t nonce)
 {
@@ -42,12 +74,6 @@
   return insertResult.second;
 }
 
-static inline bool
-predicate_FaceRecord_Face(const FaceRecord& faceRecord, shared_ptr<Face> face)
-{
-  return faceRecord.getFace() == face;
-}
-
 InRecordCollection::iterator
 Entry::insertOrUpdateInRecord(shared_ptr<Face> face, const Interest& interest)
 {