hsw-nbt 1.2.0
OPTIGA Authenticate NBT Host Library for C
Data Structures | Macros | Typedefs | Functions
ifx-protocol.h File Reference

Generic protocol API (ISO/OSI stack). More...

#include <stddef.h>
#include <stdint.h>
#include "infineon/ifx-error.h"
#include "infineon/ifx-logger.h"

Go to the source code of this file.

Data Structures

struct  ifx_protocol_t
 Generic protocol struct for building ISO/OSI layer stack. More...
 

Macros

#define LIB_PROTOCOL   UINT8_C(0x20)
 Protocol library identifier ID.
 
#define IFX_PROTOCOL_ACTIVATE   UINT8_C(0x01)
 IFX error encoding function identifier for ifx_protocol_activate() and ifx_protocol_activate_callback_t.
 
#define IFX_PROTOCOL_TRANSMIT   UINT8_C(0x02)
 IFX error encoding function identifier for ifx_protocol_transmit_callback_t.
 
#define IFX_PROTOCOL_RECEIVE   UINT8_C(0x03)
 IFX error encoding function identifier for ifx_protocol_receive_callback_t.
 
#define IFX_PROTOCOL_RECEIVE_LEN_UNKOWN   SIZE_MAX
 Indicator for unknown length in ifx_protocol_receive_callback_t.
 
#define IFX_PROTOCOL_LAYER_INITIALIZE   UINT8_C(0x04)
 IFX error encoding function identifier for ifx_protocol_layer_initialize().
 
#define IFX_PROTOCOL_TRANSCEIVE   UINT8_C(0x05)
 Return code for successful calls to ifx_protocol_transceive() and ifx_protocol_transceive_callback_t.
 
#define IFX_PROTOCOL_STACK_INVALID   UINT8_C(0x01)
 Function independent error reason for invalid protocol stack (missing required function).
 

Typedefs

typedef ifx_status_t(* ifx_protocol_activate_callback_t) (ifx_protocol_t *self, uint8_t **response, size_t *response_len)
 Protocol layer specific secure element activation function.
 
typedef ifx_status_t(* ifx_protocol_transceive_callback_t) (ifx_protocol_t *self, const uint8_t *data, size_t data_len, uint8_t **response, size_t *response_len)
 Protocol layer specific transceive (send + receive) function.
 
typedef ifx_status_t(* ifx_protocol_transmit_callback_t) (ifx_protocol_t *self, const uint8_t *data, size_t data_len)
 Protocol layer specific transmit function.
 
typedef ifx_status_t(* ifx_protocol_receive_callback_t) (ifx_protocol_t *self, size_t expected_len, uint8_t **response, size_t *response_len)
 Protocol layer specific receive function.
 
typedef void(* ifx_protocol_destroy_callback_t) (ifx_protocol_t *self)
 Protocol layer specific destructor.
 

Functions

ifx_status_t ifx_protocol_layer_initialize (ifx_protocol_t *self)
 Initializes Protocol object by setting all members to valid values.
 

Detailed Description

Generic protocol API (ISO/OSI stack).

Definition in file ifx-protocol.h.

Macro Definition Documentation

◆ IFX_PROTOCOL_ACTIVATE

#define IFX_PROTOCOL_ACTIVATE   UINT8_C(0x01)

IFX error encoding function identifier for ifx_protocol_activate() and ifx_protocol_activate_callback_t.

Definition at line 30 of file ifx-protocol.h.

◆ IFX_PROTOCOL_LAYER_INITIALIZE

#define IFX_PROTOCOL_LAYER_INITIALIZE   UINT8_C(0x04)

IFX error encoding function identifier for ifx_protocol_layer_initialize().

Definition at line 53 of file ifx-protocol.h.

◆ IFX_PROTOCOL_RECEIVE

#define IFX_PROTOCOL_RECEIVE   UINT8_C(0x03)

IFX error encoding function identifier for ifx_protocol_receive_callback_t.

Definition at line 42 of file ifx-protocol.h.

◆ IFX_PROTOCOL_RECEIVE_LEN_UNKOWN

#define IFX_PROTOCOL_RECEIVE_LEN_UNKOWN   SIZE_MAX

Indicator for unknown length in ifx_protocol_receive_callback_t.

Definition at line 47 of file ifx-protocol.h.

◆ IFX_PROTOCOL_STACK_INVALID

#define IFX_PROTOCOL_STACK_INVALID   UINT8_C(0x01)

