From 50eebdd0bb923f5a976c69a14a1ac6fd1eff0409 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Fri, 13 Mar 2009 14:52:48 +0300 Subject: [PATCH] Removed ELEMENT_ID, added proper methods, which returns element id --- .../wifi/dot11s-peer-management-element.cc | 6 ++--- .../wifi/dot11s-peer-management-element.h | 2 +- .../wifi/mesh-configuration-element.cc | 9 ++++--- src/devices/wifi/mesh-configuration-element.h | 2 ++ .../wifi/mesh-wifi-beacon-timing-element.cc | 13 ++++------ .../wifi/mesh-wifi-beacon-timing-element.h | 2 ++ .../mesh-wifi-perr-information-element.cc | 7 ++---- .../wifi/mesh-wifi-perr-information-element.h | 2 ++ .../mesh-wifi-prep-information-element.cc | 7 ++---- .../wifi/mesh-wifi-prep-information-element.h | 3 ++- .../mesh-wifi-preq-information-element.cc | 7 ++---- .../wifi/mesh-wifi-preq-information-element.h | 2 ++ .../mesh-wifi-rann-information-element.cc | 24 ++++++++----------- .../wifi/mesh-wifi-rann-information-element.h | 2 ++ 14 files changed, 39 insertions(+), 49 deletions(-) diff --git a/src/devices/wifi/dot11s-peer-management-element.cc b/src/devices/wifi/dot11s-peer-management-element.cc index 843fddb61..66e61bcc2 100644 --- a/src/devices/wifi/dot11s-peer-management-element.cc +++ b/src/devices/wifi/dot11s-peer-management-element.cc @@ -106,7 +106,7 @@ PeerLinkManagementElement::SubtypeIsConfirm() const Buffer::Iterator PeerLinkManagementElement::Serialize (Buffer::Iterator i) const { - i.WriteU8(PEER_LINK_MANAGEMENT); + i.WriteU8(ElementId()); i.WriteU8(m_length); i.WriteU8(m_subtype); i.WriteHtonU16(m_localLinkId); @@ -119,9 +119,7 @@ PeerLinkManagementElement::Serialize (Buffer::Iterator i) const Buffer::Iterator PeerLinkManagementElement::Deserialize (Buffer::Iterator i) { - dot11sElementID ElementId; - ElementId = (dot11sElementID)i.ReadU8(); - NS_ASSERT(ElementId == PEER_LINK_MANAGEMENT); + NS_ASSERT(ElementId() == i.ReadU8()); m_length = i.ReadU8(); m_subtype = i.ReadU8(); m_localLinkId = i.ReadNtohU16(); diff --git a/src/devices/wifi/dot11s-peer-management-element.h b/src/devices/wifi/dot11s-peer-management-element.h index ff8e1fd58..a4a51ad40 100644 --- a/src/devices/wifi/dot11s-peer-management-element.h +++ b/src/devices/wifi/dot11s-peer-management-element.h @@ -55,6 +55,7 @@ class PeerLinkManagementElement Buffer::Iterator Serialize (Buffer::Iterator i) const; Buffer::Iterator Deserialize (Buffer::Iterator i); private: + static uint8_t ElementId() { return (uint8_t)PEER_LINK_MANAGEMENT; } uint8_t m_length; uint8_t m_subtype; uint16_t m_localLinkId; //always is present @@ -63,4 +64,3 @@ class PeerLinkManagementElement }; } //namespace NS3 #endif - diff --git a/src/devices/wifi/mesh-configuration-element.cc b/src/devices/wifi/mesh-configuration-element.cc index 4eef36a8b..85e0ca7aa 100644 --- a/src/devices/wifi/mesh-configuration-element.cc +++ b/src/devices/wifi/mesh-configuration-element.cc @@ -22,7 +22,6 @@ #include "mesh-configuration-element.h" #include "ns3/assert.h" -#include "dot11s-codes.h" //NS_LOG_COMPONENT_DEFINE ("MeshConfigurationElement"); @@ -104,7 +103,7 @@ Buffer::Iterator MeshConfigurationElement::Serialize (Buffer::Iterator i) const { - i.WriteU8 (MESH_CONFIGURATION); + i.WriteU8 (ElementId()); i.WriteU8 (GetSerializedSize()); // Length i.WriteU8 (1); //Version // Active Path Selection Protocol ID: @@ -123,12 +122,12 @@ Buffer::Iterator MeshConfigurationElement::Deserialize (Buffer::Iterator i) { - uint8_t elementId; + //uint8_t elementId; uint8_t size; uint8_t version; - elementId = i.ReadU8 (); + //elementId = i.ReadU8 (); - NS_ASSERT (elementId == MESH_CONFIGURATION); + NS_ASSERT (ElementId() == i.ReadU8()); size = i.ReadU8 (); version = i.ReadU8(); diff --git a/src/devices/wifi/mesh-configuration-element.h b/src/devices/wifi/mesh-configuration-element.h index 6a3e9f875..c9a71349b 100644 --- a/src/devices/wifi/mesh-configuration-element.h +++ b/src/devices/wifi/mesh-configuration-element.h @@ -25,6 +25,7 @@ #include #include "ns3/buffer.h" +#include "dot11s-codes.h" namespace ns3 { @@ -87,6 +88,7 @@ class MeshConfigurationElement // TODO: Release and fill other fields in configuration // element private: + static uint8_t ElementId() { return (uint8_t)MESH_CONFIGURATION; } /** Active Path Selection Protocol ID */ dot11sPathSelectionProtocol m_APSId; /** Active Path Metric ID */ diff --git a/src/devices/wifi/mesh-wifi-beacon-timing-element.cc b/src/devices/wifi/mesh-wifi-beacon-timing-element.cc index 968d3e20a..b3fc2200b 100644 --- a/src/devices/wifi/mesh-wifi-beacon-timing-element.cc +++ b/src/devices/wifi/mesh-wifi-beacon-timing-element.cc @@ -20,7 +20,6 @@ #include "mesh-wifi-beacon-timing-element.h" -#define ELEMENT_ID (19) namespace ns3 { /******************************************* * WifiBeaconTimingElementUnit @@ -153,7 +152,7 @@ WifiBeaconTimingElement::Serialize (Buffer::Iterator i) const { uint8_t can_be_written = (2+5*m_numOfUnits > m_maxSize) ? ((m_maxSize-2)/5) : m_numOfUnits; int actually_written = 0; - i.WriteU8 (ELEMENT_ID); + i.WriteU8 (ElementId()); i.WriteU8 (can_be_written); for(NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin(); j!= m_neighbours.end(); j++) { @@ -176,13 +175,9 @@ WifiBeaconTimingElement::Serialize (Buffer::Iterator i) const Buffer::Iterator WifiBeaconTimingElement::Deserialize (Buffer::Iterator i) { - uint8_t elementId; - uint8_t num_to_read = 0; - int j; - elementId = i.ReadU8(); - NS_ASSERT(elementId == ELEMENT_ID); - num_to_read = i.ReadU8(); - for(j=0;j new_element = Create(); new_element->SetAID(i.ReadU8()); diff --git a/src/devices/wifi/mesh-wifi-beacon-timing-element.h b/src/devices/wifi/mesh-wifi-beacon-timing-element.h index 83d1ca1ba..4d2952025 100644 --- a/src/devices/wifi/mesh-wifi-beacon-timing-element.h +++ b/src/devices/wifi/mesh-wifi-beacon-timing-element.h @@ -26,6 +26,7 @@ #include "ns3/buffer.h" #include "ns3/nstime.h" #include +#include "dot11s-codes.h" namespace ns3 { class WifiBeaconTimingElementUnit : public RefCountBase @@ -93,6 +94,7 @@ class WifiBeaconTimingElement Buffer::Iterator Serialize (Buffer::Iterator i) const; Buffer::Iterator Deserialize (Buffer::Iterator i); private: + static uint8_t ElementId() { return (uint8_t)BEACON_TIMING; } NeighboursTimingUnitsList m_neighbours; //The maximum size of this element: const static uint16_t DEFAULT_MAX_SIZE = 255*5 +2; diff --git a/src/devices/wifi/mesh-wifi-perr-information-element.cc b/src/devices/wifi/mesh-wifi-perr-information-element.cc index 5b38d486d..254f10a91 100644 --- a/src/devices/wifi/mesh-wifi-perr-information-element.cc +++ b/src/devices/wifi/mesh-wifi-perr-information-element.cc @@ -22,7 +22,6 @@ #include "mesh-wifi-perr-information-element.h" #include "ns3/address-utils.h" -#define ELEMENT_ID (21) namespace ns3 { WifiPerrInformationElement::~WifiPerrInformationElement() @@ -58,7 +57,7 @@ WifiPerrInformationElement::GetNumOfDest() void WifiPerrInformationElement::Serialize(Buffer::Iterator i)const { - i.WriteU8 (ELEMENT_ID); + i.WriteU8 (ElementId()); i.WriteU8 (2+10*m_numOfDest); i.WriteU8(0); i.WriteU8 (m_numOfDest); @@ -73,9 +72,7 @@ uint32_t WifiPerrInformationElement::Deserialize(Buffer::Iterator start) { Buffer::Iterator i = start; - uint8_t ElementId; - ElementId = i.ReadU8(); - NS_ASSERT (ElementId = ELEMENT_ID); + NS_ASSERT (ElementId() == i.ReadU8()); int length = i.ReadU8(); i.Next(1); //Mode flags is not used now m_numOfDest = i.ReadU8(); diff --git a/src/devices/wifi/mesh-wifi-perr-information-element.h b/src/devices/wifi/mesh-wifi-perr-information-element.h index 17c4acdaf..c0124cac8 100644 --- a/src/devices/wifi/mesh-wifi-perr-information-element.h +++ b/src/devices/wifi/mesh-wifi-perr-information-element.h @@ -29,6 +29,7 @@ #include "ns3/mac48-address.h" #include "ns3/hwmp-rtable.h" #include "ns3/header.h" +#include "dot11s-codes.h" namespace ns3 { @@ -56,6 +57,7 @@ class WifiPerrInformationElement : public Header void DeleteAddressUnit(Mac48Address address); void ResetPerr(); private: + static uint8_t ElementId() { return (uint8_t)PATH_ERROR; } uint8_t m_numOfDest; std::vector m_addressUnits; diff --git a/src/devices/wifi/mesh-wifi-prep-information-element.cc b/src/devices/wifi/mesh-wifi-prep-information-element.cc index 1ef0a9171..32b7f84ce 100644 --- a/src/devices/wifi/mesh-wifi-prep-information-element.cc +++ b/src/devices/wifi/mesh-wifi-prep-information-element.cc @@ -23,7 +23,6 @@ #include "mesh-wifi-prep-information-element.h" #include "ns3/address-utils.h" #include "ns3/assert.h" -#define ELEMENT_ID (30) namespace ns3{ /******************************** * WifiPrepInformationElement @@ -167,7 +166,7 @@ WifiPrepInformationElement::IncrementMetric(uint32_t metric) void WifiPrepInformationElement::Serialize(Buffer::Iterator i) const { - i.WriteU8 (ELEMENT_ID); + i.WriteU8 (ElementId()); i.WriteU8 (32);//length = 32 i.WriteU8 (m_flags); i.WriteU8 (m_hopcount); @@ -183,9 +182,7 @@ uint32_t WifiPrepInformationElement::Deserialize(Buffer::Iterator start) { Buffer::Iterator i = start; - uint8_t ElementId; - ElementId = i.ReadU8(); - NS_ASSERT (ElementId == ELEMENT_ID); + NS_ASSERT (ElementId() == i.ReadU8()); i.Next(1); // length is constatnt m_flags = i.ReadU8(); m_hopcount = i.ReadU8(); diff --git a/src/devices/wifi/mesh-wifi-prep-information-element.h b/src/devices/wifi/mesh-wifi-prep-information-element.h index 48e7db1ab..c7db0be17 100644 --- a/src/devices/wifi/mesh-wifi-prep-information-element.h +++ b/src/devices/wifi/mesh-wifi-prep-information-element.h @@ -29,6 +29,7 @@ #include "ns3/buffer.h" #include "ns3/mac48-address.h" #include "ns3/header.h" +#include "dot11s-codes.h" namespace ns3 { class WifiPrepInformationElement : public Header @@ -65,7 +66,7 @@ class WifiPrepInformationElement : public Header void DecrementTtl(); void IncrementMetric(uint32_t metric); private: - + static uint8_t ElementId() { return (uint8_t)PATH_REPLY; } uint8_t m_flags; uint8_t m_hopcount; uint8_t m_ttl; diff --git a/src/devices/wifi/mesh-wifi-preq-information-element.cc b/src/devices/wifi/mesh-wifi-preq-information-element.cc index ff7f83713..fbbfe8c73 100644 --- a/src/devices/wifi/mesh-wifi-preq-information-element.cc +++ b/src/devices/wifi/mesh-wifi-preq-information-element.cc @@ -23,7 +23,6 @@ #include "mesh-wifi-preq-information-element.h" #include "ns3/address-utils.h" #include "ns3/assert.h" -#define ELEMENT_ID (22) namespace ns3{ /************************* * DestinationAddressUnit @@ -250,7 +249,7 @@ WifiPreqInformationElement::IncrementMetric(uint32_t metric) void WifiPreqInformationElement::Serialize(Buffer::Iterator i) const { - i.WriteU8 (ELEMENT_ID); + i.WriteU8 (ElementId()); //TODO:Check maxsize uint8_t length = m_destCount*11+28; if(m_destCount> m_maxSize) @@ -286,9 +285,7 @@ uint32_t WifiPreqInformationElement::Deserialize(Buffer::Iterator start) { Buffer::Iterator i = start; - uint8_t ElementId; - ElementId = i.ReadU8(); - NS_ASSERT (ElementId == ELEMENT_ID); + NS_ASSERT (ElementId() == i.ReadU8()); uint8_t length; length = i.ReadU8(); m_flags = i.ReadU8(); diff --git a/src/devices/wifi/mesh-wifi-preq-information-element.h b/src/devices/wifi/mesh-wifi-preq-information-element.h index 7a1517ef9..79867f1a3 100644 --- a/src/devices/wifi/mesh-wifi-preq-information-element.h +++ b/src/devices/wifi/mesh-wifi-preq-information-element.h @@ -29,6 +29,7 @@ #include "ns3/mac48-address.h" #include "ns3/header.h" #include +#include "dot11s-codes.h" namespace ns3 { class DestinationAddressUnit : public RefCountBase @@ -102,6 +103,7 @@ class WifiPreqInformationElement : public Header void IncrementMetric(uint32_t metric); private: + static uint8_t ElementId() { return (uint8_t)PATH_REQUEST; } //how many destinations we support uint8_t m_maxSize; //TODO: make as an attrubute //Fields: diff --git a/src/devices/wifi/mesh-wifi-rann-information-element.cc b/src/devices/wifi/mesh-wifi-rann-information-element.cc index eea19ced1..07e7f9c82 100644 --- a/src/devices/wifi/mesh-wifi-rann-information-element.cc +++ b/src/devices/wifi/mesh-wifi-rann-information-element.cc @@ -23,7 +23,6 @@ #include "mesh-wifi-rann-information-element.h" #include "ns3/assert.h" #include "ns3/address-utils.h" -#define ELEMENT_ID (20) namespace ns3{ @@ -46,15 +45,14 @@ WifiRannInformationElement::Print(std::ostream &os)const { // FILL } -WifiRannInformationElement::WifiRannInformationElement() -{ m_flags = 0; - m_hopcount = 0; - m_ttl = 0; - m_destSeqNumber = 0; - m_metric = 0; - m_originatorAddress = Mac48Address::GetBroadcast(); - m_destSeqNumber = 0; - +WifiRannInformationElement::WifiRannInformationElement(): + m_flags(0), + m_hopcount(0), + m_ttl(0), + m_originatorAddress(Mac48Address::GetBroadcast()), + m_destSeqNumber(0), + m_metric(0) +{ } void WifiRannInformationElement::SetFlags(uint8_t flags) @@ -120,7 +118,7 @@ WifiRannInformationElement::GetOriginatorAddress() void WifiRannInformationElement::Serialize(Buffer::Iterator i) const { - i.WriteU8 (ELEMENT_ID); + i.WriteU8 (ElementId()); i.WriteU8 (21);//length = 21 i.WriteU8 (m_flags); i.WriteU8 (m_hopcount); @@ -133,9 +131,7 @@ uint32_t WifiRannInformationElement::Deserialize(Buffer::Iterator start) { Buffer::Iterator i = start; - uint8_t ElementId; - ElementId = i.ReadU8(); - NS_ASSERT (ElementId == ELEMENT_ID); + NS_ASSERT (ElementId() == i.ReadU8()); i.Next(1);// length is constant m_flags = i.ReadU8(); m_hopcount = i.ReadU8(); diff --git a/src/devices/wifi/mesh-wifi-rann-information-element.h b/src/devices/wifi/mesh-wifi-rann-information-element.h index d0bb8fa5d..4ca9d7ff9 100644 --- a/src/devices/wifi/mesh-wifi-rann-information-element.h +++ b/src/devices/wifi/mesh-wifi-rann-information-element.h @@ -29,6 +29,7 @@ #include "ns3/mac48-address.h" #include "ns3/node.h" #include "ns3/header.h" +#include "dot11s-codes.h" namespace ns3 { @@ -60,6 +61,7 @@ class WifiRannInformationElement void IncrementMetric(uint32_t metric); private: + static uint8_t ElementId() { return (uint8_t)ROOT_ANNOUCEMENT; } uint8_t m_flags; uint8_t m_hopcount; uint8_t m_ttl;