rework the Wifi API to not use a single WifiNetDevice::Setup method
This commit is contained in:
@@ -110,7 +110,10 @@ WifiHelper::Build (NodeContainer c, Ptr<WifiChannel> channel) const
|
||||
Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
|
||||
Ptr<WifiMac> mac = m_mac.Create<WifiMac> ();
|
||||
Ptr<WifiPhy> phy = m_phy.Create<WifiPhy> ();
|
||||
device->Setup (node, mac, phy, manager, channel);
|
||||
device->SetMac (mac);
|
||||
device->SetPhy (phy);
|
||||
device->SetRemoteStationManager (manager);
|
||||
device->SetChannel (channel);
|
||||
node->AddDevice (device);
|
||||
devices.Add (device);
|
||||
NS_LOG_DEBUG ("node="<<node<<", mob="<<node->GetObject<MobilityModel> ());
|
||||
|
||||
@@ -80,25 +80,57 @@ WifiNetDevice::DoDispose (void)
|
||||
}
|
||||
|
||||
void
|
||||
WifiNetDevice::Setup (Ptr<Node> node, Ptr<WifiMac> mac, Ptr<WifiPhy> phy,
|
||||
Ptr<WifiRemoteStationManager> manager,
|
||||
Ptr<WifiChannel> channel)
|
||||
WifiNetDevice::SetMac (Ptr<WifiMac> mac)
|
||||
{
|
||||
m_node = node;
|
||||
m_mac = mac;
|
||||
Setup ();
|
||||
}
|
||||
void
|
||||
WifiNetDevice::SetPhy (Ptr<WifiPhy> phy)
|
||||
{
|
||||
m_phy = phy;
|
||||
Setup ();
|
||||
}
|
||||
void
|
||||
WifiNetDevice::SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager)
|
||||
{
|
||||
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 @@ WifiNetDevice::GetIfIndex(void) const
|
||||
Ptr<Channel>
|
||||
WifiNetDevice::GetChannel (void) const
|
||||
{
|
||||
return m_phy->GetChannel ();
|
||||
return m_channel;
|
||||
}
|
||||
Address
|
||||
WifiNetDevice::GetAddress (void) const
|
||||
|
||||
@@ -46,10 +46,10 @@ public:
|
||||
WifiNetDevice ();
|
||||
virtual ~WifiNetDevice ();
|
||||
|
||||
|
||||
void Setup (Ptr<Node> node, Ptr<WifiMac> mac, Ptr<WifiPhy> phy,
|
||||
Ptr<WifiRemoteStationManager> manager,
|
||||
Ptr<WifiChannel> channel);
|
||||
void SetMac (Ptr<WifiMac> mac);
|
||||
void SetPhy (Ptr<WifiPhy> phy);
|
||||
void SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager);
|
||||
void SetChannel (Ptr<WifiChannel> channel);
|
||||
Ptr<WifiMac> GetMac (void) const;
|
||||
Ptr<WifiPhy> GetPhy (void) const;
|
||||
Ptr<WifiRemoteStationManager> GetRemoteStationManager (void) const;
|
||||
@@ -83,8 +83,10 @@ private:
|
||||
void ForwardUp (Ptr<Packet> packet, const Mac48Address &from);
|
||||
void LinkUp (void);
|
||||
void LinkDown (void);
|
||||
void Setup (void);
|
||||
Ptr<Node> m_node;
|
||||
Ptr<WifiPhy> m_phy;
|
||||
Ptr<WifiChannel> m_channel;
|
||||
Ptr<WifiMac> m_mac;
|
||||
Ptr<WifiRemoteStationManager> m_stationManager;
|
||||
Callback <bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &> m_forwardUp;
|
||||
|
||||
Reference in New Issue
Block a user