LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2008,2009 IITP RAS | 3 * Copyright (c) 2008,2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Kirill Andreev <andreev@iitp.ru> | 18 * Author: Kirill Andreev <andreev@iitp.ru> |
19 */ | 19 */ |
20 | 20 |
21 | |
22 #include "ie-dot11s-preq.h" | 21 #include "ie-dot11s-preq.h" |
23 #include "ns3/address-utils.h" | 22 #include "ns3/address-utils.h" |
24 #include "ns3/node.h" | |
25 #include "ns3/assert.h" | 23 #include "ns3/assert.h" |
26 #include "ns3/test.h" | |
27 #include "ns3/packet.h" | 24 #include "ns3/packet.h" |
28 | 25 |
29 namespace ns3 { | 26 namespace ns3 { |
30 namespace dot11s { | 27 namespace dot11s { |
31 /************************* | 28 /************************* |
32 * DestinationAddressUnit | 29 * DestinationAddressUnit |
33 ************************/ | 30 ************************/ |
34 DestinationAddressUnit::DestinationAddressUnit (): | 31 DestinationAddressUnit::DestinationAddressUnit () : |
35 m_do (false), | 32 m_do (false), m_rf (false), m_usn (false), m_destinationAddress (Mac48Address
()), m_destSeqNumber (0) |
36 m_rf (false), | |
37 m_usn (false), | |
38 m_destinationAddress (Mac48Address ()), | |
39 m_destSeqNumber (0) | |
40 { | 33 { |
41 } | 34 } |
42 void | 35 void |
43 DestinationAddressUnit::SetFlags (bool doFlag, bool rfFlag, bool usnFlag) | 36 DestinationAddressUnit::SetFlags (bool doFlag, bool rfFlag, bool usnFlag) |
44 { | 37 { |
45 m_do = doFlag; | 38 m_do = doFlag; |
46 m_rf = rfFlag; | 39 m_rf = rfFlag; |
47 m_usn = usnFlag; | 40 m_usn = usnFlag; |
48 } | 41 } |
49 | 42 |
50 void | 43 void |
51 DestinationAddressUnit::SetDestSeqNumber (uint32_t dest_seq_number) | 44 DestinationAddressUnit::SetDestSeqNumber (uint32_t dest_seq_number) |
52 { | 45 { |
53 m_destSeqNumber = dest_seq_number; | 46 m_destSeqNumber = dest_seq_number; |
54 if(m_destSeqNumber != 0) | 47 if (m_destSeqNumber != 0) |
55 m_usn = true; | 48 { |
| 49 m_usn = true; |
| 50 } |
56 } | 51 } |
57 void | 52 void |
58 DestinationAddressUnit::SetDestinationAddress (Mac48Address dest_address) | 53 DestinationAddressUnit::SetDestinationAddress (Mac48Address dest_address) |
59 { | 54 { |
60 m_destinationAddress = dest_address; | 55 m_destinationAddress = dest_address; |
61 } | 56 } |
62 bool | 57 bool |
63 DestinationAddressUnit::IsDo () | 58 DestinationAddressUnit::IsDo () |
64 { | 59 { |
65 return m_do; | 60 return m_do; |
(...skipping 18 matching lines...) Expand all Loading... |
84 DestinationAddressUnit::GetDestinationAddress () const | 79 DestinationAddressUnit::GetDestinationAddress () const |
85 { | 80 { |
86 return m_destinationAddress; | 81 return m_destinationAddress; |
87 } | 82 } |
88 /******************************** | 83 /******************************** |
89 * IePreq | 84 * IePreq |
90 *******************************/ | 85 *******************************/ |
91 IePreq::~IePreq () | 86 IePreq::~IePreq () |
92 { | 87 { |
93 } | 88 } |
94 IePreq::IePreq (): | 89 IePreq::IePreq () : |
95 m_maxSize (32), | 90 m_maxSize (32), m_flags (0), m_hopCount (0), m_ttl (0), m_preqId (0), m_origin
atorAddress ( |
96 m_flags (0), | 91 Mac48Address::GetBroadcast ()), m_originatorSeqNumber (0), m_lifetime (0),
m_metric (0), |
97 m_hopCount (0), | 92 m_destCount (0) |
98 m_ttl (0), | 93 { |
99 m_preqId (0), | 94 } |
100 m_originatorAddress (Mac48Address::GetBroadcast()), | 95 WifiElementId |
101 m_originatorSeqNumber (0), | 96 IePreq::ElementId () const |
102 m_lifetime (0), | 97 { |
103 m_metric (0), | 98 return IE11S_PREQ; |
104 m_destCount (0) | |
105 { | |
106 } | 99 } |
107 void | 100 void |
108 IePreq::SetUnicastPreq () | 101 IePreq::SetUnicastPreq () |
109 { | 102 { |
110 m_flags |= 1<<1; | 103 m_flags |= 1 << 1; |
111 } | 104 } |
112 | 105 |
113 void | 106 void |
114 IePreq::SetNeedNotPrep () | 107 IePreq::SetNeedNotPrep () |
115 { | 108 { |
116 m_flags |= 1<<2; | 109 m_flags |= 1 << 2; |
117 } | 110 } |
118 //void | 111 //void |
119 //IePreq::SetFlags (uint8_t flags) | 112 //IePreq::SetFlags (uint8_t flags) |
120 //{ | 113 //{ |
121 // m_flags = flags; | 114 // m_flags = flags; |
122 //} | 115 //} |
123 void | 116 void |
124 IePreq::SetHopcount (uint8_t hopcount) | 117 IePreq::SetHopcount (uint8_t hopcount) |
125 { | 118 { |
126 m_hopCount = hopcount; | 119 m_hopCount = hopcount; |
(...skipping 29 matching lines...) Expand all Loading... |
156 m_lifetime = lifetime; | 149 m_lifetime = lifetime; |
157 } | 150 } |
158 void | 151 void |
159 IePreq::SetDestCount (uint8_t dest_count) | 152 IePreq::SetDestCount (uint8_t dest_count) |
160 { | 153 { |
161 m_destCount = dest_count; | 154 m_destCount = dest_count; |
162 } | 155 } |
163 bool | 156 bool |
164 IePreq::IsUnicastPreq () const | 157 IePreq::IsUnicastPreq () const |
165 { | 158 { |
166 return (m_flags & (1<<1)); | 159 return (m_flags & (1 << 1)); |
167 } | 160 } |
168 bool | 161 bool |
169 IePreq::IsNeedNotPrep () const | 162 IePreq::IsNeedNotPrep () const |
170 { | 163 { |
171 return (m_flags & (1<<2)); | 164 return (m_flags & (1 << 2)); |
172 } | 165 } |
173 uint8_t | 166 uint8_t |
174 IePreq::GetHopCount () const | 167 IePreq::GetHopCount () const |
175 { | 168 { |
176 return m_hopCount; | 169 return m_hopCount; |
177 } | 170 } |
178 uint8_t | 171 uint8_t |
179 IePreq::GetTtl () const | 172 IePreq::GetTtl () const |
180 { | 173 { |
181 return m_ttl; | 174 return m_ttl; |
(...skipping 25 matching lines...) Expand all Loading... |
207 } | 200 } |
208 | 201 |
209 uint8_t | 202 uint8_t |
210 IePreq::GetDestCount () const | 203 IePreq::GetDestCount () const |
211 { | 204 { |
212 return m_destCount; | 205 return m_destCount; |
213 } | 206 } |
214 void | 207 void |
215 IePreq::DecrementTtl () | 208 IePreq::DecrementTtl () |
216 { | 209 { |
217 m_ttl --; | 210 m_ttl--; |
218 m_hopCount ++; | 211 m_hopCount++; |
219 } | 212 } |
220 void | 213 void |
221 IePreq::IncrementMetric (uint32_t metric) | 214 IePreq::IncrementMetric (uint32_t metric) |
222 { | 215 { |
223 m_metric +=metric; | 216 m_metric += metric; |
224 } | 217 } |
225 void | 218 void |
226 IePreq::SerializeInformation (Buffer::Iterator i) const | 219 IePreq::SerializeInformation (Buffer::Iterator i) const |
227 { | 220 { |
228 i.WriteU8 (m_flags); | 221 i.WriteU8 (m_flags); |
229 i.WriteU8 (m_hopCount); | 222 i.WriteU8 (m_hopCount); |
230 i.WriteU8 (m_ttl); | 223 i.WriteU8 (m_ttl); |
231 i.WriteHtolsbU32 (m_preqId); | 224 i.WriteHtolsbU32 (m_preqId); |
232 WriteTo (i, m_originatorAddress); | 225 WriteTo (i, m_originatorAddress); |
233 i.WriteHtolsbU32 (m_originatorSeqNumber); | 226 i.WriteHtolsbU32 (m_originatorSeqNumber); |
234 i.WriteHtolsbU32 (m_lifetime); | 227 i.WriteHtolsbU32 (m_lifetime); |
235 i.WriteHtolsbU32 (m_metric); | 228 i.WriteHtolsbU32 (m_metric); |
236 i.WriteU8 (m_destCount); | 229 i.WriteU8 (m_destCount); |
237 int written = 0; | 230 int written = 0; |
238 for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator j = m_destinati
ons.begin (); j != m_destinations.end(); j++) | 231 for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator j = m_destinati
ons.begin (); j |
| 232 != m_destinations.end (); j++) |
239 { | 233 { |
240 uint8_t flags = 0; | 234 uint8_t flags = 0; |
241 if ((*j)->IsDo ()) | 235 if ((*j)->IsDo ()) |
242 flags |= 1 << 0; | 236 { |
| 237 flags |= 1 << 0; |
| 238 } |
243 if ((*j)->IsRf ()) | 239 if ((*j)->IsRf ()) |
244 flags |= 1 << 1; | 240 { |
245 if((*j)->IsUsn ()) | 241 flags |= 1 << 1; |
246 flags |= 1 << 2; | 242 } |
| 243 if ((*j)->IsUsn ()) |
| 244 { |
| 245 flags |= 1 << 2; |
| 246 } |
247 i.WriteU8 (flags); | 247 i.WriteU8 (flags); |
248 WriteTo (i, (*j)->GetDestinationAddress()); | 248 WriteTo (i, (*j)->GetDestinationAddress ()); |
249 i.WriteHtolsbU32 ((*j)->GetDestSeqNumber ()); | 249 i.WriteHtolsbU32 ((*j)->GetDestSeqNumber ()); |
250 written++; | 250 written++; |
251 if (written > m_maxSize) | 251 if (written > m_maxSize) |
252 break; | 252 { |
| 253 break; |
| 254 } |
253 } | 255 } |
254 } | 256 } |
255 uint8_t | 257 uint8_t |
256 IePreq::DeserializeInformation (Buffer::Iterator start, uint8_t length) | 258 IePreq::DeserializeInformation (Buffer::Iterator start, uint8_t length) |
257 { | 259 { |
258 Buffer::Iterator i = start; | 260 Buffer::Iterator i = start; |
259 m_flags = i.ReadU8 (); | 261 m_flags = i.ReadU8 (); |
260 m_hopCount = i.ReadU8 (); | 262 m_hopCount = i.ReadU8 (); |
261 m_ttl = i.ReadU8 (); | 263 m_ttl = i.ReadU8 (); |
262 m_preqId = i.ReadLsbtohU32 (); | 264 m_preqId = i.ReadLsbtohU32 (); |
263 ReadFrom (i, m_originatorAddress); | 265 ReadFrom (i, m_originatorAddress); |
264 m_originatorSeqNumber = i.ReadLsbtohU32 (); | 266 m_originatorSeqNumber = i.ReadLsbtohU32 (); |
265 m_lifetime = i.ReadLsbtohU32 (); | 267 m_lifetime = i.ReadLsbtohU32 (); |
266 m_metric = i.ReadLsbtohU32 (); | 268 m_metric = i.ReadLsbtohU32 (); |
267 m_destCount = i.ReadU8 (); | 269 m_destCount = i.ReadU8 (); |
268 for (int j = 0; j < m_destCount; j++ ) | 270 for (int j = 0; j < m_destCount; j++) |
269 { | 271 { |
270 Ptr<DestinationAddressUnit> new_element = Create<DestinationAddressUnit> (
); | 272 Ptr<DestinationAddressUnit> new_element = Create<DestinationAddressUnit> (
); |
271 bool doFlag = false; | 273 bool doFlag = false; |
272 bool rfFlag = false; | 274 bool rfFlag = false; |
273 bool usnFlag = false; | 275 bool usnFlag = false; |
274 uint8_t flags = i.ReadU8 (); | 276 uint8_t flags = i.ReadU8 (); |
275 if (flags & (1 << 0)) | 277 if (flags & (1 << 0)) |
| 278 { |
276 doFlag = true; | 279 doFlag = true; |
| 280 } |
277 if (flags & (1 << 1)) | 281 if (flags & (1 << 1)) |
278 rfFlag = true; | 282 { |
| 283 rfFlag = true; |
| 284 } |
279 if (flags & (1 << 2)) | 285 if (flags & (1 << 2)) |
280 usnFlag = true; | 286 { |
| 287 usnFlag = true; |
| 288 } |
281 new_element->SetFlags (doFlag, rfFlag, usnFlag); | 289 new_element->SetFlags (doFlag, rfFlag, usnFlag); |
282 Mac48Address addr; | 290 Mac48Address addr; |
283 ReadFrom (i,addr); | 291 ReadFrom (i, addr); |
284 new_element->SetDestinationAddress (addr); | 292 new_element->SetDestinationAddress (addr); |
285 new_element->SetDestSeqNumber (i.ReadLsbtohU32()); | 293 new_element->SetDestSeqNumber (i.ReadLsbtohU32 ()); |
286 m_destinations.push_back (new_element); | 294 m_destinations.push_back (new_element); |
287 NS_ASSERT (28+j*11 < length); | 295 NS_ASSERT (28 + j * 11 < length); |
288 } | 296 } |
289 return i.GetDistanceFrom (start); | 297 return i.GetDistanceFrom (start); |
290 } | 298 } |
291 uint8_t | 299 uint8_t |
292 IePreq::GetInformationSize () const | 300 IePreq::GetInformationSize () const |
293 { | 301 { |
294 uint8_t retval = | 302 uint8_t retval = 1 //Flags |
295 1 //Flags | 303 + 1 //Hopcount |
296 +1 //Hopcount | 304 + 1 //TTL |
297 +1 //TTL | 305 + 4 //PREQ ID |
298 +4 //PREQ ID | 306 + 6 //Source address (originator) |
299 +6 //Source address (originator) | 307 + 4 //Originator seqno |
300 +4 //Originator seqno | 308 + 4 //Lifetime |
301 +4 //Lifetime | 309 + 4 //metric |
302 +4 //metric | 310 + 1; //destination count |
303 +1; //destination count | |
304 if (m_destCount > m_maxSize) | 311 if (m_destCount > m_maxSize) |
305 retval += (m_maxSize*11); | 312 { |
| 313 retval += (m_maxSize * 11); |
| 314 } |
306 else | 315 else |
307 retval += (m_destCount*11); | 316 { |
| 317 retval += (m_destCount * 11); |
| 318 } |
308 return retval; | 319 return retval; |
309 } | 320 } |
310 void | 321 void |
311 IePreq::PrintInformation (std::ostream &os) const | 322 IePreq::Print (std::ostream &os) const |
312 { | 323 { |
313 os << " originator address = " << m_originatorAddress << "\n"; | 324 os << std::endl << "<information_element id=" << ElementId () << ">" << std::e
ndl; |
314 os << " TTL = " << (uint16_t)m_ttl << "\n"; | 325 os << " originator address = " << m_originatorAddress << "std::endl"; |
315 os << " hop count = " << (uint16_t)m_hopCount << "\n"; | 326 os << " TTL = " << (uint16_t) m_ttl << "std::endl"; |
316 os << " metric = " << m_metric << "\n"; | 327 os << " hop count = " << (uint16_t) m_hopCount << "std::endl"; |
317 os << " seqno = " << m_originatorSeqNumber << "\n"; | 328 os << " metric = " << m_metric << "std::endl"; |
318 os << " lifetime = " << m_lifetime << "\n"; | 329 os << " seqno = " << m_originatorSeqNumber << "std::endl"; |
319 os << " preq ID = " <<m_preqId << "\n"; | 330 os << " lifetime = " << m_lifetime << "std::endl"; |
320 os << " Destinations are:\n"; | 331 os << " preq ID = " << m_preqId << "std::endl"; |
321 for (int j = 0; j < m_destCount; j++ ) | 332 os << " Destinations are:std::endl"; |
322 os << " " << m_destinations[j]->GetDestinationAddress () << "\n"; | 333 for (int j = 0; j < m_destCount; j++) |
| 334 { |
| 335 os << " " << m_destinations[j]->GetDestinationAddress () << "std::endl"
; |
| 336 } |
| 337 os << "</information_element>" << std::endl; |
323 } | 338 } |
324 std::vector<Ptr<DestinationAddressUnit> > | 339 std::vector<Ptr<DestinationAddressUnit> > |
325 IePreq::GetDestinationList () | 340 IePreq::GetDestinationList () |
326 { | 341 { |
327 return m_destinations; | 342 return m_destinations; |
328 } | 343 } |
329 void | 344 void |
330 IePreq::AddDestinationAddressElement ( | 345 IePreq::AddDestinationAddressElement (bool doFlag, bool rfFlag, Mac48Address des
t_address, |
331 bool doFlag, bool rfFlag, | 346 uint32_t dest_seq_number) |
332 Mac48Address dest_address, | 347 { |
333 uint32_t dest_seq_number | 348 for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator i = m_destinati
ons.begin (); i |
334 ) | 349 != m_destinations.end (); i++) |
335 { | 350 { |
336 for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator i = m_destinati
ons.begin (); i != m_destinations.end(); i++ ) | 351 if ((*i)->GetDestinationAddress () == dest_address) |
337 if ((*i)->GetDestinationAddress () == dest_address) | 352 { |
338 return; | 353 return; |
339 Ptr<DestinationAddressUnit>new_element = Create<DestinationAddressUnit> (); | 354 } |
340 new_element->SetFlags (doFlag, rfFlag, false); | 355 } |
| 356 //TODO: check overflow |
| 357 Ptr<DestinationAddressUnit> new_element = Create<DestinationAddressUnit> (); |
| 358 new_element->SetFlags (doFlag, rfFlag, (dest_seq_number == 0)); |
341 new_element->SetDestinationAddress (dest_address); | 359 new_element->SetDestinationAddress (dest_address); |
342 new_element->SetDestSeqNumber (dest_seq_number); | 360 new_element->SetDestSeqNumber (dest_seq_number); |
343 m_destinations.push_back (new_element); | 361 m_destinations.push_back (new_element); |
344 m_destCount++; | 362 m_destCount++; |
345 } | 363 } |
346 void | 364 void |
347 IePreq::DelDestinationAddressElement (Mac48Address dest_address) | 365 IePreq::DelDestinationAddressElement (Mac48Address dest_address) |
348 { | 366 { |
349 for (std::vector<Ptr<DestinationAddressUnit> >::iterator i = m_destinations.be
gin (); i != m_destinations.end(); i++) | 367 for (std::vector<Ptr<DestinationAddressUnit> >::iterator i = m_destinations.be
gin (); i |
350 if ((*i)->GetDestinationAddress () == dest_address) | 368 != m_destinations.end (); i++) |
351 { | 369 { |
352 m_destinations.erase (i); | 370 if ((*i)->GetDestinationAddress () == dest_address) |
353 m_destCount--; | 371 { |
354 break; | 372 m_destinations.erase (i); |
355 } | 373 m_destCount--; |
356 } | 374 break; |
357 void | 375 } |
358 IePreq::ClearDestinationAddressElement () | 376 } |
| 377 } |
| 378 void |
| 379 IePreq::ClearDestinationAddressElements () |
359 { | 380 { |
360 int i; | 381 int i; |
361 for (std::vector<Ptr<DestinationAddressUnit> >::iterator j = m_destinations.be
gin (); j != m_destinations.end(); j++) | 382 for (std::vector<Ptr<DestinationAddressUnit> >::iterator j = m_destinations.be
gin (); j |
362 (*j) = 0; | 383 != m_destinations.end (); j++) |
363 for (i = 0; i < m_destCount; i ++) | 384 { |
364 m_destinations.pop_back (); | 385 (*j) = 0; |
| 386 } |
| 387 for (i = 0; i < m_destCount; i++) |
| 388 { |
| 389 m_destinations.pop_back (); |
| 390 } |
365 m_destinations.clear (); | 391 m_destinations.clear (); |
366 } | 392 m_destCount = 0; |
367 bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit
& b) | 393 } |
368 { | 394 bool |
369 return (a.m_do == b.m_do· | 395 operator== (const DestinationAddressUnit & a, const DestinationAddressUnit & b) |
370 && a.m_rf == b.m_rf | 396 { |
371 && a.m_usn == b.m_usn | 397 return (a.m_do == b.m_do && a.m_rf == b.m_rf && a.m_usn == b.m_usn && a.m_dest
inationAddress |
372 && a.m_destinationAddress == b.m_destinationAddress | 398 == b.m_destinationAddress && a.m_destSeqNumber == b.m_destSeqNumber); |
373 && a.m_destSeqNumber == b.m_destSeqNumber | 399 } |
374 ); | 400 bool |
375 } | 401 operator== (const IePreq & a, const IePreq & b) |
376 bool operator== (const IePreq & a, const IePreq & b) | 402 { |
377 { | 403 bool ok = (a.m_flags == b.m_flags && a.m_hopCount == b.m_hopCount && a.m_ttl =
= b.m_ttl && a.m_preqId |
378 bool ok = ( a.m_flags == b.m_flags· | 404 == b.m_preqId && a.m_originatorAddress == b.m_originatorAddress && a.m_ori
ginatorSeqNumber |
379 && a.m_hopCount == b.m_hopCount | 405 == b.m_originatorSeqNumber && a.m_lifetime == b.m_lifetime && a.m_metric =
= b.m_metric && a.m_destCount |
380 && a.m_ttl == b.m_ttl | 406 == b.m_destCount); |
381 && a.m_preqId == b.m_preqId· | 407 |
382 && a.m_originatorAddress == b.m_originatorAddress | 408 if (!ok) |
383 && a.m_originatorSeqNumber == b.m_originatorSeqNumber | 409 { |
384 && a.m_lifetime == b.m_lifetime | |
385 && a.m_metric == b.m_metric | |
386 && a.m_destCount == b.m_destCount | |
387 ); | |
388 ·· | |
389 if (! ok)· | |
390 return false; | |
391 ·· | |
392 if (a.m_destinations.size() != b.m_destinations.size()) | |
393 return false; | |
394 ·· | |
395 for (size_t i = 0; i < a.m_destinations.size(); ++i) | |
396 if (!( *(PeekPointer (a.m_destinations[i])) ==· | |
397 *(PeekPointer (b.m_destinations[i])) | |
398 ) | |
399 ) | |
400 return false; | 410 return false; |
401 ·· | 411 } |
| 412 if (a.m_destinations.size () != b.m_destinations.size ()) |
| 413 { |
| 414 return false; |
| 415 } |
| 416 for (size_t i = 0; i < a.m_destinations.size (); ++i) |
| 417 { |
| 418 if (!(*(PeekPointer (a.m_destinations[i])) == *(PeekPointer (b.m_destinati
ons[i])))) |
| 419 { |
| 420 return false; |
| 421 } |
| 422 } |
402 return true; | 423 return true; |
403 } | 424 } |
404 bool | 425 bool |
405 IePreq::MayAddAddress (Mac48Address originator) | 426 IePreq::MayAddAddress (Mac48Address originator) |
406 { | 427 { |
407 if (m_originatorAddress != originator) | 428 if (m_originatorAddress != originator) |
408 return false; | 429 { |
409 if(m_destinations[0]->GetDestinationAddress () == Mac48Address::GetBroadcast (
)) | 430 return false; |
410 return false; | 431 } |
| 432 if (m_destinations[0]->GetDestinationAddress () == Mac48Address::GetBroadcast
()) |
| 433 { |
| 434 return false; |
| 435 } |
| 436 if ((GetInformationSize () + 11) > 255) |
| 437 { |
| 438 return false; |
| 439 } |
411 return true; | 440 return true; |
412 } | 441 } |
413 #ifdef RUN_SELF_TESTS | 442 bool |
414 | 443 IePreq::IsFull () const |
415 /// Built-in self test for IePreq | 444 { |
416 struct IePreqBist : public IeTest· | 445 return ((GetInformationSize () + 11) > 255); |
417 { | 446 } |
418 IePreqBist () : IeTest ("Mesh/802.11s/IE/PREQ") {} | 447 std::ostream & |
419 virtual bool RunTests();· | 448 operator << (std::ostream &os, const IePreq &a) |
420 }; | 449 { |
421 | 450 a.Print (os); |
422 /// Test instance | 451 return os; |
423 static IePreqBist g_IePreqBist; | 452 } |
424 | |
425 bool IePreqBist::RunTests () | |
426 { | |
427 bool result(true); | |
428 ·· | |
429 // create test information element | |
430 IePreq a; | |
431 a.SetHopcount (0); | |
432 a.SetTTL (1); | |
433 a.SetPreqID (2); | |
434 a.SetOriginatorAddress ( Mac48Address("11:22:33:44:55:66") ); | |
435 a.SetOriginatorSeqNumber (3); | |
436 a.SetLifetime (4); | |
437 a.AddDestinationAddressElement (false, false, Mac48Address("11:11:11:11:11:11"
), 5); | |
438 a.AddDestinationAddressElement (false, false, Mac48Address("22:22:22:22:22:22"
), 6); | |
439 | |
440 result = result && TestRoundtripSerialization (a); | |
441 return result; | |
442 } | |
443 | |
444 #endif // RUN_SELF_TESTS | |
445 ·· | |
446 } // namespace dot11s | 453 } // namespace dot11s |
447 } //namespace ns3 | 454 } //namespace ns3 |
448 | 455 |
LEFT | RIGHT |