A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ie-dot11s-peer-management.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 * Authors: Kirill Andreev <andreev@iitp.ru>
18 * Aleksey Kovalenko <kovalenko@iitp.ru>
19 */
20
22
23#include "ns3/assert.h"
24#include "ns3/packet.h"
25
26namespace ns3
27{
28namespace dot11s
29{
30
32 : m_length(3),
33 m_subtype(PEER_OPEN),
34 m_localLinkId(0),
35 m_peerLinkId(0),
36 m_reasonCode(REASON11S_RESERVED)
37{
38}
39
42{
44}
45
46void
47IePeerManagement::SetPeerOpen(uint16_t localLinkId)
48{
49 m_length = 3;
51 m_localLinkId = localLinkId;
52}
53
54void
55IePeerManagement::SetPeerClose(uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode reasonCode)
56{
57 m_length = 7;
59 m_localLinkId = localLinkId;
60 m_peerLinkId = peerLinkId;
61 m_reasonCode = reasonCode;
62}
63
64void
65IePeerManagement::SetPeerConfirm(uint16_t localLinkId, uint16_t peerLinkId)
66{
67 m_length = 5;
69 m_localLinkId = localLinkId;
70 m_peerLinkId = peerLinkId;
71}
72
75{
76 return m_reasonCode;
77}
78
79uint16_t
81{
82 return m_localLinkId;
83}
84
85uint16_t
87{
88 return m_peerLinkId;
89}
90
91uint16_t
93{
94 return m_length;
95}
96
97uint8_t
99{
100 return m_subtype;
101}
102
103bool
105{
106 return (m_subtype == PEER_OPEN);
107}
108
109bool
111{
112 return (m_subtype == PEER_CLOSE);
113}
114
115bool
117{
118 return (m_subtype == PEER_CONFIRM);
119}
120
121void
123{
126 if (m_length > 3)
127 {
129 }
130 if (m_length > 5)
131 {
133 }
134}
135
136uint16_t
138{
139 Buffer::Iterator i = start;
140 m_subtype = i.ReadU8();
141 m_length = length;
142 if (m_subtype == PEER_OPEN)
143 {
144 NS_ASSERT(length == 3);
145 }
146 if (m_subtype == PEER_CONFIRM)
147 {
148 NS_ASSERT(length == 5);
149 }
150 if (m_subtype == PEER_CLOSE)
151 {
152 NS_ASSERT(length == 7);
153 }
155 if (m_length > 3)
156 {
158 }
159 if (m_length > 5)
160 {
162 }
163 return i.GetDistanceFrom(start);
164}
165
166void
167IePeerManagement::Print(std::ostream& os) const
168{
169 os << "PeerMgmt=(Subtype=" << (uint16_t)m_subtype << ", Length=" << (uint16_t)m_length
170 << ", LocalLinkId=" << m_localLinkId << ", PeerLinkId=" << m_peerLinkId
171 << ", ReasonCode=" << m_reasonCode << ")";
172}
173
174bool
176{
177 return ((a.m_length == b.m_length) && (a.m_subtype == b.m_subtype) &&
179 (a.m_reasonCode == b.m_reasonCode));
180}
181
182std::ostream&
183operator<<(std::ostream& os, const IePeerManagement& a)
184{
185 a.Print(os);
186 return os;
187}
188} // namespace dot11s
189} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:902
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
uint16_t ReadLsbtohU16()
Definition: buffer.cc:1064
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
according to IEEE 802.11 - 2012
uint16_t m_peerLinkId
Present within confirm and may be present in close.
bool SubtypeIsOpen() const
Subtype is open function.
PmpReasonCode m_reasonCode
Present only within close frame.
bool SubtypeIsClose() const
Subtype is close function.
PmpReasonCode GetReasonCode() const
Get reason code 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)
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
bool SubtypeIsConfirm() const
Subtype is confirm function.
void SetPeerConfirm(uint16_t localLinkID, uint16_t peerLinkId)
Set peer confirm function.
uint8_t GetSubtype() const
Get subtype function.
uint16_t GetPeerLinkId() const
Get peer link ID function.
void SetPeerOpen(uint16_t localLinkId)
Set peer open function.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
void SetPeerClose(uint16_t localLinkID, uint16_t peerLinkId, PmpReasonCode reasonCode)
Set peer close function.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
uint16_t GetLocalLinkId() const
Get local link ID function.
uint16_t DeserializeInformationField(Buffer::Iterator i, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
PmpReasonCode
Codes used by 802.11s Peer Management Protocol.
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.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
#define IE_MESH_PEERING_MANAGEMENT