A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ie-dot11s-prep.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Kirill Andreev <andreev@iitp.ru>
18 */
19
20#include "ie-dot11s-prep.h"
21
22#include "ns3/address-utils.h"
23#include "ns3/assert.h"
24#include "ns3/packet.h"
25
26namespace ns3
27{
28namespace dot11s
29{
30/********************************
31 * IePrep
32 *******************************/
34{
35}
36
38 : m_flags(0),
39 m_hopcount(0),
40 m_ttl(0),
41 m_destinationAddress(Mac48Address::GetBroadcast()),
42 m_destSeqNumber(0),
43 m_lifetime(0),
44 m_metric(0),
45 m_originatorAddress(Mac48Address::GetBroadcast()),
46 m_originatorSeqNumber(0)
47{
48}
49
52{
53 return IE_PREP;
54}
55
56void
57IePrep::SetFlags(uint8_t flags)
58{
59 m_flags = flags;
60}
61
62void
63IePrep::SetHopcount(uint8_t hopcount)
64{
65 m_hopcount = hopcount;
66}
67
68void
69IePrep::SetTtl(uint8_t ttl)
70{
71 m_ttl = ttl;
72}
73
74void
76{
77 m_destSeqNumber = destSeqNumber;
78}
79
80void
82{
83 m_destinationAddress = destAddress;
84}
85
86void
88{
89 m_metric = metric;
90}
91
92void
94{
95 m_originatorAddress = originatorAddress;
96}
97
98void
100{
101 m_originatorSeqNumber = originatorSeqNumber;
102}
103
104void
106{
107 m_lifetime = lifetime;
108}
109
110uint8_t
112{
113 return m_flags;
114}
115
116uint8_t
118{
119 return m_hopcount;
120}
121
124{
125 return m_ttl;
126}
127
130{
131 return m_destSeqNumber;
132}
133
136{
138}
139
142{
143 return m_metric;
144}
145
148{
149 return m_originatorAddress;
150}
151
154{
156}
157
160{
161 return m_lifetime;
162}
163
164void
166{
167 m_ttl--;
168 m_hopcount++;
169}
170
171void
173{
174 m_metric += metric;
175}
176
177void
179{
180 i.WriteU8(m_flags);
182 i.WriteU8(m_ttl);
189}
190
191uint16_t
193{
194 Buffer::Iterator i = start;
195 m_flags = i.ReadU8();
196 m_hopcount = i.ReadU8();
197 m_ttl = i.ReadU8();
204 return i.GetDistanceFrom(start);
205}
206
207uint16_t
209{
210 uint32_t retval = 1 // Flags
211 + 1 // Hopcount
212 + 1 // Ttl
213 + 6 // Dest address
214 + 4 // Dest seqno
215 + 4 // Lifetime
216 + 4 // metric
217 + 6 // Originator address
218 + 4; // Originator seqno
219 return retval;
220}
221
222void
223IePrep::Print(std::ostream& os) const
224{
225 os << "PREP=(Flags=" << +m_flags << ", Hopcount=" << +m_hopcount << ", TTL=" << m_ttl
226 << ",Destination=" << m_destinationAddress << ", Dest. seqnum=" << m_destSeqNumber
227 << ", Lifetime=" << m_lifetime << ", Metric=" << m_metric
228 << ", Originator=" << m_originatorAddress << ", Orig. seqnum=" << m_originatorSeqNumber
229 << ")";
230}
231
232bool
233operator==(const IePrep& a, const IePrep& b)
234{
235 return ((a.m_flags == b.m_flags) && (a.m_hopcount == b.m_hopcount) && (a.m_ttl == b.m_ttl) &&
240}
241
242std::ostream&
243operator<<(std::ostream& os, const IePrep& a)
244{
245 a.Print(os);
246 return os;
247}
248} // namespace dot11s
249} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:910
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
uint32_t ReadLsbtohU32()
Definition: buffer.cc:1076
an EUI-48 address
Definition: mac48-address.h:46
See 7.3.2.97 of 802.11s draft 2.07.
uint32_t GetMetric() const
Get metric function.
uint8_t m_flags
flags
void SerializeInformationField(Buffer::Iterator i) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
void SetTtl(uint8_t ttl)
Set TTL function.
uint32_t m_lifetime
lifetime
void SetDestinationSeqNumber(uint32_t dest_seq_number)
Set destination sequence number function.
uint32_t m_destSeqNumber
destination sequence number
uint8_t GetFlags() const
Get flags function.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
Mac48Address GetDestinationAddress() const
Get destination address function.
void SetFlags(uint8_t flags)
Set flags function.
void SetHopcount(uint8_t hopcount)
Set hop count function.
uint8_t m_hopcount
hop count
uint32_t m_originatorSeqNumber
originator sequence number
void IncrementMetric(uint32_t metric)
Increment metric function.
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint32_t GetLifetime() const
Get lifetime function.
uint32_t GetOriginatorSeqNumber() const
Get originator sequence number.
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address function.
void SetMetric(uint32_t metric)
Set metric function.
void SetDestinationAddress(Mac48Address dest_address)
Set destination address function.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
uint32_t m_metric
metric
void SetLifetime(uint32_t lifetime)
Set lifetime function.
Mac48Address GetOriginatorAddress() const
Get originator address function.
uint32_t GetTtl() const
Get TTL function.
void DecrementTtl()
Decrement TTL function.
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
Set originator sequence number function.
Mac48Address m_originatorAddress
originator address
uint32_t GetDestinationSeqNumber() const
Get destination sequence number function.
Mac48Address m_destinationAddress
destination address
void Print(std::ostream &os) const override
Generate human-readable form of IE.
uint8_t GetHopcount() const
Get hop count function.
bool operator==(const MeshHeader &a, const MeshHeader &b)
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
#define IE_PREP