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
}
src
wifi
model
wifi-information-element.cc
Generated on Tue May 14 2013 11:08:36 for ns-3 by
1.8.1.2