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
iterator in a Buffer instance
Definition: buffer.h:99
void Next(void)
go forward by one byte
Definition: buffer.h:845
uint8_t ReadU8(void)
Definition: buffer.h:1021
void Prev(void)
go backward by one byte
Definition: buffer.h:851
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
Introspection did not find any typical Config paths.
TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
virtual uint32_t DeserializeSingleIe(Buffer::Iterator start)
Needed when you try to deserialize a lonely IE inside other header.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
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)
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:165
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
#define IE11S_MESH_PEERING_PROTOCOL_VERSION
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853
#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