OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* vim: set ts=2 sw=2 sta expandtab ai si cin: */ | 2 /* vim: set ts=2 sw=2 sta expandtab ai si cin: */ |
3 /*· | 3 /*· |
4 * Copyright (c) 2009 Drexel University | 4 * Copyright (c) 2009 Drexel University |
5 *· | 5 *· |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 PbbTlvBlock::End (void) const | 97 PbbTlvBlock::End (void) const |
98 { | 98 { |
99 NS_LOG_FUNCTION (this); | 99 NS_LOG_FUNCTION (this); |
100 return m_tlvList.end (); | 100 return m_tlvList.end (); |
101 } | 101 } |
102 | 102 |
103 int | 103 int |
104 PbbTlvBlock::Size (void) const | 104 PbbTlvBlock::Size (void) const |
105 { | 105 { |
106 NS_LOG_FUNCTION (this); | 106 NS_LOG_FUNCTION (this); |
107 return m_tlvList.size (); | 107 return static_cast<int> (m_tlvList.size ()); |
108 } | 108 } |
109 | 109 |
110 bool | 110 bool |
111 PbbTlvBlock::Empty (void) const | 111 PbbTlvBlock::Empty (void) const |
112 { | 112 { |
113 NS_LOG_FUNCTION (this); | 113 NS_LOG_FUNCTION (this); |
114 return m_tlvList.empty (); | 114 return m_tlvList.empty (); |
115 } | 115 } |
116 | 116 |
117 Ptr<PbbTlv> | 117 Ptr<PbbTlv> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 /* We need to write the size of the TLV block in front, so save its | 214 /* We need to write the size of the TLV block in front, so save its |
215 * position. */ | 215 * position. */ |
216 Buffer::Iterator tlvsize = start; | 216 Buffer::Iterator tlvsize = start; |
217 start.Next (2); | 217 start.Next (2); |
218 for (ConstIterator iter = Begin (); iter != End (); iter++) | 218 for (ConstIterator iter = Begin (); iter != End (); iter++) |
219 { | 219 { |
220 (*iter)->Serialize (start); | 220 (*iter)->Serialize (start); |
221 } | 221 } |
222 /* - 2 to not include the size field */ | 222 /* - 2 to not include the size field */ |
223 uint16_t size = start.GetDistanceFrom (tlvsize) - 2; | 223 uint16_t size = static_cast<uint16_t> (start.GetDistanceFrom (tlvsize) - 2); |
224 tlvsize.WriteHtonU16 (size); | 224 tlvsize.WriteHtonU16 (size); |
225 } | 225 } |
226 | 226 |
227 void | 227 void |
228 PbbTlvBlock::Deserialize (Buffer::Iterator &start) | 228 PbbTlvBlock::Deserialize (Buffer::Iterator &start) |
229 { | 229 { |
230 NS_LOG_FUNCTION (this << &start); | 230 NS_LOG_FUNCTION (this << &start); |
231 uint16_t size = start.ReadNtohU16 (); | 231 uint16_t size = start.ReadNtohU16 (); |
232 | 232 |
233 Buffer::Iterator tlvstart = start; | 233 Buffer::Iterator tlvstart = start; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 PbbAddressTlvBlock::End (void) const | 338 PbbAddressTlvBlock::End (void) const |
339 { | 339 { |
340 NS_LOG_FUNCTION (this); | 340 NS_LOG_FUNCTION (this); |
341 return m_tlvList.end (); | 341 return m_tlvList.end (); |
342 } | 342 } |
343 | 343 |
344 int | 344 int |
345 PbbAddressTlvBlock::Size (void) const | 345 PbbAddressTlvBlock::Size (void) const |
346 { | 346 { |
347 NS_LOG_FUNCTION (this); | 347 NS_LOG_FUNCTION (this); |
348 return m_tlvList.size (); | 348 return static_cast<int> (m_tlvList.size ()); |
349 } | 349 } |
350 | 350 |
351 bool | 351 bool |
352 PbbAddressTlvBlock::Empty (void) const | 352 PbbAddressTlvBlock::Empty (void) const |
353 { | 353 { |
354 NS_LOG_FUNCTION (this); | 354 NS_LOG_FUNCTION (this); |
355 return m_tlvList.empty (); | 355 return m_tlvList.empty (); |
356 } | 356 } |
357 | 357 |
358 Ptr<PbbAddressTlv> | 358 Ptr<PbbAddressTlv> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 454 |
455 /* We need to write the size of the TLV block in front, so save its | 455 /* We need to write the size of the TLV block in front, so save its |
456 * position. */ | 456 * position. */ |
457 Buffer::Iterator tlvsize = start; | 457 Buffer::Iterator tlvsize = start; |
458 start.Next (2); | 458 start.Next (2); |
459 for (ConstIterator iter = Begin (); iter != End (); iter++) | 459 for (ConstIterator iter = Begin (); iter != End (); iter++) |
460 { | 460 { |
461 (*iter)->Serialize (start); | 461 (*iter)->Serialize (start); |
462 } | 462 } |
463 /* - 2 to not include the size field */ | 463 /* - 2 to not include the size field */ |
464 uint16_t size = start.GetDistanceFrom (tlvsize) - 2; | 464 uint16_t size = static_cast<uint16_t> (start.GetDistanceFrom (tlvsize) - 2); |
465 tlvsize.WriteHtonU16 (size); | 465 tlvsize.WriteHtonU16 (size); |
466 } | 466 } |
467 | 467 |
468 void | 468 void |
469 PbbAddressTlvBlock::Deserialize (Buffer::Iterator &start) | 469 PbbAddressTlvBlock::Deserialize (Buffer::Iterator &start) |
470 { | 470 { |
471 NS_LOG_FUNCTION (this << &start); | 471 NS_LOG_FUNCTION (this << &start); |
472 uint16_t size = start.ReadNtohU16 (); | 472 uint16_t size = start.ReadNtohU16 (); |
473 | 473 |
474 Buffer::Iterator tlvstart = start; | 474 Buffer::Iterator tlvstart = start; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 PbbPacket::MessageEnd (void) const | 734 PbbPacket::MessageEnd (void) const |
735 { | 735 { |
736 NS_LOG_FUNCTION (this); | 736 NS_LOG_FUNCTION (this); |
737 return m_messageList.end (); | 737 return m_messageList.end (); |
738 } | 738 } |
739 | 739 |
740 int | 740 int |
741 PbbPacket::MessageSize (void) const | 741 PbbPacket::MessageSize (void) const |
742 { | 742 { |
743 NS_LOG_FUNCTION (this); | 743 NS_LOG_FUNCTION (this); |
744 return m_messageList.size (); | 744 return static_cast<int> (m_messageList.size ()); |
745 } | 745 } |
746 | 746 |
747 bool | 747 bool |
748 PbbPacket::MessageEmpty (void) const | 748 PbbPacket::MessageEmpty (void) const |
749 { | 749 { |
750 NS_LOG_FUNCTION (this); | 750 NS_LOG_FUNCTION (this); |
751 return m_messageList.empty (); | 751 return m_messageList.empty (); |
752 } | 752 } |
753 | 753 |
754 Ptr<PbbMessage> | 754 Ptr<PbbMessage> |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 PbbMessage::AddressBlockEnd (void) const | 1300 PbbMessage::AddressBlockEnd (void) const |
1301 { | 1301 { |
1302 NS_LOG_FUNCTION (this); | 1302 NS_LOG_FUNCTION (this); |
1303 return m_addressBlockList.end (); | 1303 return m_addressBlockList.end (); |
1304 } | 1304 } |
1305 | 1305 |
1306 int | 1306 int |
1307 PbbMessage::AddressBlockSize (void) const | 1307 PbbMessage::AddressBlockSize (void) const |
1308 { | 1308 { |
1309 NS_LOG_FUNCTION (this); | 1309 NS_LOG_FUNCTION (this); |
1310 return m_addressBlockList.size (); | 1310 return static_cast<int> (m_addressBlockList.size ()); |
1311 } | 1311 } |
1312 | 1312 |
1313 bool | 1313 bool |
1314 PbbMessage::AddressBlockEmpty (void) const | 1314 PbbMessage::AddressBlockEmpty (void) const |
1315 { | 1315 { |
1316 NS_LOG_FUNCTION (this); | 1316 NS_LOG_FUNCTION (this); |
1317 return m_addressBlockList.empty (); | 1317 return m_addressBlockList.empty (); |
1318 } | 1318 } |
1319 | 1319 |
1320 Ptr<PbbAddressBlock> | 1320 Ptr<PbbAddressBlock> |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 { | 1445 { |
1446 NS_LOG_FUNCTION (this << &start); | 1446 NS_LOG_FUNCTION (this << &start); |
1447 Buffer::Iterator front = start; | 1447 Buffer::Iterator front = start; |
1448 | 1448 |
1449 start.WriteU8 (GetType ()); | 1449 start.WriteU8 (GetType ()); |
1450 | 1450 |
1451 /* Save a reference to the spot where we will later write the flags */ | 1451 /* Save a reference to the spot where we will later write the flags */ |
1452 Buffer::Iterator bufref = start; | 1452 Buffer::Iterator bufref = start; |
1453 start.Next (1); | 1453 start.Next (1); |
1454 | 1454 |
1455 uint8_t flags = 0; | 1455 uint8_t flags = static_cast<uint8_t> (GetAddressLength ()); |
1456 | |
1457 flags = GetAddressLength (); | |
1458 | 1456 |
1459 Buffer::Iterator sizeref = start; | 1457 Buffer::Iterator sizeref = start; |
1460 start.Next (2); | 1458 start.Next (2); |
1461 | 1459 |
1462 if (HasOriginatorAddress ()) | 1460 if (HasOriginatorAddress ()) |
1463 { | 1461 { |
1464 flags |= MHAS_ORIG; | 1462 flags |= MHAS_ORIG; |
1465 SerializeOriginatorAddress (start); | 1463 SerializeOriginatorAddress (start); |
1466 } | 1464 } |
1467 | 1465 |
(...skipping 19 matching lines...) Expand all Loading... |
1487 | 1485 |
1488 m_tlvList.Serialize (start); | 1486 m_tlvList.Serialize (start); |
1489 | 1487 |
1490 for (ConstAddressBlockIterator iter = AddressBlockBegin (); | 1488 for (ConstAddressBlockIterator iter = AddressBlockBegin (); |
1491 iter != AddressBlockEnd (); | 1489 iter != AddressBlockEnd (); |
1492 iter++) | 1490 iter++) |
1493 { | 1491 { |
1494 (*iter)->Serialize (start); | 1492 (*iter)->Serialize (start); |
1495 } | 1493 } |
1496 | 1494 |
1497 sizeref.WriteHtonU16 (front.GetDistanceFrom (start)); | 1495 sizeref.WriteHtonU16 (static_cast<uint16_t> (front.GetDistanceFrom (start))); |
1498 } | 1496 } |
1499 | 1497 |
1500 Ptr<PbbMessage> | 1498 Ptr<PbbMessage> |
1501 PbbMessage::DeserializeMessage (Buffer::Iterator &start) | 1499 PbbMessage::DeserializeMessage (Buffer::Iterator &start) |
1502 { | 1500 { |
1503 NS_LOG_FUNCTION (&start); | 1501 NS_LOG_FUNCTION (&start); |
1504 /* We need to read the msg-addr-len field to determine what kind of object to | 1502 /* We need to read the msg-addr-len field to determine what kind of object to |
1505 * construct. */ | 1503 * construct. */ |
1506 start.Next (); | 1504 start.Next (); |
1507 uint8_t addrlen = start.ReadU8 (); | 1505 uint8_t addrlen = start.ReadU8 (); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 PbbAddressBlock::AddressEnd (void) const | 1870 PbbAddressBlock::AddressEnd (void) const |
1873 { | 1871 { |
1874 NS_LOG_FUNCTION (this); | 1872 NS_LOG_FUNCTION (this); |
1875 return m_addressList.end (); | 1873 return m_addressList.end (); |
1876 } | 1874 } |
1877 | 1875 |
1878 int | 1876 int |
1879 PbbAddressBlock::AddressSize (void) const | 1877 PbbAddressBlock::AddressSize (void) const |
1880 { | 1878 { |
1881 NS_LOG_FUNCTION (this); | 1879 NS_LOG_FUNCTION (this); |
1882 return m_addressList.size (); | 1880 return static_cast<int> (m_addressList.size ()); |
1883 } | 1881 } |
1884 | 1882 |
1885 bool | 1883 bool |
1886 PbbAddressBlock::AddressEmpty (void) const | 1884 PbbAddressBlock::AddressEmpty (void) const |
1887 { | 1885 { |
1888 NS_LOG_FUNCTION (this); | 1886 NS_LOG_FUNCTION (this); |
1889 return m_addressList.empty (); | 1887 return m_addressList.empty (); |
1890 } | 1888 } |
1891 | 1889 |
1892 Address | 1890 Address |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1980 PbbAddressBlock::PrefixEnd (void) const | 1978 PbbAddressBlock::PrefixEnd (void) const |
1981 { | 1979 { |
1982 NS_LOG_FUNCTION (this); | 1980 NS_LOG_FUNCTION (this); |
1983 return m_prefixList.end (); | 1981 return m_prefixList.end (); |
1984 } | 1982 } |
1985 | 1983 |
1986 int | 1984 int |
1987 PbbAddressBlock::PrefixSize (void) const | 1985 PbbAddressBlock::PrefixSize (void) const |
1988 { | 1986 { |
1989 NS_LOG_FUNCTION (this); | 1987 NS_LOG_FUNCTION (this); |
1990 return m_prefixList.size (); | 1988 return static_cast<int> (m_prefixList.size ()); |
1991 } | 1989 } |
1992 | 1990 |
1993 bool | 1991 bool |
1994 PbbAddressBlock::PrefixEmpty (void) const | 1992 PbbAddressBlock::PrefixEmpty (void) const |
1995 { | 1993 { |
1996 NS_LOG_FUNCTION (this); | 1994 NS_LOG_FUNCTION (this); |
1997 return m_prefixList.empty (); | 1995 return m_prefixList.empty (); |
1998 } | 1996 } |
1999 | 1997 |
2000 uint8_t | 1998 uint8_t |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 | 2231 |
2234 size += m_addressTlvList.GetSerializedSize (); | 2232 size += m_addressTlvList.GetSerializedSize (); |
2235 | 2233 |
2236 return size; | 2234 return size; |
2237 } | 2235 } |
2238 | 2236 |
2239 void | 2237 void |
2240 PbbAddressBlock::Serialize (Buffer::Iterator &start) const | 2238 PbbAddressBlock::Serialize (Buffer::Iterator &start) const |
2241 { | 2239 { |
2242 NS_LOG_FUNCTION (this << &start); | 2240 NS_LOG_FUNCTION (this << &start); |
2243 start.WriteU8 (AddressSize ()); | 2241 start.WriteU8 (static_cast<uint8_t> (AddressSize ())); |
2244 Buffer::Iterator bufref = start; | 2242 Buffer::Iterator bufref = start; |
2245 uint8_t flags = 0; | 2243 uint8_t flags = 0; |
2246 start.Next (); | 2244 start.Next (); |
2247 | 2245 |
2248 if (AddressSize () == 1) | 2246 if (AddressSize () == 1) |
2249 { | 2247 { |
2250 uint8_t* buf = new uint8_t[GetAddressLength ()]; | 2248 uint8_t* buf = new uint8_t[GetAddressLength ()]; |
2251 SerializeAddress (buf, AddressBegin ()); | 2249 SerializeAddress (buf, AddressBegin ()); |
2252 start.Write (buf, GetAddressLength ()); | 2250 start.Write (buf, GetAddressLength ()); |
2253 | 2251 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2499 | 2497 |
2500 SerializeAddress (buflast, AddressBegin ()); | 2498 SerializeAddress (buflast, AddressBegin ()); |
2501 | 2499 |
2502 /* Skip the first item */ | 2500 /* Skip the first item */ |
2503 for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin ()++; | 2501 for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin ()++; |
2504 iter != AddressEnd (); | 2502 iter != AddressEnd (); |
2505 iter++) | 2503 iter++) |
2506 { | 2504 { |
2507 SerializeAddress (bufcur, iter); | 2505 SerializeAddress (bufcur, iter); |
2508 | 2506 |
2509 int i; | 2507 uint8_t i = 0; |
2510 for (i = 0; i < headlen; i++) | 2508 for (i = 0; i < headlen; i++) |
2511 { | 2509 { |
2512 if (buflast[i] != bufcur[i]) | 2510 if (buflast[i] != bufcur[i]) |
2513 { | 2511 { |
2514 headlen = i; | 2512 headlen = i; |
2515 break; | 2513 break; |
2516 } | 2514 } |
2517 } | 2515 } |
2518 | 2516 |
2519 /* If headlen == fulllen - 1, then tail is 0 */ | 2517 /* If headlen == fulllen - 1, then tail is 0 */ |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 } | 2858 } |
2861 | 2859 |
2862 if (HasValue ())· | 2860 if (HasValue ())· |
2863 { | 2861 { |
2864 flags |= THAS_VALUE; | 2862 flags |= THAS_VALUE; |
2865 | 2863 |
2866 uint32_t size = GetValue ().GetSize (); | 2864 uint32_t size = GetValue ().GetSize (); |
2867 if (size > 255) | 2865 if (size > 255) |
2868 { | 2866 { |
2869 flags |= THAS_EXT_LEN; | 2867 flags |= THAS_EXT_LEN; |
2870 start.WriteHtonU16 (size); | 2868 start.WriteHtonU16 (static_cast<uint16_t> (size)); |
2871 } | 2869 } |
2872 else | 2870 else |
2873 { | 2871 { |
2874 start.WriteU8 (size); | 2872 start.WriteU8 (static_cast<uint8_t> (size)); |
2875 } | 2873 } |
2876 | 2874 |
2877 if (IsMultivalue ()) | 2875 if (IsMultivalue ()) |
2878 { | 2876 { |
2879 flags |= TIS_MULTIVALUE; | 2877 flags |= TIS_MULTIVALUE; |
2880 } | 2878 } |
2881 | 2879 |
2882 start.Write (GetValue ().Begin (), GetValue ().End ()); | 2880 start.Write (GetValue ().Begin (), GetValue ().End ()); |
2883 } | 2881 } |
2884 | 2882 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 } | 3076 } |
3079 | 3077 |
3080 bool | 3078 bool |
3081 PbbAddressTlv::IsMultivalue (void) const | 3079 PbbAddressTlv::IsMultivalue (void) const |
3082 { | 3080 { |
3083 NS_LOG_FUNCTION (this); | 3081 NS_LOG_FUNCTION (this); |
3084 return PbbTlv::IsMultivalue (); | 3082 return PbbTlv::IsMultivalue (); |
3085 } | 3083 } |
3086 | 3084 |
3087 } /* namespace ns3 */ | 3085 } /* namespace ns3 */ |
OLD | NEW |