Peer link frame - done
authorKirill Andreev <andreev@iitp.ru>
Wed, 22 Apr 2009 14:00:09 +0400
changeset 4974 8009731514d2
parent 4973 59b050ada622
child 4975 d01441d16808
Peer link frame - done
src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc
src/devices/mesh/dot11s/ie-dot11s-peering-protocol.h
src/devices/mesh/dot11s/peer-link-frame.cc
src/devices/mesh/dot11s/peer-link-frame.h
src/devices/mesh/dot11s/wscript
src/devices/mesh/wifi-information-element.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc	Wed Apr 22 14:00:09 2009 +0400
@@ -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 <andreev@iitp.ru>
+ */
+
+
+#include "ie-dot11s-peering-protocol.h"
+namespace ns3 {
+namespace dot11s {
+TypeId
+IePeeringProtocol::GetTypeId ()
+{
+  static TypeId tid = TypeId ("ns3::dot11s::IePeeringProtocol")
+    .SetParent<WifiInformationElement> ();
+  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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.h	Wed Apr 22 14:00:09 2009 +0400
@@ -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 <andreev@iitp.ru>
+ */
+
+
+#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
--- a/src/devices/mesh/dot11s/peer-link-frame.cc	Wed Apr 22 13:12:22 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-link-frame.cc	Wed Apr 22 14:00:09 2009 +0400
@@ -48,7 +48,7 @@
 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 @@
 {
   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 @@
 {
   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)
--- a/src/devices/mesh/dot11s/peer-link-frame.h	Wed Apr 22 13:12:22 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-link-frame.h	Wed Apr 22 14:00:09 2009 +0400
@@ -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 @@
   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 @@
    */
 private:
   uint8_t m_subtype;
+  IePeeringProtocol m_protocol;
   uint16_t m_capability;
   uint16_t m_aid;
   SupportedRates m_rates;
--- a/src/devices/mesh/dot11s/wscript	Wed Apr 22 13:12:22 2009 +0400
+++ b/src/devices/mesh/dot11s/wscript	Wed Apr 22 14:00:09 2009 +0400
@@ -10,6 +10,7 @@
         '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',
--- a/src/devices/mesh/wifi-information-element.h	Wed Apr 22 13:12:22 2009 +0400
+++ b/src/devices/mesh/wifi-information-element.h	Wed Apr 22 14:00:09 2009 +0400
@@ -56,7 +56,7 @@
   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,