A Discrete-Event Network Simulator
API
ie-dot11s-peer-management.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  * Authors: Kirill Andreev <andreev@iitp.ru>
19  * Aleksey Kovalenko <kovalenko@iitp.ru>
20  */
21 
23 #include "ns3/assert.h"
24 #include "ns3/packet.h"
25 
26 namespace ns3 {
27 namespace dot11s {
28 
30  m_length (3), m_subtype (PEER_OPEN), m_localLinkId (0), m_peerLinkId (0), m_reasonCode (REASON11S_RESERVED)
31 {
32 }
35 {
37 }
38 void
39 IePeerManagement::SetPeerOpen (uint16_t localLinkId)
40 {
41  m_length = 3;
43  m_localLinkId = localLinkId;
44 }
45 void
46 IePeerManagement::SetPeerClose (uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode reasonCode)
47 {
48  m_length = 7;
50  m_localLinkId = localLinkId;
51  m_peerLinkId = peerLinkId;
52  m_reasonCode = reasonCode;
53 }
54 
55 void
56 IePeerManagement::SetPeerConfirm (uint16_t localLinkId, uint16_t peerLinkId)
57 {
58  m_length = 5;
60  m_localLinkId = localLinkId;
61  m_peerLinkId = peerLinkId;
62 }
63 
66 {
67  return m_reasonCode;
68 }
69 
70 uint16_t
72 {
73  return m_localLinkId;
74 }
75 
76 uint16_t
78 {
79  return m_peerLinkId;
80 }
81 
82 uint8_t
84 {
85  return m_length;
86 }
87 uint8_t
89 {
90  return m_subtype;
91 }
92 bool
94 {
95  return (m_subtype == PEER_OPEN);
96 }
97 bool
99 {
100  return (m_subtype == PEER_CLOSE);
101 }
102 bool
104 {
105  return (m_subtype == PEER_CONFIRM);
106 }
107 
108 void
110 {
111  i.WriteU8 (m_subtype);
113  if (m_length > 3)
114  {
116  }
117  if (m_length > 5)
118  {
120  }
121 }
122 uint8_t
124 {
126  m_subtype = i.ReadU8 ();
127  m_length = length;
128  if (m_subtype == PEER_OPEN)
129  {
130  NS_ASSERT (length == 3);
131  }
132  if (m_subtype == PEER_CONFIRM)
133  {
134  NS_ASSERT (length == 5);
135  }
136  if (m_subtype == PEER_CLOSE)
137  {
138  NS_ASSERT (length == 7);
139  }
141  if (m_length > 3)
142  {
144  }
145  if (m_length > 5)
146  {
148  }
149  return i.GetDistanceFrom (start);
150 }
151 void
152 IePeerManagement::Print (std::ostream& os) const
153 {
154  os << "PeerMgmt=(Subtype=" << (uint16_t) m_subtype
155  << ", Length=" << (uint16_t) m_length
156  << ", LocalLinkId=" << m_localLinkId
157  << ", PeerLinkId=" << m_peerLinkId
158  << ", ReasonCode=" << m_reasonCode
159  << ")";
160 }
161 bool
163 {
164  return ((a.m_length == b.m_length) && (a.m_subtype == b.m_subtype) && (a.m_localLinkId == b.m_localLinkId)
165  && (a.m_peerLinkId == b.m_peerLinkId) && (a.m_reasonCode == b.m_reasonCode));
166 }
167 std::ostream &
168 operator << (std::ostream &os, const IePeerManagement &a)
169 {
170  a.Print (os);
171  return os;
172 }
173 } // namespace dot11s
174 } // namespace ns3
175 
iterator in a Buffer instance
Definition: buffer.h:99
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:911
void WriteU8(uint8_t data)
Definition: buffer.h:869
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1066
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
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.
virtual WifiInformationElementId ElementId() const
bool SubtypeIsClose() const
Subtype is close function.
PmpReasonCode GetReasonCode() const
Get reason code function.
virtual uint8_t DeserializeInformationField(Buffer::Iterator i, uint8_t length)
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
bool SubtypeIsConfirm() const
Subtype is confirm function.
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
void SetPeerConfirm(uint16_t localLinkID, uint16_t peerLinkId)
Set peer confirm function.
uint8_t GetSubtype() const
Get subtype function.
virtual uint8_t GetInformationFieldSize(void) const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
virtual void SerializeInformationField(Buffer::Iterator i) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint16_t GetPeerLinkId() const
Get peer link ID function.
void SetPeerOpen(uint16_t localLinkId)
Set peer open function.
void SetPeerClose(uint16_t localLinkID, uint16_t peerLinkId, PmpReasonCode reasonCode)
Set peer close function.
uint16_t GetLocalLinkId() const
Get local link ID function.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
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.
def start()
Definition: core.py:1853
#define IE_MESH_PEERING_MANAGEMENT