21 #ifndef UTP_PACKETBUFFER_H_
22 #define UTP_PACKETBUFFER_H_
24 #include <QSharedPointer>
25 #include <ktorrent_export.h>
26 #include <util/constants.h>
27 #include <util/circularbuffer.h>
28 #include <util/bufferpool.h>
37 class KTORRENT_EXPORT PacketBuffer
43 PacketBuffer(
const PacketBuffer & buf) =
default;
44 PacketBuffer &operator=(
const PacketBuffer & buf) =
default;
49 bool isEmpty()
const {
return size == 0;}
57 bool setHeader(
const Header & hdr, bt::Uint32 extension_length);
60 bt::Uint8* extensionData() {
return extension;}
76 bt::Uint32 fillData(
const bt::Uint8* data, bt::Uint32 data_size);
82 void fillDummyData(bt::Uint32 amount);
87 static void clearPool();
90 const bt::Uint8* data()
const {
return header;}
93 bt::Uint32 bufferSize()
const {
return size;}
96 bt::Uint32 payloadSize()
const {
return payload ? (buffer->get() + MAX_SIZE) - payload: 0;}
99 bt::Uint32 headRoom()
const {
return payload ? payload - buffer->get() : MAX_SIZE;}
101 static const bt::Uint32 MAX_SIZE = 1500;
104 bt::Buffer::Ptr buffer;
106 bt::Uint8* extension;
110 static bt::BufferPool::Ptr pool;