EPS Conduits  v0.0.2-2413
networking over networking
EPS::NetBuffer Class Reference

NetBuffer objects manage blocks of buffer bytes used for either reading from, and writing to sockets. More...

#include "NetBuffer.hpp"

Collaboration diagram for EPS::NetBuffer:

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::CommHeader1get_header (void)
 Get the decrypted header pointer. More...
 
EPS::NetBuffercreate_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...
 
NetBufferget (const EPS::NetBuffer::EType type)
 Convert the buffer to the specified type. More...
 
NetBufferget_encrypted (void)
 Convert the buffer to the specified type. More...
 
NetBufferget_decrypted (void)
 Convert the buffer to the specified type. More...
 
NetBufferget_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::NetBufferrelated
 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_sizeBuffer
 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
 

Detailed Description

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.

Member Typedef Documentation

◆ Buffer

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.

See also
buffer

Member Enumeration Documentation

◆ EType

Enumerator to describe the contents of this buffer.

Enumerator
kInvalid 

unused buffer

kEncrypted 

encrypted buffer

kPartiallyDecrypted 

first 16 bytes (header) is decrypted

kFullyDecrypted 

decrypted buffer

kMax 

Constructor & Destructor Documentation

◆ NetBuffer() [1/2]

EPS::NetBuffer::NetBuffer ( const EPS::NetBuffer::EType  type = EPS::NetBuffer::EType::kInvalid)

Constructor.

Here is the call graph for this function:

◆ NetBuffer() [2/2]

EPS::NetBuffer::NetBuffer ( const NetBuffer nb)

Constructor. Calls clone().

Here is the call graph for this function:

◆ ~NetBuffer()

EPS::NetBuffer::~NetBuffer ( void  )

Destructor.

Here is the call graph for this function:

Member Function Documentation

◆ clear() [1/2]

void EPS::NetBuffer::clear ( const bool  also_clear_related_buffer)

Clear out a buffer so it can be re-used.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear() [2/2]

void EPS::NetBuffer::clear ( const EPS::NetBuffer::EType  type = EPS::NetBuffer::EType::kInvalid)

Clear out a buffer so it can be re-used.

Here is the call graph for this function:

◆ clone()

void EPS::NetBuffer::clone ( const EPS::NetBuffer nb)

Make a copy of the NetBuffer (ignoring the related pointer).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_related_buffer()

EPS::NetBuffer * EPS::NetBuffer::create_related_buffer ( const EPS::NetBuffer::EType  type)

Create and setup the related buffer pointer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data() [1/2]

const uint8_t* EPS::NetBuffer::data ( void  ) const
inline

Convert the type to a text string.

Here is the caller graph for this function:

◆ data() [2/2]

uint8_t* EPS::NetBuffer::data ( void  )
inline

Convert the type to a text string.

◆ data_after_header()

uint8_t* EPS::NetBuffer::data_after_header ( void  )
inline

Convert the type to a text string.

Here is the call graph for this function:

◆ get()

EPS::NetBuffer * EPS::NetBuffer::get ( const EPS::NetBuffer::EType  type)

Convert the buffer to the specified type.

Here is the call graph for this function:

◆ get_decrypted()

NetBuffer* EPS::NetBuffer::get_decrypted ( void  )
inline

Convert the buffer to the specified type.

Here is the caller graph for this function:

◆ get_decrypted_header()

NetBuffer* EPS::NetBuffer::get_decrypted_header ( void  )
inline

Convert the buffer to the specified type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_encrypted()

NetBuffer* EPS::NetBuffer::get_encrypted ( void  )
inline

Convert the buffer to the specified type.

Here is the caller graph for this function:

◆ get_header()

EPS::CommHeader1* EPS::NetBuffer::get_header ( void  )
inline

Get the decrypted header pointer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_decrypted()

bool EPS::NetBuffer::is_decrypted ( void  )
inline

Return TRUE if the buffer is either partially or fully decrypted.

Here is the caller graph for this function:

◆ is_encrypted()

bool EPS::NetBuffer::is_encrypted ( void  )
inline

Return TRUE if the buffer is encrypted.

◆ is_fully_decrypted()

bool EPS::NetBuffer::is_fully_decrypted ( void  )
inline

Return TRUE if the buffer is fully decrypted.

Here is the caller graph for this function:

◆ is_partially_decrypted()

bool EPS::NetBuffer::is_partially_decrypted ( void  )
inline

Return TRUE if the buffer is partially decrypted.

◆ lengths_are_valid()

bool EPS::NetBuffer::lengths_are_valid ( void  )

Check that both the original lenght and encryption lengths are valid.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ name() [1/2]

std::string EPS::NetBuffer::name ( void  ) const

Convert the type to a text string.

Here is the caller graph for this function:

◆ name() [2/2]

std::string EPS::NetBuffer::name ( const EPS::NetBuffer::EType  type) const

Convert the type to a text string.

◆ operator uint8_t *()

EPS::NetBuffer::operator uint8_t * ( void  )
inline

Return a pointer to the data.

Member Data Documentation

◆ buffer

Buffer EPS::NetBuffer::buffer
See also
buffer_type

◆ buffer_1st

boost::asio::mutable_buffers_1 EPS::NetBuffer::buffer_1st

buffer used by asio; references buffer[0]

◆ buffer_2nd

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)

◆ buffer_type

EType EPS::NetBuffer::buffer_type

Buffer used to read/write to sockets, as well as encrypt/decrypt packet payloads.

See also
buffer

◆ length

size_t EPS::NetBuffer::length

number of usable bytes in the buffer

◆ related

EPS::NetBuffer* EPS::NetBuffer::related

a buffer which is related to this one through either encryption or decryption


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