|
29 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkOpenStart); |
29 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkOpenStart); |
30 |
|
30 |
|
31 |
PeerLinkOpenStart::PeerLinkOpenStart () : |
31 |
PeerLinkOpenStart::PeerLinkOpenStart () : |
32 |
m_subtype ((uint8_t)(WifiActionHeader::PEER_LINK_OPEN)), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (), |
32 |
m_capability (0), m_rates (SupportedRates ()), m_meshId (), |
33 |
m_config (IeConfiguration ()) |
33 |
m_config (IeConfiguration ()) |
34 |
{ |
34 |
{ |
35 |
} |
35 |
} |
36 |
void |
36 |
void |
37 |
PeerLinkOpenStart::SetPlinkOpenStart (PeerLinkOpenStart::PlinkOpenStartFields fields) |
37 |
PeerLinkOpenStart::SetPlinkOpenStart (PeerLinkOpenStart::PlinkOpenStartFields fields) |
38 |
{ |
38 |
{ |
39 |
m_subtype = fields.subtype; |
39 |
m_capability = fields.capability; |
40 |
|
40 |
m_rates = fields.rates; |
41 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
41 |
m_meshId = fields.meshId; |
42 |
{ |
42 |
m_config = fields.config; |
43 |
m_capability = fields.capability; |
|
|
44 |
} |
45 |
if (m_subtype == (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)) |
46 |
{ |
47 |
m_aid = fields.aid; |
48 |
} |
49 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
50 |
{ |
51 |
m_rates = fields.rates; |
52 |
} |
53 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)) |
54 |
{ |
55 |
m_meshId = fields.meshId; |
56 |
} |
57 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
58 |
{ |
59 |
m_config = fields.config; |
60 |
} |
61 |
else |
62 |
{ |
63 |
//reasonCode not used here |
64 |
} |
65 |
} |
43 |
} |
66 |
PeerLinkOpenStart::PlinkOpenStartFields |
44 |
PeerLinkOpenStart::PlinkOpenStartFields |
67 |
PeerLinkOpenStart::GetFields () const |
45 |
PeerLinkOpenStart::GetFields () const |
68 |
{ |
46 |
{ |
69 |
PlinkOpenStartFields retval; |
47 |
PlinkOpenStartFields retval; |
70 |
/// \todo protocol version: |
48 |
/// \todo protocol version: |
71 |
retval.subtype = m_subtype; |
|
|
72 |
retval.capability = m_capability; |
49 |
retval.capability = m_capability; |
73 |
retval.aid = m_aid; |
|
|
74 |
retval.rates = m_rates; |
50 |
retval.rates = m_rates; |
75 |
retval.meshId = m_meshId; |
51 |
retval.meshId = m_meshId; |
76 |
retval.config = m_config; |
52 |
retval.config = m_config; |
|
95 |
void |
71 |
void |
96 |
PeerLinkOpenStart::Print (std::ostream &os) const |
72 |
PeerLinkOpenStart::Print (std::ostream &os) const |
97 |
{ |
73 |
{ |
98 |
os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = " |
74 |
os << "capability=" << m_capability << ", rates=" << m_rates; |
99 |
<< (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = "; |
75 |
os << ", "; |
100 |
m_meshId.Print (os); |
76 |
m_meshId.Print (os); |
101 |
os << std::endl << "configuration = "; |
77 |
os << ", "; |
102 |
m_config.Print (os); |
78 |
m_config.Print (os); |
103 |
os << std::endl << "reason code = " << m_reasonCode; |
|
|
104 |
} |
79 |
} |
105 |
uint32_t |
80 |
uint32_t |
106 |
PeerLinkOpenStart::GetSerializedSize () const |
81 |
PeerLinkOpenStart::GetSerializedSize () const |
107 |
{ |
82 |
{ |
108 |
uint32_t size =0; //Peering protocol |
83 |
uint32_t size =0; //Peering protocol |
109 |
NS_ASSERT (m_subtype < 4); |
84 |
size += 2; //capability |
110 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
85 |
size += m_rates.GetSerializedSize (); |
111 |
{ |
86 |
size += m_rates.extended.GetSerializedSize (); |
112 |
size += 2; //capability |
87 |
size += m_meshId.GetInformationFieldSize () + 2; |
113 |
} |
88 |
size += m_config.GetInformationFieldSize () + 2; |
114 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
|
|
115 |
{ |
116 |
size += 2; //AID of remote peer |
117 |
} |
118 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
119 |
{ |
120 |
size += m_rates.GetSerializedSize (); |
121 |
size += m_rates.extended.GetSerializedSize (); |
122 |
} |
123 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
124 |
{ |
125 |
size += m_meshId.GetInformationFieldSize () + 2; |
126 |
} |
127 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
128 |
{ |
129 |
size += m_config.GetInformationFieldSize () + 2; |
130 |
} |
131 |
else |
132 |
{ |
133 |
//reasonCode not used here |
134 |
} |
135 |
return size; |
89 |
return size; |
136 |
} |
90 |
} |
137 |
void |
91 |
void |
138 |
PeerLinkOpenStart::Serialize (Buffer::Iterator start) const |
92 |
PeerLinkOpenStart::Serialize (Buffer::Iterator start) const |
139 |
{ |
93 |
{ |
140 |
Buffer::Iterator i = start; |
94 |
Buffer::Iterator i = start; |
141 |
NS_ASSERT (m_subtype < 4); |
|
|
142 |
|
95 |
|
143 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
96 |
i.WriteHtolsbU16 (m_capability); |
144 |
{ |
97 |
i = m_rates.Serialize (i); |
145 |
i.WriteHtolsbU16 (m_capability); |
98 |
i = m_rates.extended.Serialize (i); |
146 |
} |
99 |
i = m_meshId.Serialize (i); |
147 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
100 |
i = m_config.Serialize (i); |
148 |
{ |
|
|
149 |
i.WriteHtolsbU16 (m_aid); |
150 |
} |
151 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
152 |
{ |
153 |
i = m_rates.Serialize (i); |
154 |
i = m_rates.extended.Serialize (i); |
155 |
} |
156 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
157 |
{ |
158 |
i = m_meshId.Serialize (i); |
159 |
} |
160 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
161 |
{ |
162 |
i = m_config.Serialize (i); |
163 |
} |
164 |
else |
165 |
{ |
166 |
//reasonCode not used here |
167 |
} |
168 |
} |
101 |
} |
169 |
uint32_t |
102 |
uint32_t |
170 |
PeerLinkOpenStart::Deserialize (Buffer::Iterator start) |
103 |
PeerLinkOpenStart::Deserialize (Buffer::Iterator start) |
171 |
{ |
104 |
{ |
172 |
Buffer::Iterator i = start; |
105 |
Buffer::Iterator i = start; |
173 |
NS_ASSERT (m_subtype < 4); |
|
|
174 |
|
106 |
|
175 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
107 |
m_capability = i.ReadLsbtohU16 (); |
|
|
108 |
i = m_rates.Deserialize (i); |
109 |
i = m_rates.extended.DeserializeIfPresent (i); |
110 |
uint8_t id = i.ReadU8 (); |
111 |
uint8_t length = i.ReadU8 (); |
112 |
m_meshId.DeserializeInformationField (i, length); |
113 |
if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length)) |
176 |
{ |
114 |
{ |
177 |
m_capability = i.ReadLsbtohU16 (); |
115 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
178 |
} |
116 |
} |
179 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
117 |
i.Next (m_meshId.GetInformationFieldSize ()); |
|
|
118 |
id = i.ReadU8 (); |
119 |
length = i.ReadU8 (); |
120 |
m_config.DeserializeInformationField (i, length); |
121 |
if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length)) |
180 |
{ |
122 |
{ |
181 |
m_aid = i.ReadLsbtohU16 (); |
123 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
182 |
} |
124 |
} |
183 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
125 |
i.Next (m_config.GetInformationFieldSize ()); |
184 |
{ |
126 |
|
185 |
i = m_rates.Deserialize (i); |
|
|
186 |
i = m_rates.extended.DeserializeIfPresent (i); |
187 |
} |
188 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
189 |
{ |
190 |
uint8_t id = i.ReadU8 (); |
191 |
uint8_t length = i.ReadU8 (); |
192 |
m_meshId.DeserializeInformationField (i, length); |
193 |
if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length)) |
194 |
{ |
195 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
196 |
} |
197 |
i.Next (m_meshId.GetInformationFieldSize ()); |
198 |
} |
199 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
200 |
{ |
201 |
uint8_t id = i.ReadU8 (); |
202 |
uint8_t length = i.ReadU8 (); |
203 |
m_config.DeserializeInformationField (i, length); |
204 |
if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length)) |
205 |
{ |
206 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
207 |
} |
208 |
i.Next (m_config.GetInformationFieldSize ()); |
209 |
} |
210 |
else |
211 |
{ |
212 |
//reasonCode not used here |
213 |
} |
214 |
return i.GetDistanceFrom (start); |
127 |
return i.GetDistanceFrom (start); |
215 |
} |
128 |
} |
216 |
bool |
129 |
bool |
217 |
operator== (const PeerLinkOpenStart & a, const PeerLinkOpenStart & b) |
130 |
operator== (const PeerLinkOpenStart & a, const PeerLinkOpenStart & b) |
218 |
{ |
131 |
{ |
219 |
return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid) |
132 |
return ((a.m_capability == b.m_capability) |
220 |
&& (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config)); |
133 |
&& (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config)); |
221 |
|
134 |
|
222 |
} |
135 |
} |
223 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkCloseStart); |
136 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkCloseStart); |
224 |
|
137 |
|
225 |
PeerLinkCloseStart::PeerLinkCloseStart () : |
138 |
PeerLinkCloseStart::PeerLinkCloseStart () : |
226 |
m_subtype ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (), |
139 |
m_meshId () |
227 |
m_config (IeConfiguration ()) |
|
|
228 |
{ |
140 |
{ |
229 |
} |
141 |
} |
230 |
void |
142 |
void |
231 |
PeerLinkCloseStart::SetPlinkCloseStart (PeerLinkCloseStart::PlinkCloseStartFields fields) |
143 |
PeerLinkCloseStart::SetPlinkCloseStart (PeerLinkCloseStart::PlinkCloseStartFields fields) |
232 |
{ |
144 |
{ |
233 |
m_subtype = fields.subtype; |
145 |
m_meshId = fields.meshId; |
234 |
|
|
|
235 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
236 |
{ |
237 |
m_capability = fields.capability; |
238 |
} |
239 |
if (m_subtype == (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)) |
240 |
{ |
241 |
m_aid = fields.aid; |
242 |
} |
243 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
244 |
{ |
245 |
m_rates = fields.rates; |
246 |
} |
247 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)) |
248 |
{ |
249 |
m_meshId = fields.meshId; |
250 |
} |
251 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
252 |
{ |
253 |
m_config = fields.config; |
254 |
} |
255 |
else |
256 |
{ |
257 |
//reasonCode not used here |
258 |
} |
259 |
} |
146 |
} |
260 |
PeerLinkCloseStart::PlinkCloseStartFields |
147 |
PeerLinkCloseStart::PlinkCloseStartFields |
261 |
PeerLinkCloseStart::GetFields () const |
148 |
PeerLinkCloseStart::GetFields () const |
262 |
{ |
149 |
{ |
263 |
PlinkCloseStartFields retval; |
150 |
PlinkCloseStartFields retval; |
264 |
/// \todo protocol version: |
151 |
/// \todo protocol version: |
265 |
retval.subtype = m_subtype; |
|
|
266 |
retval.capability = m_capability; |
267 |
retval.aid = m_aid; |
268 |
retval.rates = m_rates; |
269 |
retval.meshId = m_meshId; |
152 |
retval.meshId = m_meshId; |
270 |
retval.config = m_config; |
|
|
271 |
|
153 |
|
272 |
return retval; |
154 |
return retval; |
273 |
} |
155 |
} |
|
289 |
void |
171 |
void |
290 |
PeerLinkCloseStart::Print (std::ostream &os) const |
172 |
PeerLinkCloseStart::Print (std::ostream &os) const |
291 |
{ |
173 |
{ |
292 |
os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = " |
|
|
293 |
<< (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = "; |
294 |
m_meshId.Print (os); |
174 |
m_meshId.Print (os); |
295 |
os << std::endl << "configuration = "; |
|
|
296 |
m_config.Print (os); |
297 |
os << std::endl << "reason code = " << m_reasonCode; |
298 |
} |
175 |
} |
299 |
uint32_t |
176 |
uint32_t |
300 |
PeerLinkCloseStart::GetSerializedSize () const |
177 |
PeerLinkCloseStart::GetSerializedSize () const |
301 |
{ |
178 |
{ |
302 |
uint32_t size =0; //Peering protocol |
179 |
uint32_t size =0; //Peering protocol |
303 |
NS_ASSERT (m_subtype < 4); |
180 |
size += m_meshId.GetInformationFieldSize () + 2; |
304 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
|
|
305 |
{ |
306 |
size += 2; //capability |
307 |
} |
308 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
309 |
{ |
310 |
size += 2; //AID of remote peer |
311 |
} |
312 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
313 |
{ |
314 |
size += m_rates.GetSerializedSize (); |
315 |
size += m_rates.extended.GetSerializedSize (); |
316 |
} |
317 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
318 |
{ |
319 |
size += m_meshId.GetInformationFieldSize () + 2; |
320 |
} |
321 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
322 |
{ |
323 |
size += m_config.GetInformationFieldSize () + 2; |
324 |
} |
325 |
else |
326 |
{ |
327 |
//reasonCode not used here |
328 |
} |
329 |
return size; |
181 |
return size; |
330 |
} |
182 |
} |
331 |
void |
183 |
void |
332 |
PeerLinkCloseStart::Serialize (Buffer::Iterator start) const |
184 |
PeerLinkCloseStart::Serialize (Buffer::Iterator start) const |
333 |
{ |
185 |
{ |
334 |
Buffer::Iterator i = start; |
186 |
Buffer::Iterator i = start; |
335 |
NS_ASSERT (m_subtype < 4); |
187 |
i = m_meshId.Serialize (i); |
336 |
|
|
|
337 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
338 |
{ |
339 |
i.WriteHtolsbU16 (m_capability); |
340 |
} |
341 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
342 |
{ |
343 |
i.WriteHtolsbU16 (m_aid); |
344 |
} |
345 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
346 |
{ |
347 |
i = m_rates.Serialize (i); |
348 |
i = m_rates.extended.Serialize (i); |
349 |
} |
350 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
351 |
{ |
352 |
i = m_meshId.Serialize (i); |
353 |
} |
354 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
355 |
{ |
356 |
i = m_config.Serialize (i); |
357 |
} |
358 |
else |
359 |
{ |
360 |
//reasonCode not used here |
361 |
} |
362 |
} |
188 |
} |
363 |
uint32_t |
189 |
uint32_t |
364 |
PeerLinkCloseStart::Deserialize (Buffer::Iterator start) |
190 |
PeerLinkCloseStart::Deserialize (Buffer::Iterator start) |
365 |
{ |
191 |
{ |
366 |
Buffer::Iterator i = start; |
192 |
Buffer::Iterator i = start; |
367 |
NS_ASSERT (m_subtype < 4); |
|
|
368 |
|
193 |
|
369 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
194 |
uint8_t id = i.ReadU8 (); |
|
|
195 |
uint8_t length = i.ReadU8 (); |
196 |
m_meshId.DeserializeInformationField (i, length); |
197 |
if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length)) |
370 |
{ |
198 |
{ |
371 |
m_capability = i.ReadLsbtohU16 (); |
199 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
372 |
} |
200 |
} |
373 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
201 |
i.Next (m_meshId.GetInformationFieldSize ()); |
374 |
{ |
|
|
375 |
m_aid = i.ReadLsbtohU16 (); |
376 |
} |
377 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
378 |
{ |
379 |
i = m_rates.Deserialize (i); |
380 |
i = m_rates.extended.DeserializeIfPresent (i); |
381 |
} |
382 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
383 |
{ |
384 |
uint8_t id = i.ReadU8 (); |
385 |
uint8_t length = i.ReadU8 (); |
386 |
m_meshId.DeserializeInformationField (i, length); |
387 |
if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length)) |
388 |
{ |
389 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
390 |
} |
391 |
i.Next (m_meshId.GetInformationFieldSize ()); |
392 |
} |
393 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
394 |
{ |
395 |
uint8_t id = i.ReadU8 (); |
396 |
uint8_t length = i.ReadU8 (); |
397 |
m_config.DeserializeInformationField (i, length); |
398 |
if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length)) |
399 |
{ |
400 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
401 |
} |
402 |
i.Next (m_config.GetInformationFieldSize ()); |
403 |
} |
404 |
else |
405 |
{ |
406 |
//reasonCode not used here |
407 |
} |
408 |
return i.GetDistanceFrom (start); |
202 |
return i.GetDistanceFrom (start); |
409 |
} |
203 |
} |
410 |
bool |
204 |
bool |
411 |
operator== (const PeerLinkCloseStart & a, const PeerLinkCloseStart & b) |
205 |
operator== (const PeerLinkCloseStart & a, const PeerLinkCloseStart & b) |
412 |
{ |
206 |
{ |
413 |
return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid) |
207 |
return ((a.m_meshId.IsEqual (b.m_meshId))); |
414 |
&& (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config)); |
|
|
415 |
|
416 |
} |
208 |
} |
417 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkConfirmStart); |
209 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkConfirmStart); |
418 |
|
210 |
|
419 |
PeerLinkConfirmStart::PeerLinkConfirmStart () : |
211 |
PeerLinkConfirmStart::PeerLinkConfirmStart () : |
420 |
m_subtype ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (), |
212 |
m_capability (0), m_aid (0), m_rates (SupportedRates ()), |
421 |
m_config (IeConfiguration ()) |
213 |
m_config (IeConfiguration ()) |
422 |
{ |
214 |
{ |
423 |
} |
215 |
} |
424 |
void |
216 |
void |
425 |
PeerLinkConfirmStart::SetPlinkConfirmStart (PeerLinkConfirmStart::PlinkConfirmStartFields fields) |
217 |
PeerLinkConfirmStart::SetPlinkConfirmStart (PeerLinkConfirmStart::PlinkConfirmStartFields fields) |
426 |
{ |
218 |
{ |
427 |
m_subtype = fields.subtype; |
219 |
m_capability = fields.capability; |
428 |
|
220 |
m_aid = fields.aid; |
429 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
221 |
m_rates = fields.rates; |
430 |
{ |
222 |
m_config = fields.config; |
431 |
m_capability = fields.capability; |
|
|
432 |
} |
433 |
if (m_subtype == (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)) |
434 |
{ |
435 |
m_aid = fields.aid; |
436 |
} |
437 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
438 |
{ |
439 |
m_rates = fields.rates; |
440 |
} |
441 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM)) |
442 |
{ |
443 |
m_meshId = fields.meshId; |
444 |
} |
445 |
if (m_subtype != (uint8_t)(WifiActionHeader::PEER_LINK_CLOSE)) |
446 |
{ |
447 |
m_config = fields.config; |
448 |
} |
449 |
else |
450 |
{ |
451 |
//reasonCode not used here |
452 |
} |
453 |
} |
223 |
} |
454 |
PeerLinkConfirmStart::PlinkConfirmStartFields |
224 |
PeerLinkConfirmStart::PlinkConfirmStartFields |
455 |
PeerLinkConfirmStart::GetFields () const |
225 |
PeerLinkConfirmStart::GetFields () const |
456 |
{ |
226 |
{ |
457 |
PlinkConfirmStartFields retval; |
227 |
PlinkConfirmStartFields retval; |
458 |
/// \todo protocol version: |
228 |
/// \todo protocol version: |
459 |
retval.subtype = m_subtype; |
|
|
460 |
retval.capability = m_capability; |
229 |
retval.capability = m_capability; |
461 |
retval.aid = m_aid; |
230 |
retval.aid = m_aid; |
462 |
retval.rates = m_rates; |
231 |
retval.rates = m_rates; |
463 |
retval.meshId = m_meshId; |
|
|
464 |
retval.config = m_config; |
232 |
retval.config = m_config; |
465 |
|
233 |
|
466 |
return retval; |
234 |
return retval; |
|
483 |
void |
251 |
void |
484 |
PeerLinkConfirmStart::Print (std::ostream &os) const |
252 |
PeerLinkConfirmStart::Print (std::ostream &os) const |
485 |
{ |
253 |
{ |
486 |
os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = " |
254 |
os << "capability=" << m_capability << ", rates=" << m_rates; |
487 |
<< (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = "; |
255 |
os << ", "; |
488 |
m_meshId.Print (os); |
|
|
489 |
os << std::endl << "configuration = "; |
490 |
m_config.Print (os); |
256 |
m_config.Print (os); |
491 |
os << std::endl << "reason code = " << m_reasonCode; |
|
|
492 |
} |
257 |
} |
493 |
uint32_t |
258 |
uint32_t |
494 |
PeerLinkConfirmStart::GetSerializedSize () const |
259 |
PeerLinkConfirmStart::GetSerializedSize () const |
495 |
{ |
260 |
{ |
496 |
uint32_t size =0; //Peering protocol |
261 |
uint32_t size =0; //Peering protocol |
497 |
NS_ASSERT (m_subtype < 4); |
262 |
size += 2; //capability |
498 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
263 |
size += 2; //AID of remote peer |
499 |
{ |
264 |
size += m_rates.GetSerializedSize (); |
500 |
size += 2; //capability |
265 |
size += m_rates.extended.GetSerializedSize (); |
501 |
} |
266 |
size += m_config.GetInformationFieldSize () + 2; |
502 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
|
|
503 |
{ |
504 |
size += 2; //AID of remote peer |
505 |
} |
506 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
507 |
{ |
508 |
size += m_rates.GetSerializedSize (); |
509 |
size += m_rates.extended.GetSerializedSize (); |
510 |
} |
511 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
512 |
{ |
513 |
size += m_meshId.GetInformationFieldSize () + 2; |
514 |
} |
515 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
516 |
{ |
517 |
size += m_config.GetInformationFieldSize () + 2; |
518 |
} |
519 |
else |
520 |
{ |
521 |
//reasonCode not used here |
522 |
} |
523 |
return size; |
267 |
return size; |
524 |
} |
268 |
} |
525 |
void |
269 |
void |
526 |
PeerLinkConfirmStart::Serialize (Buffer::Iterator start) const |
270 |
PeerLinkConfirmStart::Serialize (Buffer::Iterator start) const |
527 |
{ |
271 |
{ |
528 |
Buffer::Iterator i = start; |
272 |
Buffer::Iterator i = start; |
529 |
NS_ASSERT (m_subtype < 4); |
|
|
530 |
|
273 |
|
531 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
274 |
i.WriteHtolsbU16 (m_capability); |
532 |
{ |
275 |
i.WriteHtolsbU16 (m_aid); |
533 |
i.WriteHtolsbU16 (m_capability); |
276 |
i = m_rates.Serialize (i); |
534 |
} |
277 |
i = m_rates.extended.Serialize (i); |
535 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
278 |
i = m_config.Serialize (i); |
536 |
{ |
|
|
537 |
i.WriteHtolsbU16 (m_aid); |
538 |
} |
539 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
540 |
{ |
541 |
i = m_rates.Serialize (i); |
542 |
i = m_rates.extended.Serialize (i); |
543 |
} |
544 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
545 |
{ |
546 |
i = m_meshId.Serialize (i); |
547 |
} |
548 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
549 |
{ |
550 |
i = m_config.Serialize (i); |
551 |
} |
552 |
else |
553 |
{ |
554 |
//reasonCode not used here |
555 |
} |
556 |
} |
279 |
} |
557 |
uint32_t |
280 |
uint32_t |
558 |
PeerLinkConfirmStart::Deserialize (Buffer::Iterator start) |
281 |
PeerLinkConfirmStart::Deserialize (Buffer::Iterator start) |
559 |
{ |
282 |
{ |
560 |
Buffer::Iterator i = start; |
283 |
Buffer::Iterator i = start; |
561 |
NS_ASSERT (m_subtype < 4); |
|
|
562 |
|
284 |
|
563 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
285 |
m_capability = i.ReadLsbtohU16 (); |
|
|
286 |
m_aid = i.ReadLsbtohU16 (); |
287 |
i = m_rates.Deserialize (i); |
288 |
i = m_rates.extended.DeserializeIfPresent (i); |
289 |
uint8_t id = i.ReadU8 (); |
290 |
uint8_t length = i.ReadU8 (); |
291 |
m_config.DeserializeInformationField (i, length); |
292 |
if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length)) |
564 |
{ |
293 |
{ |
565 |
m_capability = i.ReadLsbtohU16 (); |
294 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
566 |
} |
295 |
} |
567 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype) |
296 |
i.Next (m_config.GetInformationFieldSize ()); |
568 |
{ |
|
|
569 |
m_aid = i.ReadLsbtohU16 (); |
570 |
} |
571 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
572 |
{ |
573 |
i = m_rates.Deserialize (i); |
574 |
i = m_rates.extended.DeserializeIfPresent (i); |
575 |
} |
576 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype) |
577 |
{ |
578 |
uint8_t id = i.ReadU8 (); |
579 |
uint8_t length = i.ReadU8 (); |
580 |
m_meshId.DeserializeInformationField (i, length); |
581 |
if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length)) |
582 |
{ |
583 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
584 |
} |
585 |
i.Next (m_meshId.GetInformationFieldSize ()); |
586 |
} |
587 |
if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype) |
588 |
{ |
589 |
uint8_t id = i.ReadU8 (); |
590 |
uint8_t length = i.ReadU8 (); |
591 |
m_config.DeserializeInformationField (i, length); |
592 |
if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length)) |
593 |
{ |
594 |
NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!"); |
595 |
} |
596 |
i.Next (m_config.GetInformationFieldSize ()); |
597 |
} |
598 |
else |
599 |
{ |
600 |
//reasonCode not used here |
601 |
} |
602 |
return i.GetDistanceFrom (start); |
297 |
return i.GetDistanceFrom (start); |
603 |
} |
298 |
} |
604 |
bool |
299 |
bool |
605 |
operator== (const PeerLinkConfirmStart & a, const PeerLinkConfirmStart & b) |
300 |
operator== (const PeerLinkConfirmStart & a, const PeerLinkConfirmStart & b) |
606 |
{ |
301 |
{ |
607 |
return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid) |
302 |
return ((a.m_capability == b.m_capability) && (a.m_aid == b.m_aid) |
608 |
&& (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config)); |
303 |
&& (a.m_config == b.m_config)); |
609 |
|
|
|
610 |
} |
304 |
} |
611 |
} // namespace dot11s |
305 |
} // namespace dot11s |
612 |
} // namespace ns3 |
306 |
} // namespace ns3 |