diff --git a/src/devices/p2p/p2p-net-device.cc b/src/devices/p2p/p2p-net-device.cc index cb3b930bc..c37b946da 100644 --- a/src/devices/p2p/p2p-net-device.cc +++ b/src/devices/p2p/p2p-net-device.cc @@ -106,6 +106,16 @@ PointToPointNetDevice::PointToPointNetDevice (const PointToPointNetDevice& nd) } +void PointToPointNetDevice::Dispose() +{ + if (m_channel != 0) + { + m_channel->Unref (); + m_channel = 0; + } + NetDevice::Dispose (); +} + // // Assignment operator for PointToPointNetDevice. // @@ -357,6 +367,7 @@ PointToPointNetDevice::GetQueue(void) const Channel* PointToPointNetDevice::DoGetChannel(void) const { + m_channel->Ref(); return m_channel; } diff --git a/src/devices/p2p/p2p-net-device.h b/src/devices/p2p/p2p-net-device.h index 12f02530a..ecf35510d 100644 --- a/src/devices/p2p/p2p-net-device.h +++ b/src/devices/p2p/p2p-net-device.h @@ -96,6 +96,10 @@ public: * This is the destructor for the PointToPointNetDevice. */ virtual ~PointToPointNetDevice(); + /** + *Dispose method for refcounting + */ + virtual void Dispose(); /** * Assignment Operator for a PointToPointNetDevice * diff --git a/src/node/internet-node.cc b/src/node/internet-node.cc index b4f5055aa..edcdcdcab 100644 --- a/src/node/internet-node.cc +++ b/src/node/internet-node.cc @@ -106,6 +106,12 @@ InternetNode::CreateTraceResolver (TraceContext const &context) return resolver; } +void InternetNode::Dispose() +{ + for(uint32_t i=0;iDispose(); + +} ApplicationList* InternetNode::GetApplicationList() const diff --git a/src/node/internet-node.h b/src/node/internet-node.h index ad117be71..c9e6e286b 100644 --- a/src/node/internet-node.h +++ b/src/node/internet-node.h @@ -47,6 +47,7 @@ public: virtual ~InternetNode (); virtual InternetNode* Copy() const; virtual TraceResolver *CreateTraceResolver (TraceContext const &context); + virtual void Dispose(); // Capability access virtual ApplicationList* GetApplicationList() const; virtual L3Demux* GetL3Demux() const; diff --git a/src/node/net-device.cc b/src/node/net-device.cc index d520ff7ce..11c22cece 100644 --- a/src/node/net-device.cc +++ b/src/node/net-device.cc @@ -25,6 +25,7 @@ #include "net-device.h" #include "llc-snap-header.h" #include "node.h" +#include "ns3/channel.h" namespace ns3 { @@ -225,4 +226,9 @@ NetDevice::SetReceiveCallback (Callback cb); + + virtual void Dispose(); protected: /** diff --git a/src/node/node.cc b/src/node/node.cc index 2e34fb8d5..825b0620d 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -87,6 +87,10 @@ Node::GetNDevices (void) const return m_devices.size (); } +void Node::Dispose() +{ +} + // Node stack creation and management routines. Node* Node::Create() { diff --git a/src/node/node.h b/src/node/node.h index b48ab43af..e2d728493 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -122,6 +122,8 @@ public: uint32_t AddDevice (NetDevice *device); NetDevice *GetDevice (uint32_t index) const; uint32_t GetNDevices (void) const; + + virtual void Dispose(); private: virtual void DoAddDevice (NetDevice *device) const = 0;