NetBuffer objects manage blocks of buffer bytes used for either reading from, and writing to sockets. More...
#include "NetBuffer.hpp"
Public Types | |
enum | EType { kInvalid = 0, kEncrypted = 1, kPartiallyDecrypted = 2, kFullyDecrypted = 3, kMax } |
Enumerator to describe the contents of this buffer. More... | |
Public Member Functions | |
NetBuffer (const EPS::NetBuffer::EType type=EPS::NetBuffer::EType::kInvalid) | |
Constructor. More... | |
NetBuffer (const NetBuffer &nb) | |
Constructor. Calls clone(). More... | |
~NetBuffer (void) | |
Destructor. More... | |
bool | is_encrypted (void) |
Return TRUE if the buffer is encrypted. More... | |
bool | is_partially_decrypted (void) |
Return TRUE if the buffer is partially decrypted. More... | |
bool | is_fully_decrypted (void) |
Return TRUE if the buffer is fully decrypted. More... | |
bool | is_decrypted (void) |
Return TRUE if the buffer is either partially or fully decrypted. More... | |
bool | lengths_are_valid (void) |
Check that both the original lenght and encryption lengths are valid. More... | |
EPS::CommHeader1 * | get_header (void) |
Get the decrypted header pointer. More... | |
EPS::NetBuffer * | create_related_buffer (const EPS::NetBuffer::EType type) |
Create and setup the related buffer pointer. More... | |
void | clone (const EPS::NetBuffer &nb) |
Make a copy of the NetBuffer (ignoring the related pointer). More... | |
void | clear (const bool also_clear_related_buffer) |
Clear out a buffer so it can be re-used. More... | |
void | clear (const EPS::NetBuffer::EType type=EPS::NetBuffer::EType::kInvalid) |
Clear out a buffer so it can be re-used. More... | |
NetBuffer * | get (const EPS::NetBuffer::EType type) |
Convert the buffer to the specified type. More... | |
NetBuffer * | get_encrypted (void) |
Convert the buffer to the specified type. More... | |
NetBuffer * | get_decrypted (void) |
Convert the buffer to the specified type. More... | |
NetBuffer * | get_decrypted_header (void) |
Convert the buffer to the specified type. More... | |
std::string | name (void) const |
Convert the type to a text string. More... | |
std::string | name (const EPS::NetBuffer::EType type) const |
Convert the type to a text string. More... | |
operator uint8_t * (void) | |
Return a pointer to the data. More... | |
const uint8_t * | data (void) const |
Convert the type to a text string. More... | |
uint8_t * | data (void) |
Convert the type to a text string. More... | |
uint8_t * | data_after_header (void) |
Convert the type to a text string. More... | |
Public Attributes | |
size_t | length |
number of usable bytes in the buffer More... | |
EPS::NetBuffer * | related |
a buffer which is related to this one through either encryption or decryption More... | |
boost::asio::mutable_buffers_1 | buffer_1st |
buffer used by asio; references buffer[0] More... | |
boost::asio::mutable_buffers_1 | buffer_2nd |
buffer used by asio; references buffer[16] (aka EPS::cipher_block_size, to bypass the common header) More... | |
typedef std::array< uint8_t, EPS::network_buffer_size > | Buffer |
Buffer used to read/write to sockets, as well as encrypt/decrypt packet payloads. More... | |
EType | buffer_type |
Buffer used to read/write to sockets, as well as encrypt/decrypt packet payloads. More... | |
Buffer | buffer |
NetBuffer objects manage blocks of buffer bytes used for either reading from, and writing to sockets.
Included in this class is the ability to manage encryption and decryption of EPS network data. When a buffer is either encrypted or decrypted, a link to the original NetBuffer object is kept so the original data can easily be referenced without having to re-encrypt or re-decrypt the data should it be necessary to get access to the original bytes.
typedef std::array<uint8_t, EPS::network_buffer_size> EPS::NetBuffer::Buffer |
Buffer used to read/write to sockets, as well as encrypt/decrypt packet payloads.
EPS::NetBuffer::NetBuffer | ( | const EPS::NetBuffer::EType | type = EPS::NetBuffer::EType::kInvalid | ) |
Constructor.
EPS::NetBuffer::NetBuffer | ( | const NetBuffer & | nb | ) |
EPS::NetBuffer::~NetBuffer | ( | void | ) |
Destructor.
void EPS::NetBuffer::clear | ( | const bool | also_clear_related_buffer | ) |
Clear out a buffer so it can be re-used.
void EPS::NetBuffer::clear | ( | const EPS::NetBuffer::EType | type = EPS::NetBuffer::EType::kInvalid | ) |
Clear out a buffer so it can be re-used.
void EPS::NetBuffer::clone | ( | const EPS::NetBuffer & | nb | ) |
Make a copy of the NetBuffer (ignoring the related pointer).
EPS::NetBuffer * EPS::NetBuffer::create_related_buffer | ( | const EPS::NetBuffer::EType | type | ) |
Create and setup the related buffer pointer.
|
inline |
Convert the type to a text string.
|
inline |
Convert the type to a text string.
|
inline |
Convert the type to a text string.
EPS::NetBuffer * EPS::NetBuffer::get | ( | const EPS::NetBuffer::EType | type | ) |
Convert the buffer to the specified type.
|
inline |
Convert the buffer to the specified type.
|
inline |
Convert the buffer to the specified type.
|
inline |
Convert the buffer to the specified type.
|
inline |
Get the decrypted header pointer.
|
inline |
Return TRUE
if the buffer is either partially or fully decrypted.
|
inline |
Return TRUE
if the buffer is encrypted.
|
inline |
Return TRUE
if the buffer is fully decrypted.
|
inline |
Return TRUE
if the buffer is partially decrypted.
bool EPS::NetBuffer::lengths_are_valid | ( | void | ) |
Check that both the original lenght and encryption lengths are valid.
std::string EPS::NetBuffer::name | ( | void | ) | const |
Convert the type to a text string.
std::string EPS::NetBuffer::name | ( | const EPS::NetBuffer::EType | type | ) | const |
Convert the type to a text string.
|
inline |
Return a pointer to the data.
Buffer EPS::NetBuffer::buffer |
boost::asio::mutable_buffers_1 EPS::NetBuffer::buffer_1st |
buffer used by asio; references buffer[0]
boost::asio::mutable_buffers_1 EPS::NetBuffer::buffer_2nd |
buffer used by asio; references buffer[16] (aka EPS::cipher_block_size, to bypass the common header)
EType EPS::NetBuffer::buffer_type |
Buffer used to read/write to sockets, as well as encrypt/decrypt packet payloads.
size_t EPS::NetBuffer::length |
number of usable bytes in the buffer
EPS::NetBuffer* EPS::NetBuffer::related |
a buffer which is related to this one through either encryption or decryption