diff -r a1e00acc5986 src/internet-stack/icmpv6-header.cc --- a/src/internet-stack/icmpv6-header.cc Thu May 27 08:34:16 2010 +0200 +++ b/src/internet-stack/icmpv6-header.cc Fri May 28 14:42:19 2010 +1000 @@ -983,10 +983,12 @@ void Icmpv6DestinationUnreachable::Serialize (Buffer::Iterator start) const { - const uint8_t *packet = m_packet->PeekData (); + uint8_t *packet = new uint8_t[m_packet->GetSize ()]; uint16_t checksum = 0; Buffer::Iterator i = start; + m_packet->CopyData (packet, m_packet->GetSize ()); + i.WriteU8 (GetType ()); i.WriteU8 (GetCode ()); i.WriteHtonU16 (0); @@ -1000,6 +1002,8 @@ i = start; i.Next (2); i.WriteU16 (checksum); + + delete[] packet; } uint32_t Icmpv6DestinationUnreachable::Deserialize (Buffer::Iterator start) @@ -1078,10 +1082,12 @@ void Icmpv6TooBig::Serialize (Buffer::Iterator start) const { - const uint8_t *packet = m_packet->PeekData (); + uint8_t *packet = new uint8_t[m_packet->GetSize ()]; uint16_t checksum = 0; Buffer::Iterator i = start; + m_packet->CopyData (packet, m_packet->GetSize ()); + i.WriteU8 (GetType ()); i.WriteU8 (GetCode ()); i.WriteHtonU16 (0); @@ -1095,6 +1101,8 @@ i = start; i.Next (2); i.WriteU16 (checksum); + + delete[] packet; } uint32_t Icmpv6TooBig::Deserialize (Buffer::Iterator start) @@ -1162,10 +1170,12 @@ void Icmpv6TimeExceeded::Serialize (Buffer::Iterator start) const { - const uint8_t *packet = m_packet->PeekData (); + uint8_t *packet = new uint8_t[m_packet->GetSize ()]; uint16_t checksum = 0; Buffer::Iterator i = start; + m_packet->CopyData (packet, m_packet->GetSize ()); + i.WriteU8 (GetType ()); i.WriteU8 (GetCode ()); i.WriteHtonU16 (0); @@ -1179,6 +1189,8 @@ i = start; i.Next (2); i.WriteU16 (checksum); + + delete[] packet; } uint32_t Icmpv6TimeExceeded::Deserialize (Buffer::Iterator start) @@ -1257,10 +1269,12 @@ void Icmpv6ParameterError::Serialize (Buffer::Iterator start) const { - const uint8_t *packet = m_packet->PeekData (); + uint8_t *packet = new uint8_t[m_packet->GetSize ()]; uint16_t checksum = 0; Buffer::Iterator i = start; + m_packet->CopyData (packet, m_packet->GetSize ()); + i.WriteU8 (GetType ()); i.WriteU8 (GetCode ()); i.WriteHtonU16 (0); @@ -1274,6 +1288,8 @@ i = start; i.Next (2); i.WriteU16 (checksum); + + delete[] packet; } uint32_t Icmpv6ParameterError::Deserialize (Buffer::Iterator start) @@ -1749,7 +1765,11 @@ i.WriteU16 (0); i.WriteU32 (0); - i.Write (m_packet->PeekData (), m_packet->GetSize ()); + uint32_t size = m_packet->GetSize (); + uint8_t *packet = new uint8_t[size]; + m_packet->CopyData (packet, size); + i.Write (packet, size); + delete[] packet; } uint32_t Icmpv6OptionRedirected::Deserialize (Buffer::Iterator start)