helper+model: Create helper to select the replacement policy of NFD's CS
Change-Id: I10933b5c96fd95bc395a1d08642a1e07e826dc45
Refs: #3837
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index 33e0113..e8f7ccc 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -179,6 +179,7 @@
nfd::ConfigSection m_config;
Ptr<ContentStore> m_csFromNdnSim;
+ PolicyCreationCallback m_policy;
};
L3Protocol::L3Protocol()
@@ -239,6 +240,12 @@
}
void
+L3Protocol::setCsReplacementPolicy(const PolicyCreationCallback& policy)
+{
+ m_impl->m_policy = policy;
+}
+
+void
L3Protocol::initializeManagement()
{
auto& forwarder = m_impl->m_forwarder;
@@ -280,6 +287,12 @@
ConfigFile config(&ConfigFile::ignoreUnknownSection);
+ // if we use NFD's CS, we have to specify a replacement policy
+ m_impl->m_csFromNdnSim = GetObject<ContentStore>();
+ if (m_impl->m_csFromNdnSim == nullptr) {
+ forwarder->getCs().setPolicy(m_impl->m_policy());
+ }
+
TablesConfigSection tablesConfig(forwarder->getCs(),
forwarder->getPit(),
forwarder->getFib(),
diff --git a/model/ndn-l3-protocol.hpp b/model/ndn-l3-protocol.hpp
index a34d36f..cca0277 100644
--- a/model/ndn-l3-protocol.hpp
+++ b/model/ndn-l3-protocol.hpp
@@ -40,6 +40,9 @@
namespace pit {
class Entry;
} // namespace pit
+namespace cs {
+class Policy;
+} // namespace cs
} // namespace nfd
namespace ns3 {
@@ -153,6 +156,14 @@
void
injectInterest(const Interest& interest);
+ typedef std::function<std::unique_ptr<nfd::cs::Policy>()> PolicyCreationCallback;
+
+ /**
+ * \brief Set the replacement policy of NFD's CS
+ */
+ void
+ setCsReplacementPolicy(const PolicyCreationCallback& policy);
+
public: // Workaround for python bindings
static Ptr<L3Protocol>
getL3Protocol(Ptr<Object> node);