From 92d65a529f435629969df7ca5667d390b0ed82b0 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 31 Oct 2007 12:05:25 +0100 Subject: [PATCH] derive WifiPhy from Object and manage it with a Ptr<> --- src/devices/wifi/dca-txop.cc | 2 +- src/devices/wifi/dca-txop.h | 2 +- src/devices/wifi/mac-high-adhoc.cc | 6 ++++-- src/devices/wifi/mac-high-adhoc.h | 4 ++-- src/devices/wifi/mac-high-nqap.cc | 6 ++++-- src/devices/wifi/mac-high-nqap.h | 4 ++-- src/devices/wifi/mac-high-nqsta.cc | 6 ++++-- src/devices/wifi/mac-high-nqsta.h | 4 ++-- src/devices/wifi/mac-low.cc | 3 ++- src/devices/wifi/mac-low.h | 4 ++-- src/devices/wifi/wifi-net-device.cc | 5 ++--- src/devices/wifi/wifi-net-device.h | 2 +- src/devices/wifi/wifi-phy.h | 3 ++- 13 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/devices/wifi/dca-txop.cc b/src/devices/wifi/dca-txop.cc index 3d29bf1ff..f18bc3522 100644 --- a/src/devices/wifi/dca-txop.cc +++ b/src/devices/wifi/dca-txop.cc @@ -165,7 +165,7 @@ DcaTxop::SetLow (MacLow *low) m_low->RegisterNavListener (m_navListener); } void -DcaTxop::SetPhy (WifiPhy *phy) +DcaTxop::SetPhy (Ptr phy) { m_phyListener = new DcaTxop::PhyListener (m_dcf); phy->RegisterListener (m_phyListener); diff --git a/src/devices/wifi/dca-txop.h b/src/devices/wifi/dca-txop.h index 19289e262..a4e3cf07f 100644 --- a/src/devices/wifi/dca-txop.h +++ b/src/devices/wifi/dca-txop.h @@ -48,7 +48,7 @@ public: ~DcaTxop (); void SetLow (MacLow *low); - void SetPhy (WifiPhy *phy); + void SetPhy (Ptr phy); void SetParameters (MacParameters *parameters); void SetTxMiddle (MacTxMiddle *txMiddle); void SetTxOkCallback (TxOk callback); diff --git a/src/devices/wifi/mac-high-adhoc.cc b/src/devices/wifi/mac-high-adhoc.cc index 2edd56a3b..46e525935 100644 --- a/src/devices/wifi/mac-high-adhoc.cc +++ b/src/devices/wifi/mac-high-adhoc.cc @@ -33,7 +33,9 @@ namespace ns3 { MacHighAdhoc::MacHighAdhoc () {} MacHighAdhoc::~MacHighAdhoc () -{} +{ + m_phy = 0; +} void MacHighAdhoc::SetDevice (WifiNetDevice *device) @@ -57,7 +59,7 @@ MacHighAdhoc::SetStations (MacStations *stations) m_stations = stations; } void -MacHighAdhoc::SetPhy (WifiPhy *phy) +MacHighAdhoc::SetPhy (Ptr phy) { m_phy = phy; } diff --git a/src/devices/wifi/mac-high-adhoc.h b/src/devices/wifi/mac-high-adhoc.h index 7c84368e3..b6e41e23c 100644 --- a/src/devices/wifi/mac-high-adhoc.h +++ b/src/devices/wifi/mac-high-adhoc.h @@ -44,7 +44,7 @@ public: void SetForwardCallback (ForwardCallback callback); void SetDcaTxop (DcaTxop *dca); void SetStations (MacStations *stations); - void SetPhy (WifiPhy *phy); + void SetPhy (Ptr phy); Mac48Address GetBssid (void) const; @@ -57,7 +57,7 @@ private: WifiNetDevice *m_device; ForwardCallback m_callback; MacStations *m_stations; - WifiPhy *m_phy; + Ptr m_phy; }; } // namespace ns3 diff --git a/src/devices/wifi/mac-high-nqap.cc b/src/devices/wifi/mac-high-nqap.cc index e236c5509..54988df1b 100644 --- a/src/devices/wifi/mac-high-nqap.cc +++ b/src/devices/wifi/mac-high-nqap.cc @@ -39,7 +39,9 @@ MacHighNqap::MacHighNqap () : m_beaconIntervalUs (500000) {} MacHighNqap::~MacHighNqap () -{} +{ + m_phy = 0; +} void MacHighNqap::SetDcaTxop (DcaTxop *dca) @@ -59,7 +61,7 @@ MacHighNqap::SetStations (MacStations *stations) m_stations = stations; } void -MacHighNqap::SetPhy (WifiPhy *phy) +MacHighNqap::SetPhy (Ptr phy) { m_phy = phy; } diff --git a/src/devices/wifi/mac-high-nqap.h b/src/devices/wifi/mac-high-nqap.h index 289f850c8..18d792dd0 100644 --- a/src/devices/wifi/mac-high-nqap.h +++ b/src/devices/wifi/mac-high-nqap.h @@ -44,7 +44,7 @@ public: void SetDcaTxop (DcaTxop *dca); void SetDevice (WifiNetDevice *device); void SetStations (MacStations *stations); - void SetPhy (WifiPhy *phy); + void SetPhy (Ptr phy); void SetForwardCallback (ForwardCallback callback); void SetBeaconIntervalUs (uint64_t us); @@ -62,7 +62,7 @@ private: DcaTxop *m_dca; WifiNetDevice *m_device; MacStations *m_stations; - WifiPhy *m_phy; + Ptr m_phy; ForwardCallback m_forwardUp; uint64_t m_beaconIntervalUs; }; diff --git a/src/devices/wifi/mac-high-nqsta.cc b/src/devices/wifi/mac-high-nqsta.cc index 65876851a..83f1e7a0f 100644 --- a/src/devices/wifi/mac-high-nqsta.cc +++ b/src/devices/wifi/mac-high-nqsta.cc @@ -69,7 +69,9 @@ MacHighNqsta::MacHighNqsta () } MacHighNqsta::~MacHighNqsta () -{} +{ + m_phy = 0; +} void MacHighNqsta::SetDcaTxop (DcaTxop *dca) @@ -97,7 +99,7 @@ MacHighNqsta::SetDisAssociatedCallback (DisAssociatedCallback callback) m_disAssociatedCallback = callback; } void -MacHighNqsta::SetPhy (WifiPhy *phy) +MacHighNqsta::SetPhy (Ptr phy) { m_phy = phy; } diff --git a/src/devices/wifi/mac-high-nqsta.h b/src/devices/wifi/mac-high-nqsta.h index 54a6502f6..1b860c4ea 100644 --- a/src/devices/wifi/mac-high-nqsta.h +++ b/src/devices/wifi/mac-high-nqsta.h @@ -52,7 +52,7 @@ public: void SetForwardCallback (ForwardCallback callback); void SetAssociatedCallback (AssociatedCallback callback); void SetDisAssociatedCallback (DisAssociatedCallback callback); - void SetPhy (WifiPhy *phy); + void SetPhy (Ptr phy); void SetStations (MacStations *stations); void SetMaxMissedBeacons (uint32_t missed); @@ -98,7 +98,7 @@ private: Time m_beaconWatchdogEnd; Mac48Address m_bssid; uint32_t m_maxMissedBeacons; - WifiPhy *m_phy; + Ptr m_phy; MacStations *m_stations; }; diff --git a/src/devices/wifi/mac-low.cc b/src/devices/wifi/mac-low.cc index b38b3a696..6a1edf8be 100644 --- a/src/devices/wifi/mac-low.cc +++ b/src/devices/wifi/mac-low.cc @@ -237,6 +237,7 @@ MacLow::MacLow () MacLow::~MacLow () { CancelAllEvents (); + m_phy = 0; } void @@ -304,7 +305,7 @@ MacLow::SetDevice (Ptr device) m_device = device; } void -MacLow::SetPhy (WifiPhy *phy) +MacLow::SetPhy (Ptr phy) { m_phy = phy; } diff --git a/src/devices/wifi/mac-low.h b/src/devices/wifi/mac-low.h index 6656d5baf..aa0948d31 100644 --- a/src/devices/wifi/mac-low.h +++ b/src/devices/wifi/mac-low.h @@ -152,7 +152,7 @@ public: ~MacLow (); void SetDevice (Ptr device); - void SetPhy (WifiPhy *phy); + void SetPhy (Ptr phy); void SetStations (MacStations *stations); void SetParameters (MacParameters *parameters); void SetRxCallback (MacLowRxCallback callback); @@ -216,7 +216,7 @@ private: void StartDataTxTimers (void); Ptr m_device; - WifiPhy *m_phy; + Ptr m_phy; MacStations *m_stations; MacParameters *m_parameters; MacLowRxCallback m_rxCallback; diff --git a/src/devices/wifi/wifi-net-device.cc b/src/devices/wifi/wifi-net-device.cc index 42627a449..203360241 100644 --- a/src/devices/wifi/wifi-net-device.cc +++ b/src/devices/wifi/wifi-net-device.cc @@ -81,7 +81,7 @@ WifiNetDeviceTraceType::GetTypeName (void) const static WifiMode -GetWifiModeForPhyMode (WifiPhy *phy, enum WifiDefaultParameters::PhyModeParameter mode) +GetWifiModeForPhyMode (Ptr phy, enum WifiDefaultParameters::PhyModeParameter mode) { uint32_t phyRate = (uint32_t)mode; for (uint32_t i= 0; i < phy->GetNModes (); i++) @@ -112,7 +112,7 @@ void WifiNetDevice::Construct (void) { // the physical layer. - m_phy = new WifiPhy (this); + m_phy = Create (this); // the rate control algorithm switch (WifiDefaultParameters::GetRateControlAlgorithm ()) { @@ -282,7 +282,6 @@ WifiNetDevice::DoDispose (void) NetDevice::DoDispose (); // cleanup local m_channel = 0; - delete m_phy; delete m_stations; delete m_low; delete m_rxMiddle; diff --git a/src/devices/wifi/wifi-net-device.h b/src/devices/wifi/wifi-net-device.h index 3b5678b1a..fba7b0ace 100644 --- a/src/devices/wifi/wifi-net-device.h +++ b/src/devices/wifi/wifi-net-device.h @@ -120,7 +120,7 @@ protected: DcaTxop *CreateDca (uint32_t minCw, uint32_t maxCw) const; Ptr m_channel; - WifiPhy *m_phy; + Ptr m_phy; MacStations *m_stations; MacLow *m_low; MacRxMiddle *m_rxMiddle; diff --git a/src/devices/wifi/wifi-phy.h b/src/devices/wifi/wifi-phy.h index 6aacef323..ccf3cc43c 100644 --- a/src/devices/wifi/wifi-phy.h +++ b/src/devices/wifi/wifi-phy.h @@ -27,6 +27,7 @@ #include "ns3/callback.h" #include "ns3/event-id.h" #include "ns3/packet.h" +#include "ns3/object.h" #include "ns3/callback-trace-source.h" #include "ns3/nstime.h" #include "ns3/ptr.h" @@ -68,7 +69,7 @@ public: -class WifiPhy +class WifiPhy : public Object { public: typedef Callback SyncOkCallback;