medcrypt::guardian::ChannelGuard

Name channel within a Session.

#include <ChannelGuard.h>

Public Functions

Name

~ChannelGuard() The destructor.

bool

IsReady() The ChannelGuard is ready to send data.

DataForChannel(const char * in_data, const size_t & in_data_size) Accepts data to encode and send over parent session (blocking)

AsyncDataForChannel(const char * in_data, const size_t & in_data_size) Accepts data to encode and send over parent session (non-blocking)

DataFromChannel(char out_data, size_t io_data_size) Returns decoded data received by parent session (blocking)

AsyncDataFromChannel(char out_data, size_t io_data_size)

bool

IsDataGone() Indicates if all data provided to [Async]DataForChannel has has been sent.

bool

IsDataWaiting() Indicates if there is data waiting to be received with [Async]DataFromChannel.

Public Functions Documentation

function ~ChannelGuard

~ChannelGuard()

The destructor.

Parameters:

  • none

Return: none

The destructor will not affect the internal Guardian representation of the ChannelGuard.

function IsReady

bool IsReady()

The ChannelGuard is ready to send data.

Parameters:

  • none

Returns:

  • true the channel is ready to send data

  • false the channel is not ready to send data

Return: bool

ChannelGuard will always return any available data with DataFromChannel no matter the internal state. It will block from sending new data unless it is ready.

function DataForChannel

Status DataForChannel(
    const char * in_data,
    const size_t & in_data_size
)

Accepts data to encode and send over parent session (blocking)

Parameters:

  • in_data binary data buffer to encode and send

  • in_data_size size of binary data in in_data

Returns:

  • OK in_data has been processed

  • FAIL general failure, check log

  • BADPARAM in_data is nullptr

  • OUTOFMEMORY provided buffer is too large

Return: medcrypt::guardian::Status

Blocking call to send data. When this call completes successfully the provided data has been secured based on the loaded profile and handed to the configured managed network library or unmanaged callback.

If this is a channel in an unmanaged session/service the session must have a registered DataForSocket callback.

function AsyncDataForChannel

Status AsyncDataForChannel(
    const char * in_data,
    const size_t & in_data_size
)

Accepts data to encode and send over parent session (non-blocking)

Parameters:

  • in_data binary data buffer to encode and send

  • in_data_size size of binary data in in_data

Returns:

  • OK in_data has been processed

  • FAIL general failure, check log

  • BADPARAM in_data is nullptr

  • OUTOFMEMORY provided buffer is too large

Return: medcrypt::guardian::Status

Non-blocking call to send data. When this call completes successfully the provided data has been secured based on the loaded profile and queued in the parent session to be sent.

function DataFromChannel

Status DataFromChannel(
    char * out_data,
    size_t * io_data_size
)

Returns decoded data received by parent session (blocking)

Parameters:

  • out_data binary data buffer to store output data

  • io_data_size provide size of provided out_data buffer, on a successful return is set to size of the data in out_data

Returns:

  • OK out_data is populated with application data

  • FAIL general failure

  • BADPARAM out_data is nullptr or io_data_size is nullptr or 0

  • VERIFYFAIL out_data may be populated with data but any contained data failed signature verification

  • OUTOFMEMORY provided buffer is too small

Return: medcrypt::guardian::Status

Blocking call to receive data. When this call completes successfully out_data is populated with valid data.

If this is a channel in an unmanaged session/service the session must have a registered DataFromSocket callback.

function AsyncDataFromChannel

Status AsyncDataFromChannel(
    char * out_data,
    size_t * io_data_size
)

Parameters:

  • out_data binary data buffer to store output data

  • io_data_size provide size of provided out_data buffer, on a successful return is set to size of the data in out_data

Returns:

  • OK out_data is populated with application data

  • FAIL general failure

  • BADPARAM out_data is nullptr or io_data_size is nullptr or 0

  • VERIFYFAIL out_data may be populated with data but any contained data failed signature verification

  • OUTOFMEMORY provided buffer is too small

  • AGAIN no data is currently available, try again

Return: medcrypt::guardian::Status

Returns decoded data received by parent session (non-blocking)

Non-blocking call to receive data. When this call completes successfully out_data is populated with valid data.

function IsDataGone

bool IsDataGone()

Indicates if all data provided to [Async]DataForChannel has has been sent.

Parameters:

  • none

Returns:

  • false data is waiting to be sent

  • true no data is waiting to be sent

Return: bool

If false there is data that has not been handed to the network layer or user managed transport.

function IsDataWaiting

bool IsDataWaiting()

Indicates if there is data waiting to be received with [Async]DataFromChannel.

Parameters:

  • none

Returns:

  • false no data is waiting to be received

  • true data is waiting to be received

Return: bool

If true [Async]DataFromChannel will return successfully and DataFromChannel will not block.

Last updated

Was this helpful?