network: (workaround for #2505) Printing a packet can raise an assert
This commit is contained in:
@@ -247,24 +247,26 @@ uint32_t
|
||||
Icmpv4Echo::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &start);
|
||||
|
||||
uint32_t optionalPayloadSize = start.GetRemainingSize () -4;
|
||||
NS_ASSERT (start.GetRemainingSize () >= 4);
|
||||
|
||||
m_identifier = start.ReadNtohU16 ();
|
||||
m_sequence = start.ReadNtohU16 ();
|
||||
NS_ASSERT (start.GetSize () >= 4);
|
||||
uint32_t size = start.GetSize () - 4;
|
||||
if (size != m_dataSize)
|
||||
if (optionalPayloadSize != m_dataSize)
|
||||
{
|
||||
delete [] m_data;
|
||||
m_data = new uint8_t[size];
|
||||
m_dataSize = size;
|
||||
m_dataSize = optionalPayloadSize;
|
||||
m_data = new uint8_t[m_dataSize];
|
||||
}
|
||||
start.Read (m_data, m_dataSize);
|
||||
return m_dataSize;
|
||||
return m_dataSize+4;
|
||||
}
|
||||
void
|
||||
Icmpv4Echo::Print (std::ostream &os) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &os);
|
||||
os << "identifier=" << m_identifier << ", sequence=" << m_sequence;
|
||||
os << "identifier=" << m_identifier << ", sequence=" << m_sequence << ", data size=" << m_dataSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1123,7 +1123,7 @@ void Icmpv6DestinationUnreachable::Serialize (Buffer::Iterator start) const
|
||||
uint32_t Icmpv6DestinationUnreachable::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &start);
|
||||
uint16_t length = start.GetSize () - 8;
|
||||
uint16_t length = start.GetRemainingSize () - 8;
|
||||
uint8_t* data = new uint8_t[length];
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
@@ -1234,7 +1234,7 @@ void Icmpv6TooBig::Serialize (Buffer::Iterator start) const
|
||||
uint32_t Icmpv6TooBig::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &start);
|
||||
uint16_t length = start.GetSize () - 8;
|
||||
uint16_t length = start.GetRemainingSize () - 8;
|
||||
uint8_t* data = new uint8_t[length];
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
@@ -1334,7 +1334,7 @@ uint32_t Icmpv6TimeExceeded::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &start);
|
||||
|
||||
uint16_t length = start.GetSize () - 8;
|
||||
uint16_t length = start.GetRemainingSize () - 8;
|
||||
uint8_t* data = new uint8_t[length];
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
@@ -1445,7 +1445,7 @@ void Icmpv6ParameterError::Serialize (Buffer::Iterator start) const
|
||||
uint32_t Icmpv6ParameterError::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &start);
|
||||
uint16_t length = start.GetSize () - 8;
|
||||
uint16_t length = start.GetRemainingSize () - 8;
|
||||
uint8_t* data = new uint8_t[length];
|
||||
Buffer::Iterator i = start;
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ uint32_t RipHeader::Deserialize (Buffer::Iterator start)
|
||||
uint16_t temp16 = i.ReadU16 ();
|
||||
NS_ASSERT_MSG (temp16 == 0, "RIP received a message with invalid filled flags, aborting.");
|
||||
|
||||
uint8_t rteNumber = (i.GetSize () - 4)/20;
|
||||
uint8_t rteNumber = i.GetRemainingSize ()/20;
|
||||
for (uint8_t n=0; n<rteNumber; n++)
|
||||
{
|
||||
RipRte rte;
|
||||
|
||||
@@ -208,7 +208,7 @@ uint32_t RipNgHeader::Deserialize (Buffer::Iterator start)
|
||||
uint16_t temp16 = i.ReadU16 ();
|
||||
NS_ASSERT_MSG (temp16 == 0, "RipNG received a message with invalid filled flags, aborting.");
|
||||
|
||||
uint8_t rteNumber = (i.GetSize () - 4)/20;
|
||||
uint8_t rteNumber = i.GetRemainingSize ()/20;
|
||||
for (uint8_t n=0; n<rteNumber; n++)
|
||||
{
|
||||
RipNgRte rte;
|
||||
|
||||
@@ -1161,6 +1161,13 @@ Buffer::Iterator::GetSize (void) const
|
||||
return m_dataEnd - m_dataStart;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Buffer::Iterator::GetRemainingSize (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_dataEnd - m_current;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
Buffer::Iterator::GetReadErrorMessage (void) const
|
||||
|
||||
@@ -376,6 +376,11 @@ public:
|
||||
*/
|
||||
uint32_t GetSize (void) const;
|
||||
|
||||
/**
|
||||
* \returns the size left to read of the underlying buffer we are iterating
|
||||
*/
|
||||
uint32_t GetRemainingSize (void) const;
|
||||
|
||||
private:
|
||||
friend class Buffer;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user