diff --git a/src/devices/wifi/wifi-net-device.cc b/src/devices/wifi/wifi-net-device.cc index 5a8fccbaf..840d635bc 100644 --- a/src/devices/wifi/wifi-net-device.cc +++ b/src/devices/wifi/wifi-net-device.cc @@ -37,19 +37,23 @@ WifiNetDevice::GetTypeId (void) .SetParent () .AddAttribute ("Channel", "XXX", Ptr (0), - MakePtrAccessor (&WifiNetDevice::GetChannel), + MakePtrAccessor (&WifiNetDevice::DoGetChannel, + &WifiNetDevice::SetChannel), MakePtrChecker ()) .AddAttribute ("Phy", "XXX", Ptr (0), - MakePtrAccessor (&WifiNetDevice::m_phy), + MakePtrAccessor (&WifiNetDevice::GetPhy, + &WifiNetDevice::SetPhy), MakePtrChecker ()) .AddAttribute ("Mac", "XXX", Ptr (0), - MakePtrAccessor (&WifiNetDevice::m_mac), + MakePtrAccessor (&WifiNetDevice::GetMac, + &WifiNetDevice::SetMac), MakePtrChecker ()) .AddAttribute ("RemoteStationManager", "XXX", Ptr (0), - MakePtrAccessor (&WifiNetDevice::m_stationManager), + MakePtrAccessor (&WifiNetDevice::SetRemoteStationManager, + &WifiNetDevice::GetRemoteStationManager), MakePtrChecker ()) .AddTraceSource ("Rx", "XXX", MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger)) @@ -84,40 +88,6 @@ void WifiNetDevice::SetMac (Ptr mac) { m_mac = mac; - Setup (); -} -void -WifiNetDevice::SetPhy (Ptr phy) -{ - m_phy = phy; - Setup (); -} -void -WifiNetDevice::SetRemoteStationManager (Ptr manager) -{ - m_stationManager = manager; - Setup (); -} -void -WifiNetDevice::SetChannel (Ptr channel) -{ - m_channel = channel; - Setup (); -} -void -WifiNetDevice::Setup (void) -{ - if (m_phy != 0 && m_channel != 0) - { - m_channel->Add (this, m_phy); - m_phy->SetChannel (m_channel); - } - - if (m_stationManager != 0 && m_phy != 0) - { - m_stationManager->SetupPhy (m_phy); - } - if (m_mac != 0) { if (m_stationManager != 0) @@ -133,6 +103,53 @@ WifiNetDevice::Setup (void) m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this)); } } +void +WifiNetDevice::SetPhy (Ptr phy) +{ + m_phy = phy; + if (m_phy != 0) + { + if (m_channel != 0) + { + m_channel->Add (this, m_phy); + m_phy->SetChannel (m_channel); + } + if (m_stationManager != 0) + { + m_stationManager->SetupPhy (m_phy); + } + if (m_mac != 0) + { + m_mac->SetWifiPhy (m_phy); + } + } +} +void +WifiNetDevice::SetRemoteStationManager (Ptr manager) +{ + m_stationManager = manager; + if (m_stationManager != 0) + { + if (m_phy != 0) + { + m_stationManager->SetupPhy (m_phy); + } + if (m_mac != 0) + { + m_mac->SetWifiRemoteStationManager (m_stationManager); + } + } +} +void +WifiNetDevice::SetChannel (Ptr channel) +{ + m_channel = channel; + if (m_channel != 0 && m_phy != 0) + { + m_channel->Add (this, m_phy); + m_phy->SetChannel (m_channel); + } +} Ptr WifiNetDevice::GetMac (void) const { @@ -174,6 +191,11 @@ WifiNetDevice::GetChannel (void) const { return m_channel; } +Ptr +WifiNetDevice::DoGetChannel (void) const +{ + return m_channel; +} Address WifiNetDevice::GetAddress (void) const { diff --git a/src/devices/wifi/wifi-net-device.h b/src/devices/wifi/wifi-net-device.h index 1f52b55f4..3483f7641 100644 --- a/src/devices/wifi/wifi-net-device.h +++ b/src/devices/wifi/wifi-net-device.h @@ -84,6 +84,7 @@ private: void LinkUp (void); void LinkDown (void); void Setup (void); + Ptr DoGetChannel (void) const; Ptr m_node; Ptr m_phy; Ptr m_channel;