CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
|
This file contains internal definitions and implementation used with the SDK that is not part of the API. The Endpoint Manager is used to synchronize connection reset and shutdown events across all threads that are related to the connection. More...
#include "adapter_efa.h"
#include "endpoint_manager.h"
#include <arpa/inet.h>
#include "adapter_api.h"
#include "cdi_logger_api.h"
#include "cdi_os_api.h"
#include "internal.h"
#include "internal_rx.h"
#include "internal_tx.h"
#include "internal_utility.h"
#include "rx_reorder_payloads.h"
#include "statistics.h"
#include "utilities_api.h"
Data Structures | |
struct | InternalEndpointState |
This defines a structure that contains all the state information for endpoint state changes. More... | |
struct | EndpointManagerState |
This defines a structure that contains all the state information for endpoint state changes. More... | |
This file contains internal definitions and implementation used with the SDK that is not part of the API. The Endpoint Manager is used to synchronize connection reset and shutdown events across all threads that are related to the connection.
|
static |
Convert an CDI endpoint handle into and internal endpoint state structure (InternalEndpointState).
handle | CDI Endpoint handle |
|
static |
Create resources common to both Tx and Rx endpoints.
mgr_ptr | Pointer to Endpoint Manager. |
ret_internal_endpoint_ptr | Address where to write returned endpoint handle. |
|
static |
Decrement the thread wait counter. If the count reaches zero, the state of signals will be changed so additional state change commands can be processed by EndpointManagerThread().
mgr_ptr | Pointer to Endpoint Manager state data. |
|
static |
Destroy an endpoint, closing its adapter endpoint and freeing resources used by it.
handle | Handle of endpoint to destroy. |
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().
handle | Handle of endpoint. |
status_code | Connection status code (connected or disconnected). |
error_msg_str | Pointer to optional error message string to provide to the user registered callback function. |
EndpointManagerHandle EndpointManagerConnectionToEndpointManager | ( | CdiConnectionHandle | handle | ) |
Return the Endpoint Manager associated with the specified connection.
handle | Handle of the connection. |
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.
handle | Handle of connection. |
stats_cb_ptr | Address of stats callback function. |
stats_user_cb_param | User-defined parameter in structure passed to stats_cb_ptr. |
stats_config_ptr | Pointer to statistics configuration data. |
ret_handle_ptr | Address where to write returned Endpoint Manager handle. |
void EndpointManagerDestroy | ( | EndpointManagerHandle | handle | ) |
Destroys the resources used by the instance of the specified Endpoint Manager.
handle | Handle of Endpoint Manager. |
void EndpointManagerEndpointDestroy | ( | CdiEndpointHandle | handle | ) |
Destroy the specified endpoint. Thread will block until the endpoint is destroyed by EndpointManagerPoll().
handle | Handle of CDI endpoint. |
int EndpointManagerEndpointGetCount | ( | EndpointManagerHandle | handle | ) |
Return the number of endpoints associated with the specified Endpoint Manager.
handle | Handle of Endpoint Manager. |
const struct sockaddr_in * EndpointManagerEndpointRemoteAddressGet | ( | CdiEndpointHandle | handle | ) |
Get the remote address structure (sockaddr_in) related to the provided endpoint.
handle | Handle of endpoint. |
const char * EndpointManagerEndpointRemoteIpGet | ( | CdiEndpointHandle | handle | ) |
Get the remote IP address related to the provided endpoint.
handle | Handle of endpoint. |
int EndpointManagerEndpointRemotePortGet | ( | CdiEndpointHandle | handle | ) |
Get the remote port related to the provided endpoint.
handle | Handle of endpoint. |
const char * EndpointManagerEndpointStreamNameGet | ( | CdiEndpointHandle | handle | ) |
Get the stream name related to the provided endpoint. If the stream name empty, then NULL is returned.
handle | Handle of endpoint. |
AdapterEndpointHandle EndpointManagerEndpointToAdapterEndpoint | ( | CdiEndpointHandle | handle | ) |
Return the adapter endpoint related to the specified CDI endpoint.
handle | Handle of CDI endpoint. |
CdiEndpointHandle EndpointManagerGetFirstEndpoint | ( | EndpointManagerHandle | handle | ) |
Returns the first endpoint in the list of endpoints associated with the specified Endpoint Manager.
handle | Handle of CDI Endpoint Manager. |
CdiEndpointHandle EndpointManagerGetNextEndpoint | ( | CdiEndpointHandle | handle | ) |
Returns the next endpoint in the list of endpoints associated with the specified CDI endpoint.
handle | Handle of CDI endpoint. |
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.
handle | Handle of endpoint. |
bool EndpointManagerIsConnectionShuttingDown | ( | EndpointManagerHandle | handle | ) |
Return true if the connection is in the process of being shutdown.
handle | Handle of Endpoint Manager. |
bool EndpointManagerIsEndpoint | ( | EndpointManagerHandle | handle, |
CdiEndpointHandle | endpoint_handle ) |
Returns true if the specified endpoint exists within the specified Endpoint Manager.
handle | Handle of CDI Endpoint Manager. |
endpoint_handle | Handle of CDI endpoint. |
bool EndpointManagerPoll | ( | CdiEndpointHandle * | handle_ptr | ) |
Perform Endpoint Manager polling and determine if adapter level poll APIs should be used or not.
handle_ptr | On entry, Address to handle of endpoint. On exit, handle of next endpoint is written to to address. |
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.
handle | Handle of Endpoint Manager. |
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.
handle | Handle of CDI endpoint. |
remote_version_ptr | Pointer to remote protocol version data. |
void EndpointManagerQueueEndpointReset | ( | CdiEndpointHandle | handle | ) |
Queue a request to reset the endpoint associated with the specified Endpoint Manager.
handle | Handle of endpoint. |
void EndpointManagerQueueEndpointStart | ( | CdiEndpointHandle | handle | ) |
Queue a request to start the endpoint associated with the specified Endpoint Manager.
handle | Handle of endpoint. |
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.
handle | Handle of endpoint. |
remote_address_ptr | Pointer to remote address (sockaddr_in) |
stream_name_str | Pointer to endpoint stream name. If the stream name is NULL, then a '\0' will be stored. |
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.
handle | Handle of Endpoint Manager. |
dest_port | Destination port. |
source_address_ptr | Pointer to source address (from the sender). |
stream_name_str | Pointer to stream name string. |
ret_endpoint_handle_ptr | Address where to write the handle of the new endpoint. |
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.
handle | Handle of Endpoint Manager. |
|
static |
Thread used to manage endpoint reset, start and shutdown events.
ptr | Pointer to Endpoint Manager state data. |
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.
handle | Handle of Endpoint Manager. |
thread_name_str | Name of thread. |
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.
handle | Handle of Endpoint Manager. |
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.
handle | Handle of Endpoint Manager. |
is_multi_stream | True if the Tx endpoint is going to be used by multiple Tx streams. |
dest_ip_addr_str | Pointer to destination IP address string. |
dest_port | Destination port. |
stream_name_str | Pointer to stream name string. |
ret_endpoint_handle_ptr | Address where to write the handle of the new endpoint. |
|
static |
Flush resources associated with the specified connection.
endpoint_ptr | Pointer to endpoint to free resources. |
|
static |
Increment the thread wait counter. If the count matches the number of threads registered to wait, a signal will be set to wakeup EndpointManagerThread() so it can process pending endpoint state changes.
mgr_ptr | Pointer to Endpoint Manager state data. |
|
static |
Add a new command to the endpoint queue to be processed by EndpointManagerThread().
internal_endpoint_ptr | Pointer to internal endpoint structure to queue new command. |
command | New command to add to the queue. |