bug 1912: avoid multiple MacTxMiddle instances
authorl.salameh@cs.ucl.ac.uk
Thu, 29 May 2014 22:51:05 -0700
changeset 10792 75d257577104
parent 10791 9b29bb9d495b
child 10793 378318e42625
bug 1912: avoid multiple MacTxMiddle instances
src/wifi/model/ap-wifi-mac.cc
src/wifi/model/dca-txop.cc
src/wifi/model/dca-txop.h
src/wifi/model/regular-wifi-mac.cc
--- a/src/wifi/model/ap-wifi-mac.cc	Thu May 29 21:37:33 2014 +0200
+++ b/src/wifi/model/ap-wifi-mac.cc	Thu May 29 22:51:05 2014 -0700
@@ -81,6 +81,7 @@
   m_beaconDca->SetMaxCw (0);
   m_beaconDca->SetLow (m_low);
   m_beaconDca->SetManager (m_dcfManager);
+  m_beaconDca->SetTxMiddle (m_txMiddle);
 
   // Let the lower layers know that we are acting as an AP.
   SetTypeOfStation (AP);
--- a/src/wifi/model/dca-txop.cc	Thu May 29 21:37:33 2014 +0200
+++ b/src/wifi/model/dca-txop.cc	Thu May 29 22:51:05 2014 -0700
@@ -145,7 +145,6 @@
   m_dcf = new DcaTxop::Dcf (this);
   m_queue = CreateObject<WifiMacQueue> ();
   m_rng = new RealRandomStream ();
-  m_txMiddle = new MacTxMiddle ();
 }
 
 DcaTxop::~DcaTxop ()
@@ -163,7 +162,6 @@
   delete m_transmissionListener;
   delete m_dcf;
   delete m_rng;
-  delete m_txMiddle;
   m_transmissionListener = 0;
   m_dcf = 0;
   m_rng = 0;
@@ -178,6 +176,11 @@
   m_manager->Add (m_dcf);
 }
 
+void DcaTxop::SetTxMiddle (MacTxMiddle *txMiddle)
+{
+  m_txMiddle = txMiddle;
+}
+
 void
 DcaTxop::SetLow (Ptr<MacLow> low)
 {
--- a/src/wifi/model/dca-txop.h	Thu May 29 21:37:33 2014 +0200
+++ b/src/wifi/model/dca-txop.h	Thu May 29 22:51:05 2014 -0700
@@ -101,6 +101,12 @@
    * \param remoteManager WifiRemoteStationManager
    */
   void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager);
+  /**
+   * Set MacTxMiddle this DcaTxop is associated to.
+   *
+   * \param txMiddle MacTxMiddle
+   */
+  void SetTxMiddle (MacTxMiddle *txMiddle);
 
   /**
    * \param callback the callback to invoke when a
--- a/src/wifi/model/regular-wifi-mac.cc	Thu May 29 21:37:33 2014 +0200
+++ b/src/wifi/model/regular-wifi-mac.cc	Thu May 29 22:51:05 2014 -0700
@@ -57,6 +57,7 @@
   m_dca = CreateObject<DcaTxop> ();
   m_dca->SetLow (m_low);
   m_dca->SetManager (m_dcfManager);
+  m_dca->SetTxMiddle(m_txMiddle);
   m_dca->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this));
   m_dca->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this));