helper: Extending customization of Face creating in ndn::StackHelper
diff --git a/helper/ndn-stack-helper.cc b/helper/ndn-stack-helper.cc
index c6cf1c3..e0bf401 100644
--- a/helper/ndn-stack-helper.cc
+++ b/helper/ndn-stack-helper.cc
@@ -284,6 +284,31 @@
m_netDeviceCallbacks.push_back (std::make_pair (netDeviceType, callback));
}
+void
+StackHelper::UpdateNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback)
+{
+ for (NetDeviceCallbackList::iterator i = m_netDeviceCallbacks.begin (); i != m_netDeviceCallbacks.end (); i++)
+ {
+ if (i->first == netDeviceType)
+ {
+ i->second = callback;
+ return;
+ }
+ }
+}
+
+void
+StackHelper::RemoveNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback)
+{
+ for (NetDeviceCallbackList::iterator i = m_netDeviceCallbacks.begin (); i != m_netDeviceCallbacks.end (); i++)
+ {
+ if (i->first == netDeviceType)
+ {
+ m_netDeviceCallbacks.erase (i);
+ return;
+ }
+ }
+}
Ptr<NetDeviceFace>
StackHelper::DefaultNetDeviceCallback (Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const
diff --git a/helper/ndn-stack-helper.h b/helper/ndn-stack-helper.h
index 4b26040..8303440 100644
--- a/helper/ndn-stack-helper.h
+++ b/helper/ndn-stack-helper.h
@@ -146,6 +146,22 @@
AddNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
/**
+ * @brief Update callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<NetDevice>
+ *
+ * It is possible to set up several callbacks for different NetDevice types.
+ *
+ * Using this method, it is possible to override Face creation for PointToPointNetDevices
+ */
+ void
+ UpdateNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+
+ /**
+ * @brief Remove callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<NetDevice>
+ */
+ void
+ RemoveNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+
+ /**
* @brief Enable Interest limits (disabled by default)
*
* @param enable Enable or disable limits
@@ -293,7 +309,8 @@
uint32_t m_avgInterestSize;
bool m_needSetDefaultRoutes;
- std::list< std::pair<TypeId, NetDeviceFaceCreateCallback> > m_netDeviceCallbacks;
+ typedef std::list< std::pair<TypeId, NetDeviceFaceCreateCallback> > NetDeviceCallbackList;
+ NetDeviceCallbackList m_netDeviceCallbacks;
};
} // namespace ndn