CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
endpoint_manager.h File Reference

The declarations in this header file correspond to the definitions in endpoint_manager.c. More...

#include "configuration.h"
#include "cdi_core_api.h"
#include "cdi_os_api.h"
#include "private.h"
#include "protocol.h"

Go to the source code of this file.

Typedefs

typedef struct EndpointManagerGlobalState * EndpointManagerGlobalHandle
 Type used as the handle (pointer to an opaque structure) for Endpoint Manager global data.
 
typedef struct EndpointManagerStateEndpointManagerHandle
 Type used as the handle (pointer to an opaque structure) for a Endpoint Manager. Each handle represents a instance of a Endpoint Manager associated with a connection.
 
typedef struct CdiConnectionState CdiConnectionState
 Forward reference of structure to create pointers later.
 
typedef struct AdapterEndpointState AdapterEndpointState
 Forward reference of structure to create pointers later.
 

Enumerations

enum  EndpointManagerCommand { kEndpointStateIdle , kEndpointStateReset , kEndpointStateStart , kEndpointStateShutdown }
 This enumeration is used in the EndpointManagerState structure to indicate what type of endpoint command to process. More...
 

Functions

CdiReturnStatus EndpointManagerCreate (CdiConnectionHandle handle, CdiCoreStatsCallback stats_cb_ptr, CdiUserCbParameter stats_user_cb_param, const CdiStatsConfigData *stats_config_ptr, EndpointManagerHandle *ret_handle_ptr)
 
void EndpointManagerDestroy (EndpointManagerHandle handle)
 
EndpointManagerHandle EndpointManagerConnectionToEndpointManager (CdiConnectionHandle handle)
 
void EndpointManagerRemoteEndpointInfoSet (CdiEndpointHandle handle, const struct sockaddr_in *remote_address_ptr, const char *stream_name_str)
 
const char * EndpointManagerEndpointStreamNameGet (CdiEndpointHandle handle)
 
const char * EndpointManagerEndpointRemoteIpGet (CdiEndpointHandle handle)
 
int EndpointManagerEndpointRemotePortGet (CdiEndpointHandle handle)
 
const struct sockaddr_in * EndpointManagerEndpointRemoteAddressGet (CdiEndpointHandle handle)
 
CdiReturnStatus EndpointManagerTxCreateEndpoint (EndpointManagerHandle handle, bool is_multi_stream, const char *dest_ip_addr_str, int dest_port, const char *stream_name_str, CdiEndpointHandle *ret_endpoint_handle_ptr)
 
CdiReturnStatus EndpointManagerRxCreateEndpoint (EndpointManagerHandle handle, int dest_port, const struct sockaddr_in *source_address_ptr, const char *stream_name_str, CdiEndpointHandle *ret_endpoint_handle_ptr)
 
CdiReturnStatus EndpointManagerProtocolVersionSet (CdiEndpointHandle handle, const CdiProtocolVersionNumber *remote_version_ptr)
 Set the protocol version for the specified endpoint. The protocol version actually used is negotiated using the specified remote version and the current version of the CDI-SDK.
 
bool EndpointManagerIsEndpoint (EndpointManagerHandle handle, CdiEndpointHandle endpoint_handle)
 
CdiEndpointHandle EndpointManagerGetFirstEndpoint (EndpointManagerHandle handle)
 
CdiEndpointHandle EndpointManagerGetNextEndpoint (CdiEndpointHandle handle)
 
int EndpointManagerEndpointGetCount (EndpointManagerHandle handle)
 
AdapterEndpointHandle EndpointManagerEndpointToAdapterEndpoint (CdiEndpointHandle handle)
 
CdiSignalType EndpointManagerThreadRegister (EndpointManagerHandle handle, const char *thread_name_str)
 
void EndpointManagerThreadWait (EndpointManagerHandle handle)
 
bool EndpointManagerPoll (CdiEndpointHandle *handle_ptr)
 
bool EndpointManagerPollThreadExit (EndpointManagerHandle handle)
 
CdiSignalType EndpointManagerGetNotificationSignal (EndpointManagerHandle handle)
 
