wifi: cleanup duplicated setters in WifiMacHeader

This commit is contained in:
Sébastien Deronne
2017-11-04 09:14:57 +01:00
parent fec5cca9e2
commit 1ea32ebe47
13 changed files with 32 additions and 143 deletions

View File

@@ -55,9 +55,9 @@ AirtimeLinkMetricCalculator::AirtimeLinkMetricCalculator ()
void
AirtimeLinkMetricCalculator::SetHeaderTid (uint8_t tid)
{
m_testHeader.SetType (WIFI_MAC_DATA);
m_testHeader.SetDsFrom ();
m_testHeader.SetDsTo ();
m_testHeader.SetTypeData ();
m_testHeader.SetQosTid (tid);
}
void

View File

@@ -245,7 +245,7 @@ HwmpProtocolMac::SendPreq (std::vector<IePreq> preq)
packet->AddHeader (GetWifiActionHeader ());
//create 802.11 header:
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
hdr.SetAddr2 (m_parent->GetAddress ());
@@ -315,7 +315,7 @@ HwmpProtocolMac::SendPrep (IePrep prep, Mac48Address receiver)
packet->AddHeader (GetWifiActionHeader ());
//create 802.11 header:
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
hdr.SetAddr1 (receiver);
@@ -356,7 +356,7 @@ HwmpProtocolMac::ForwardPerr (std::vector<HwmpProtocol::FailedDestination> faile
packet->AddHeader (GetWifiActionHeader ());
//create 802.11 header:
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
hdr.SetAddr2 (m_parent->GetAddress ());

View File

@@ -314,7 +314,7 @@ PeerManagementProtocolMac::SendPeerLinkManagementFrame (Mac48Address peerAddress
m_stats.txMgtBytes += packet->GetSize ();
// Wifi Mac header:
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetAddr1 (peerAddress);
hdr.SetAddr2 (m_parent->GetAddress ());
//Addr is not used here, we use it as our MP address

View File

@@ -20,7 +20,6 @@
#include "ns3/mesh-wifi-beacon.h"
namespace ns3 {
MeshWifiBeacon::MeshWifiBeacon (Ssid ssid, SupportedRates rates, uint64_t us)
@@ -29,6 +28,7 @@ MeshWifiBeacon::MeshWifiBeacon (Ssid ssid, SupportedRates rates, uint64_t us)
m_header.SetSupportedRates (rates);
m_header.SetBeaconIntervalUs (us);
}
void
MeshWifiBeacon::AddInformationElement (Ptr<WifiInformationElement> ie)
{
@@ -49,19 +49,19 @@ MeshWifiBeacon::CreatePacket ()
packet->AddHeader (BeaconHeader ());
return packet;
}
WifiMacHeader
MeshWifiBeacon::CreateHeader (Mac48Address address, Mac48Address mpAddress)
{
WifiMacHeader hdr;
hdr.SetBeacon ();
hdr.SetType (WIFI_MAC_MGT_BEACON);
hdr.SetAddr1 (Mac48Address::GetBroadcast ());
hdr.SetAddr2 (address);
hdr.SetAddr3 (mpAddress);
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
return hdr;
}
} // namespace ns3

View File

@@ -70,7 +70,7 @@ OcbWifiMac::SendVsc (Ptr<Packet> vsc, Mac48Address peer, OrganizationIdentifier
{
NS_LOG_FUNCTION (this << vsc << peer << oi);
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetAddr1 (peer);
hdr.SetAddr2 (GetAddress ());
hdr.SetAddr3 (WILDCARD_BSSID);
@@ -207,7 +207,7 @@ OcbWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
}
else
{
hdr.SetTypeData ();
hdr.SetType (WIFI_MAC_DATA);
}
if (m_htSupported || m_vhtSupported)

View File

@@ -81,15 +81,15 @@ AdhocWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
}
if (m_htSupported)
{
m_stationManager->AddStationHtCapabilities (to, GetHtCapabilities());
m_stationManager->AddStationHtCapabilities (to, GetHtCapabilities ());
}
if (m_vhtSupported)
{
m_stationManager->AddStationVhtCapabilities (to, GetVhtCapabilities());
m_stationManager->AddStationVhtCapabilities (to, GetVhtCapabilities ());
}
if (m_heSupported)
{
m_stationManager->AddStationHeCapabilities (to, GetHeCapabilities());
m_stationManager->AddStationHeCapabilities (to, GetHeCapabilities ());
}
m_stationManager->AddAllSupportedModes (to);
m_stationManager->RecordDisassociated (to);
@@ -130,7 +130,7 @@ AdhocWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
}
else
{
hdr.SetTypeData ();
hdr.SetType (WIFI_MAC_DATA);
}
if (m_htSupported || m_vhtSupported || m_heSupported)
@@ -181,19 +181,19 @@ AdhocWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr)
if (m_htSupported || m_vhtSupported || m_heSupported)
{
m_stationManager->AddAllSupportedMcs (from);
m_stationManager->AddStationHtCapabilities (from, GetHtCapabilities());
m_stationManager->AddStationHtCapabilities (from, GetHtCapabilities ());
}
if (m_htSupported)
{
m_stationManager->AddStationHtCapabilities (from, GetHtCapabilities());
m_stationManager->AddStationHtCapabilities (from, GetHtCapabilities ());
}
if (m_vhtSupported)
{
m_stationManager->AddStationVhtCapabilities (from, GetVhtCapabilities());
m_stationManager->AddStationVhtCapabilities (from, GetVhtCapabilities ());
}
if (m_heSupported)
{
m_stationManager->AddStationHeCapabilities (from, GetHeCapabilities());
m_stationManager->AddStationHeCapabilities (from, GetHeCapabilities ());
}
m_stationManager->AddAllSupportedModes (from);
m_stationManager->RecordDisassociated (from);

