fw: ASF should check if FaceInfo exists before using it

refs: #3968

Change-Id: I4c20a51609dd714e6104b103a4bef63ac8761083
diff --git a/daemon/fw/asf-measurements.hpp b/daemon/fw/asf-measurements.hpp
index c6ff096..ba858df 100644
--- a/daemon/fw/asf-measurements.hpp
+++ b/daemon/fw/asf-measurements.hpp
@@ -215,10 +215,15 @@
   void
   extendFaceInfoLifetime(FaceInfo& info, const Face& face);
 
-  FaceInfo&
+  FaceInfo*
   get(nfd::face::FaceId faceId)
   {
-    return m_fit.at(faceId);
+    if (m_fit.find(faceId) != m_fit.end()) {
+      return &m_fit.at(faceId);
+    }
+    else {
+      return nullptr;
+    }
   }
 
   FaceInfoTable::iterator
diff --git a/daemon/fw/asf-strategy.cpp b/daemon/fw/asf-strategy.cpp
index 45b0d72..871ff2f 100644
--- a/daemon/fw/asf-strategy.cpp
+++ b/daemon/fw/asf-strategy.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2016,  Regents of the University of California,
+ * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -97,6 +97,8 @@
     return;
   }
 
+  NFD_LOG_TRACE("Forwarding interest to face: " << faceToUse->getId());
+
   forwardInterest(interest, fibEntry, pitEntry, *faceToUse);
 
   // If necessary, send probe
@@ -123,14 +125,17 @@
   }
 
   // Record the RTT between the Interest out to Data in
-  FaceInfo& faceInfo = namespaceInfo->get(inFace.getId());
-  faceInfo.recordRtt(pitEntry, inFace);
+  FaceInfo* faceInfo = namespaceInfo->get(inFace.getId());
+  if (faceInfo == nullptr) {
+    return;
+  }
+  faceInfo->recordRtt(pitEntry, inFace);
 
   // Extend lifetime for measurements associated with Face
-  namespaceInfo->extendFaceInfoLifetime(faceInfo, inFace);
+  namespaceInfo->extendFaceInfoLifetime(*faceInfo, inFace);
 
-  if (faceInfo.isTimeoutScheduled()) {
-    faceInfo.cancelTimeoutEvent(data.getName());
+  if (faceInfo->isTimeoutScheduled()) {
+    faceInfo->cancelTimeoutEvent(data.getName());
   }
 }