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

Generic transmission of SGCTP payload. More...

#include <sgctp/transmit.hpp>

Inheritance diagram for SGCTP::CTransmit:
SGCTP::CParameters SGCTP::CTransmit_File SGCTP::CTransmit_TCP SGCTP::CTransmit_UDP

Public Types

enum  ETransmitType { TRANSMIT_UDP = 0, TRANSMIT_TCP = 1, TRANSMIT_FILE = 128, TRANSMIT_UNDEFINED = 255 }
 Transmission types. More...
 
enum  EPayloadType { PAYLOAD_RAW = 0, PAYLOAD_AES128 = 1, PAYLOAD_UNDEFINED = 255 }
 Payload types. More...
 

Public Member Functions

 CTransmit ()
 
virtual ~CTransmit ()
 
virtual void setTimeout (int _iDescriptor, double _fdTimeout)
 Set the transmission (send/receive) timeout, in seconds. More...
 
bool hasData ()
 Return whether data are available (in the transmission buffer) More...
 
virtual ETransmitType getTransmitType ()=0
 Return the transmission type. More...
 
virtual bool hasPayload ()
 Return whether a payload object has been successfully associated/initialized. More...
 
virtual void resetPayload ()
 Reset (clear) the associated payload object. More...
 
virtual int initPayload (uint8_t _ui8tPayloadType=PAYLOAD_RAW)
 Associate and initialize payload object. More...
 
virtual int allocPayload ()
 Allocate resources required for payload (un-)serialization. More...
 
virtual void freePayload ()
 Free resources required for payload (un-)serialization. More...
 
virtual EPayloadType getPayloadType ()
 Return the payload type. More...
 
virtual int alloc ()=0
 Allocate resources required for data transmission (un-/serialization) More...
 
virtual int serialize (int _iDescriptor, const CData &_roData)
 Serialize the given SGCTP data to the given descriptor. More...
 
virtual int unserialize (int _iDescriptor, CData *_poData, int _iMaxSize=0)
 Unserialize the SGCTP data from the given descriptor. More...
 
virtual void free ()
 Free resources required for data transmission (un-/serialization) More...
 
- Public Member Functions inherited from SGCTP::CParameters
 CParameters ()
 
 ~CParameters ()
 
CPrincipalusePrincipal ()
 Return the principal (pointer) More...
 
void reset ()
 Reset (undefines) all data. More...
 
void setSocketAddress (struct sockaddr *_ptSockaddr, socklen_t *_ptSocklenT)
 Set the network socket address (pointers to existing variables) More...
 
void setPrincipalsPath (const char *_pcPrincipalsPath)
 Set the principals (database) path (pointer to existing variable) More...
 
void setPasswordSalt (const unsigned char *_pucPasswordSalt)
 Set the cryptographic password salt/nonce (pointer to existing variable) More...
 

Static Public Attributes

static const uint8_t PROTOCOL_VERSION = 1
 Protocol version. More...
 

Protected Member Functions

int allocBuffer ()
 Allocate resources required for data transmission. More...
 
int recvBuffer (int _iDescriptor, int _iSize)
 Receive data from the given descriptor (and push them on the data buffer) More...
 
const unsigned char * pullBuffer (int _iSize)
 Pull data from the transmission buffer. More...
 
void flushBuffer ()
 Flush the data buffer (from pulled data) More...
 
void resetBuffer ()
 Reset the data buffer (clear all data) More...
 
virtual int recv (int _iDescriptor, void *_pBuffer, int _iSize, int _iFlags)=0
 Receive data from the given descriptor. More...
 
virtual int send (int _iDescriptor, const void *_pBuffer, int _iSize, int _iFlags)=0
 Send data to the given descriptor. More...
 

Protected Attributes

unsigned char * pucBuffer
 Transmission buffer. More...
 
int iBufferSize
 Transmission buffer size. More...
 
int iBufferDataStart
 Transmission buffer actual data start offset. More...
 
int iBufferDataEnd
 Transmission buffer actual data end offset. More...
 
double fdTimeout
 Transmission timeout, in seconds. More...
 
CPayloadpoPayload
 Associated payload object. More...
 
EPayloadType ePayloadType
 Associated payload type. More...
 