void EndpointManagerQueueEndpointReset (CdiEndpointHandle handle)
 
void EndpointManagerQueueEndpointStart (CdiEndpointHandle handle)
 
void EndpointManagerEndpointDestroy (CdiEndpointHandle handle)
 
void EndpointManagerShutdownConnection (EndpointManagerHandle handle)
 
bool EndpointManagerIsConnectionShuttingDown (EndpointManagerHandle handle)
 
void EndpointManagerConnectionStateChange (CdiEndpointHandle handle, CdiConnectionStatus status_code, const char *error_msg_str)
 

Detailed Description

The declarations in this header file correspond to the definitions in endpoint_manager.c.

Enumeration Type Documentation

◆ EndpointManagerCommand

This enumeration is used in the EndpointManagerState structure to indicate what type of endpoint command to process.

Enumerator
kEndpointStateIdle 

Endpoint Manager is idle. Nothing special to do.

kEndpointStateReset 

Reset the endpoint.

kEndpointStateStart 

Start the endpoint.

kEndpointStateShutdown 

Shutdown the endpoint.

Function Documentation

◆ EndpointManagerConnectionStateChange()

void EndpointManagerConnectionStateChange ( CdiEndpointHandle handle,
CdiConnectionStatus status_code,
const char * error_msg_str )

Notify the application of a connection state change using the user registered connection callback function, if the state has actually changed.

NOTE: This function is called from ProbeControlThread().

Parameters
handleHandle of endpoint.
status_codeConnection status code (connected or disconnected).
error_msg_strPointer to optional error message string to provide to the user registered callback function.

◆ EndpointManagerConnectionToEndpointManager()

EndpointManagerHandle EndpointManagerConnectionToEndpointManager ( CdiConnectionHandle handle)

Return the Endpoint Manager associated with the specified connection.

Parameters
handleHandle of the connection.
Returns
Endpoint Manager handle.

◆ EndpointManagerCreate()

CdiReturnStatus EndpointManagerCreate ( CdiConnectionHandle handle,
CdiCoreStatsCallback stats_cb_ptr,
CdiUserCbParameter stats_user_cb_param,
const CdiStatsConfigData * stats_config_ptr,
EndpointManagerHandle * ret_handle_ptr )

Create an instance of the Endpoint Manager for the specified connection.

Parameters
handleHandle of connection.
stats_cb_ptrAddress of stats callback function.
stats_user_cb_paramUser-defined parameter in structure passed to stats_cb_ptr.
stats_config_ptrPointer to statistics configuration data.
ret_handle_ptrAddress where to write returned Endpoint Manager handle.
Returns
kCdiStatusOk if the operation was successful or a value that indicates the nature of the failure.

◆ EndpointManagerDestroy()

void EndpointManagerDestroy ( EndpointManagerHandle handle)

Destroys the resources used by the instance of the specified Endpoint Manager.

Parameters
handleHandle of Endpoint Manager.

◆ EndpointManagerEndpointDestroy()

void EndpointManagerEndpointDestroy ( CdiEndpointHandle handle)

Destroy the specified endpoint. Thread will block until the endpoint is destroyed by EndpointManagerPoll().

Parameters
handleHandle of CDI endpoint.

◆ EndpointManagerEndpointGetCount()

int EndpointManagerEndpointGetCount ( EndpointManagerHandle handle)

Return the number of endpoints associated with the specified Endpoint Manager.

Parameters
handleHandle of Endpoint Manager.
Returns
Number of endpoints.

◆ EndpointManagerEndpointRemoteAddressGet()

const struct sockaddr_in * EndpointManagerEndpointRemoteAddressGet ( CdiEndpointHandle handle)

Get the remote address structure (sockaddr_in) related to the provided endpoint.

Parameters
handleHandle of endpoint.
Returns
Pointer to remote address structure.

◆ EndpointManagerEndpointRemoteIpGet()

const char * EndpointManagerEndpointRemoteIpGet ( CdiEndpointHandle handle)

Get the remote IP address related to the provided endpoint.

Parameters
handleHandle of endpoint.
Returns
Pointer to IP address string.

◆ EndpointManagerEndpointRemotePortGet()

