26 #include "ns3/assert.h" 
   28 #define BUFFER_FREE_LIST 1 
  105     inline void Next (
void);
 
  109     inline void Prev (
void);
 
  113     inline void Next (uint32_t delta);
 
  117     inline void Prev (uint32_t delta);
 
  132     bool IsEnd (
void) 
const;
 
  153     inline void WriteU8 (uint8_t data, uint32_t len);
 
  239     void Write (uint8_t 
const*buffer, uint32_t size);
 
  258     inline uint8_t  
PeekU8 (
void);
 
  266     inline uint8_t  
ReadU8 (
void);
 
  274     inline uint16_t 
ReadU16 (
void);
 
  347     void Read (uint8_t *buffer, uint32_t size);
 
  407     bool CheckNoZero (uint32_t start, uint32_t end) 
const;
 
  414     bool Check (uint32_t i) 
const;
 
  484   inline uint32_t 
GetSize (
void) 
const;
 
  495   uint8_t 
const*
PeekData (
void) 
const;
 
  579   uint32_t 
Serialize (uint8_t* buffer, uint32_t maxSize) 
const;
 
  589   uint32_t 
Deserialize (
const uint8_t* buffer, uint32_t size);
 
  597   void CopyData (std::ostream *os, uint32_t size) 
const;
 
  606   uint32_t 
CopyData (uint8_t *buffer, uint32_t size) 
const;
 
  627   Buffer (uint32_t dataSize);
 
  637   Buffer (uint32_t dataSize, 
bool initialize);
 
  787 #ifdef BUFFER_FREE_LIST 
  788   typedef std::vector<struct Buffer::Data*> 
FreeList;
 
  803 #include "ns3/assert.h" 
  820   m_current = m_dataStart;
 
  825   m_current = m_dataEnd;
 
  834   m_dataEnd = buffer->
m_end;
 
  853   NS_ASSERT (m_current + delta <= m_dataEnd);
 
  866                  GetWriteErrorMessage ());
 
  868   if (m_current < m_zeroStart)
 
  875       m_data[m_current - (m_zeroEnd-m_zeroStart)] = data;
 
  884                  GetWriteErrorMessage ());
 
  885   if (m_current <= m_zeroStart)
 
  887       std::memset (&(
m_data[m_current]), data, len);
 
  892       uint8_t *buffer = &
m_data[m_current - (m_zeroEnd-m_zeroStart)];
 
  893       std::memset (buffer, data, len);
 
  902                  GetWriteErrorMessage ());
 
  904   if (m_current + 2 <= m_zeroStart)
 
  906       buffer = &
m_data[m_current];
 
  910       buffer = &
m_data[m_current - (m_zeroEnd - m_zeroStart)];
 
  912   buffer[0] = (data >> 8)& 0xff;
 
  913   buffer[1] = (data >> 0)& 0xff;
 
  921                  GetWriteErrorMessage ());
 
  924   if (m_current + 4 <= m_zeroStart)
 
  926       buffer = &
m_data[m_current];
 
  930       buffer = &
m_data[m_current - (m_zeroEnd - m_zeroStart)];
 
  932   buffer[0] = (data >> 24)& 0xff;
 
  933   buffer[1] = (data >> 16)& 0xff;
 
  934   buffer[2] = (data >> 8)& 0xff;
 
  935   buffer[3] = (data >> 0)& 0xff;
 
  943   if (m_current + 2 <= m_zeroStart)
 
  945       buffer = &
m_data[m_current];
 
  947   else if (m_current >= m_zeroEnd)
 
  949       buffer = &
m_data[m_current - (m_zeroEnd - m_zeroStart)];
 
  953       return SlowReadNtohU16 ();
 
  967   if (m_current + 4 <= m_zeroStart)
 
  969       buffer = &
m_data[m_current];
 
  971   else if (m_current >= m_zeroEnd)
 
  973       buffer = &
m_data[m_current - (m_zeroEnd - m_zeroStart)];
 
  977       return SlowReadNtohU32 ();
 
  995                  m_current < m_dataEnd,
 
  996                  GetReadErrorMessage ());
 
  998   if (m_current < m_zeroStart)
 
 1003   else if (m_current < m_zeroEnd)
 
 1009       uint8_t 
data = 
m_data[m_current - (m_zeroEnd-m_zeroStart)];
 
 1017   uint8_t ret = PeekU8 ();
 
 1025   uint8_t byte0 = ReadU8 ();
 
 1026   uint8_t byte1 = ReadU8 ();
 
 1027   uint16_t 
data = byte1;
 
 1040   start.
Write (*
this, end);
 
uint16_t CalculateIpChecksum(uint16_t size)
Calculate the checksum. 
 
uint16_t SlowReadNtohU16(void)
 
void Initialize(uint32_t zeroSize)
Initializes the buffer with a number of zeroes. 
 
void WriteHtonU64(uint64_t data)
 
void AddAtStart(uint32_t start)
 
uint32_t m_end
offset to the end of the data referenced by this Buffer instance from the start of m_data->m_data ...
 
void RemoveAtEnd(uint32_t end)
 
uint8_t * m_data
a pointer to the underlying byte buffer. 
 
void RemoveAtStart(uint32_t start)
 
uint32_t m_size
the size of the m_data field below. 
 
