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

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

#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include "cdi_core_api.h"
#include "cdi_pool_api.h"
#include "payload.h"

Go to the source code of this file.

Data Structures

struct  CdiProtocolVersionNumber
 CDI header used to identify protocol version number information. More...
 
struct  CdiDecodedPacketDataOffsetInfo
 CDI decoded header for payload packets that contains a data offset value (payload type is kPayloadTypeDataOffset). Decoded headers are protocol independent. More...
 
struct  CdiDecodedPacketNum0Info
 CDI decoded header for payload packet #0. This packet never uses payload_data_offset, since it is always zero. Decoded headers are protocol independent. More...
 
struct  CdiDecodedPacketHeader
 Union of decoded CDI packet headers. Use to reserve memory that can be used to hold any type of decoded CDI packet header. Decoded headers are protocol independent. More...
 
struct  CdiRawPacketHeader
 Union of raw CDI packet headers. Use to reserve memory that can be used to hold raw CDI packet headers that do not contain extra data. Each protocol version uses a specific data format and is kept internal. Use PayloadHeaderDecode() to decoded the raw packet header into CdiDecodedPacketHeader, which is protocol independent. Use PayloadHeaderInit() to convert a CdiDecodedPacketHeader into this format. More...
 
struct  CdiRawExtraPacketHeader
 Union of raw CDI extra packet headers. Use to reserve memory that can be used to hold raw CDI packet headers that contain extra data (ie. AVM configuration data). Each protocol version uses a specific data format and is kept internal. Use PayloadHeaderDecode() to decoded the raw packet header into CdiDecodedPacketHeader, which is protocol independent. Use PayloadHeaderInit() to convert a CdiDecodedPacketHeader into this format. More...
 
struct  CdiPacketRxReorderInfo
 Structure used to hold packet data used by Rx packet reordering. More...
 
struct  CdiDecodedProbeCommand
 Probe command packet that is being transmitted. More...
 
struct  CdiDecodedProbeAck
 Control ACK packet that is a response for a transmitted command. More...
 
struct  CdiDecodedProbeHeader
 Union of decoded probe headers. Use to reserve memory that can be used to hold any type of decoded CDI probe header. Decoded headers are protocol independent. More...
 
struct  EfaProbePacket
 Packet format used by probe when sending probe packets over the EFA interface. More...
 
struct  CdiRawProbeHeader
 Union of raw probe headers. Use to reserve memory that can be used to hold any type of raw probe header. Each protocol version uses a specific data format and is kept internal. Use ProtocolPayloadHeaderDecode() to decoded the raw packet header into CdiDecodedProbeHeader, which is protocol independent. Use ProtocolProbeHeaderEncode() to convert a CdiDecodedProbeHeader into this format. More...
 
struct  CdiProtocol
 Structure used to hold negotiated protocol version information. More...
 
struct  CdiProtocolVTableApi
 Type used to hold V-table of APIs that must be implemented by payload protocol versions. More...
 

Macros

#define CDI_RAW_PACKET_HEADER_SIZE_V1   (34)
 Define the size of the PacketHeaderUnion structure used in protocol V1. This is done so the size of the structure is known at compile time without having to expose the contents of it in a header file.
 
#define CDI_RAW_PACKET_HEADER_SIZE_V2   (47)
 Define the size of the PacketHeaderUnion structure used in protocol V2. This is done so the size of the structure is known at compile time without having to expose the contents of it in a header file.
 
#define CDI_RAW_PROBE_HEADER_SIZE_V1   (257)
 Define the size of the ProbeHeaderUnion structure used in protocol V1. This is done so the size of the structure is known at compile time without having to expose the contents of it in a header file.
 
#define CDI_RAW_PROBE_HEADER_SIZE_V2   (253)
 Define the size of the ProbeHeaderUnion structure used in protocol V2. This is done so the size of the structure is known at compile time without having to expose the contents of it in a header file.
 

Typedefs

typedef struct CdiProtocolVersionNumber CdiProtocolVersionNumber
 Forward reference of structure to create pointers later.
 
typedef struct CdiRawProbeHeader CdiRawProbeHeader
 Forward reference of structure to create pointers later.
 