int EndpointManagerEndpointRemotePortGet ( CdiEndpointHandle handle)

Get the remote port related to the provided endpoint.

Parameters
handleHandle of endpoint.
Returns
Remote port as integer value.

◆ EndpointManagerEndpointStreamNameGet()

const char * EndpointManagerEndpointStreamNameGet ( CdiEndpointHandle handle)

Get the stream name related to the provided endpoint. If the stream name empty, then NULL is returned.

Parameters
handleHandle of endpoint.
Returns
Pointer to stream name or NULL if empty.

◆ EndpointManagerEndpointToAdapterEndpoint()

AdapterEndpointHandle EndpointManagerEndpointToAdapterEndpoint ( CdiEndpointHandle handle)

Return the adapter endpoint related to the specified CDI endpoint.

Parameters
handleHandle of CDI endpoint.
Returns
Handle of adapter endpoint.

◆ EndpointManagerGetFirstEndpoint()

CdiEndpointHandle EndpointManagerGetFirstEndpoint ( EndpointManagerHandle handle)

Returns the first endpoint in the list of endpoints associated with the specified Endpoint Manager.

Parameters
handleHandle of CDI Endpoint Manager.
Returns
Handle of first endpoint in the list. Returns NULL if the list is empty.

◆ EndpointManagerGetNextEndpoint()

CdiEndpointHandle EndpointManagerGetNextEndpoint ( CdiEndpointHandle handle)

Returns the next endpoint in the list of endpoints associated with the specified CDI endpoint.

Parameters
handleHandle of CDI endpoint.
Returns
Handle of next endpoint in the list. Returns NULL if no more endpoints.

◆ EndpointManagerGetNotificationSignal()

CdiSignalType EndpointManagerGetNotificationSignal ( EndpointManagerHandle handle)

Return the signal that is used to notify registered threads that they must call EndpointManagerThreadWait() so a queued state change can be processed.

Parameters
handleHandle of endpoint.
Returns
Returns the notification signal.

◆ EndpointManagerIsConnectionShuttingDown()

bool EndpointManagerIsConnectionShuttingDown ( EndpointManagerHandle handle)

Return true if the connection is in the process of being shutdown.

Parameters
handleHandle of Endpoint Manager.
Returns
Returns true if the connection is in the process of being shutdown, otherwise false is returned.

◆ EndpointManagerIsEndpoint()

bool EndpointManagerIsEndpoint ( EndpointManagerHandle handle,
CdiEndpointHandle endpoint_handle )

Returns true if the specified endpoint exists within the specified Endpoint Manager.

Parameters
handleHandle of CDI Endpoint Manager.
endpoint_handleHandle of CDI endpoint.
Returns
Handle of first endpoint in the list. Returns NULL if the list is empty.

◆ EndpointManagerPoll()

bool EndpointManagerPoll ( CdiEndpointHandle * handle_ptr)

Perform Endpoint Manager polling and determine if adapter level poll APIs should be used or not.

Parameters
handle_ptrOn entry, Address to handle of endpoint. On exit, handle of next endpoint is written to to address.
Returns
true if poll thread should invoke adapter poll APIs, false if it should not.

◆ EndpointManagerPollThreadExit()

bool EndpointManagerPollThreadExit ( EndpointManagerHandle handle)

Called by poll thread when it is about to exit. Must continue to call this as part of the polling cycle until true is returned.

Parameters
handleHandle of Endpoint Manager.
Returns
true if ok to exit.

◆ EndpointManagerProtocolVersionSet()

CdiReturnStatus EndpointManagerProtocolVersionSet ( CdiEndpointHandle handle,
const CdiProtocolVersionNumber * remote_version_ptr )

Set the protocol version for the specified endpoint. The protocol version actually used is negotiated using the specified remote version and the current version of the CDI-SDK.

Parameters
handleHandle of CDI endpoint.
remote_version_ptrPointer to remote protocol version data.
Returns
kCdiStatusOk if the operation was successful or a value that indicates the nature of the failure.

◆ EndpointManagerQueueEndpointReset()

void EndpointManagerQueueEndpointReset ( CdiEndpointHandle handle)

