src/devices/wifi/wifi-net-device.cc
changeset 2601 4297e8c61615
parent 2600 6c389d0c717d
child 2602 d9262bff6df2
equal deleted inserted replaced
2600:6c389d0c717d 2601:4297e8c61615
    78   // chain up.
    78   // chain up.
    79   NetDevice::DoDispose ();
    79   NetDevice::DoDispose ();
    80 }
    80 }
    81   
    81   
    82 void 
    82 void 
    83 WifiNetDevice::Setup (Ptr<Node> node, Ptr<WifiMac> mac, Ptr<WifiPhy> phy,
    83 WifiNetDevice::SetMac (Ptr<WifiMac> mac)
    84                       Ptr<WifiRemoteStationManager> manager,
    84 {
    85                       Ptr<WifiChannel> channel)
       
    86 {
       
    87   m_node = node;
       
    88   m_mac = mac;
    85   m_mac = mac;
       
    86   Setup ();
       
    87 }
       
    88 void 
       
    89 WifiNetDevice::SetPhy (Ptr<WifiPhy> phy)
       
    90 {
    89   m_phy = phy;
    91   m_phy = phy;
       
    92   Setup ();
       
    93 }
       
    94 void 
       
    95 WifiNetDevice::SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager)
       
    96 {
    90   m_stationManager = manager;
    97   m_stationManager = manager;
    91 
    98   Setup ();
    92   m_stationManager->SetupPhy (m_phy);
    99 }
    93 
   100 void 
    94   m_mac->SetWifiRemoteStationManager (m_stationManager);
   101 WifiNetDevice::SetChannel (Ptr<WifiChannel> channel)
    95   m_mac->SetWifiPhy (m_phy);
   102 {
    96   m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this));
   103   m_channel = channel;
    97   m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this));
   104   Setup ();
    98   m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this));
   105 }
    99   channel->Add (this, m_phy);
   106 void 
   100 
   107 WifiNetDevice::Setup (void)
   101   m_phy->SetChannel (channel);
   108 {
       
   109   if (m_phy != 0 && m_channel != 0)
       
   110     {
       
   111       m_channel->Add (this, m_phy);
       
   112       m_phy->SetChannel (m_channel);
       
   113     }
       
   114 
       
   115   if (m_stationManager != 0 && m_phy != 0)
       
   116     {
       
   117       m_stationManager->SetupPhy (m_phy);
       
   118     }
       
   119 
       
   120   if (m_mac != 0)
       
   121     {
       
   122       if (m_stationManager != 0)
       
   123         {
       
   124           m_mac->SetWifiRemoteStationManager (m_stationManager);
       
   125         }
       
   126       if (m_phy != 0)
       
   127         {
       
   128           m_mac->SetWifiPhy (m_phy);
       
   129         }
       
   130       m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this));
       
   131       m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this));
       
   132       m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this));
       
   133     }
   102 }
   134 }
   103 Ptr<WifiMac> 
   135 Ptr<WifiMac> 
   104 WifiNetDevice::GetMac (void) const
   136 WifiNetDevice::GetMac (void) const
   105 {
   137 {
   106   return m_mac;
   138   return m_mac;
   137   return m_ifIndex;
   169   return m_ifIndex;
   138 }
   170 }
   139 Ptr<Channel> 
   171 Ptr<Channel> 
   140 WifiNetDevice::GetChannel (void) const
   172 WifiNetDevice::GetChannel (void) const
   141 {
   173 {
   142   return m_phy->GetChannel ();
   174   return m_channel;
   143 }
   175 }
   144 Address 
   176 Address 
   145 WifiNetDevice::GetAddress (void) const
   177 WifiNetDevice::GetAddress (void) const
   146 {
   178 {
   147   return m_mac->GetAddress ();
   179   return m_mac->GetAddress ();