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

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

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

Go to the source code of this file.

Data Structures

struct  CdiPayloadPacketState
 Structure used to hold state data for a single payload. More...
 

Typedefs

typedef struct CdiPacketizerStateCdiPacketizerStateHandle
 An opaque type for the packetizer to keep track of its progress in case it must be suspended for lack of resources.
 
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 CdiRawPacketHeader CdiRawPacketHeader
 Forward reference of structure to create pointers later.
 
typedef struct CdiRawExtraPacketHeader CdiRawExtraPacketHeader
 Forward reference of structure to create pointers later.
 
typedef struct CdiProtocol CdiProtocol
 Forward reference of structure to create pointers later.
 
typedef struct CdiProtocolCdiProtocolHandle
 Forward reference of structure to create pointers later.
 

Enumerations

enum  CdiPayloadType { kPayloadTypeData = 0 , kPayloadTypeDataOffset , kPayloadTypeProbe , kPayloadTypeKeepAlive }
 Enumeration used to identify packet type. More...
 

Functions

bool PayloadInit (CdiConnectionState *con_state_ptr, const CdiSgList *source_sgl_ptr, TxPayloadState *payload_state_ptr)
 
CdiPacketizerStateHandle PayloadPacketizerCreate (void)
 
void PayloadPacketizerDestroy (CdiPacketizerStateHandle packetizer_state_handle)
 
void PayloadPacketizerStateInit (CdiPacketizerStateHandle packetizer_state_handle)
 
bool PayloadPacketizerPacketGet (CdiProtocolHandle protocol_handle, CdiPacketizerStateHandle packetizer_state_handle, char *header_ptr, int header_buffer_size, CdiPoolHandle packet_sgl_entry_pool_handle, TxPayloadState *payload_state_ptr, CdiSgList *packet_sgl_ptr, bool *ret_is_last_packet_ptr)
 

Detailed Description

The declarations in this header file correspond to the definitions in payload.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

◆ CdiPayloadType

Enumeration used to identify packet type.

Enumerator
kPayloadTypeData 

Payload contains application payload data.

kPayloadTypeDataOffset 

Payload contains application payload data with data offset field in each packet.

kPayloadTypeProbe 

Payload contains probe data.

kPayloadTypeKeepAlive 

Payload is being used for keeping the connection alive (don't use app payload callbacks).

Function Documentation

◆ PayloadInit()

bool PayloadInit ( CdiConnectionState * con_state_ptr,
const CdiSgList * source_sgl_ptr,
TxPayloadState * payload_state_ptr )

Initialize an CdiPayloadPacketState structure before using CdiPayloadPacketizerPacketGet() to split the payload into packets. NOTE: If an error occurs, caller is responsible for freeing the pool buffers that it allocates.

Parameters
con_state_ptrPointer to connection state data.
source_sgl_ptrPointer to Tx Payload source SGL list.
payload_state_ptrPointer to payload state data.
Returns
true if successful, otherwise an error occurred.

◆ PayloadPacketizerCreate()

CdiPacketizerStateHandle PayloadPacketizerCreate ( void )

Creates a packetizer state object. This must be destroyed with CdiPayloadPacketizerDestroy() when the connection is closed.

Returns
Handle for the created packetizer state or NULL if the creation failed.

◆ PayloadPacketizerDestroy()

void PayloadPacketizerDestroy ( CdiPacketizerStateHandle packetizer_state_handle)

Frees the memory previously allocated for a packetizer state object through CdiPayloadPacketizerCreate().

Parameters
packetizer_state_handleThe handle of the packetizer state to be destroyed.

◆ PayloadPacketizerPacketGet()

bool PayloadPacketizerPacketGet ( CdiProtocolHandle protocol_handle,
CdiPacketizerStateHandle packetizer_state_handle,
char * header_ptr,
int header_buffer_size,
CdiPoolHandle packet_sgl_entry_pool_handle,
TxPayloadState * payload_state_ptr,
CdiSgList * packet_sgl_ptr,
bool * ret_is_last_packet_ptr )

Get the next packet for a payload. Must use CdiPayloadPacketizerStateInit() for a new payload before using this function. If false is returned, one of the pools from which required resources are taken is dry so this function should be called again until it returns true.

NOTE: All the pools used in this function are not thread-safe, so must ensure that only one thread is accessing them at a time.

Parameters
protocol_handleHandle of protocol to use.
packetizer_state_handleHandle of the packetizer state for this connection.
header_ptrPointer to the header data structure to be filled in for the new packet.
header_buffer_sizeSize of header data buffer in bytes.
packet_sgl_entry_pool_handleCDI packet SGL list entry pool.
payload_state_ptrPointer to payload state data.
packet_sgl_ptrPointer to returned packet SGL list
ret_is_last_packet_ptrPointer to returned last packet state. True if last packet, otherwise false.
Returns
true if packet returned, otherwise a pool was empty so false is returned.

◆ PayloadPacketizerStateInit()

void PayloadPacketizerStateInit ( CdiPacketizerStateHandle packetizer_state_handle)

Initializes a packetizer state object. This function should be called before calling CdiPayloadPacketizerPacketGet() the first time for a given payload.

Parameters
packetizer_state_handleHandle of packetizer object.