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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Kirill Andreev <andreev@iitp.ru>
7 * Aleksey Kovalenko <kovalenko@iitp.ru>
8 */
9
11
12#include "ns3/assert.h"
13#include "ns3/packet.h"
14
15namespace ns3
16{
17namespace dot11s
18{
19
21 : m_length(3),
22 m_subtype(PEER_OPEN),
23 m_localLinkId(0),
24 m_peerLinkId(0),
25 m_reasonCode(REASON11S_RESERVED)
26{
27}
28
34
35void
36IePeerManagement::SetPeerOpen(uint16_t localLinkId)
37{
38 m_length = 3;
40 m_localLinkId = localLinkId;
41}
42
43void
44IePeerManagement::SetPeerClose(uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode reasonCode)
45{
46 m_length = 7;
48 m_localLinkId = localLinkId;
49 m_peerLinkId = peerLinkId;
50 m_reasonCode = reasonCode;
51}
52
53void
54IePeerManagement::SetPeerConfirm(uint16_t localLinkId, uint16_t peerLinkId)
55{
56 m_length = 5;
58 m_localLinkId = localLinkId;
59 m_peerLinkId = peerLinkId;
60}
61
67
68uint16_t
73
74uint16_t
79
80uint16_t
85
86uint8_t
88{
89 return m_subtype;
90}
91
92bool
94{
95 return (m_subtype == PEER_OPEN);
96}
97
98bool
100{
101 return (m_subtype == PEER_CLOSE);
102}
103
104bool
109
110void
124
125uint16_t
127{
128 Buffer::Iterator i = start;
129 m_subtype = i.ReadU8();
130 m_length = length;
131 if (m_subtype == PEER_OPEN)
132 {
133 NS_ASSERT(length == 3);
134 }
135 if (m_subtype == PEER_CONFIRM)
136 {
137 NS_ASSERT(length == 5);
138 }
139 if (m_subtype == PEER_CLOSE)
140 {
141 NS_ASSERT(length == 7);
142 }
144 if (m_length > 3)
145 {
147 }
148 if (m_length > 5)
149 {
151 }
152 return i.GetDistanceFrom(start);
153}
154
155void
156IePeerManagement::Print(std::ostream& os) const
157{
158 os << "PeerMgmt=(Subtype=" << (uint16_t)m_subtype << ", Length=" << (uint16_t)m_length
159 << ", LocalLinkId=" << m_localLinkId << ", PeerLinkId=" << m_peerLinkId
160 << ", ReasonCode=" << m_reasonCode << ")";
161}
162
163bool
165{
166 return ((a.m_length == b.m_length) && (a.m_subtype == b.m_subtype) &&
168 (a.m_reasonCode == b.m_reasonCode));
169}
170
171std::ostream&
172operator<<(std::ostream& os, const IePeerManagement& a)
173{
174 a.Print(os);
175 return os;
176}
177} // namespace dot11s
178} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteHtolsbU16(uint16_t data)
Definition buffer.cc:891
void WriteU8(uint8_t data)
Definition buffer.h:870
uint16_t ReadLsbtohU16()
Definition buffer.cc:1053
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
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:55
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