typedef struct CdiConnectionState CdiConnectionState
 Forward reference of structure to create pointers later.
 
typedef struct TxPayloadState TxPayloadState
 Forward reference of structure to create pointers later.
 
typedef struct CdiProtocolCdiProtocolHandle
 Forward reference of structure to create pointers later.
 
typedef void(* VtblPayloadHeaderDecode) (const void *encoded_data_ptr, int encoded_data_size, CdiDecodedPacketHeader *dest_header_ptr)
 Prototype of function used for protocol version VTable API.
 
typedef int(* VtblPayloadHeaderInit) (void *header_ptr, int header_buffer_size, const TxPayloadState *payload_state_ptr)
 Prototype of function used for protocol version VTable API.
 
typedef void(* VtblPayloadPacketRxReorderInfo) (const CdiRawPacketHeader *header_ptr, CdiPacketRxReorderInfo *ret_info_ptr)
 Prototype of function used for protocol version VTable API.
 
typedef CdiReturnStatus(* VtblProbeHeaderDecode) (const void *encoded_data_ptr, int encoded_data_size, CdiDecodedProbeHeader *dest_header_ptr)
 Prototype of function used for protocol version VTable API.
 
typedef int(* VtblProbeHeaderEncode) (const CdiDecodedProbeHeader *state_ptr, CdiRawProbeHeader *dest_header_ptr)
 Prototype of function used for protocol version VTable API.
 

Enumerations

enum  ProbeCommand {
  kProbeCommandReset = 1 , kProbeCommandPing , kProbeCommandConnected , kProbeCommandAck ,
  kProbeCommandProtocolVersion
}
 This enumeration is used in the ProbePacketHeader structure to indicate a probe command. NOTE: Any changes made here MUST also be made to "probe_command_key_array". More...
 

Functions

void ProtocolVersionSet (const CdiProtocolVersionNumber *remote_version_ptr, CdiProtocolHandle *ret_handle_ptr)
 Create a protocol version using the specified remote protocol version. The version is compared against the versions in the current SDK and the most recent compatible version is returned.
 
void ProtocolVersionSetLegacy (CdiProtocolHandle *ret_handle_ptr)
 Create a protocol version using the legacy version 1, which is compatible will all SDK versions.
 
void ProtocolVersionDestroy (CdiProtocolHandle protocol_handle)
 Freeup resources used by a protocol.
 
void ProtocolPayloadHeaderDecode (CdiProtocolHandle protocol_handle, void *encoded_data_ptr, int encoded_data_size, CdiDecodedPacketHeader *dest_header_ptr)
 Decode an encoded raw header into a header structure that is protocol version independent.
 
int ProtocolPayloadHeaderInit (CdiProtocolHandle protocol_handle, void *header_ptr, int header_buffer_size, const TxPayloadState *payload_state_ptr)
 Initialize raw packet encoded header data using the specified protocol and packet state data.
 
void ProtocolPayloadPacketRxReorderInfo (CdiProtocolHandle protocol_handle, const CdiRawPacketHeader *header_ptr, CdiPacketRxReorderInfo *ret_info_ptr)
 Get Rx reorder information for the specified packet.
 
CdiReturnStatus ProtocolProbeHeaderDecode (const void *encoded_data_ptr, int encoded_data_size, CdiDecodedProbeHeader *dest_header_ptr)
 Decode an encoded raw probe header into a header structure that is protocol version independent.
 
int ProtocolProbeHeaderEncode (CdiProtocolHandle protocol_handle, CdiDecodedProbeHeader *src_header_ptr, CdiRawProbeHeader *dest_header_ptr)
 Encode raw payload header data using the specified protocol and probe state data.
 

Detailed Description

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

Typedef Documentation

◆ TxPayloadState

typedef struct TxPayloadState TxPayloadState

Forward reference of structure to create pointers later.

Forward reference of structure to allow pointer creation.

Enumeration Type Documentation

◆ ProbeCommand

This enumeration is used in the ProbePacketHeader structure to indicate a probe command. NOTE: Any changes made here MUST also be made to "probe_command_key_array".