- Protected Attributes inherited from SGCTP::CParameters
struct sockaddr * ptSockaddr
 Network socket address (pointer to existing variable) More...
 
socklen_t * ptSocklenT
 Network socket address length (pointer to existing variable) More...
 
const char * pcPrincipalsPath
 Principals (database) path (pointer to existing variable) More...
 
CPrincipal oPrincipal
 Principal. More...
 
const unsigned char * pucPasswordSalt
 Cryptographic password salt/nonce (pointer to existing variable) More...
 

Detailed Description

Generic transmission of SGCTP payload.

This class defines the generic aspects of the transmission of a SGCTP payload. WARNING: Different objects MUST be used for serialization and unserialization!

Definition at line 46 of file transmit.hpp.

Member Enumeration Documentation

Transmission types.

Enumerator
TRANSMIT_UDP 

UDP socket.

TRANSMIT_TCP 

TCP socket.

TRANSMIT_FILE 

File socket.

TRANSMIT_UNDEFINED 

undefined

Definition at line 58 of file transmit.hpp.

Payload types.

Enumerator
PAYLOAD_RAW 

raw payload

PAYLOAD_AES128 

AES128-encrypted payload.

PAYLOAD_UNDEFINED 

undefined

Definition at line 66 of file transmit.hpp.

Constructor & Destructor Documentation

CTransmit::CTransmit ( )

Definition at line 42 of file transmit.cpp.

CTransmit::~CTransmit ( )
virtual

Definition at line 53 of file transmit.cpp.

Member Function Documentation

int CTransmit::allocBuffer ( )
protected

Allocate resources required for data transmission.

Returns
Negative error code in case of error, zero otherwise

Definition at line 66 of file transmit.cpp.

int CTransmit::recvBuffer ( int  _iDescriptor,
int  _iSize 
)
protected

Receive data from the given descriptor (and push them on the data buffer)

Parameters
[in]_iDescriptorFile/socket/... descriptor
[in]_iSizeSize of data to receive
Returns
(Positive) Quantity of data actually received; Negative error code in case of error

Definition at line 80 of file transmit.cpp.

const unsigned char * CTransmit::pullBuffer ( int  _iSize)
protected

Pull data from the transmission buffer.

Parameters
[in]_iSizeSize of data to pull
Returns
Pointer to the data (within the transmission buffer)

Definition at line 121 of file transmit.cpp.

void CTransmit::flushBuffer ( )
protected

Flush the data buffer (from pulled data)

Definition at line 127 of file transmit.cpp.

void CTransmit::resetBuffer ( )
protected

Reset the data buffer (clear all data)

Definition at line 146 of file transmit.cpp.

virtual void SGCTP::CTransmit::setTimeout ( int  _iDescriptor,
double  _fdTimeout 
)
inlinevirtual

Set the transmission (send/receive) timeout, in seconds.

Parameters
[in]_iDescriptorFile/socket/... descriptor
[in]_fdTimeoutTransmission timeout, in seconds

Reimplemented in SGCTP::CTransmit_TCP.

Definition at line 140 of file transmit.hpp.

bool SGCTP::CTransmit::hasData ( )
inline

Return whether data are available (in the transmission buffer)

Definition at line 146 of file transmit.hpp.

virtual int SGCTP::CTransmit::recv ( int  _iDescriptor,
void *  _pBuffer,
int  _iSize,
int  _iFlags 
)
protectedpure virtual

Receive data from the given descriptor.

Parameters
[in]_iDescriptorFile/socket/... descriptor
[in]_pBufferPointer to buffer (to store received data)
[in]_iSizeSize of data to receive
[in]_iFlagsDescriptor-specific control flags
Returns
(Positive) Quantity of data actually received; Negative error code in case of error

Implemented in SGCTP::CTransmit_TCP, SGCTP::CTransmit_File, and SGCTP::CTransmit_UDP.

virtual int SGCTP::CTransmit::send ( int  _iDescriptor,
const void *  _pBuffer,
int  _iSize,
int  _iFlags 
)
protectedpure virtual

Send data to the given descriptor.

Parameters
[in]_iDescriptorFile/socket/... descriptor
[in]_pBufferPointer to buffer (containing data to be sent)
[in]_iSizeSize of data to send
[in]_iFlagsDescriptor-specific control flags
Returns
(Positive) Quantity of data actually sent; Negative error code in case of error

