libktorrent  2.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
utp::PacketBuffer Class Reference

#include <packetbuffer.h>

Public Member Functions

 PacketBuffer (const PacketBuffer &buf)=default
 
bt::Uint32 bufferSize () const
 Get the buffer size.
 
const bt::Uint8 * data () const
 Get the data pointer.
 
bt::Uint8 * extensionData ()
 Get a pointer to the extension data.
 
bt::Uint32 fillData (bt::CircularBuffer &cbuf, bt::Uint32 to_read)
 
bt::Uint32 fillData (const bt::Uint8 *data, bt::Uint32 data_size)
 
void fillDummyData (bt::Uint32 amount)
 
bt::Uint32 headRoom () const
 Get the amount of headroom (room in front of payload)
 
bool isEmpty () const
 
PacketBufferoperator= (const PacketBuffer &buf)=default
 
bt::Uint32 payloadSize () const
 Get the size of the payload.
 
bool setHeader (const Header &hdr, bt::Uint32 extension_length)
 

Static Public Member Functions

static void clearPool ()
 

Static Public Attributes

static const bt::Uint32 MAX_SIZE = 1500
 

Detailed Description

Special packet buffer for UTP packets

Definition at line 37 of file packetbuffer.h.

Member Function Documentation

◆ clearPool()

static void utp::PacketBuffer::clearPool ( )
static

Clear the PacketBufferDataPool

◆ fillData() [1/2]

bt::Uint32 utp::PacketBuffer::fillData ( bt::CircularBuffer cbuf,
bt::Uint32  to_read 
)

Fill with data from a circular buffer. This will invalidate already filled in headers.

Parameters
cbufThe buffer
to_readAmount to read
Returns
The amount used as payload

◆ fillData() [2/2]

bt::Uint32 utp::PacketBuffer::fillData ( const bt::Uint8 *  data,
bt::Uint32  data_size 
)

Fill with data from a buffer.

Parameters
dataThe data to copy from
data_sizeThe data size
Returns
The amount used as payload

◆ fillDummyData()

void utp::PacketBuffer::fillDummyData ( bt::Uint32  amount)

For testing purpoes fill with dummy data.

Parameters
amountAmount to fill

◆ isEmpty()

bool utp::PacketBuffer::isEmpty ( ) const
inline

Is the buffer empty

Definition at line 49 of file packetbuffer.h.

◆ setHeader()

bool utp::PacketBuffer::setHeader ( const Header hdr,
bt::Uint32  extension_length 
)

Set the packet's header.

Parameters
headerHeader
extension_lengthLength of the extension header
Returns
False if there is not enough head room, true otherwise

The documentation for this class was generated from the following file: