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) 2007-2009 Strasbourg University | 3 * Copyright (c) 2007-2009 Strasbourg University |
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 it.WriteU16 (0); /* zero */ | 168 it.WriteU16 (0); /* zero */ |
169 it.WriteU8 (0); /* zero */ | 169 it.WriteU8 (0); /* zero */ |
170 it.WriteU8 (protocol); /* next header */ | 170 it.WriteU8 (protocol); /* next header */ |
171 | 171 |
172 it = buf.Begin (); | 172 it = buf.Begin (); |
173 m_checksum = ~(it.CalculateIpChecksum (40)); | 173 m_checksum = ~(it.CalculateIpChecksum (40)); |
174 } | 174 } |
175 | 175 |
176 void Icmpv6Header::CalculatePseudoHeaderChecksum(Ipv6Address src, Ipv6Address ds
t, uint32_t length, uint8_t protocol) | 176 void Icmpv6Header::CalculatePseudoHeaderChecksum(Ipv6Address src, Ipv6Address ds
t, uint32_t length, uint8_t protocol) |
177 { | 177 { |
178 CalculatePseudoHeaderChecksum(src, dst, static_cast<uint16_t>(length), protoco
l); | 178 CalculatePseudoHeaderChecksum(src, dst, static_cast<uint16_t> (length), protoc
ol); |
179 } | 179 } |
180 | 180 |
181 NS_OBJECT_ENSURE_REGISTERED (Icmpv6NS); | 181 NS_OBJECT_ENSURE_REGISTERED (Icmpv6NS); |
182 | 182 |
183 Icmpv6NS::Icmpv6NS () | 183 Icmpv6NS::Icmpv6NS () |
184 { | 184 { |
185 NS_LOG_FUNCTION (this); | 185 NS_LOG_FUNCTION (this); |
186 SetType (ICMPV6_ND_NEIGHBOR_SOLICITATION); | 186 SetType (ICMPV6_ND_NEIGHBOR_SOLICITATION); |
187 SetCode (0); | 187 SetCode (0); |
188 SetReserved (0); | 188 SetReserved (0); |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST); | 951 SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST); |
952 SetCode (0); | 952 SetCode (0); |
953 m_checksum = 0; | 953 m_checksum = 0; |
954 SetId (0); | 954 SetId (0); |
955 SetSeq (0); | 955 SetSeq (0); |
956 } | 956 } |
957 | 957 |
958 Icmpv6Echo::Icmpv6Echo (bool request) | 958 Icmpv6Echo::Icmpv6Echo (bool request) |
959 { | 959 { |
960 NS_LOG_FUNCTION (this << request); | 960 NS_LOG_FUNCTION (this << request); |
961 SetType (request ? static_cast<uint8_t>(Icmpv6Header::ICMPV6_ECHO_REQUEST) : s
tatic_cast<uint8_t>(Icmpv6Header::ICMPV6_ECHO_REPLY)); | 961 SetType (request ? static_cast<uint8_t> (Icmpv6Header::ICMPV6_ECHO_REQUEST) :
static_cast<uint8_t> (Icmpv6Header::ICMPV6_ECHO_REPLY)); |
962 SetCode (0); | 962 SetCode (0); |
963 m_checksum = 0; | 963 m_checksum = 0; |
964 SetId (0); | 964 SetId (0); |
965 SetSeq (0); | 965 SetSeq (0); |
966 } | 966 } |
967 | 967 |
968 Icmpv6Echo::~Icmpv6Echo () | 968 Icmpv6Echo::~Icmpv6Echo () |
969 { | 969 { |
970 NS_LOG_FUNCTION (this); | 970 NS_LOG_FUNCTION (this); |
971 } | 971 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); | 1121 checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); |
1122 | 1122 |
1123 i = start; | 1123 i = start; |
1124 i.Next (2); | 1124 i.Next (2); |
1125 i.WriteU16 (checksum); | 1125 i.WriteU16 (checksum); |
1126 } | 1126 } |
1127 | 1127 |
1128 uint32_t Icmpv6DestinationUnreachable::Deserialize (Buffer::Iterator start) | 1128 uint32_t Icmpv6DestinationUnreachable::Deserialize (Buffer::Iterator start) |
1129 { | 1129 { |
1130 NS_LOG_FUNCTION (this << &start); | 1130 NS_LOG_FUNCTION (this << &start); |
1131 uint16_t length = static_cast<uint16_t>(start.GetRemainingSize ()) - 8; | 1131 uint16_t length = static_cast<uint16_t> (start.GetRemainingSize ()) - 8; |
1132 uint8_t* data = new uint8_t[length]; | 1132 uint8_t* data = new uint8_t[length]; |
1133 Buffer::Iterator i = start; | 1133 Buffer::Iterator i = start; |
1134 | 1134 |
1135 SetType (i.ReadU8 ()); | 1135 SetType (i.ReadU8 ()); |
1136 SetCode (i.ReadU8 ()); | 1136 SetCode (i.ReadU8 ()); |
1137 m_checksum = i.ReadU16 (); | 1137 m_checksum = i.ReadU16 (); |
1138 i.ReadNtohU32 (); | 1138 i.ReadNtohU32 (); |
1139 i.Read (data, length); | 1139 i.Read (data, length); |
1140 m_packet = Create<Packet> (data, length); | 1140 m_packet = Create<Packet> (data, length); |
1141 | 1141 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); | 1232 checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); |
1233 | 1233 |
1234 i = start; | 1234 i = start; |
1235 i.Next (2); | 1235 i.Next (2); |
1236 i.WriteU16 (checksum); | 1236 i.WriteU16 (checksum); |
1237 } | 1237 } |
1238 | 1238 |
1239 uint32_t Icmpv6TooBig::Deserialize (Buffer::Iterator start)· | 1239 uint32_t Icmpv6TooBig::Deserialize (Buffer::Iterator start)· |
1240 { | 1240 { |
1241 NS_LOG_FUNCTION (this << &start); | 1241 NS_LOG_FUNCTION (this << &start); |
1242 uint16_t length = static_cast<uint16_t>(start.GetRemainingSize ()) - 8; | 1242 uint16_t length = static_cast<uint16_t> (start.GetRemainingSize ()) - 8; |
1243 uint8_t* data = new uint8_t[length]; | 1243 uint8_t* data = new uint8_t[length]; |
1244 Buffer::Iterator i = start; | 1244 Buffer::Iterator i = start; |
1245 | 1245 |
1246 SetType (i.ReadU8 ()); | 1246 SetType (i.ReadU8 ()); |
1247 SetCode (i.ReadU8 ()); | 1247 SetCode (i.ReadU8 ()); |
1248 m_checksum = i.ReadU16 (); | 1248 m_checksum = i.ReadU16 (); |
1249 SetMtu (i.ReadNtohU32 ()); | 1249 SetMtu (i.ReadNtohU32 ()); |
1250 i.Read (data, length); | 1250 i.Read (data, length); |
1251 m_packet = Create<Packet> (data, length); | 1251 m_packet = Create<Packet> (data, length); |
1252 | 1252 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 | 1332 |
1333 i = start; | 1333 i = start; |
1334 i.Next (2); | 1334 i.Next (2); |
1335 i.WriteU16 (checksum); | 1335 i.WriteU16 (checksum); |
1336 } | 1336 } |
1337 | 1337 |
1338 uint32_t Icmpv6TimeExceeded::Deserialize (Buffer::Iterator start) | 1338 uint32_t Icmpv6TimeExceeded::Deserialize (Buffer::Iterator start) |
1339 { | 1339 { |
1340 NS_LOG_FUNCTION (this << &start); | 1340 NS_LOG_FUNCTION (this << &start); |
1341 ·· | 1341 ·· |
1342 uint16_t length = static_cast<uint16_t>(start.GetRemainingSize ()) - 8; | 1342 uint16_t length = static_cast<uint16_t> (start.GetRemainingSize ()) - 8; |
1343 uint8_t* data = new uint8_t[length]; | 1343 uint8_t* data = new uint8_t[length]; |
1344 Buffer::Iterator i = start; | 1344 Buffer::Iterator i = start; |
1345 | 1345 |
1346 SetType (i.ReadU8 ()); | 1346 SetType (i.ReadU8 ()); |
1347 SetCode (i.ReadU8 ()); | 1347 SetCode (i.ReadU8 ()); |
1348 m_checksum = i.ReadU16 (); | 1348 m_checksum = i.ReadU16 (); |
1349 i.ReadNtohU32 (); | 1349 i.ReadNtohU32 (); |
1350 i.Read (data, length); | 1350 i.Read (data, length); |
1351 m_packet = Create<Packet> (data, length); | 1351 m_packet = Create<Packet> (data, length); |
1352 | 1352 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); | 1443 checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ()); |
1444 | 1444 |
1445 i = start; | 1445 i = start; |
1446 i.Next (2); | 1446 i.Next (2); |
1447 i.WriteU16 (checksum); | 1447 i.WriteU16 (checksum); |
1448 } | 1448 } |
1449 | 1449 |
1450 uint32_t Icmpv6ParameterError::Deserialize (Buffer::Iterator start)· | 1450 uint32_t Icmpv6ParameterError::Deserialize (Buffer::Iterator start)· |
1451 { | 1451 { |
1452 NS_LOG_FUNCTION (this << &start); | 1452 NS_LOG_FUNCTION (this << &start); |
1453 uint16_t length = static_cast<uint16_t>(start.GetRemainingSize ()) - 8; | 1453 uint16_t length = static_cast<uint16_t> (start.GetRemainingSize ()) - 8; |
1454 uint8_t* data = new uint8_t[length]; | 1454 uint8_t* data = new uint8_t[length]; |
1455 Buffer::Iterator i = start; | 1455 Buffer::Iterator i = start; |
1456 | 1456 |
1457 SetType (i.ReadU8 ()); | 1457 SetType (i.ReadU8 ()); |
1458 SetCode (i.ReadU8 ()); | 1458 SetCode (i.ReadU8 ()); |
1459 m_checksum = i.ReadU16 (); | 1459 m_checksum = i.ReadU16 (); |
1460 SetPtr (i.ReadNtohU32 ()); | 1460 SetPtr (i.ReadNtohU32 ()); |
1461 i.Read (data, length); | 1461 i.Read (data, length); |
1462 m_packet = Create<Packet> (data, length); | 1462 m_packet = Create<Packet> (data, length); |
1463 delete[] data; | 1463 delete[] data; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 | 1829 |
1830 TypeId Icmpv6OptionLinkLayerAddress::GetInstanceTypeId () const | 1830 TypeId Icmpv6OptionLinkLayerAddress::GetInstanceTypeId () const |
1831 { | 1831 { |
1832 NS_LOG_FUNCTION (this); | 1832 NS_LOG_FUNCTION (this); |
1833 return GetTypeId (); | 1833 return GetTypeId (); |
1834 } | 1834 } |
1835 | 1835 |
1836 Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress (bool source) | 1836 Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress (bool source) |
1837 { | 1837 { |
1838 NS_LOG_FUNCTION (this << source); | 1838 NS_LOG_FUNCTION (this << source); |
1839 SetType (source ? static_cast<uint8_t>(Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOU
RCE) : static_cast<uint8_t>(Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET)); | 1839 SetType (source ? static_cast<uint8_t> (Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SO
URCE) : static_cast<uint8_t> (Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET)); |
1840 } | 1840 } |
1841 | 1841 |
1842 Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress () | 1842 Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress () |
1843 { | 1843 { |
1844 NS_LOG_FUNCTION (this); | 1844 NS_LOG_FUNCTION (this); |
1845 SetType (Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE); | 1845 SetType (Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE); |
1846 } | 1846 } |
1847 | 1847 |
1848 Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress (bool source, Address
addr) | 1848 Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress (bool source, Address
addr) |
1849 { | 1849 { |
1850 NS_LOG_FUNCTION (this << source << addr); | 1850 NS_LOG_FUNCTION (this << source << addr); |
1851 SetType (source ? static_cast<uint8_t>(Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOU
RCE) : static_cast<uint8_t>(Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET)); | 1851 SetType (source ? static_cast<uint8_t> (Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SO
URCE) : static_cast<uint8_t> (Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET)); |
1852 SetAddress (addr); | 1852 SetAddress (addr); |
1853 | 1853 |
1854 uint8_t len = (2 + m_addr.GetLength ()) / 8; | 1854 uint8_t len = (2 + m_addr.GetLength ()) / 8; |
1855 if ( (2 + m_addr.GetLength ()) % 8 ) | 1855 if ( (2 + m_addr.GetLength ()) % 8 ) |
1856 { | 1856 { |
1857 len ++; | 1857 len ++; |
1858 } | 1858 } |
1859 SetLength (len); | 1859 SetLength (len); |
1860 } | 1860 } |
1861 | 1861 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 { | 1959 { |
1960 NS_LOG_FUNCTION (this); | 1960 NS_LOG_FUNCTION (this); |
1961 return m_packet; | 1961 return m_packet; |
1962 } | 1962 } |
1963 | 1963 |
1964 void Icmpv6OptionRedirected::SetPacket (Ptr<Packet> packet) | 1964 void Icmpv6OptionRedirected::SetPacket (Ptr<Packet> packet) |
1965 { | 1965 { |
1966 NS_LOG_FUNCTION (this << *packet); | 1966 NS_LOG_FUNCTION (this << *packet); |
1967 NS_ASSERT (packet->GetSize () <= 1280); | 1967 NS_ASSERT (packet->GetSize () <= 1280); |
1968 m_packet = packet; | 1968 m_packet = packet; |
1969 SetLength (1 + (static_cast<uint8_t>(m_packet->GetSize ()) / 8)); | 1969 SetLength (1 + (static_cast<uint8_t> (m_packet->GetSize ()) / 8)); |
1970 } | 1970 } |
1971 | 1971 |
1972 void Icmpv6OptionRedirected::Print (std::ostream& os) const | 1972 void Icmpv6OptionRedirected::Print (std::ostream& os) const |
1973 { | 1973 { |
1974 NS_LOG_FUNCTION (this << &os); | 1974 NS_LOG_FUNCTION (this << &os); |
1975 os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLeng
th () << ")"; | 1975 os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLeng
th () << ")"; |
1976 } | 1976 } |
1977 | 1977 |
1978 uint32_t Icmpv6OptionRedirected::GetSerializedSize () const | 1978 uint32_t Icmpv6OptionRedirected::GetSerializedSize () const |
1979 { | 1979 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 uint8_t* buff = new uint8_t[len2]; | 2014 uint8_t* buff = new uint8_t[len2]; |
2015 i.Read (buff, len2); | 2015 i.Read (buff, len2); |
2016 m_packet = Create<Packet> (buff, len2); | 2016 m_packet = Create<Packet> (buff, len2); |
2017 delete[] buff; | 2017 delete[] buff; |
2018 | 2018 |
2019 return GetSerializedSize (); | 2019 return GetSerializedSize (); |
2020 } | 2020 } |
2021 | 2021 |
2022 } /* namespace ns3 */ | 2022 } /* namespace ns3 */ |
2023 | 2023 |
LEFT | RIGHT |