network: Adding Read (Buffer::Iterator start, uint32_t size) and PeakU8 methods to ns3::Buffer::Iterator class
This commit is contained in:
1 parent
19a649bbe2
commit
7b321fba3e
1 file changed
+36
-1
@@ -248,6 +248,13 @@ public:
|
||||
*/
|
||||
void Write (Iterator start, Iterator end);
|
||||
|
||||
/**
|
||||
* \return the byte read in the buffer.
|
||||
*
|
||||
* Read data, but do not advance the Iterator read.
|
||||
*/
|
||||
inline uint8_t PeekU8 (void);
|
||||
|
||||
/**
|
||||
* \return the byte read in the buffer.
|
||||
*
|
||||
@@ -332,11 +339,21 @@ public:
|
||||
* \param size number of bytes to copy
|
||||
*
|
||||
* Copy size bytes of data from the internal buffer to the
|
||||
* input buffer and avance the Iterator by the number of
|
||||
* input buffer and advance the Iterator by the number of
|
||||
* bytes read.
|
||||
*/
|
||||
void Read (uint8_t *buffer, uint32_t size);
|
||||
|
||||
/**
|
||||
* \param start start iterator of the buffer to copy data into
|
||||
* \param size number of bytes to copy
|
||||
*
|
||||
* Copy size bytes of data from the internal buffer to the input buffer via
|
||||
* the provided iterator and advance the Iterator by the number of bytes
|
||||
* read.
|
||||
*/
|
||||
inline void Read (Iterator start, uint32_t size);
|
||||
|
||||
/**
|
||||
* \brief Calculate the checksum.
|
||||
* \param size size of the buffer.
|
||||
@@ -813,6 +830,14 @@ Buffer::Iterator::ReadNtohU32 (void)
|
||||
return retval;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Buffer::Iterator::PeekU8 (void)
|
||||
{
|
||||
uint8_t ret = ReadU8 ();
|
||||
Prev ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Buffer::Iterator::ReadU8 (void)
|
||||
{
|
||||
@@ -851,6 +876,16 @@ Buffer::Iterator::ReadU16 (void)
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
Buffer::Iterator::Read (Buffer::Iterator start, uint32_t size)
|
||||
{
|
||||
Buffer::Iterator end = *this;
|
||||
end.Next (size);
|
||||
|
||||
start.Write (*this, end);
|
||||
}
|
||||
|
||||
|
||||
Buffer::Buffer (Buffer const&o)
|
||||
: m_data (o.m_data),
|
||||
m_maxZeroAreaStart (o.m_zeroAreaStart),
|
||||
|
||||
Reference in new issue
Block a user