automatically resized byte buffer 
 
uint64_t ReadNtohU64(void)
 
uint32_t m_count
The reference count of an instance of this data structure. 
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
uint32_t GetSerializedSize(void) const 
Return the number of bytes required for serialization. 
 
bool CheckInternalState(void) const 
Checks the internal buffer structures consistency. 
 
Buffer & operator=(Buffer const &o)
Assignment operator. 
 
uint32_t ReadNtohU32(void)
 
Local static destructor structure. 
 
uint32_t m_start
offset to the start of the data referenced by this Buffer instance from the start of m_data->m_data ...
 
uint32_t GetDistanceFrom(Iterator const &o) const 
 
iterator in a Buffer instance 
 
uint32_t SlowReadNtohU32(void)
 
uint32_t m_zeroStart
offset in virtual bytes from the start of the data buffer to the start of the "virtual zero area"...
 
uint32_t m_dirtyEnd
offset from the start of the m_data field below to the end of the area in which user bytes were writt...
 
uint32_t Deserialize(const uint8_t *buffer, uint32_t size)
 
uint8_t m_data[1]
The real data buffer holds at least one byte. 
 
This data structure is variable-sized through its last member whose size is determined at allocation ...
 
std::string GetWriteErrorMessage(void) const 
Returns an appropriate message indicating a write error. 
 
void Prev(void)
go backward by one byte 
 
void WriteU16(uint16_t data)
 
void WriteHtonU16(uint16_t data)
 
static struct Buffer::Data * Create(uint32_t size)
Create a buffer data storage. 
 
Buffer::Iterator End(void) const 
 
uint8_t const * PeekData(void) const 
 
void Next(void)
go forward by one byte 
 
uint32_t m_current
offset in virtual bytes from the start of the data buffer to the current position represented by this...
 
void WriteU64(uint64_t data)
 
static FreeList * g_freeList
Buffer data container. 
 
void CopyData(std::ostream *os, uint32_t size) const 
Copy the specified amount of data from the buffer to the given output stream. 
 
void TransformIntoRealBuffer(void) const 
Transform a "Virtual byte buffer" into a "Real byte buffer". 
 
Buffer::Iterator Begin(void) const 
 
bool Check(uint32_t i) const 
Checks that the buffer position is not in the "virtual zero area". 
 
void AddAtEnd(uint32_t end)
 
std::vector< struct Buffer::Data * > FreeList
Container for buffer data. 
 
bool CheckNoZero(uint32_t start, uint32_t end) const 
Checks that the [start, end) is not in the "virtual zero area". 
 
std::string GetReadErrorMessage(void) const 
Returns an appropriate message indicating a read error. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
static void Recycle(struct Buffer::Data *data)
Recycle the buffer memory. 
 
static uint32_t g_maxSize
Max observed data size. 
 
uint32_t m_dataEnd
offset in virtual bytes from the start of the data buffer to the end of the data which can be read by...
 
void Read(uint8_t *buffer, uint32_t size)
 
uint32_t m_zeroEnd
offset in virtual bytes from the start of the data buffer to the end of the "virtual zero area"...
 
uint32_t m_zeroAreaStart
offset to the start of the virtual zero area from the start of m_data->m_data 
 
void WriteHtonU32(uint32_t data)
 
uint32_t GetSize(void) const 
 
Buffer CreateFragment(uint32_t start, uint32_t length) const 
 
void WriteHtolsbU16(uint16_t data)
 
static struct Buffer::Data * Allocate(uint32_t reqSize)
Allocate a buffer data storage. 
 
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
 
uint32_t Serialize(uint8_t *buffer, uint32_t maxSize) const 
 
struct Data * m_data
the buffer data storage 
 
uint32_t m_dirtyStart
offset from the start of the m_data field below to the start of the area in which user bytes were wri...
 
void WriteU8(uint8_t data)
 
uint32_t m_maxZeroAreaStart
keep track of the maximum value of m_zeroAreaStart across the lifetime of a Buffer instance...
 
void WriteHtolsbU64(uint64_t data)
 
Buffer CreateFullCopy(void) const 
Create a full copy of the buffer, including all the internal structures. 
 
static void Deallocate(struct Buffer::Data *data)
Deallocate the buffer memory. 
 
uint32_t m_dataStart
offset in virtual bytes from the start of the data buffer to the start of the data which can be read ...
 
static uint32_t g_recommendedStart
location in a newly-allocated buffer where you should start writing data. 
 
void Write(uint8_t const *buffer, uint32_t size)
 
uint32_t GetInternalSize(void) const 
Get the buffer real size. 
 
uint16_t ReadLsbtohU16(void)
 
static struct LocalStaticDestructor g_localStaticDestructor
Local static destructor. 
 
uint64_t ReadLsbtohU64(void)
 
uint16_t ReadNtohU16(void)
 
void WriteU32(uint32_t data)
 
uint32_t GetInternalEnd(void) const 
Get the buffer end position. 
 
uint32_t GetSize(void) const 
 
uint32_t ReadLsbtohU32(void)
 
uint32_t m_zeroAreaEnd
offset to the end of the virtual zero area from the start of m_data->m_data 
 
void Construct(const Buffer *buffer)
Initializes the iterator values. 
 
void WriteHtolsbU32(uint32_t data)