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) 2013 Universita' di Firenze, Italy | 3 * Copyright (c) 2013 Universita' di Firenze, Italy |
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 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 | 112 |
113 TypeId SixLowPanHc1::GetInstanceTypeId (void) const | 113 TypeId SixLowPanHc1::GetInstanceTypeId (void) const |
114 { | 114 { |
115 return GetTypeId (); | 115 return GetTypeId (); |
116 } | 116 } |
117 | 117 |
118 void SixLowPanHc1::Print (std::ostream & os) const | 118 void SixLowPanHc1::Print (std::ostream & os) const |
119 { | 119 { |
120 uint8_t encoding; | 120 uint8_t encoding; |
121 encoding = (uint8_t)m_srcCompression; | 121 encoding = m_srcCompression; |
122 encoding <<= 2; | 122 encoding <<= 2; |
123 encoding |= m_dstCompression; | 123 encoding |= m_dstCompression; |
124 encoding <<= 1; | 124 encoding <<= 1; |
125 encoding |= (uint8_t)m_tcflCompression; | 125 encoding |= static_cast<uint8_t> (m_tcflCompression); |
126 encoding <<= 2; | 126 encoding <<= 2; |
127 encoding |= m_nextHeaderCompression; | 127 encoding |= m_nextHeaderCompression; |
128 encoding <<= 1; | 128 encoding <<= 1; |
129 encoding |= (uint8_t)m_hc2HeaderPresent; | 129 encoding |= static_cast<uint8_t> (m_hc2HeaderPresent); |
130 | 130 |
131 os << "encoding " << static_cast<int> (encoding) << ", hopLimit " << static_ca
st<int> (m_hopLimit); | 131 os << "encoding " << static_cast<int> (encoding) << ", hopLimit " << static_ca
st<int> (m_hopLimit); |
132 } | 132 } |
133 | 133 |
134 uint32_t SixLowPanHc1::GetSerializedSize () const | 134 uint32_t SixLowPanHc1::GetSerializedSize () const |
135 { | 135 { |
136 uint32_t serializedSize = 3; | 136 uint32_t serializedSize = 3; |
137 | 137 |
138 switch (m_srcCompression) | 138 switch (m_srcCompression) |
139 { | 139 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 serializedSize++; | 174 serializedSize++; |
175 } | 175 } |
176 | 176 |
177 return serializedSize; | 177 return serializedSize; |
178 } | 178 } |
179 | 179 |
180 void SixLowPanHc1::Serialize (Buffer::Iterator start) const | 180 void SixLowPanHc1::Serialize (Buffer::Iterator start) const |
181 { | 181 { |
182 Buffer::Iterator i = start; | 182 Buffer::Iterator i = start; |
183 uint8_t encoding; | 183 uint8_t encoding; |
184 encoding = (uint8_t)m_srcCompression; | 184 encoding = m_srcCompression; |
185 encoding <<= 2; | 185 encoding <<= 2; |
186 encoding |= m_dstCompression; | 186 encoding |= m_dstCompression; |
187 encoding <<= 1; | 187 encoding <<= 1; |
188 encoding |= (uint8_t)m_tcflCompression; | 188 encoding |= static_cast<uint8_t> (m_tcflCompression); |
189 encoding <<= 2; | 189 encoding <<= 2; |
190 encoding |= m_nextHeaderCompression; | 190 encoding |= m_nextHeaderCompression; |
191 encoding <<= 1; | 191 encoding <<= 1; |
192 encoding |= (uint8_t)m_hc2HeaderPresent; | 192 encoding |= static_cast<uint8_t> (m_hc2HeaderPresent); |
193 | 193 |
194 i.WriteU8 (SixLowPanDispatch::LOWPAN_HC1); | 194 i.WriteU8 (SixLowPanDispatch::LOWPAN_HC1); |
195 i.WriteU8 (encoding); | 195 i.WriteU8 (encoding); |
196 i.WriteU8 (m_hopLimit); | 196 i.WriteU8 (m_hopLimit); |
197 switch (m_srcCompression) | 197 switch (m_srcCompression) |
198 { | 198 { |
199 case HC1_PIII: | 199 case HC1_PIII: |
200 for ( int j = 0; j < 8; j++ ) | 200 for ( int j = 0; j < 8; j++ ) |
201 { | 201 { |
202 i.WriteU8 (m_srcPrefix[j]); | 202 i.WriteU8 (m_srcPrefix[j]); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 { | 938 { |
939 i.WriteU8 (m_srcdstContextId); | 939 i.WriteU8 (m_srcdstContextId); |
940 } | 940 } |
941 // Traffic Class and Flow Label | 941 // Traffic Class and Flow Label |
942 switch ( GetTf () ) | 942 switch ( GetTf () ) |
943 { | 943 { |
944 uint8_t temp; | 944 uint8_t temp; |
945 case TF_FULL: | 945 case TF_FULL: |
946 temp = (m_ecn << 6) | m_dscp; | 946 temp = (m_ecn << 6) | m_dscp; |
947 i.WriteU8 (temp); | 947 i.WriteU8 (temp); |
948 temp = (uint8_t)(m_flowLabel >> 16); | 948 temp = static_cast<uint8_t> (m_flowLabel >> 16); |
949 i.WriteU8 (temp); | 949 i.WriteU8 (temp); |
950 temp = (m_flowLabel >> 8) & 0xff; | 950 temp = (m_flowLabel >> 8) & 0xff; |
951 i.WriteU8 (temp); | 951 i.WriteU8 (temp); |
952 temp = m_flowLabel & 0xff; | 952 temp = m_flowLabel & 0xff; |
953 i.WriteU8 (temp); | 953 i.WriteU8 (temp); |
954 break; | 954 break; |
955 case TF_DSCP_ELIDED: | 955 case TF_DSCP_ELIDED: |
956 temp = (m_ecn << 6) | (uint8_t)(m_flowLabel >> 16 ); | 956 temp = (m_ecn << 6) | static_cast<uint8_t> (m_flowLabel >> 16 ); |
957 i.WriteU8 (temp); | 957 i.WriteU8 (temp); |
958 temp = (m_flowLabel >> 8) & 0xff; | 958 temp = (m_flowLabel >> 8) & 0xff; |
959 i.WriteU8 (temp); | 959 i.WriteU8 (temp); |
960 temp = m_flowLabel & 0xff; | 960 temp = m_flowLabel & 0xff; |
961 i.WriteU8 (temp); | 961 i.WriteU8 (temp); |
962 break; | 962 break; |
963 case TF_FL_ELIDED: | 963 case TF_FL_ELIDED: |
964 temp = (m_ecn << 6) | m_dscp; | 964 temp = (m_ecn << 6) | m_dscp; |
965 i.WriteU8 (temp); | 965 i.WriteU8 (temp); |
966 break; | 966 break; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 } | 1261 } |
1262 if ( GetDac () == true ) | 1262 if ( GetDac () == true ) |
1263 { | 1263 { |
1264 PostProcessDac (); | 1264 PostProcessDac (); |
1265 } | 1265 } |
1266 return GetSerializedSize (); | 1266 return GetSerializedSize (); |
1267 } | 1267 } |
1268 | 1268 |
1269 void SixLowPanIphc::SetTf (TrafficClassFlowLabel_e tfField) | 1269 void SixLowPanIphc::SetTf (TrafficClassFlowLabel_e tfField) |
1270 { | 1270 { |
1271 uint16_t field = (uint16_t)tfField; | 1271 uint16_t field = static_cast<uint16_t> (tfField); |
1272 m_baseFormat |= (field << 11); | 1272 m_baseFormat |= (field << 11); |
1273 } | 1273 } |
1274 | 1274 |
1275 SixLowPanIphc::TrafficClassFlowLabel_e SixLowPanIphc::GetTf (void) const | 1275 SixLowPanIphc::TrafficClassFlowLabel_e SixLowPanIphc::GetTf (void) const |
1276 { | 1276 { |
1277 return TrafficClassFlowLabel_e ((m_baseFormat >> 11) & 0x3); | 1277 return TrafficClassFlowLabel_e ((m_baseFormat >> 11) & 0x3); |
1278 } | 1278 } |
1279 | 1279 |
1280 void SixLowPanIphc::SetNh (bool nhField) | 1280 void SixLowPanIphc::SetNh (bool nhField) |
1281 { | 1281 { |
1282 uint16_t field = nhField; | 1282 uint16_t field = nhField; |
1283 m_baseFormat |= (field << 10); | 1283 m_baseFormat |= (field << 10); |
1284 } | 1284 } |
1285 | 1285 |
1286 bool SixLowPanIphc::GetNh (void) const | 1286 bool SixLowPanIphc::GetNh (void) const |
1287 { | 1287 { |
1288 return ((m_baseFormat >> 10) & 0x1); | 1288 return ((m_baseFormat >> 10) & 0x1); |
1289 } | 1289 } |
1290 | 1290 |
1291 void SixLowPanIphc::SetHlim (Hlim_e hlimField) | 1291 void SixLowPanIphc::SetHlim (Hlim_e hlimField) |
1292 { | 1292 { |
1293 uint16_t field = (uint16_t)hlimField; | 1293 uint16_t field = static_cast<uint16_t> (hlimField); |
1294 m_baseFormat |= (field << 8); | 1294 m_baseFormat |= (field << 8); |
1295 } | 1295 } |
1296 | 1296 |
1297 SixLowPanIphc::Hlim_e SixLowPanIphc::GetHlim (void) const | 1297 SixLowPanIphc::Hlim_e SixLowPanIphc::GetHlim (void) const |
1298 { | 1298 { |
1299 return Hlim_e ((m_baseFormat >> 8) & 0x3); | 1299 return Hlim_e ((m_baseFormat >> 8) & 0x3); |
1300 } | 1300 } |
1301 | 1301 |
1302 void SixLowPanIphc::SetCid (bool cidField) | 1302 void SixLowPanIphc::SetCid (bool cidField) |
1303 { | 1303 { |
(...skipping 12 matching lines...) Expand all Loading... |
1316 m_baseFormat |= (field << 6); | 1316 m_baseFormat |= (field << 6); |
1317 } | 1317 } |
1318 | 1318 |
1319 bool SixLowPanIphc::GetSac (void) const | 1319 bool SixLowPanIphc::GetSac (void) const |
1320 { | 1320 { |
1321 return ((m_baseFormat >> 6) & 0x1); | 1321 return ((m_baseFormat >> 6) & 0x1); |
1322 } | 1322 } |
1323 | 1323 |
1324 void SixLowPanIphc::SetSam (HeaderCompression_e samField) | 1324 void SixLowPanIphc::SetSam (HeaderCompression_e samField) |
1325 { | 1325 { |
1326 uint16_t field = (uint16_t)samField; | 1326 uint16_t field = static_cast<uint16_t> (samField); |
1327 m_baseFormat |= (field << 4); | 1327 m_baseFormat |= (field << 4); |
1328 } | 1328 } |
1329 | 1329 |
1330 SixLowPanIphc::HeaderCompression_e SixLowPanIphc::GetSam (void) const | 1330 SixLowPanIphc::HeaderCompression_e SixLowPanIphc::GetSam (void) const |
1331 { | 1331 { |
1332 return HeaderCompression_e ((m_baseFormat >> 4) & 0x3); | 1332 return HeaderCompression_e ((m_baseFormat >> 4) & 0x3); |
1333 } | 1333 } |
1334 | 1334 |
1335 void SixLowPanIphc::SetM (bool mField) | 1335 void SixLowPanIphc::SetM (bool mField) |
1336 { | 1336 { |
(...skipping 12 matching lines...) Expand all Loading... |
1349 m_baseFormat |= (field << 2); | 1349 m_baseFormat |= (field << 2); |
1350 } | 1350 } |
1351 | 1351 |
1352 bool SixLowPanIphc::GetDac (void) const | 1352 bool SixLowPanIphc::GetDac (void) const |
1353 { | 1353 { |
1354 return ((m_baseFormat >> 2) & 0x1); | 1354 return ((m_baseFormat >> 2) & 0x1); |
1355 } | 1355 } |
1356 | 1356 |
1357 void SixLowPanIphc::SetDam (HeaderCompression_e damField) | 1357 void SixLowPanIphc::SetDam (HeaderCompression_e damField) |
1358 { | 1358 { |
1359 uint16_t field = (uint16_t)damField; | 1359 uint16_t field = static_cast<uint16_t> (damField); |
1360 m_baseFormat |= field; | 1360 m_baseFormat |= field; |
1361 } | 1361 } |
1362 | 1362 |
1363 SixLowPanIphc::HeaderCompression_e SixLowPanIphc::GetDam (void) const | 1363 SixLowPanIphc::HeaderCompression_e SixLowPanIphc::GetDam (void) const |
1364 { | 1364 { |
1365 return HeaderCompression_e (m_baseFormat & 0x3); | 1365 return HeaderCompression_e (m_baseFormat & 0x3); |
1366 } | 1366 } |
1367 | 1367 |
1368 void SixLowPanIphc::SetSrcContextId (uint8_t srcContextId) | 1368 void SixLowPanIphc::SetSrcContextId (uint8_t srcContextId) |
1369 { | 1369 { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 } | 1547 } |
1548 | 1548 |
1549 SixLowPanDispatch::NhcDispatch_e | 1549 SixLowPanDispatch::NhcDispatch_e |
1550 SixLowPanNhcExtension::GetNhcDispatchType (void) const | 1550 SixLowPanNhcExtension::GetNhcDispatchType (void) const |
1551 { | 1551 { |
1552 return SixLowPanDispatch::LOWPAN_NHC; | 1552 return SixLowPanDispatch::LOWPAN_NHC; |
1553 } | 1553 } |
1554 | 1554 |
1555 void SixLowPanNhcExtension::SetEid (Eid_e extensionHeaderType) | 1555 void SixLowPanNhcExtension::SetEid (Eid_e extensionHeaderType) |
1556 { | 1556 { |
1557 uint8_t field = (uint8_t)extensionHeaderType; | 1557 uint8_t field = static_cast<uint8_t> (extensionHeaderType); |
1558 m_nhcExtensionHeader |= (field << 1); | 1558 m_nhcExtensionHeader |= (field << 1); |
1559 } | 1559 } |
1560 | 1560 |
1561 SixLowPanNhcExtension::Eid_e SixLowPanNhcExtension::GetEid (void) const | 1561 SixLowPanNhcExtension::Eid_e SixLowPanNhcExtension::GetEid (void) const |
1562 { | 1562 { |
1563 return Eid_e ((m_nhcExtensionHeader >> 1) & 0x7); | 1563 return Eid_e ((m_nhcExtensionHeader >> 1) & 0x7); |
1564 } | 1564 } |
1565 | 1565 |
1566 void SixLowPanNhcExtension::SetNextHeader (uint8_t nextHeader) | 1566 void SixLowPanNhcExtension::SetNextHeader (uint8_t nextHeader) |
1567 { | 1567 { |
(...skipping 13 matching lines...) Expand all Loading... |
1581 | 1581 |
1582 bool SixLowPanNhcExtension::GetNh (void) const | 1582 bool SixLowPanNhcExtension::GetNh (void) const |
1583 { | 1583 { |
1584 return m_nhcExtensionHeader & 0x01; | 1584 return m_nhcExtensionHeader & 0x01; |
1585 } | 1585 } |
1586 | 1586 |
1587 void SixLowPanNhcExtension::SetBlob (const uint8_t* blob, uint32_t size) | 1587 void SixLowPanNhcExtension::SetBlob (const uint8_t* blob, uint32_t size) |
1588 { | 1588 { |
1589 NS_ASSERT_MSG ( size < 255, "Buffer too long" ); | 1589 NS_ASSERT_MSG ( size < 255, "Buffer too long" ); |
1590 | 1590 |
1591 m_nhcBlobLength = (uint8_t)size; | 1591 m_nhcBlobLength = static_cast<uint8_t> (size); |
1592 std::memcpy (m_nhcBlob, blob, size); | 1592 std::memcpy (m_nhcBlob, blob, size); |
1593 } | 1593 } |
1594 | 1594 |
1595 uint32_t SixLowPanNhcExtension::CopyBlob (uint8_t* blob, uint32_t size) const | 1595 uint32_t SixLowPanNhcExtension::CopyBlob (uint8_t* blob, uint32_t size) const |
1596 { | 1596 { |
1597 NS_ASSERT_MSG ( size > m_nhcBlobLength, "Buffer too short" ); | 1597 NS_ASSERT_MSG ( size > m_nhcBlobLength, "Buffer too short" ); |
1598 (void)size; // make compiler happy | 1598 (void)size; // make compiler happy |
1599 | 1599 |
1600 std::memcpy (blob, m_nhcBlob, m_nhcBlobLength); | 1600 std::memcpy (blob, m_nhcBlob, m_nhcBlobLength); |
1601 return m_nhcBlobLength; | 1601 return m_nhcBlobLength; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 } | 1742 } |
1743 | 1743 |
1744 SixLowPanDispatch::NhcDispatch_e | 1744 SixLowPanDispatch::NhcDispatch_e |
1745 SixLowPanUdpNhcExtension::GetNhcDispatchType (void) const | 1745 SixLowPanUdpNhcExtension::GetNhcDispatchType (void) const |
1746 { | 1746 { |
1747 return SixLowPanDispatch::LOWPAN_UDPNHC; | 1747 return SixLowPanDispatch::LOWPAN_UDPNHC; |
1748 } | 1748 } |
1749 | 1749 |
1750 void SixLowPanUdpNhcExtension::SetPorts (Ports_e ports) | 1750 void SixLowPanUdpNhcExtension::SetPorts (Ports_e ports) |
1751 { | 1751 { |
1752 uint16_t field = (uint16_t)ports; | 1752 uint16_t field = static_cast<uint16_t> (ports); |
1753 m_baseFormat |= field; | 1753 m_baseFormat |= field; |
1754 } | 1754 } |
1755 | 1755 |
1756 SixLowPanUdpNhcExtension::Ports_e SixLowPanUdpNhcExtension::GetPorts (void) cons
t | 1756 SixLowPanUdpNhcExtension::Ports_e SixLowPanUdpNhcExtension::GetPorts (void) cons
t |
1757 { | 1757 { |
1758 return Ports_e (m_baseFormat & 0x3); | 1758 return Ports_e (m_baseFormat & 0x3); |
1759 } | 1759 } |
1760 | 1760 |
1761 void SixLowPanUdpNhcExtension::SetSrcPort (uint16_t srcport) | 1761 void SixLowPanUdpNhcExtension::SetSrcPort (uint16_t srcport) |
1762 { | 1762 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 | 1801 |
1802 std::ostream & operator << (std::ostream & os, const SixLowPanUdpNhcExtension &
h) | 1802 std::ostream & operator << (std::ostream & os, const SixLowPanUdpNhcExtension &
h) |
1803 { | 1803 { |
1804 h.Print (os); | 1804 h.Print (os); |
1805 return os; | 1805 return os; |
1806 } | 1806 } |
1807 | 1807 |
1808 | 1808 |
1809 } | 1809 } |
1810 | 1810 |
LEFT | RIGHT |