mirror of https://github.com/infosecn1nja/C3.git
Add documentation for QualityOfService::PacketSplitter
parent
bad00afac5
commit
307602b85e
|
@ -32,6 +32,7 @@ namespace FSecure::C3
|
||||||
/// Informs that packet can be merged from chunks.
|
/// Informs that packet can be merged from chunks.
|
||||||
bool IsReady();
|
bool IsReady();
|
||||||
|
|
||||||
|
/// m_ExpectedSize setter.
|
||||||
void SetExpectedSize(uint32_t size);
|
void SetExpectedSize(uint32_t size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -66,17 +67,36 @@ namespace FSecure::C3
|
||||||
static constexpr size_t s_MinFrameSize = 64U;
|
static constexpr size_t s_MinFrameSize = 64U;
|
||||||
static constexpr size_t s_MinBodySize = s_MinFrameSize - s_HeaderSize;
|
static constexpr size_t s_MinBodySize = s_MinFrameSize - s_HeaderSize;
|
||||||
|
|
||||||
|
/// Class responsible for delivering data with correct chunk headers for sending.
|
||||||
|
/// This class does not own copy of data to be sent.
|
||||||
|
/// Original blob must be valid as long as PacketSplitter is used.
|
||||||
class PacketSplitter
|
class PacketSplitter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// Constructor.
|
||||||
|
/// @param data - blob of data to be sent.
|
||||||
|
/// @param id - packet number.
|
||||||
PacketSplitter(ByteView data, uint32_t id);
|
PacketSplitter(ByteView data, uint32_t id);
|
||||||
|
|
||||||
|
/// Update PacketSplitter state after sending part of data.
|
||||||
|
/// @param sent - number of bytes that was successfully sent.
|
||||||
|
/// @returns true if sent data was enough to be accepted as correct chunk.
|
||||||
bool Update(size_t sent);
|
bool Update(size_t sent);
|
||||||
|
|
||||||
|
/// Get chunk ready to be sent.
|
||||||
|
/// @returns chunk of data with correct QOS header.
|
||||||
|
/// Content of returned data will be same as long as Update was not called, or called but returned false.
|
||||||
ByteVector NextChunk() const;
|
ByteVector NextChunk() const;
|
||||||
|
|
||||||
|
/// Informs if there is still part of packet awaiting for sending.
|
||||||
bool HasMore() const;
|
bool HasMore() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// View of data to be send.
|
||||||
ByteView m_Data;
|
ByteView m_Data;
|
||||||
|
/// Current packed id.
|
||||||
uint32_t m_PacketId;
|
uint32_t m_PacketId;
|
||||||
|
/// Current packet chunk id.
|
||||||
uint32_t m_ChunkId;
|
uint32_t m_ChunkId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,6 +115,7 @@ namespace FSecure::C3
|
||||||
/// @param chunk chunk of packet.
|
/// @param chunk chunk of packet.
|
||||||
void PushReceivedChunk(uint32_t packetId, uint32_t chunkId, uint32_t expectedSize, ByteView chunk);
|
void PushReceivedChunk(uint32_t packetId, uint32_t chunkId, uint32_t expectedSize, ByteView chunk);
|
||||||
|
|
||||||
|
/// Get Packet Splitter for data to be sent through channel.
|
||||||
PacketSplitter GetPacketSplitter(ByteView data);
|
PacketSplitter GetPacketSplitter(ByteView data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue