model: Removing more legacy code and make code to compile
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index 07d38f3..4ea8189 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -32,11 +32,7 @@
#include "ns3/simulator.h"
#include "ns3/random-variable.h"
-#include "ns3/ndn-pit.hpp"
-
-#include "ns3/ndn-face.hpp"
-#include "ns3/ndn-forwarding-strategy.hpp"
-
+#include "ndn-face.hpp"
#include "ndn-net-device-face.hpp"
#include <boost/foreach.hpp>
@@ -59,14 +55,14 @@
.SetGroupName("ndn")
.SetParent<Object>()
.AddConstructor<L3Protocol>()
- .AddAttribute("FaceList", "List of faces associated with ndn stack", ObjectVectorValue(),
- MakeObjectVectorAccessor(&L3Protocol::m_faces),
- MakeObjectVectorChecker<Face>());
+ ;
+ // .AddAttribute("FaceList", "List of faces associated with ndn stack", ObjectVectorValue(),
+ // MakeObjectVectorAccessor(&L3Protocol::m_faces),
+ // MakeObjectVectorChecker<Face>());
return tid;
}
L3Protocol::L3Protocol()
- : m_faceCounter(0)
{
NS_LOG_FUNCTION(this);
}
@@ -87,15 +83,10 @@
if (m_node == 0) {
m_node = GetObject<Node>();
if (m_node != 0) {
- NS_ASSERT_MSG(m_forwardingStrategy != 0,
- "Forwarding strategy should be aggregated before L3Protocol");
}
}
- if (m_forwardingStrategy == 0) {
- m_forwardingStrategy = GetObject<ForwardingStrategy>();
- }
- Object::NotifyNewAggregate();
+ Object::NotifyNewAggregate ();
}
void
@@ -103,112 +94,47 @@
{
NS_LOG_FUNCTION(this);
- // for (FaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
- // {
- // *i = 0;
- // }
- m_faces.clear();
m_node = 0;
- // Force delete on objects
- m_forwardingStrategy = 0; // there is a reference to PIT stored in here
-
Object::DoDispose();
}
uint32_t
-L3Protocol::AddFace(const Ptr<Face>& face)
+L3Protocol::AddFace(const shared_ptr<Face>& face)
{
NS_LOG_FUNCTION(this << &face);
- face->SetId(
- m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
-
- // ask face to register in lower-layer stack
- face->RegisterProtocolHandlers(MakeCallback(&ForwardingStrategy::OnInterest,
- m_forwardingStrategy),
- MakeCallback(&ForwardingStrategy::OnData, m_forwardingStrategy));
-
- m_faces.push_back(face);
- m_faceCounter++;
-
- m_forwardingStrategy->AddFace(face); // notify that face is added
- return face->GetId();
+ return 0;
}
void
-L3Protocol::RemoveFace(Ptr<Face> face)
+L3Protocol::RemoveFace(shared_ptr<Face> face)
{
- NS_LOG_FUNCTION(this << boost::cref(*face));
- // ask face to register in lower-layer stack
- face->UnRegisterProtocolHandlers();
- Ptr<Pit> pit = GetObject<Pit>();
-
- // just to be on a safe side. Do the process in two steps
- std::list<Ptr<pit::Entry>> entriesToRemoves;
- for (Ptr<pit::Entry> pitEntry = pit->Begin(); pitEntry != 0; pitEntry = pit->Next(pitEntry)) {
- pitEntry->RemoveAllReferencesToFace(face);
-
- // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
- // Thus, we have to remove the whole PIT entry
- if (pitEntry->GetFibEntry()->m_faces.size() == 1
- && pitEntry->GetFibEntry()->m_faces.begin()->GetFace() == face) {
- entriesToRemoves.push_back(pitEntry);
- }
- }
- BOOST_FOREACH (Ptr<pit::Entry> removedEntry, entriesToRemoves) {
- pit->MarkErased(removedEntry);
- }
-
- FaceList::iterator face_it = find(m_faces.begin(), m_faces.end(), face);
- if (face_it == m_faces.end()) {
- return;
- }
- m_faces.erase(face_it);
-
- GetObject<Fib>()->RemoveFromAll(face);
- m_forwardingStrategy->RemoveFace(face); // notify that face is removed
+ NS_LOG_FUNCTION(this << std::cref(*face));
}
-Ptr<Face>
+shared_ptr<Face>
L3Protocol::GetFace(uint32_t index) const
{
- NS_ASSERT(0 <= index && index < m_faces.size());
- return m_faces[index];
+ return nullptr;
}
-Ptr<Face>
+shared_ptr<Face>
L3Protocol::GetFaceById(uint32_t index) const
{
- BOOST_FOREACH (const Ptr<Face>& face, m_faces) // this function is not supposed to be called
- // often, so linear search is fine
- {
- if (face->GetId() == index)
- return face;
- }
- return 0;
+ return nullptr;
}
-Ptr<Face>
+shared_ptr<Face>
L3Protocol::GetFaceByNetDevice(Ptr<NetDevice> netDevice) const
{
- BOOST_FOREACH (const Ptr<Face>& face, m_faces) // this function is not supposed to be called
- // often, so linear search is fine
- {
- Ptr<NetDeviceFace> netDeviceFace = DynamicCast<NetDeviceFace>(face);
- if (netDeviceFace == 0)
- continue;
-
- if (netDeviceFace->GetNetDevice() == netDevice)
- return face;
- }
- return 0;
+ return nullptr;
}
uint32_t
L3Protocol::GetNFaces(void) const
{
- return m_faces.size();
+ return 0;
}
} // namespace ndn