|
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 |
|