Implemented in SGCTP::CTransmit_TCP, SGCTP::CTransmit_File, and SGCTP::CTransmit_UDP.

virtual ETransmitType SGCTP::CTransmit::getTransmitType ( )
pure virtual

Return the transmission type.

Implemented in SGCTP::CTransmit_TCP, SGCTP::CTransmit_File, and SGCTP::CTransmit_UDP.

virtual bool SGCTP::CTransmit::hasPayload ( )
inlinevirtual

Return whether a payload object has been successfully associated/initialized.

Definition at line 181 of file transmit.hpp.

void CTransmit::resetPayload ( )
virtual

Reset (clear) the associated payload object.

Definition at line 152 of file transmit.cpp.

int CTransmit::initPayload ( uint8_t  _ui8tPayloadType = PAYLOAD_RAW)
virtual

Associate and initialize payload object.

Returns
Negative error code in case of error, zero otherwise

Definition at line 160 of file transmit.cpp.

int CTransmit::allocPayload ( )
virtual

Allocate resources required for payload (un-)serialization.

Returns
Negative error code in case of error, zero otherwise

Definition at line 198 of file transmit.cpp.

void CTransmit::freePayload ( )
virtual

Free resources required for payload (un-)serialization.

Definition at line 205 of file transmit.cpp.

virtual EPayloadType SGCTP::CTransmit::getPayloadType ( )
inlinevirtual

Return the payload type.

Definition at line 200 of file transmit.hpp.

virtual int SGCTP::CTransmit::alloc ( )
pure virtual

Allocate resources required for data transmission (un-/serialization)

Returns
Negative error code in case of error, zero otherwise

Implemented in SGCTP::CTransmit_TCP, SGCTP::CTransmit_File, and SGCTP::CTransmit_UDP.

int CTransmit::serialize ( int  _iDescriptor,
const CData _roData 
)
virtual

Serialize the given SGCTP data to the given descriptor.

Parameters
[in]_iDescriptorFile/socket/... descriptor
[in]_roDataSGCTP data object (to be serialized/sent)
Returns
(Positive) Quantity of data actually serialized/sent; Negative error code in case of error

Reimplemented in SGCTP::CTransmit_TCP.

Definition at line 212 of file transmit.cpp.

int CTransmit::unserialize ( int  _iDescriptor,
CData _poData,
int  _iMaxSize = 0 
)
virtual

Unserialize the SGCTP data from the given descriptor.

Parameters
[in]_iDescriptorFile/socket/... descriptor
[in]_poDataSGCTP data object (to store unserialized/received data)
[in]_iMaxSizeMaximum size of expected data (0 = no limit)
Returns
(Positive) Quantity of data actually unserialized/received; Negative error code in case of error

Reimplemented in SGCTP::CTransmit_TCP, and SGCTP::CTransmit_UDP.

Definition at line 256 of file transmit.cpp.

void CTransmit::free ( )
virtual

Free resources required for data transmission (un-/serialization)

Definition at line 304 of file transmit.cpp.

Member Data Documentation

const uint8_t SGCTP::CTransmit::PROTOCOL_VERSION = 1
static

Protocol version.

Definition at line 55 of file transmit.hpp.

unsigned char* SGCTP::CTransmit::pucBuffer
protected

Transmission buffer.

Definition at line 79 of file transmit.hpp.

int SGCTP::CTransmit::iBufferSize
protected

Transmission buffer size.

Definition at line 81 of file transmit.hpp.

int SGCTP::CTransmit::iBufferDataStart
protected

Transmission buffer actual data start offset.

Definition at line 83 of file transmit.hpp.

int SGCTP::CTransmit::iBufferDataEnd
protected

Transmission buffer actual data end offset.

Definition at line 85 of file transmit.hpp.

double SGCTP::CTransmit::fdTimeout
protected

Transmission timeout, in seconds.

Definition at line 88 of file transmit.hpp.

CPayload* SGCTP::CTransmit::poPayload
protected

Associated payload object.

Definition at line 91 of file transmit.hpp.

EPayloadType SGCTP::CTransmit::ePayloadType
protected

Associated payload type.

Definition at line 93 of file transmit.hpp.


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