A Discrete-Event Network Simulator
API
mesh-information-element-vector.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 IITP RAS
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Pavel Boyko <boyko@iitp.ru>
18  */
19 
21 
22 #include "ns3/hwmp-protocol.h"
23 #include "ns3/packet.h"
24 
25 #include <algorithm>
26 // All information elements:
27 #include "ns3/ie-dot11s-beacon-timing.h"
28 #include "ns3/ie-dot11s-configuration.h"
29 #include "ns3/ie-dot11s-id.h"
30 #include "ns3/ie-dot11s-metric-report.h"
31 #include "ns3/ie-dot11s-peer-management.h"
32 #include "ns3/ie-dot11s-peering-protocol.h"
33 #include "ns3/ie-dot11s-perr.h"
34 #include "ns3/ie-dot11s-prep.h"
35 #include "ns3/ie-dot11s-preq.h"
36 #include "ns3/ie-dot11s-rann.h"
37 
38 namespace ns3
39 {
40 
41 NS_OBJECT_ENSURE_REGISTERED(MeshInformationElementVector);
42 
44 {
45 }
46 
48 {
49 }
50 
51 TypeId
53 {
54  static TypeId tid = TypeId("ns3::MeshInformationElementVector")
56  .SetGroupName("Mesh")
57  .AddConstructor<MeshInformationElementVector>();
58  return tid;
59 }
60 
61 TypeId
63 {
64  return GetTypeId();
65 }
66 
67 uint32_t
69 {
71  uint8_t id = i.ReadU8();
72  uint8_t length = i.ReadU8();
73  i.Prev(2);
74  Ptr<WifiInformationElement> newElement;
75  switch (id)
76  {
78  newElement = Create<dot11s::IeConfiguration>();
79  break;
80  case IE_MESH_ID:
81  newElement = Create<dot11s::IeMeshId>();
82  break;
84  newElement = Create<dot11s::IeLinkMetricReport>();
85  break;
87  newElement = Create<dot11s::IePeerManagement>();
88  break;
89  case IE_BEACON_TIMING:
90  newElement = Create<dot11s::IeBeaconTiming>();
91  break;
92  case IE_RANN:
93  newElement = Create<dot11s::IeRann>();
94  break;
95  case IE_PREQ:
96  newElement = Create<dot11s::IePreq>();
97  break;
98  case IE_PREP:
99  newElement = Create<dot11s::IePrep>();
100  break;
101  case IE_PERR:
102  newElement = Create<dot11s::IePerr>();
103  break;
105  newElement = Create<dot11s::IePeeringProtocol>();
106  break;
107  default:
109  }
110  if (GetSize() + length > m_maxSize)
111  {
112  NS_FATAL_ERROR("Check max size for information element!");
113  }
114  i = newElement->Deserialize(i);
115  m_elements.push_back(newElement);
116  return i.GetDistanceFrom(start);
117 }
118 
119 } // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:783
void Prev()
go backward by one byte
Definition: buffer.h:860
Introspection did not find any typical Config paths.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t DeserializeSingleIe(Buffer::Iterator start) override
Needed when you try to deserialize a lonely IE inside other header.
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize entire IE (which may possibly be fragmented into multiple elements), which must be presen...
IE_VECTOR m_elements
Information element vector.
virtual uint32_t DeserializeSingleIe(Buffer::Iterator start)
Needed when you try to deserialize a lonely IE inside other header.
uint32_t GetSize() const
Current number of bytes.
uint16_t m_maxSize
Size in bytes (actually, max packet length)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
#define IE11S_MESH_PEERING_PROTOCOL_VERSION
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define IE_PREQ
#define IE_RANN
#define IE_MESH_CONFIGURATION
#define IE_PREP
#define IE_BEACON_TIMING
#define IE_MESH_LINK_METRIC_REPORT
#define IE_MESH_PEERING_MANAGEMENT
#define IE_MESH_ID
#define IE_PERR