View | Details | Raw Unified | Return to bug 2505
Collapse All | Expand All

(-)a/src/internet/model/icmpv4.cc (-7 / +9 lines)
 Lines 247-270    Link Here 
247
Icmpv4Echo::Deserialize (Buffer::Iterator start)
247
Icmpv4Echo::Deserialize (Buffer::Iterator start)
248
{
248
{
249
  NS_LOG_FUNCTION (this << &start);
249
  NS_LOG_FUNCTION (this << &start);
250
251
  uint32_t optionalPayloadSize = start.GetRemainingSize () -4;
252
  NS_ASSERT (start.GetRemainingSize () >= 4);
253
250
  m_identifier = start.ReadNtohU16 ();
254
  m_identifier = start.ReadNtohU16 ();
251
  m_sequence = start.ReadNtohU16 ();
255
  m_sequence = start.ReadNtohU16 ();
252
  NS_ASSERT (start.GetSize () >= 4);
256
  if (optionalPayloadSize != m_dataSize)
253
  uint32_t size = start.GetSize () - 4;
254
  if (size != m_dataSize)
255
    {
257
    {
256
      delete [] m_data;
258
      delete [] m_data;
257
      m_data = new uint8_t[size];
259
      m_data = new uint8_t[optionalPayloadSize];
258
      m_dataSize = size;
260
      m_dataSize = optionalPayloadSize;
259
    }
261
    }
260
  start.Read (m_data, m_dataSize);
262
  start.Read (m_data, m_dataSize);
261
  return m_dataSize;
263
  return m_dataSize+4;
262
}
264
}
263
void 
265
void 
264
Icmpv4Echo::Print (std::ostream &os) const
266
Icmpv4Echo::Print (std::ostream &os) const
265
{
267
{
266
  NS_LOG_FUNCTION (this << &os);
268
  NS_LOG_FUNCTION (this << &os);
267
  os << "identifier=" << m_identifier << ", sequence="  << m_sequence;
269
  os << "identifier=" << m_identifier << ", sequence="  << m_sequence << ", data size=" << m_dataSize;
268
}
270
}
269
271
270
272
(-)a/src/network/model/buffer.cc (+7 lines)
 Lines 1161-1166    Link Here 
1161
  return m_dataEnd - m_dataStart;
1161
  return m_dataEnd - m_dataStart;
1162
}
1162
}
1163
1163
1164
uint32_t
1165
Buffer::Iterator::GetRemainingSize (void) const
1166
{
1167
  NS_LOG_FUNCTION (this);
1168
  return m_dataEnd - m_current;
1169
}
1170
1164
1171
1165
std::string 
1172
std::string 
1166
Buffer::Iterator::GetReadErrorMessage (void) const
1173
Buffer::Iterator::GetReadErrorMessage (void) const
(-)a/src/network/model/buffer.h (+5 lines)
 Lines 376-381    Link Here 
376
     */
376
     */
377
    uint32_t GetSize (void) const;
377
    uint32_t GetSize (void) const;
378
378
379
    /**
380
     * \returns the size left to read of the underlying buffer we are iterating
381
     */
382
    uint32_t GetRemainingSize (void) const;
383
379
private:
384
private:
380
    friend class Buffer;
385
    friend class Buffer;
381
    /**
386
    /**

Return to bug 2505