Simple Geolocalization and Course Transmission Protocol (SGCTP)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
SGCTP::CPayload Class Reference

(Raw) SGCTP payload More...

#include <sgctp/payload.hpp>

Inheritance diagram for SGCTP::CPayload:
SGCTP::CPayload_AES128

Public Member Functions

 CPayload ()
 
virtual ~CPayload ()
 
virtual int alloc ()
 Allocate resources for payload (un-)serialization. More...
 
virtual int serialize (unsigned char *_pucBuffer, const CData &_roData)
 Serialize the given SGCTP data into the given payload buffer. More...
 
virtual int unserialize (CData *_poData, const unsigned char *_pucBuffer, uint16_t _ui16tBufferSize)
 Unserialize the SGCTP data from the given payload buffer. More...
 
virtual void free ()
 Free resources for payload (un-)serialization. More...
 

Static Public Member Functions

static unsigned char * allocBuffer ()
 Allocate a buffer for payload (un-)serialization. More...
 
static void zeroBuffer (unsigned char *_pucBuffer)
 Zero-out a buffer required for payload (un-)serialization. More...
 
static void freeBuffer (unsigned char *_pucBuffer)
 Free a buffer allocated for payload (un-)serialization. More...
 

Static Public Attributes

static const uint16_t BUFFER_SIZE = 33024
 Buffer size required for payload (un-)serialization. More...
 

Private Member Functions

void putBits (uint8_t _ui8tBitsSize, uint8_t _ui8tBits)
 Add the given bits to the payload. More...
 
void putBytes (uint16_t _ui16tBytesSize, const unsigned char *_pucBytes)
 Add the given bytes to the payload. More...
 
uint8_t getBits (uint8_t _ui8tBitsSize)
 Retrieve the given bits from the payload. More...
 
void getBytes (uint16_t _ui16tBytesSize, unsigned char *_pucBytes)
 Retrieve the given bytes from the payload. More...
 

Private Attributes

unsigned char * pucBufferPut
 SGCTP payload export buffer pointer. More...
 
const unsigned char * pucBufferGet
 SGCTP payload import buffer pointer. More...
 
uint32_t ui32tBufferBitOffset
 SGCTP payload bit position. More...
 

Static Private Attributes

static const uint8_t BITMASK [9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }
 Bit masks used to (un-)serialize data bit-per-bit. More...
 

Detailed Description

(Raw) SGCTP payload

This class (un-)serializes data from/to a (raw) SGCTP payload.

Definition at line 41 of file payload.hpp.

Constructor & Destructor Documentation

SGCTP::CPayload::CPayload ( )
inline

Definition at line 102 of file payload.hpp.

virtual SGCTP::CPayload::~CPayload ( )
inlinevirtual

Definition at line 104 of file payload.hpp.

Member Function Documentation

static unsigned char* SGCTP::CPayload::allocBuffer ( )
inlinestatic

Allocate a buffer for payload (un-)serialization.

Returns
Pointer to the allocated buffer; NULL in case of error

Definition at line 61 of file payload.hpp.

static void SGCTP::CPayload::zeroBuffer ( unsigned char *  _pucBuffer)
inlinestatic

Zero-out a buffer required for payload (un-)serialization.

Parameters
[in]_pucBufferAllocated buffer
See Also
allocBuffer()

Definition at line 70 of file payload.hpp.

static void SGCTP::CPayload::freeBuffer ( unsigned char *  _pucBuffer)
inlinestatic

Free a buffer allocated for payload (un-)serialization.

Parameters
[in]_pucBufferAllocated buffer
See Also
allocBuffer()

Definition at line 79 of file payload.hpp.

void CPayload::putBits ( uint8_t  _ui8tBitsSize,
uint8_t  _ui8tBits 
)
private

Add the given bits to the payload.

Parameters
[in]_ui8tBitsSizeData size (bits quantity)
[in]_ui8tBitsData (bits)

Definition at line 42 of file payload.cpp.

void CPayload::putBytes ( uint16_t  _ui16tBytesSize,
const unsigned char *  _pucBytes 
)
private

Add the given bytes to the payload.

Parameters
[in]_ui16tBytesSizeData size (bytes quantity)
[in]_pucBytesData buffer (to read the data from)

Definition at line 57 of file payload.cpp.

uint8_t CPayload::getBits ( uint8_t  _ui8tBitsSize)
private

Retrieve the given bits from the payload.

Parameters
[in]_ui8tBitsSizeData size (bits quantity)
Returns
Data (bits)

Definition at line 69 of file payload.cpp.

void CPayload::getBytes ( uint16_t  _ui16tBytesSize,
unsigned char *  _pucBytes 
)
private

Retrieve the given bytes from the payload.

Parameters
[in]_ui16tBytesSizeData size (bytes quantity)
[in]_pucBytesData buffer (to write the data to)

Definition at line 81 of file payload.cpp.

virtual int SGCTP::CPayload::alloc ( )
inlinevirtual

Allocate resources for payload (un-)serialization.

Returns
Negative error code in case of error, zero otherwise

Reimplemented in SGCTP::CPayload_AES128.

Definition at line 146 of file payload.hpp.

int CPayload::serialize ( unsigned char *  _pucBuffer,
const CData _roData 
)
virtual

Serialize the given SGCTP data into the given payload buffer.

Parameters
[in]_pucBufferPayload buffer (to write the serialization data to)
[in]_roDataSGCTP data object (to be serialized)
Returns
(Positive) Quantity of data actually serialized; Negative error code in case of error

Reimplemented in SGCTP::CPayload_AES128.

Definition at line 93 of file payload.cpp.

int CPayload::unserialize ( CData _poData,
const unsigned char *  _pucBuffer,
uint16_t  _ui16tBufferSize 
)
virtual

Unserialize the SGCTP data from the given payload buffer.

Parameters
[in]_poDataSGCTP data object (to store unserialized data)
[in]_pucBufferPayload buffer (to read the serialization data from)
Returns
(Positive) Quantity of data actually unserialized; Negative error code in case of error

Reimplemented in SGCTP::CPayload_AES128.

Definition at line 355 of file payload.cpp.

virtual void SGCTP::CPayload::free ( )
inlinevirtual

Free resources for payload (un-)serialization.

Reimplemented in SGCTP::CPayload_AES128.

Definition at line 168 of file payload.hpp.

Member Data Documentation

const uint16_t SGCTP::CPayload::BUFFER_SIZE = 33024
static

Buffer size required for payload (un-)serialization.

Definition at line 50 of file payload.hpp.

const uint8_t CPayload::BITMASK = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }
staticprivate

Bit masks used to (un-)serialize data bit-per-bit.

Definition at line 54 of file payload.hpp.

unsigned char* SGCTP::CPayload::pucBufferPut
private

SGCTP payload export buffer pointer.

Definition at line 82 of file payload.hpp.

const unsigned char* SGCTP::CPayload::pucBufferGet
private

SGCTP payload import buffer pointer.

Definition at line 92 of file payload.hpp.

uint32_t SGCTP::CPayload::ui32tBufferBitOffset
private

SGCTP payload bit position.

Definition at line 94 of file payload.hpp.


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