A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
wifi-information-element.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Dean Armstrong
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: Dean Armstrong <deanarm@gmail.com>
19
*/
20
21
#include "
wifi-information-element.h
"
22
23
namespace
ns3
{
24
25
WifiInformationElement::~WifiInformationElement
()
26
{
27
}
28
29
void
30
WifiInformationElement::Print
(std::ostream &os)
const
31
{
32
}
33
34
uint16_t
35
WifiInformationElement::GetSerializedSize
()
const
36
{
37
return
(2 +
GetInformationFieldSize
());
38
}
39
40
WifiInformationElementId
41
WifiInformationElement::ElementIdExt
()
const
42
{
43
return
0;
44
}
45
46
Buffer::Iterator
47
WifiInformationElement::Serialize
(
Buffer::Iterator
i)
const
48
{
49
i.
WriteU8
(
ElementId
());
50
i.
WriteU8
(
GetInformationFieldSize
());
51
if
(
ElementId
() ==
IE_EXTENSION
)
52
{
53
i.
WriteU8
(
ElementIdExt
());
54
SerializeInformationField
(i);
55
i.
Next
(
GetInformationFieldSize
() - 1);
56
}
57
else
58
{
59
SerializeInformationField
(i);
60
i.
Next
(
GetInformationFieldSize
());
61
}
62
return
i;
63
}
64
65
Buffer::Iterator
66
WifiInformationElement::Deserialize
(
Buffer::Iterator
i)
67
{
68
Buffer::Iterator
start
= i;
69
i =
DeserializeIfPresent
(i);
70
//This IE was not optional, so confirm that we did actually
71
//deserialise something.
72
NS_ASSERT
(i.
GetDistanceFrom
(
start
) != 0);
73
return
i;
74
}
75
76
Buffer::Iterator
77
WifiInformationElement::DeserializeIfPresent
(
Buffer::Iterator
i)
78
{
79
if
(i.
IsEnd
())
80
{
81
return
i;
82
}
83
Buffer::Iterator
start
= i;
84
uint8_t elementId = i.
ReadU8
();
85
86
//If the element here isn't the one we're after then we immediately
87
//return the iterator we were passed indicating that we haven't
88
//taken anything from the buffer.
89
if
(elementId !=
ElementId
())
90
{
91
return
start
;
92
}
93
94
uint8_t length = i.
ReadU8
();
95
if
(
ElementId
() ==
IE_EXTENSION
)
96
{
97
uint8_t elementIdExt = i.
ReadU8
();
98
//If the element here isn't the one we're after then we immediately
99
//return the iterator we were passed indicating that we haven't
100
//taken anything from the buffer.
101
if
(elementIdExt !=
ElementIdExt
())
102
{
103
return
start
;
104
}
105
DeserializeInformationField
(i, length - 1);
106
i.
Next
(length - 1);
107
}
108
else
109
{
110
DeserializeInformationField
(i, length);
111
i.
Next
(length);
112
}
113
return
i;
114
}
115
116
bool
117
WifiInformationElement::operator==
(
WifiInformationElement
const
& a)
const
118
{
119
if
(
ElementId
() != a.
ElementId
())
120
{
121
return
false
;
122
}
123
124
if
(
GetInformationFieldSize
() != a.
GetInformationFieldSize
())
125
{
126
return
false
;
127
}
128
129
if
(
ElementIdExt
() != a.
ElementIdExt
())
130
{
131
return
false
;
132
}
133
134
uint32_t ieSize =
GetInformationFieldSize
();
135
136
Buffer
myIe, hisIe;
137
myIe.
AddAtEnd
(ieSize);
138
hisIe.
AddAtEnd
(ieSize);
139
140
SerializeInformationField
(myIe.
Begin
());
141
a.
SerializeInformationField
(hisIe.
Begin
());
142
143
return
(memcmp (myIe.
PeekData
(), hisIe.
PeekData
(), ieSize) == 0);
144
}
145
146
}
//namespace ns3
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:67
ns3::Buffer::AddAtEnd
void AddAtEnd(uint32_t end)
Definition:
buffer.cc:354
ns3::WifiInformationElement::Deserialize
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize entire IE, which must be present.
Definition:
wifi-information-element.cc:66
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::WifiInformationElement::ElementId
virtual WifiInformationElementId ElementId() const =0
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:1021
ns3::WifiInformationElement
Information element, as defined in 802.11-2007 standard.
Definition:
wifi-information-element.h:234
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)
wifi-information-element.h
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:869
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
Definition:
wifi-information-element.h:40
ns3::Buffer::Iterator::Next
void Next(void)
go forward by one byte
Definition:
buffer.h:845
ns3::WifiInformationElement::GetSerializedSize
virtual uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
Definition:
wifi-information-element.cc:35
ns3::WifiInformationElement::DeserializeIfPresent
Buffer::Iterator DeserializeIfPresent(Buffer::Iterator i)
Deserialize entire IE if it is present.
Definition:
wifi-information-element.cc:77
visualizer.core.start
def start()
Definition:
core.py:1855
ns3::WifiInformationElement::Serialize
virtual Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
Definition:
wifi-information-element.cc:47
ns3::WifiInformationElement::~WifiInformationElement
virtual ~WifiInformationElement()
Definition:
wifi-information-element.cc:25
ns3::WifiInformationElement::operator==
virtual bool operator==(WifiInformationElement const &a) const
Compare two IEs for equality by ID & Length, and then through memcmp of serialised version.
Definition:
wifi-information-element.cc:117
ns3::Buffer
automatically resized byte buffer
Definition:
buffer.h:93
IE_EXTENSION
#define IE_EXTENSION
Definition:
wifi-information-element.h:189
ns3::Buffer::PeekData
uint8_t const * PeekData(void) const
Definition:
buffer.cc:710
ns3::Buffer::Begin
Buffer::Iterator Begin(void) const
Definition:
buffer.h:1069
ns3::WifiInformationElement::ElementIdExt
virtual WifiInformationElementId ElementIdExt() const
Definition:
wifi-information-element.cc:41
ns3::WifiInformationElement::GetInformationFieldSize
virtual uint8_t GetInformationFieldSize() const =0
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:99
ns3::WifiInformationElement::Print
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
Definition:
wifi-information-element.cc:30
ns3::WifiInformationElement::SerializeInformationField
virtual void SerializeInformationField(Buffer::Iterator start) const =0
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
ns3::Buffer::Iterator::IsEnd
bool IsEnd(void) const
Definition:
buffer.cc:804
src
wifi
model
wifi-information-element.cc
Generated on Fri Oct 1 2021 17:03:48 for ns-3 by
1.8.20