Queue a request to reset the endpoint associated with the specified Endpoint Manager.

Parameters
handleHandle of endpoint.

◆ EndpointManagerQueueEndpointStart()

void EndpointManagerQueueEndpointStart ( CdiEndpointHandle handle)

Queue a request to start the endpoint associated with the specified Endpoint Manager.

Parameters
handleHandle of endpoint.

◆ EndpointManagerRemoteEndpointInfoSet()

void EndpointManagerRemoteEndpointInfoSet ( CdiEndpointHandle handle,
const struct sockaddr_in * remote_address_ptr,
const char * stream_name_str )

Copy the specified information about the remote endpoint to the internal state data of the provided endpoint.

Parameters
handleHandle of endpoint.
remote_address_ptrPointer to remote address (sockaddr_in)
stream_name_strPointer to endpoint stream name. If the stream name is NULL, then a '\0' will be stored.

◆ EndpointManagerRxCreateEndpoint()

CdiReturnStatus EndpointManagerRxCreateEndpoint ( EndpointManagerHandle handle,
int dest_port,
const struct sockaddr_in * source_address_ptr,
const char * stream_name_str,
CdiEndpointHandle * ret_endpoint_handle_ptr )

Create resources used for a new Rx endpoint and add it to the list of endpoints managed by the specified Endpoint Manager.

Parameters
handleHandle of Endpoint Manager.
dest_portDestination port.
source_address_ptrPointer to source address (from the sender).
stream_name_strPointer to stream name string.
ret_endpoint_handle_ptrAddress where to write the handle of the new endpoint.
Returns
kCdiStatusOk if the operation was successful or a value that indicates the nature of the failure.

◆ EndpointManagerShutdownConnection()

void EndpointManagerShutdownConnection ( EndpointManagerHandle handle)

Shutdown the connection associated with the specified Endpoint Manager. This will block until threads registered using EndpointManagerThreadRegister() have called EndpointManagerThreadWait() and the connection shutdown has completed.

Parameters
handleHandle of Endpoint Manager.

◆ EndpointManagerThreadRegister()

CdiSignalType EndpointManagerThreadRegister ( EndpointManagerHandle handle,
const char * thread_name_str )

Register a thread with the specified Endpoint Manager. This should be called once, at the start of each thread that uses resources associated with the connection. The Endpoint Manager keeps track of how many times this function is used (how many threads). When the Endpoint Manager receives a request via one of the Queue API functions, it will wait until the number of threads have called EndpointManagerThreadWait() and are blocked. Then, it can carry out the request and unblock the waiting threads after the request has completed.

Parameters
handleHandle of Endpoint Manager.
thread_name_strName of thread.
Returns
Returns the notification signal. Same value returned from EndpointManagerGetNotificationSignal().

◆ EndpointManagerThreadWait()

void EndpointManagerThreadWait ( EndpointManagerHandle handle)

For all threads that have used EndpointManagerThreadRegister(), each must call this function whenever the signal obtained using EndpointManagerGetNotificationSignal() is set (it is set whenever one of the Queue API functions are used). This will block the thread until all registered threads have called this function. The threads are blocked until the pending state change request has completed.

Parameters
handleHandle of Endpoint Manager.

◆ EndpointManagerTxCreateEndpoint()

CdiReturnStatus EndpointManagerTxCreateEndpoint ( EndpointManagerHandle handle,
bool is_multi_stream,
const char * dest_ip_addr_str,
int dest_port,
const char * stream_name_str,
CdiEndpointHandle * ret_endpoint_handle_ptr )

Create resources used for a new Tx endpoint and add it to the list of endpoints managed by the specified Endpoint Manager.

Parameters
handleHandle of Endpoint Manager.
is_multi_streamTrue if the Tx endpoint is going to be used by multiple Tx streams.
dest_ip_addr_strPointer to destination IP address string.
dest_portDestination port.
stream_name_strPointer to stream name string.
ret_endpoint_handle_ptrAddress where to write the handle of the new endpoint.
Returns
kCdiStatusOk if the operation was successful or a value that indicates the nature of the failure.