View File

@@ -313,7 +313,7 @@ ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
}
else
{
hdr.SetTypeData ();
hdr.SetType (WIFI_MAC_DATA);
}
if (m_htSupported || m_vhtSupported || m_heSupported)
@@ -572,7 +572,7 @@ ApWifiMac::SendProbeResp (Mac48Address to)
{
NS_LOG_FUNCTION (this << to);
WifiMacHeader hdr;
hdr.SetProbeResp ();
hdr.SetType (WIFI_MAC_MGT_PROBE_RESPONSE);
hdr.SetAddr1 (to);
hdr.SetAddr2 (GetAddress ());
hdr.SetAddr3 (GetAddress ());
@@ -627,7 +627,7 @@ ApWifiMac::SendAssocResp (Mac48Address to, bool success)
{
NS_LOG_FUNCTION (this << to << success);
WifiMacHeader hdr;
hdr.SetAssocResp ();
hdr.SetType (WIFI_MAC_MGT_ASSOCIATION_RESPONSE);
hdr.SetAddr1 (to);
hdr.SetAddr2 (GetAddress ());
hdr.SetAddr3 (GetAddress ());
@@ -685,7 +685,7 @@ ApWifiMac::SendOneBeacon (void)
{
NS_LOG_FUNCTION (this);
WifiMacHeader hdr;
hdr.SetBeacon ();
hdr.SetType (WIFI_MAC_MGT_BEACON);
hdr.SetAddr1 (Mac48Address::GetBroadcast ());
hdr.SetAddr2 (GetAddress ());
hdr.SetAddr3 (GetAddress ());

View File

@@ -1447,7 +1447,7 @@ EdcaTxopN::SendAddBaRequest (Mac48Address dest, uint8_t tid, uint16_t startSeq,
NS_LOG_FUNCTION (this << dest << (uint16_t)tid << startSeq << timeout << immediateBAck);
NS_LOG_DEBUG ("sent ADDBA request to " << dest);
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetAddr1 (dest);
hdr.SetAddr2 (m_low->GetAddress ());
hdr.SetAddr3 (m_low->GetAddress ());
@@ -1507,7 +1507,7 @@ EdcaTxopN::SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator)
{
NS_LOG_FUNCTION (this << addr << (uint16_t)tid << byOriginator);
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetAddr1 (addr);
hdr.SetAddr2 (m_low->GetAddress ());
hdr.SetAddr3 (m_low->GetAddress ());

View File

@@ -1002,7 +1002,7 @@ RegularWifiMac::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr,
{
NS_LOG_FUNCTION (this);
WifiMacHeader hdr;
hdr.SetAction ();
hdr.SetType (WIFI_MAC_MGT_ACTION);
hdr.SetAddr1 (originator);
hdr.SetAddr2 (GetAddress ());
hdr.SetAddr3 (GetAddress ());

View File

@@ -130,7 +130,7 @@ StaWifiMac::SendProbeRequest (void)
{
NS_LOG_FUNCTION (this);
WifiMacHeader hdr;
hdr.SetProbeReq ();
hdr.SetType (WIFI_MAC_MGT_PROBE_REQUEST);
hdr.SetAddr1 (Mac48Address::GetBroadcast ());
hdr.SetAddr2 (GetAddress ());
hdr.SetAddr3 (Mac48Address::GetBroadcast ());
@@ -174,7 +174,7 @@ StaWifiMac::SendAssociationRequest (void)
{
NS_LOG_FUNCTION (this << GetBssid ());
WifiMacHeader hdr;
hdr.SetAssocReq ();
hdr.SetType (WIFI_MAC_MGT_ASSOCIATION_REQUEST);
hdr.SetAddr1 (GetBssid ());
hdr.SetAddr2 (GetAddress ());
hdr.SetAddr3 (GetBssid ());
@@ -363,7 +363,7 @@ StaWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
}
else
{
hdr.SetTypeData ();
hdr.SetType (WIFI_MAC_DATA);
}
if (m_htSupported || m_vhtSupported || m_heSupported)
{

View File

@@ -107,76 +107,6 @@ WifiMacHeader::SetAddr4 (Mac48Address address)
m_addr4 = address;
}
void
WifiMacHeader::SetAssocReq (void)
{
m_ctrlType = TYPE_MGT;
m_ctrlSubtype = 0;
}
void
WifiMacHeader::SetAssocResp (void)
{
m_ctrlType = TYPE_MGT;
m_ctrlSubtype = 1;
}
void
WifiMacHeader::SetProbeReq (void)
{
m_ctrlType = TYPE_MGT;
m_ctrlSubtype = 4;
}
void
WifiMacHeader::SetProbeResp (void)
{
m_ctrlType = TYPE_MGT;
m_ctrlSubtype = 5;
}
void
WifiMacHeader::SetBeacon (void)
{
m_ctrlType = TYPE_MGT;
m_ctrlSubtype = 8;
}
void
WifiMacHeader::SetBlockAckReq (void)
{
m_ctrlType = TYPE_CTL;
m_ctrlSubtype = 8;
}
void
WifiMacHeader::SetBlockAck (void)
{
m_ctrlType = TYPE_CTL;
m_ctrlSubtype = 9;
}
void
WifiMacHeader::SetTypeData (void)
{
m_ctrlType = TYPE_DATA;
m_ctrlSubtype = 0;
}
void
WifiMacHeader::SetAction (void)
{
m_ctrlType = TYPE_MGT;
m_ctrlSubtype = 0x0D;
}
void
WifiMacHeader::SetMultihopAction (void)
{
m_ctrlType = TYPE_MGT;
m_ctrlSubtype = 0x0F;
}
void
WifiMacHeader::SetType (WifiMacType type)
{

View File

@@ -116,47 +116,6 @@ public:
void Serialize (Buffer::Iterator start) const;
uint32_t Deserialize (Buffer::Iterator start);
/**
* Set Type/Subtype values for an association request header.
*/
void SetAssocReq (void);
/**
* Set Type/Subtype values for an association response header.
*/
void SetAssocResp (void);
/**
* Set Type/Subtype values for a probe request header.
*/
void SetProbeReq (void);
/**
* Set Type/Subtype values for a probe response header.
*/
void SetProbeResp (void);
/**
* Set Type/Subtype values for a beacon header.
*/
void SetBeacon (void);
/**
* Set Type/Subtype values for a data packet with
* no subtype equal to 0.
*/
void SetTypeData (void);
/**
* Set Type/Subtype values for an action header.
*/
void SetAction ();
/**
* Set Type/Subtype values for a Block Ack Request header.
*/
void SetBlockAckReq (void);
/**
* Set Type/Subtype values for a Block Ack header.
*/
void SetBlockAck (void);
/**
* Set Type/Subtype values for a multihop action header.
*/
void SetMultihopAction ();
/**
* Set the From DS bit in the Frame Control field.
*/

View File

@@ -134,7 +134,7 @@ PowerRateAdaptationTest::TestParf ()
*/
Mac48Address remoteAddress = Mac48Address::Allocate ();
WifiMacHeader packetHeader;
packetHeader.SetTypeData ();
packetHeader.SetType (WIFI_MAC_DATA);
packetHeader.SetQosTid (0);
Ptr<Packet> packet = Create<Packet> (10);
WifiMode ackMode;
@@ -354,7 +354,7 @@ PowerRateAdaptationTest::TestAparf ()
*/
Mac48Address remoteAddress = Mac48Address::Allocate ();
WifiMacHeader packetHeader;
packetHeader.SetTypeData ();
packetHeader.SetType (WIFI_MAC_DATA);
packetHeader.SetQosTid (0);
Ptr<Packet> packet = Create<Packet> (10);
WifiMode ackMode;
@@ -596,7 +596,7 @@ PowerRateAdaptationTest::TestRrpaa ()
*/
Mac48Address remoteAddress = Mac48Address::Allocate ();
WifiMacHeader packetHeader;
packetHeader.SetTypeData ();
packetHeader.SetType (WIFI_MAC_DATA);
packetHeader.SetQosTid (0);
Ptr<Packet> packet = Create<Packet> (10);
WifiMode ackMode;