NFD: Keep both the CS of NFD and ndnSIM

Ref: #2231
diff --git a/NFD/daemon/fw/forwarder.cpp b/NFD/daemon/fw/forwarder.cpp
index 1cd1d16..4066e3f 100644
--- a/NFD/daemon/fw/forwarder.cpp
+++ b/NFD/daemon/fw/forwarder.cpp
@@ -92,7 +92,14 @@
   bool isPending = inRecords.begin() != inRecords.end();
   if (!isPending) {
     // CS lookup
-    const Data* csMatch = m_cs.find(interest);
+    const Data* csMatch;
+    shared_ptr<Data> match;
+    if (m_csFromNdnSim == nullptr)
+      csMatch = m_cs.find(interest);
+    else {
+      match = m_csFromNdnSim->Lookup(interest.shared_from_this());
+      csMatch = match.get();
+    }
     if (csMatch != 0) {
       const_cast<Data*>(csMatch)->setIncomingFaceId(FACEID_CONTENT_STORE);
       // XXX should we lookup PIT for other Interests that also match csMatch?
@@ -268,7 +275,10 @@
   }
 
   // CS insert
-  m_cs.insert(data);
+  if (m_csFromNdnSim == nullptr)
+    m_cs.insert(data);
+  else
+    m_csFromNdnSim->Add(data.shared_from_this());
 
   std::set<shared_ptr<Face> > pendingDownstreams;
   // foreach PitEntry
@@ -321,7 +331,10 @@
   bool acceptToCache = inFace.isLocal();
   if (acceptToCache) {
     // CS insert
-    m_cs.insert(data, true);
+    if (m_csFromNdnSim == nullptr)
+      m_cs.insert(data, true);
+    else
+      m_csFromNdnSim->Add(data.shared_from_this());
   }
 
   NFD_LOG_DEBUG("onDataUnsolicited face=" << inFace.getId() <<
diff --git a/NFD/daemon/fw/forwarder.hpp b/NFD/daemon/fw/forwarder.hpp
index a753f15..627148e 100644
--- a/NFD/daemon/fw/forwarder.hpp
+++ b/NFD/daemon/fw/forwarder.hpp
@@ -37,6 +37,8 @@
 #include "table/strategy-choice.hpp"
 #include "table/dead-nonce-list.hpp"
 
+#include "ns3/ndnSIM/model/cs/ndn-content-store.hpp"
+
 namespace nfd {
 
 namespace fw {
@@ -104,6 +106,10 @@
   DeadNonceList&
   getDeadNonceList();
 
+public: // allow enabling ndnSIM content store (will be removed in the future)
+  void
+  setCsFromNdnSim(ns3::Ptr<ns3::ndn::ContentStore> cs);
+
 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // pipelines
   /** \brief incoming Interest pipeline
    */
@@ -199,6 +205,8 @@
   StrategyChoice m_strategyChoice;
   DeadNonceList  m_deadNonceList;
 
+  ns3::Ptr<ns3::ndn::ContentStore> m_csFromNdnSim;
+
   static const Name LOCALHOST_NAME;
 
   // allow Strategy (base class) to enter pipelines
@@ -283,6 +291,12 @@
   return m_deadNonceList;
 }
 
+inline void
+Forwarder::setCsFromNdnSim(ns3::Ptr<ns3::ndn::ContentStore> cs)
+{
+  m_csFromNdnSim = cs;
+}
+
 #ifdef WITH_TESTS
 inline void
 Forwarder::dispatchToStrategy(shared_ptr<pit::Entry> pitEntry, function<void(fw::Strategy*)> trigger)