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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#include "ie-dot11s-prep.h"
10
11#include "ns3/address-utils.h"
12#include "ns3/assert.h"
13#include "ns3/packet.h"
14
15namespace ns3
16{
17namespace dot11s
18{
19/********************************
20 * IePrep
21 *******************************/
25
27 : m_flags(0),
28 m_hopcount(0),
29 m_ttl(0),
30 m_destinationAddress(Mac48Address::GetBroadcast()),
31 m_destSeqNumber(0),
32 m_lifetime(0),
33 m_metric(0),
34 m_originatorAddress(Mac48Address::GetBroadcast()),
35 m_originatorSeqNumber(0)
36{
37}
38
41{
42 return IE_PREP;
43}
44
45void
46IePrep::SetFlags(uint8_t flags)
47{
48 m_flags = flags;
49}
50
51void
52IePrep::SetHopcount(uint8_t hopcount)
53{
54 m_hopcount = hopcount;
55}
56
57void
58IePrep::SetTtl(uint8_t ttl)
59{
60 m_ttl = ttl;
61}
62
63void
65{
66 m_destSeqNumber = destSeqNumber;
67}
68
69void
74
75void
77{
78 m_metric = metric;
79}
80
81void
83{
84 m_originatorAddress = originatorAddress;
85}
86
87void
89{
90 m_originatorSeqNumber = originatorSeqNumber;
91}
92
93void
95{
96 m_lifetime = lifetime;
97}
98
99uint8_t
101{
102 return m_flags;
103}
104
105uint8_t
107{
108 return m_hopcount;
109}
110
113{
114 return m_ttl;
115}
116
122
128
131{
132 return m_metric;
133}
134
140
146
149{
150 return m_lifetime;
151}
152
153void
155{
156 m_ttl--;
157 m_hopcount++;
158}
159
160void
162{
163 m_metric += metric;
164}
165
166void
179
180uint16_t
195
196uint16_t
198{
199 uint32_t retval = 1 // Flags
200 + 1 // Hopcount
201 + 1 // Ttl
202 + 6 // Dest address
203 + 4 // Dest seqno
204 + 4 // Lifetime
205 + 4 // metric
206 + 6 // Originator address
207 + 4; // Originator seqno
208 return retval;
209}
210
211void
212IePrep::Print(std::ostream& os) const
213{
214 os << "PREP=(Flags=" << +m_flags << ", Hopcount=" << +m_hopcount << ", TTL=" << m_ttl
215 << ",Destination=" << m_destinationAddress << ", Dest. seqnum=" << m_destSeqNumber
216 << ", Lifetime=" << m_lifetime << ", Metric=" << m_metric
217 << ", Originator=" << m_originatorAddress << ", Orig. seqnum=" << m_originatorSeqNumber
218 << ")";
219}
220
221bool
222operator==(const IePrep& a, const IePrep& b)
223{
224 return ((a.m_flags == b.m_flags) && (a.m_hopcount == b.m_hopcount) && (a.m_ttl == b.m_ttl) &&
229}
230
231std::ostream&
232operator<<(std::ostream& os, const IePrep& a)
233{
234 a.Print(os);
235 return os;
236}
237} // namespace dot11s
238} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteU8(uint8_t data)
Definition buffer.h:870
void WriteHtolsbU32(uint32_t data)
Definition buffer.cc:899
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
uint32_t ReadLsbtohU32()
Definition buffer.cc:1065
an EUI-48 address
See 7.3.2.97 of 802.11s draft 2.07.
uint32_t GetMetric() const
Get metric function.
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