Enumerator
kProbeCommandReset 

Request to reset the connection. Start with 1 so no commands have the value 0.

kProbeCommandPing 

Request to ping the connection.

kProbeCommandConnected 

Notification that connection has been established (probe has completed).

kProbeCommandAck 

Packet is an ACK response to a previously sent command.

kProbeCommandProtocolVersion 

Packet contains protocol version of sender.

Function Documentation

◆ ProtocolPayloadHeaderDecode()

void ProtocolPayloadHeaderDecode ( CdiProtocolHandle protocol_handle,
void * encoded_data_ptr,
int encoded_data_size,
CdiDecodedPacketHeader * dest_header_ptr )

Decode an encoded raw header into a header structure that is protocol version independent.

Parameters
protocol_handleHandle of protocol version.
encoded_data_ptrPointer to encoder header data.
encoded_data_sizeSize of encoded header data in bytes.
dest_header_ptrAddress where to write decoded header data.

◆ ProtocolPayloadHeaderInit()

int ProtocolPayloadHeaderInit ( CdiProtocolHandle protocol_handle,
void * header_ptr,
int header_buffer_size,
const TxPayloadState * payload_state_ptr )

Initialize raw packet encoded header data using the specified protocol and packet state data.

Parameters
protocol_handleHandle of protocol version.
header_ptrAddress where to write raw packet header.
header_buffer_sizeSize of header buffer in bytes.
payload_state_ptrPointer to TX payload state data.
Returns
Size of payload header in bytes.

◆ ProtocolPayloadPacketRxReorderInfo()

void ProtocolPayloadPacketRxReorderInfo ( CdiProtocolHandle protocol_handle,
const CdiRawPacketHeader * header_ptr,
CdiPacketRxReorderInfo * ret_info_ptr )

Get Rx reorder information for the specified packet.

Parameters
protocol_handleHandle of protocol version.
header_ptrPointer to raw encoded packet header to get Rx reorder information from.
ret_info_ptrAddress where to write returned Rx reorder info.

◆ ProtocolProbeHeaderDecode()

CdiReturnStatus ProtocolProbeHeaderDecode ( const void * encoded_data_ptr,
int encoded_data_size,
CdiDecodedProbeHeader * dest_header_ptr )

Decode an encoded raw probe header into a header structure that is protocol version independent.

Parameters
encoded_data_ptrPointer to encoder header data. NOTE: The caller must not free this data until done with the decoded version, since some of the decoded values contain pointers to it.
encoded_data_sizeSize of encoded header data in bytes.
dest_header_ptrAddress where to write decoded header data.
Returns
A value from the CdiReturnStatus enumeration.

◆ ProtocolProbeHeaderEncode()

int ProtocolProbeHeaderEncode ( CdiProtocolHandle protocol_handle,
CdiDecodedProbeHeader * src_header_ptr,
CdiRawProbeHeader * dest_header_ptr )

Encode raw payload header data using the specified protocol and probe state data.

Parameters
protocol_handleHandle of protocol version.
src_header_ptrPointer to source header data.
dest_header_ptrAddress where to write raw probe header.
Returns
Size of protocol header in bytes.

◆ ProtocolVersionDestroy()

void ProtocolVersionDestroy ( CdiProtocolHandle protocol_handle)

Freeup resources used by a protocol.

Parameters
protocol_handleHandle of protocol version.

◆ ProtocolVersionSet()

void ProtocolVersionSet ( const CdiProtocolVersionNumber * remote_version_ptr,
CdiProtocolHandle * ret_handle_ptr )

Create a protocol version using the specified remote protocol version. The version is compared against the versions in the current SDK and the most recent compatible version is returned.

Parameters
remote_version_ptrPointer to remote's protocol version.
ret_handle_ptrAddress where to write returned protocol handle.

◆ ProtocolVersionSetLegacy()

void ProtocolVersionSetLegacy ( CdiProtocolHandle * ret_handle_ptr)

Create a protocol version using the legacy version 1, which is compatible will all SDK versions.

Parameters
ret_handle_ptrAddress where to write returned protocol handle.