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. More...
#include "internal.h"
#include <arpa/inet.h>
#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
#include "adapter_api.h"
#include "adapter_control_interface.h"
#include "cdi_baseline_profile_01_00_api.h"
#include "cdi_baseline_profile_02_00_api.h"
#include "cdi_logger_api.h"
#include "cdi_utility_api.h"
#include "endpoint_manager.h"
#include "fifo_api.h"
#include "internal_tx.h"
#include "internal_rx.h"
#include "statistics.h"
Variables | |
CdiGlobalContext | cdi_global_context = { 0 } |
global configuration data. | |
static CdiStaticMutexType | global_context_mutex_lock = CDI_STATIC_MUTEX_INITIALIZER |
Statically allocated mutex used to make initialization of global data thread-safe. | |
This file contains internal definitions and implementation used with the SDK that is not part of the API.
CdiReturnStatus AdapterInitializeInternal | ( | CdiAdapterData * | adapter_data_ptr, |
CdiAdapterHandle * | ret_handle_ptr ) |
Initialize an adapter.
adapter_data_ptr | Address of a structure containing all of the pertinent information required to perform the initialization. |
ret_handle_ptr | Pointer to a location in memory to place the handle to the initialized adapter. |
|
static |
Function to shutdown an adapter.
handle | Pointer to adapter being shut down. |
|
static |
Payload thread used to notify application that payload has been transmitted and acknowledged as being received by the receiver.
ptr | Pointer to thread specific data. In this case, a pointer to CdiConnectionState. |
void BytesToHexString | ( | const void * | data_ptr, |
int | data_byte_count, | ||
char * | dest_buffer_str, | ||
int | dest_buffer_size ) |
Convert an array of bytes to a hexadecimal string.
data_ptr | Pointer to array of bytes. |
data_byte_count | Number of data bytes. |
dest_buffer_str | Address where to write the hex string to. |
dest_buffer_size | Size of destination string buffer. |
int CdiGatherInternal | ( | const CdiSgList * | sgl_ptr, |
int | offset, | ||
void * | dest_data_ptr, | ||
int | byte_count ) |
This is the implementation behind the API function CdiGather(). It is located in a private implementation file since it references names we wish to hide from cdiAPI.c.
sgl_ptr | The scatter-gather list containing the data to be gathered. |
offset | Number of bytes to skip in SGL before starting the copy. |
dest_data_ptr | Where to write the gathered data in linear format. |
byte_count | The number of bytes to copy. |
CdiReturnStatus CdiGlobalInitialization | ( | const CdiCoreConfigData * | core_config_ptr | ) |
Performs initialization of the SDK that only needs to be done once and applies to programs that transmit, receive, or both transmit and receive.
core_config_ptr | Pointer to core configuration data that is used to initalize the SDK. Value is required and cannot be NULL. |
CdiLogHandle CdiLogGlobalGetInternal | ( | void | ) |
Get the handle to the global log set by the CdiGlobalInitialization() function.
CdiReturnStatus ConnectionCommonPacketMessageThreadCreate | ( | CdiConnectionHandle | handle, |
char const * | thread_name ) |
Create connection packet message thread that is common to both Tx and Rx connection types.
handle | The handle of the connection being created. |
thread_name | The internal name of the thread. |
CdiReturnStatus ConnectionCommonResourcesCreate | ( | CdiConnectionHandle | handle, |
CdiCoreStatsCallback | stats_cb_ptr, | ||
CdiUserCbParameter | stats_user_cb_param, | ||
const CdiStatsConfigData * | stats_config_ptr ) |
Create connection resources that are common to both Tx and Rx connection types. These are OS level resources that must be created prior to the creation of any child threads related to this connection.
handle | The handle of the connection being created. |
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. |
void ConnectionCommonResourcesDestroy | ( | CdiConnectionHandle | handle | ) |
Destroy connection resources that are common to both Tx and Rx connection types. These are OS level resources that should be destroyed after all child threads related to this connection have finished using resources.
handle | The handle of the connection being destroyed. |
void ConnectionDestroyInternal | ( | CdiConnectionHandle | handle | ) |
Shuts down a connection and frees all of the resources associated with it.
handle | The handle of the connection to shut down. |
|
static |
Function to shutdown connection.
handle | Pointer to connection being shutdown. |
CdiReturnStatus CoreStatsConfigureInternal | ( | CdiConnectionHandle | handle, |
const CdiStatsConfigData * | new_config_ptr, | ||
bool | force_changes ) |
Configure transfer statistics.
handle | The handle of the connection to set statistics configuration. |
new_config_ptr | Pointer to new statistics configuration data. |
force_changes | If true, settings are applied (used to set initial values), otherwise settings are only applied if any of their values change. |
void DeviceGidToString | ( | const uint8_t * | device_gid_ptr, |
int | gid_length, | ||
char * | dest_buffer_str, | ||
int | dest_buffer_size ) |
Convert a binary device GID to a string.
device_gid_ptr | Pointer to binary device GID. |
gid_length | Number of bytes in GID. |
dest_buffer_str | Address where to write the string to. |
dest_buffer_size | Size of destination string buffer. |
void DumpPayloadConfiguration | ( | const CdiCoreExtraData * | core_extra_data_ptr, |
int | extra_data_size, | ||
const uint8_t * | extra_data_array, | ||
CdiConnectionProtocolType | protocol_type ) |
Dump to log payload configuration data. NOTE: kLogPAYLOAD_CONFIG must be enabled in the logger using CdiFileLogEnable(), otherwise no messages will be generated.
core_extra_data_ptr | Pointer to core extra data. |
extra_data_size | Number of extra data bytes. |
extra_data_array | Pointer to extra data bytes. |
protocol_type | The type of connection protocol, kProtocolTypeRaw or kProtocolTypeAvm |
void EndpointDestroyInternal | ( | CdiEndpointHandle | handle | ) |
Shuts down a endpoint and frees all of the resources associated with it.
handle | The handle of the endpoint to shut down. |
bool FreeSglEntries | ( | CdiPoolHandle | pool_handle, |
CdiSglEntry * | sgl_entry_head_ptr ) |
Free a list of scatter-gather list entries from a memory pool.
pool_handle | Handle of pool which contains the SGL entries to free. |
sgl_entry_head_ptr | Pointer to the head entry of the SGL entry list to free. |
CdiReturnStatus NetworkAdapterDestroyInternal | ( | CdiAdapterHandle | handle | ) |
Destroy an adapter.
handle | Handle of adapter to destroy. |
void PayloadErrorFreeBuffer | ( | CdiPoolHandle | pool_handle, |
AppPayloadCallbackData * | app_cb_data_ptr ) |
Free error message buffer, if it was used.
pool_handle | Handle for the pool to which to return the error buffer. |
app_cb_data_ptr | Pointer to payload callback data (AppPayloadCallbackData). |
void PayloadErrorSet | ( | CdiConnectionState * | con_state_ptr, |
AppPayloadCallbackData * | app_cb_data_ptr, | ||
CdiReturnStatus | status_code, | ||
const char * | format_str, | ||
... ) |
Set error message string in the specified payload callback. The error message is made available to the application through the user-registered Tx/Rx payload callback functions.
NOTE: Should not be used directly. Use the PAYLOAD_ERROR() macro instead.
con_state_ptr | Pointer to connection state data (CdiConnectionState). |
app_cb_data_ptr | Pointer to payload callback data (AppPayloadCallbackData). |
status_code | Status code to set (CdiReturnStatus). |
format_str | Pointer to string used for formatting the message. The remaining parameters contain a variable length list of arguments used by the format string to generate the error message. |
CdiReturnStatus SdkShutdownInternal | ( | void | ) |
Shut down the SDK, freeing all of the resources that were allocated by it.
void SdkThreadJoin | ( | CdiThreadID | thread_id, |
CdiSignalType | shutdown_signal ) |
Set shutdown signal and wait for thread to exit.
thread_id | Identifier of thread to wait for it to exit. |
shutdown_signal | The shutdown signal used to shutdown the thread. |
|
static |
System monitor thread used to detect CDI-SDK thread stall periods.
ptr | Pointer to thread specific data. |
CdiGlobalContext cdi_global_context = { 0 } |
global configuration data.
The one global variable defined by the SDK containing all of its state information.