A Discrete-Event Network Simulator
API
mesh-information-element-vector.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 IITP RAS
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Pavel Boyko <boyko@iitp.ru>
19  */
20 
22 #include "ns3/packet.h"
23 #include <algorithm>
24 #include "ns3/hwmp-protocol.h"
25 // All information elements:
26 #include "ns3/ie-dot11s-beacon-timing.h"
27 #include "ns3/ie-dot11s-configuration.h"
28 #include "ns3/ie-dot11s-id.h"
29 #include "ns3/ie-dot11s-metric-report.h"
30 #include "ns3/ie-dot11s-peer-management.h"
31 #include "ns3/ie-dot11s-peering-protocol.h"
32 #include "ns3/ie-dot11s-perr.h"
33 #include "ns3/ie-dot11s-prep.h"
34 #include "ns3/ie-dot11s-preq.h"
35 #include "ns3/ie-dot11s-rann.h"
36 
37 namespace ns3 {
38 
39 NS_OBJECT_ENSURE_REGISTERED (MeshInformationElementVector);
40 
42 {
43 }
44 
46 {
47 }
48 
49 
50 TypeId
52 {
53  static TypeId tid = TypeId ("ns3::MeshInformationElementVector")
55  .SetGroupName ("Mesh")
56  .AddConstructor<MeshInformationElementVector> ();
57  return tid;
58 }
59 
60 TypeId
62 {
63  return GetTypeId ();
64 }
65 
66 uint32_t
68 {
70  uint8_t id = i.ReadU8 ();
71  uint8_t length = i.ReadU8 ();
72  Ptr<WifiInformationElement> newElement;
73  switch (id)
74  {
76  newElement = Create<dot11s::IeConfiguration> ();
77  break;
78  case IE_MESH_ID:
79  newElement = Create<dot11s::IeMeshId> ();
80  break;
82  newElement = Create<dot11s::IeLinkMetricReport> ();
83  break;
85  newElement = Create<dot11s::IePeerManagement> ();
86  break;
87  case IE_BEACON_TIMING:
88  newElement = Create<dot11s::IeBeaconTiming> ();
89  break;
90  case IE_RANN:
91  newElement = Create<dot11s::IeRann> ();
92  break;
93  case IE_PREQ:
94  newElement = Create<dot11s::IePreq> ();
95  break;
96  case IE_PREP:
97  newElement = Create<dot11s::IePrep> ();
98  break;
99  case IE_PERR:
100  newElement = Create<dot11s::IePerr> ();
101  break;
103  newElement = Create<dot11s::IePeeringProtocol> ();
104  break;
105  default:
106  // We peeked at the ID and length, so we need to back up the
107  // pointer before deferring to our parent.
108  i.Prev (2);
110  }
111  if (GetSize () + length > m_maxSize)
112  {
113  NS_FATAL_ERROR ("Check max size for information element!");
114  }
115  newElement->DeserializeInformationField (i, length);
116  i.Next (length);
117  m_elements.push_back (newElement);
118  return i.GetDistanceFrom (start);
119 }
120 
121 
122 } // namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::MeshInformationElementVector::MeshInformationElementVector
MeshInformationElementVector()
Definition: mesh-information-element-vector.cc:41
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
IE_RANN
#define IE_RANN
Definition: wifi-information-element.h:160
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
ns3::MeshInformationElementVector::GetInstanceTypeId
TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
Definition: mesh-information-element-vector.cc:61
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition: buffer.h:1021
IE11S_MESH_PEERING_PROTOCOL_VERSION
#define IE11S_MESH_PEERING_PROTOCOL_VERSION
Definition: mesh-information-element-vector.h:29
ns3::MeshInformationElementVector::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition: mesh-information-element-vector.cc:51
ns3::WifiInformationElement::DeserializeInformationField
virtual uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)=0
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
ns3::MeshInformationElementVector::~MeshInformationElementVector
~MeshInformationElementVector()
Definition: mesh-information-element-vector.cc:45
ns3::WifiInformationElementVector::GetSize
uint32_t GetSize() const
Current number of bytes.
Definition: wifi-information-element-vector.cc:171
ns3::Buffer::Iterator::Next
void Next(void)
go forward by one byte
Definition: buffer.h:845
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::Ptr< WifiInformationElement >
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
visualizer.core.start
def start()
Definition: core.py:1855
IE_BEACON_TIMING
#define IE_BEACON_TIMING
Definition: wifi-information-element.h:154
ns3::WifiInformationElementVector::m_maxSize
uint16_t m_maxSize
Size in bytes (actually, max packet length)
Definition: wifi-information-element-vector.h:131
ns3::WifiInformationElementVector::DeserializeSingleIe
virtual uint32_t DeserializeSingleIe(Buffer::Iterator start)
Needed when you try to deserialize a lonely IE inside other header.
Definition: wifi-information-element-vector.cc:96
IE_MESH_CONFIGURATION
#define IE_MESH_CONFIGURATION
Definition: wifi-information-element.h:147
IE_PREQ
#define IE_PREQ
Definition: wifi-information-element.h:164
IE_MESH_ID
#define IE_MESH_ID
Definition: wifi-information-element.h:148
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition: buffer.h:99
ns3::MeshInformationElementVector::DeserializeSingleIe
virtual uint32_t DeserializeSingleIe(Buffer::Iterator start)
Needed when you try to deserialize a lonely IE inside other header.
Definition: mesh-information-element-vector.cc:67
IE_PERR
#define IE_PERR
Definition: wifi-information-element.h:166
ns3::WifiInformationElementVector::m_elements
IE_VECTOR m_elements
Information element vector.
Definition: wifi-information-element-vector.h:130
IE_PREP
#define IE_PREP
Definition: wifi-information-element.h:165
IE_MESH_LINK_METRIC_REPORT
#define IE_MESH_LINK_METRIC_REPORT
Definition: wifi-information-element.h:149
IE_MESH_PEERING_MANAGEMENT
#define IE_MESH_PEERING_MANAGEMENT
Definition: wifi-information-element.h:151
ns3::MeshInformationElementVector
Introspection did not find any typical Config paths.
Definition: mesh-information-element-vector.h:32
mesh-information-element-vector.h
ns3::Buffer::Iterator::Prev
void Prev(void)
go backward by one byte
Definition: buffer.h:851
ns3::WifiInformationElementVector
Information element vector.
Definition: wifi-information-element-vector.h:40