diff --git a/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc b/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc new file mode 100644 index 000000000..3e75fba81 --- /dev/null +++ b/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc @@ -0,0 +1,67 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008,2009 IITP RAS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Kirill Andreev + */ + + +#include "ie-dot11s-peering-protocol.h" +namespace ns3 { +namespace dot11s { +TypeId +IePeeringProtocol::GetTypeId () +{ + static TypeId tid = TypeId ("ns3::dot11s::IePeeringProtocol") + .SetParent (); + return tid; +} + +TypeId +IePeeringProtocol::GetInstanceTypeId () const +{ + return GetTypeId (); +} +uint8_t +IePeeringProtocol::GetInformationSize () const +{ + return 1; +} +IePeeringProtocol::IePeeringProtocol (): + m_protocol(0) +{ +} +void +IePeeringProtocol::SerializeInformation (Buffer::Iterator i) const +{ + i.WriteU8 (m_protocol); +} + +uint8_t +IePeeringProtocol::DeserializeInformation (Buffer::Iterator i, uint8_t length) +{ + Buffer::Iterator start = i; + m_protocol = i.ReadU8 (); + return i.GetDistanceFrom (start); +} +void +IePeeringProtocol::PrintInformation (std::ostream& os) const +{ + //TODO: print +} +} // namespace dot11s +} //namespace ns3 + diff --git a/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.h b/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.h new file mode 100644 index 000000000..9adeaef6f --- /dev/null +++ b/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.h @@ -0,0 +1,50 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008,2009 IITP RAS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Kirill Andreev + */ + + +#ifndef MESH_PERING_PROTOCOL_H +#define MESH_PEERING_PROTOCOL_H + +#include "ns3/wifi-information-element.h" + +namespace ns3 { +namespace dot11s { +class IePeeringProtocol : public WifiInformationElement +{ +public: + static TypeId GetTypeId (); + TypeId GetInstanceTypeId () const; + + IePeeringProtocol (); +private: + WifiElementId ElementId () const + { + return IE11S_PEERING_PROTOCOL; + } + uint8_t GetInformationSize () const; + void SerializeInformation (Buffer::Iterator i) const; + uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length); + void PrintInformation (std::ostream& os) const; +private: + uint8_t m_protocol; +}; +} // namespace dot11s +} //namespace ns3 +#endif diff --git a/src/devices/mesh/dot11s/peer-link-frame.cc b/src/devices/mesh/dot11s/peer-link-frame.cc index d6aefdcc5..753e641a7 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.cc +++ b/src/devices/mesh/dot11s/peer-link-frame.cc @@ -48,7 +48,7 @@ void PeerLinkFrameStart::SetPlinkFrameStart(PeerLinkFrameStart::PlinkFrameStartFields fields) { m_subtype = fields.subtype; - //TODO: protocol version + m_protocol = fields.protocol; if(m_subtype != (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE)) m_capability = fields.capability; if(m_subtype == (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM)) @@ -142,7 +142,8 @@ PeerLinkFrameStart::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; NS_ASSERT(m_subtype < 3); - i.Next(3); + m_protocol.Serialize (i); + i.Next (m_protocol.GetSerializedSize ()); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) i.WriteHtonU16(m_capability); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM) == m_subtype) @@ -163,7 +164,8 @@ PeerLinkFrameStart::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; NS_ASSERT(m_subtype < 3); - i.Next(3); //peering protocol: + m_protocol.Deserialize (i); + i.Next (m_protocol.GetSerializedSize ()); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) m_capability = i.ReadNtohU16(); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM) == m_subtype) diff --git a/src/devices/mesh/dot11s/peer-link-frame.h b/src/devices/mesh/dot11s/peer-link-frame.h index 2bfdbff84..c9db77e25 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.h +++ b/src/devices/mesh/dot11s/peer-link-frame.h @@ -25,6 +25,7 @@ #include "ns3/ssid.h" #include "dot11s-mac-header.h" #include "ie-dot11s-configuration.h" +#include "ie-dot11s-peering-protocol.h" namespace ns3 { class MeshWifiInterfaceMac; namespace dot11s { @@ -47,13 +48,13 @@ public: struct PlinkFrameStartFields { uint8_t subtype; - // //Peering protocol version - in all subtypes - 3 octets - uint16_t capability; //open and confirm - uint16_t aid; //confirm only - SupportedRates rates; //open and confirm - Ssid meshId; //open and confirm - IeConfiguration config; //open and confirm - uint16_t reasonCode; //close only + IePeeringProtocol protocol; //Peering protocol version - in all subtypes - 3 octets + uint16_t capability; //open and confirm + uint16_t aid; //confirm only + SupportedRates rates; //open and confirm + Ssid meshId; //open and confirm + IeConfiguration config; //open and confirm + uint16_t reasonCode; //close only }; ///\attention: must be set before deserialize, before only multihop //action header knows about subtype @@ -75,6 +76,7 @@ public: */ private: uint8_t m_subtype; + IePeeringProtocol m_protocol; uint16_t m_capability; uint16_t m_aid; SupportedRates m_rates; diff --git a/src/devices/mesh/dot11s/wscript b/src/devices/mesh/dot11s/wscript index 627e57f1d..f9df0dfa9 100644 --- a/src/devices/mesh/dot11s/wscript +++ b/src/devices/mesh/dot11s/wscript @@ -10,6 +10,7 @@ def build(bld): 'ie-dot11s-prep.cc', 'ie-dot11s-perr.cc', 'ie-dot11s-rann.cc', + 'ie-dot11s-peering-protocol.cc', 'dot11s-mac-header.cc', 'peer-link-frame.cc', 'peer-link.cc', diff --git a/src/devices/mesh/wifi-information-element.h b/src/devices/mesh/wifi-information-element.h index 616613c71..572ea29f2 100644 --- a/src/devices/mesh/wifi-information-element.h +++ b/src/devices/mesh/wifi-information-element.h @@ -56,7 +56,7 @@ enum WifiElementId { IE11S_PROXY_UPDATE_CONFIRMATION = 39, IE11S_MSCIE = 40, IE11S_MSAIE = 41, - + IE11S_PEERING_PROTOCOL = 42, /* this ID are compatible with open80211s implementation */ IE11S_MESH_CONFIGURATION = 51, IE11S_MESH_ID = 52,