A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mesh-information-element-vector.cc
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 
21 #include "mesh-information-element-vector.h"
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 uint32_t
41 {
42  Buffer::Iterator i = start;
43  uint8_t id = i.ReadU8 ();
44  uint8_t length = i.ReadU8 ();
45  Ptr<WifiInformationElement> newElement;
46  switch (id)
47  {
48  case IE11S_MESH_CONFIGURATION:
49  newElement = Create<dot11s::IeConfiguration> ();
50  break;
51  case IE11S_MESH_ID:
52  newElement = Create<dot11s::IeMeshId> ();
53  break;
54  case IE11S_LINK_METRIC_REPORT:
55  newElement = Create<dot11s::IeLinkMetricReport> ();
56  break;
57  case IE11S_PEERING_MANAGEMENT:
58  newElement = Create<dot11s::IePeerManagement> ();
59  break;
60  case IE11S_BEACON_TIMING:
61  newElement = Create<dot11s::IeBeaconTiming> ();
62  break;
63  case IE11S_RANN:
64  newElement = Create<dot11s::IeRann> ();
65  break;
66  case IE11S_PREQ:
67  newElement = Create<dot11s::IePreq> ();
68  break;
69  case IE11S_PREP:
70  newElement = Create<dot11s::IePrep> ();
71  break;
72  case IE11S_PERR:
73  newElement = Create<dot11s::IePerr> ();
74  break;
75  case IE11S_MESH_PEERING_PROTOCOL_VERSION:
76  newElement = Create<dot11s::IePeeringProtocol> ();
77  break;
78  default:
79  // We peeked at the ID and length, so we need to back up the
80  // pointer before deferring to our parent.
81  i.Prev (2);
83  }
84  if (GetSize () + length > m_maxSize)
85  {
86  NS_FATAL_ERROR ("Check max size for information element!");
87  }
88  newElement->DeserializeInformationField (i, length);
89  i.Next (length);
90  m_elements.push_back (newElement);
91  return i.GetDistanceFrom (start);
92 }
93 
94 
95 } // namespace ns3
virtual uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)=0
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:807
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
iterator in a Buffer instance
Definition: buffer.h:98
void Prev(void)
Definition: buffer.h:672
void Next(void)
Definition: buffer.h:666
virtual uint32_t DeserializeSingleIe(Buffer::Iterator start)
Needed when you try to deserialize a lonely IE inside other header.
uint16_t m_maxSize
Size in bytes (actually, max packet length)
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.
uint8_t ReadU8(void)
Definition: buffer.h:819