A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
155  os << " Subtype: = " << (uint16_t) m_subtype << std::endl;
156  os << " Length: = " << (uint16_t) m_length << std::endl;
157  os << " LocalLinkId: = " << m_localLinkId << std::endl;
158  os << " PeerLinkId: = " << m_peerLinkId << std::endl;
159  os << " ReasonCode: = " << m_reasonCode << std::endl;
160  os << "</information_element>" << std::endl;
161 }
162 bool
164 {
165  return ((a.m_length == b.m_length) && (a.m_subtype == b.m_subtype) && (a.m_localLinkId == b.m_localLinkId)
166  && (a.m_peerLinkId == b.m_peerLinkId) && (a.m_reasonCode == b.m_reasonCode));
167 }
168 std::ostream &
169 operator << (std::ostream &os, const IePeerManagement &a)
170 {
171  a.Print (os);
172  return os;
173 }
174 } // namespace dot11s
175 } // namespace ns3
176 
PmpReasonCode m_reasonCode
Present only within close frame.
#define NS_ASSERT(condition)
Definition: assert.h:64
bool operator==(const MeshHeader &a, const MeshHeader &b)
virtual WifiInformationElementId ElementId() const
Own unique Element ID.
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:807
iterator in a Buffer instance
Definition: buffer.h:98
See 7.3.2.85 of draft 2.07.
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 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) ...
void SetPeerClose(uint16_t localLinkID, uint16_t peerLinkId, PmpReasonCode reasonCode)
virtual void Print(std::ostream &os) const
In addition, a subclass may optionally override the following...
uint16_t m_peerLinkId
Present within confirm and may be present in close.
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:935
#define IE11S_PEERING_MANAGEMENT
void SetPeerConfirm(uint16_t localLinkID, uint16_t peerLinkId)
void WriteU8(uint8_t data)
Definition: buffer.h:690
PmpReasonCode
Codes used by 802.11s Peer Management Protocol.
uint8_t ReadU8(void)
Definition: buffer.h:819
void SetPeerOpen(uint16_t localLinkId)
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1090
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
virtual void SerializeInformationField(Buffer::Iterator i) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...