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
ie-dot11s-prep.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008,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: Kirill Andreev <andreev@iitp.ru>
19
*/
20
21
#include "
ie-dot11s-prep.h
"
22
#include "ns3/address-utils.h"
23
#include "ns3/assert.h"
24
#include "ns3/packet.h"
25
namespace
ns3 {
26
namespace
dot11s {
27
/********************************
28
* IePrep
29
*******************************/
30
IePrep::~IePrep
()
31
{
32
}
33
IePrep::IePrep
() :
34
m_flags (0), m_hopcount (0), m_ttl (0), m_destinationAddress (
Mac48Address
::GetBroadcast ()),
35
m_destSeqNumber (0), m_lifetime (0), m_metric (0), m_originatorAddress (
Mac48Address
::GetBroadcast ()),
36
m_originatorSeqNumber (0)
37
{
38
}
39
WifiInformationElementId
40
IePrep::ElementId
()
const
41
{
42
return
IE11S_PREP
;
43
}
44
void
45
IePrep::SetFlags
(uint8_t flags)
46
{
47
m_flags
= flags;
48
}
49
void
50
IePrep::SetHopcount
(uint8_t hopcount)
51
{
52
m_hopcount
= hopcount;
53
}
54
void
55
IePrep::SetTtl
(uint8_t ttl)
56
{
57
m_ttl
= ttl;
58
}
59
void
60
IePrep::SetDestinationSeqNumber
(uint32_t destSeqNumber)
61
{
62
m_destSeqNumber
= destSeqNumber;
63
}
64
void
65
IePrep::SetDestinationAddress
(
Mac48Address
destAddress)
66
{
67
m_destinationAddress
= destAddress;
68
}
69
void
70
IePrep::SetMetric
(uint32_t metric)
71
{
72
m_metric
= metric;
73
}
74
void
75
IePrep::SetOriginatorAddress
(
Mac48Address
originatorAddress)
76
{
77
m_originatorAddress
= originatorAddress;
78
}
79
void
80
IePrep::SetOriginatorSeqNumber
(uint32_t originatorSeqNumber)
81
{
82
m_originatorSeqNumber
= originatorSeqNumber;
83
}
84
void
85
IePrep::SetLifetime
(uint32_t lifetime)
86
{
87
m_lifetime
= lifetime;
88
}
89
uint8_t
90
IePrep::GetFlags
()
const
91
{
92
return
m_flags
;
93
}
94
uint8_t
95
IePrep::GetHopcount
()
const
96
{
97
return
m_hopcount
;
98
}
99
uint32_t
100
IePrep::GetTtl
()
const
101
{
102
return
m_ttl
;
103
}
104
uint32_t
105
IePrep::GetDestinationSeqNumber
()
const
106
{
107
return
m_destSeqNumber
;
108
}
109
Mac48Address
110
IePrep::GetDestinationAddress
()
const
111
{
112
return
m_destinationAddress
;
113
}
114
uint32_t
115
IePrep::GetMetric
()
const
116
{
117
return
m_metric
;
118
}
119
Mac48Address
120
IePrep::GetOriginatorAddress
()
const
121
{
122
return
m_originatorAddress
;
123
}
124
uint32_t
125
IePrep::GetOriginatorSeqNumber
()
const
126
{
127
return
m_originatorSeqNumber
;
128
}
129
uint32_t
130
IePrep::GetLifetime
()
const
131
{
132
return
m_lifetime
;
133
}
134
void
135
IePrep::DecrementTtl
()
136
{
137
m_ttl
--;
138
m_hopcount
++;
139
}
140
141
void
142
IePrep::IncrementMetric
(uint32_t metric)
143
{
144
m_metric
+= metric;
145
}
146
147
void
148
IePrep::SerializeInformationField
(
Buffer::Iterator
i)
const
149
{
150
i.
WriteU8
(
m_flags
);
151
i.
WriteU8
(
m_hopcount
);
152
i.
WriteU8
(
m_ttl
);
153
WriteTo
(i,
m_destinationAddress
);
154
i.
WriteHtolsbU32
(
m_destSeqNumber
);
155
i.
WriteHtolsbU32
(
m_lifetime
);
156
i.
WriteHtolsbU32
(
m_metric
);
157
WriteTo
(i,
m_originatorAddress
);
158
i.
WriteHtolsbU32
(
m_originatorSeqNumber
);
159
}
160
uint8_t
161
IePrep::DeserializeInformationField
(
Buffer::Iterator
start
, uint8_t length)
162
{
163
Buffer::Iterator
i =
start
;
164
m_flags
= i.
ReadU8
();
165
m_hopcount
= i.
ReadU8
();
166
m_ttl
= i.
ReadU8
();
167
ReadFrom
(i,
m_destinationAddress
);
168
m_destSeqNumber
= i.
ReadLsbtohU32
();
169
m_lifetime
= i.
ReadLsbtohU32
();
170
m_metric
= i.
ReadLsbtohU32
();
171
ReadFrom
(i,
m_originatorAddress
);
172
m_originatorSeqNumber
= i.
ReadLsbtohU32
();
173
return
i.
GetDistanceFrom
(start);
174
}
175
uint8_t
176
IePrep::GetInformationFieldSize
()
const
177
{
178
uint32_t retval = 1
//Flags
179
+ 1
//Hopcount
180
+ 1
//Ttl
181
+ 6
//Dest address
182
+ 4
//Dest seqno
183
+ 4
//Lifetime
184
+ 4
//metric
185
+ 6
//Originator address
186
+ 4;
//Originator seqno
187
return
retval;
188
}
189
void
190
IePrep::Print
(std::ostream& os)
const
191
{
192
os << std::endl <<
"<information_element id="
<<
ElementId
() <<
">"
<< std::endl;
193
os <<
"Flags: = "
<<
m_flags
<< std::endl <<
"Hopcount: = "
<<
m_hopcount
<< std::endl <<
"TTL: = "
<<
m_ttl
194
<< std::endl<<
"Destination: = "
<<
m_destinationAddress
<< std::endl <<
"Dest. seqnum: = "
<<
m_destSeqNumber
195
<< std::endl <<
"Lifetime: = "
<<
m_lifetime
<< std::endl<<
"Metric: = "
<<
m_metric
<< std::endl <<
"Originator: = "
196
<<
m_originatorAddress
<< std::endl <<
"Orig. seqnum: = "
<<
m_originatorSeqNumber
<< std::endl;
197
os <<
"</information_element>"
<< std::endl;
198
}
199
bool
200
operator==
(
const
IePrep
& a,
const
IePrep
& b)
201
{
202
return
((a.
m_flags
== b.
m_flags
) && (a.
m_hopcount
== b.
m_hopcount
) && (a.
m_ttl
== b.
m_ttl
)
203
&& (a.
m_destinationAddress
== b.
m_destinationAddress
) && (a.
m_destSeqNumber
== b.
m_destSeqNumber
)
204
&& (a.
m_lifetime
== b.
m_lifetime
) && (a.
m_metric
== b.
m_metric
) && (a.
m_originatorAddress
205
== b.
m_originatorAddress
) && (a.
m_originatorSeqNumber
== b.
m_originatorSeqNumber
));
206
}
207
std::ostream &
208
operator <<
(std::ostream &os,
const
IePrep
&a)
209
{
210
a.
Print
(os);
211
return
os;
212
}
213
}
// namespace dot11s
214
}
// namespace ns3
215
src
mesh
model
dot11s
ie-dot11s-prep.cc
Generated on Tue Nov 13 2012 10:32:18 for ns-3 by
1.8.1.2