From 60c71ef6c41d232defed056735a3591ac2aa61fc Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Wed, 18 Jan 2012 17:04:01 +0100 Subject: [PATCH] fixed valgrind errors of epc-s1u tests --- src/lte/helper/epc-helper.cc | 23 ++++++++++++++++------- src/lte/helper/epc-helper.h | 4 +++- src/lte/model/epc-sgw-pgw-application.cc | 7 +++++++ src/lte/model/epc-sgw-pgw-application.h | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/lte/helper/epc-helper.cc b/src/lte/helper/epc-helper.cc index c6b4ed97c..9abdc77cb 100644 --- a/src/lte/helper/epc-helper.cc +++ b/src/lte/helper/epc-helper.cc @@ -64,16 +64,16 @@ EpcHelper::EpcHelper () NS_ASSERT (retval == 0); // create TUN device implementing tunneling of user data over GTP-U/UDP/IP - Ptr tunDevice = CreateObject (); + m_tunDevice = CreateObject (); // allow jumbo packets - tunDevice->SetAttribute ("Mtu", UintegerValue (30000)); + m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000)); // yes we need this - tunDevice->SetAddress (Mac48Address::Allocate ()); + m_tunDevice->SetAddress (Mac48Address::Allocate ()); - m_sgwPgw->AddDevice (tunDevice); + m_sgwPgw->AddDevice (m_tunDevice); NetDeviceContainer tunDeviceContainer; - tunDeviceContainer.Add (tunDevice); + tunDeviceContainer.Add (m_tunDevice); // the TUN device is on the same subnet as the UEs, so when a packet // addressed to an UE arrives at the intenet to the WAN interface of @@ -81,11 +81,11 @@ EpcHelper::EpcHelper () Ipv4InterfaceContainer tunDeviceIpv4IfContainer = m_ueAddressHelper.Assign (tunDeviceContainer); // create EpcSgwPgwApplication - m_sgwPgwApp = CreateObject (tunDevice, sgwPgwS1uSocket); + m_sgwPgwApp = CreateObject (m_tunDevice, sgwPgwS1uSocket); m_sgwPgw->AddApplication (m_sgwPgwApp); // connect SgwPgwApplication and virtual net device for tunneling - tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp)); + m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp)); } @@ -119,6 +119,15 @@ EpcHelper::GetTypeId (void) return tid; } +void +EpcHelper::DoDispose () +{ + m_tunDevice->SetSendCallback (MakeNullCallback, const Address&, const Address&, uint16_t> ()); + m_tunDevice = 0; + m_sgwPgwApp = 0; + m_sgwPgw->Dispose (); +} + void EpcHelper::AddEnb (Ptr enb, Ptr lteEnbNetDevice) diff --git a/src/lte/helper/epc-helper.h b/src/lte/helper/epc-helper.h index 5cde2b006..7eae00b7d 100644 --- a/src/lte/helper/epc-helper.h +++ b/src/lte/helper/epc-helper.h @@ -32,6 +32,7 @@ namespace ns3 { class Node; class NetDevice; +class VirtualNetDevice; class EpcSgwPgwApplication; /** @@ -58,6 +59,7 @@ public: // inherited from Object static TypeId GetTypeId (void); + virtual void DoDispose (); /** @@ -126,8 +128,8 @@ private: Ipv4AddressHelper m_ueAddressHelper; Ptr m_sgwPgw; - Ptr m_sgwPgwApp; + Ptr m_tunDevice; DataRate m_s1uLinkDataRate; Time m_s1uLinkDelay; diff --git a/src/lte/model/epc-sgw-pgw-application.cc b/src/lte/model/epc-sgw-pgw-application.cc index 02f0a1aa8..c469b53c6 100644 --- a/src/lte/model/epc-sgw-pgw-application.cc +++ b/src/lte/model/epc-sgw-pgw-application.cc @@ -85,6 +85,13 @@ EpcSgwPgwApplication::GetTypeId (void) return tid; } +void +EpcSgwPgwApplication::DoDispose () +{ + m_s1uSocket->SetRecvCallback (MakeNullCallback > ()); + m_s1uSocket = 0; +} + EpcSgwPgwApplication::EpcSgwPgwApplication (const Ptr tunDevice, const Ptr s1uSocket) diff --git a/src/lte/model/epc-sgw-pgw-application.h b/src/lte/model/epc-sgw-pgw-application.h index 3fdd1ea53..4f12bf85b 100644 --- a/src/lte/model/epc-sgw-pgw-application.h +++ b/src/lte/model/epc-sgw-pgw-application.h @@ -51,6 +51,7 @@ public: // inherited from Object static TypeId GetTypeId (void); + virtual void DoDispose (); /** * Constructor that binds the tap device to the callback methods.