Function independent error reason for invalid protocol stack (missing required function).

Definition at line 65 of file ifx-protocol.h.

◆ IFX_PROTOCOL_TRANSCEIVE

#define IFX_PROTOCOL_TRANSCEIVE   UINT8_C(0x05)

Return code for successful calls to ifx_protocol_transceive() and ifx_protocol_transceive_callback_t.

Definition at line 59 of file ifx-protocol.h.

◆ IFX_PROTOCOL_TRANSMIT

#define IFX_PROTOCOL_TRANSMIT   UINT8_C(0x02)

IFX error encoding function identifier for ifx_protocol_transmit_callback_t.

Definition at line 36 of file ifx-protocol.h.

◆ LIB_PROTOCOL

#define LIB_PROTOCOL   UINT8_C(0x20)

Protocol library identifier ID.

Definition at line 24 of file ifx-protocol.h.

Typedef Documentation

◆ ifx_protocol_activate_callback_t

typedef ifx_status_t(* ifx_protocol_activate_callback_t) (ifx_protocol_t *self, uint8_t **response, size_t *response_len)

Protocol layer specific secure element activation function.

Depending on the protocol, data needs to be exchanged with a secure element to negotiate certain protocol aspects like frame sizes, waiting times, etc.

Parameters
[in]selfProtocol stack for performing necessary operations.
[out]responseBuffer to store response in (e.g. ATR, ATPO, ...).
[out]response_lenBuffer to store number of received bytes in (number of bytes in response).
Returns
ifx_status_t IFX_SUCCESS if successful, any other value in case of error.

Definition at line 84 of file ifx-protocol.h.

◆ ifx_protocol_destroy_callback_t

typedef void(* ifx_protocol_destroy_callback_t) (ifx_protocol_t *self)

Protocol layer specific destructor.

Different protocol (layers) need different clean-up functionality. This function type gives a generic interface for performing a clean shutdown.

Parameters
[in]selfProtocol stack for performing necessary operations.

Definition at line 180 of file ifx-protocol.h.

◆ ifx_protocol_receive_callback_t

typedef ifx_status_t(* ifx_protocol_receive_callback_t) (ifx_protocol_t *self, size_t expected_len, uint8_t **response, size_t *response_len)

Protocol layer specific receive function.

Parameters
[in]selfProtocol stack for performing necessary operations.
[in]expected_lenExpected number of bytes in response (use IFX_PROTOCOL_RECEIVE_LEN_UNKOWN if not known before).
[out]responseBuffer to store response in.
[out]response_lenBuffer to store number of received bytes in (number of bytes in response ).
Returns
ifx_status_t IFX_SUCCESS if successful, any other value in case of error.

Definition at line 167 of file ifx-protocol.h.

◆ ifx_protocol_transceive_callback_t

typedef ifx_status_t(* ifx_protocol_transceive_callback_t) (ifx_protocol_t *self, const uint8_t *data, size_t data_len, uint8_t **response, size_t *response_len)

Protocol layer specific transceive (send + receive) function.

Parameters
[in]selfProtocol stack for performing necessary operations.
[in]dataData to be send via protocol.
[in]data_lenNumber of bytes in data.
[out]responseBuffer to store response in.
[out]response_lenBuffer to store number of received bytes in (number of bytes in response ).
Returns
ifx_status_t IFX_SUCCESS if successful, any other value in case of error.

Definition at line 118 of file ifx-protocol.h.

◆ ifx_protocol_transmit_callback_t

typedef ifx_status_t(* ifx_protocol_transmit_callback_t) (ifx_protocol_t *self, const uint8_t *data, size_t data_len)

Protocol layer specific transmit function.

Parameters
[in]selfProtocol stack for performing necessary operations.
[in]dataData to be send via protocol.
[in]data_lenNumber of bytes in data.
Returns
ifx_status_t IFX_SUCCESS if successful, any other value in case of error.

Definition at line 151 of file ifx-protocol.h.

Function Documentation

◆ ifx_protocol_layer_initialize()

ifx_status_t ifx_protocol_layer_initialize ( ifx_protocol_t * self)

Initializes Protocol object by setting all members to valid values.

This function is for protocol stack developers to start from a clean base when initializing a layer in their custom initialization function. It initializes the given Protocol struct to a clean but unusable state (no members set).

Parameters
[in]selfProtocol object to be initialized.
Returns
ifx_status_t IFX_SUCCESS if successful, any other value in case of error.