A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
* Authors: Dean Armstrong <deanarm@gmail.com>
19
*/
20
21
#include "ns3/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
Buffer::Iterator
41
WifiInformationElement::Serialize
(
Buffer::Iterator
i)
const
42
{
43
i.
WriteU8
(
ElementId
());
44
i.
WriteU8
(
GetInformationFieldSize
());
45
SerializeInformationField
(i);
46
i.
Next
(
GetInformationFieldSize
());
47
return
i;
48
}
49
50
Buffer::Iterator
51
WifiInformationElement::Deserialize
(
Buffer::Iterator
i)
52
{
53
Buffer::Iterator
start
= i;
54
i =
DeserializeIfPresent
(i);
55
// This IE was not optional, so confirm that we did actually
56
// deserialise something.
57
NS_ASSERT
(i.
GetDistanceFrom
(start) != 0);
58
return
i;
59
}
60
61
Buffer::Iterator
62
WifiInformationElement::DeserializeIfPresent
(
Buffer::Iterator
i)
63
{
64
Buffer::Iterator
start
= i;
65
uint8_t elementId = i.
ReadU8
();
66
67
// If the element here isn't the one we're after then we immediately
68
// return the iterator we were passed indicating that we haven't
69
// taken anything from the buffer.
70
if
(elementId !=
ElementId
())
71
{
72
return
start
;
73
}
74
75
uint8_t length = i.
ReadU8
();
76
77
DeserializeInformationField
(i, length);
78
i.
Next
(length);
79
80
return
i;
81
}
82
83
84
bool
85
WifiInformationElement::operator<
(
WifiInformationElement
const
& a)
const
86
{
87
return
(
ElementId
() < a.
ElementId
());
88
}
89
90
bool
91
WifiInformationElement::operator==
(
WifiInformationElement
const
& a)
const
92
{
93
if
(
ElementId
() != a.
ElementId
())
94
{
95
return
false
;
96
}
97
98
if
(
GetInformationFieldSize
() != a.
GetInformationFieldSize
())
99
{
100
return
false
;
101
}
102
103
uint32_t ieSize =
GetInformationFieldSize
();
104
105
Buffer
myIe, hisIe;
106
myIe.
AddAtEnd
(ieSize);
107
hisIe.
AddAtEnd
(ieSize);
108
109
SerializeInformationField
(myIe.
Begin
());
110
a.
SerializeInformationField
(hisIe.
Begin
());
111
112
return
(memcmp (myIe.
PeekData
(), hisIe.
PeekData
(), ieSize) == 0);
113
}
114
115
}
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::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
automatically resized byte buffer
Definition:
buffer.h:92
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
visualizer.core.start
def start
Definition:
core.py:1482
ns3::WifiInformationElement::ElementId
virtual WifiInformationElementId ElementId() const =0
Own unique Element ID.
ns3::WifiInformationElement::Deserialize
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize entire IE, which must be present.
Definition:
wifi-information-element.cc:51
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:807
ns3::WifiInformationElement::GetSerializedSize
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
Definition:
wifi-information-element.cc:35
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::WifiInformationElement
Information element, as defined in 802.11-2007 standardThe IEEE 802.11 standard includes the notion o...
Definition:
wifi-information-element.h:130
ns3::Buffer::PeekData
uint8_t const * PeekData(void) const
Definition:
buffer.cc:729
ns3::WifiInformationElement::DeserializeIfPresent
Buffer::Iterator DeserializeIfPresent(Buffer::Iterator i)
Deserialize entire IE if it is present.
Definition:
wifi-information-element.cc:62
ns3::Buffer::Iterator::Next
void Next(void)
go forward by one byte
Definition:
buffer.h:666
ns3::WifiInformationElement::operator<
virtual bool operator<(WifiInformationElement const &a) const
Compare information elements using Element ID.
Definition:
wifi-information-element.cc:85
ns3::Buffer::Begin
Buffer::Iterator Begin(void) const
Definition:
buffer.h:875
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::WifiInformationElement::Print
virtual void Print(std::ostream &os) const
In addition, a subclass may optionally override the following...
Definition:
wifi-information-element.cc:30
ns3::Buffer::AddAtEnd
bool AddAtEnd(uint32_t end)
Definition:
buffer.cc:356
ns3::WifiInformationElement::~WifiInformationElement
virtual ~WifiInformationElement()
Definition:
wifi-information-element.cc:25
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:690
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:819
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:91
ns3::WifiInformationElement::Serialize
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
Definition:
wifi-information-element.cc:41
src
wifi
model
wifi-information-element.cc
Generated on Sat Apr 19 2014 14:07:11 for ns-3 by
1.8.6