src/devices/wifi/wifi-net-device.cc
changeset 2601 4297e8c61615
parent 2600 6c389d0c717d
child 2602 d9262bff6df2
--- a/src/devices/wifi/wifi-net-device.cc	Thu Mar 13 11:10:38 2008 -0700
+++ b/src/devices/wifi/wifi-net-device.cc	Thu Mar 13 11:21:12 2008 -0700
@@ -80,25 +80,57 @@
 }
   
 void 
-WifiNetDevice::Setup (Ptr<Node> node, Ptr<WifiMac> mac, Ptr<WifiPhy> phy,
-                      Ptr<WifiRemoteStationManager> manager,
-                      Ptr<WifiChannel> channel)
+WifiNetDevice::SetMac (Ptr<WifiMac> mac)
+{
+  m_mac = mac;
+  Setup ();
+}
+void 
+WifiNetDevice::SetPhy (Ptr<WifiPhy> phy)
+{
+  m_phy = phy;
+  Setup ();
+}
+void 
+WifiNetDevice::SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager)
 {
-  m_node = node;
-  m_mac = mac;
-  m_phy = phy;
   m_stationManager = manager;
+  Setup ();
+}
+void 
+WifiNetDevice::SetChannel (Ptr<WifiChannel> 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);
+    }
 
-  m_stationManager->SetupPhy (m_phy);
+  if (m_stationManager != 0 && m_phy != 0)
+    {
+      m_stationManager->SetupPhy (m_phy);
+    }
 
-  m_mac->SetWifiRemoteStationManager (m_stationManager);
-  m_mac->SetWifiPhy (m_phy);
-  m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this));
-  m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this));
-  m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this));
-  channel->Add (this, m_phy);
-
-  m_phy->SetChannel (channel);
+  if (m_mac != 0)
+    {
+      if (m_stationManager != 0)
+        {
+          m_mac->SetWifiRemoteStationManager (m_stationManager);
+        }
+      if (m_phy != 0)
+        {
+          m_mac->SetWifiPhy (m_phy);
+        }
+      m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this));
+      m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this));
+      m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this));
+    }
 }
 Ptr<WifiMac> 
 WifiNetDevice::GetMac (void) const
@@ -139,7 +171,7 @@
 Ptr<Channel> 
 WifiNetDevice::GetChannel (void) const
 {
-  return m_phy->GetChannel ();
+  return m_channel;
 }
 Address 
 WifiNetDevice::GetAddress (void) const