|
hsw-nbt 1.2.0
OPTIGA Authenticate NBT Host Library for C
|
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. | |
Generic protocol API (ISO/OSI stack).
Definition in file ifx-protocol.h.
| #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.
| #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.
| #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.
| #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.
| #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.
| #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.
| #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.
| #define LIB_PROTOCOL UINT8_C(0x20) |
Protocol library identifier ID.
Definition at line 24 of file ifx-protocol.h.
| 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.
| [in] | self | Protocol stack for performing necessary operations. |
| [out] | response | Buffer to store response in (e.g. ATR, ATPO, ...). |
| [out] | response_len | Buffer to store number of received bytes in (number of bytes in response). |
IFX_SUCCESS if successful, any other value in case of error. Definition at line 84 of file ifx-protocol.h.
| 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.
| [in] | self | Protocol stack for performing necessary operations. |
Definition at line 180 of file ifx-protocol.h.
| 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.
| [in] | self | Protocol stack for performing necessary operations. |
| [in] | expected_len | Expected number of bytes in response (use IFX_PROTOCOL_RECEIVE_LEN_UNKOWN if not known before). |
| [out] | response | Buffer to store response in. |
| [out] | response_len | Buffer to store number of received bytes in (number of bytes in response ). |
IFX_SUCCESS if successful, any other value in case of error. Definition at line 167 of file ifx-protocol.h.
| 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.
| [in] | self | Protocol stack for performing necessary operations. |
| [in] | data | Data to be send via protocol. |
| [in] | data_len | Number of bytes in data. |
| [out] | response | Buffer to store response in. |
| [out] | response_len | Buffer to store number of received bytes in (number of bytes in response ). |
IFX_SUCCESS if successful, any other value in case of error. Definition at line 118 of file ifx-protocol.h.
| 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.
| [in] | self | Protocol stack for performing necessary operations. |
| [in] | data | Data to be send via protocol. |
| [in] | data_len | Number of bytes in data. |
IFX_SUCCESS if successful, any other value in case of error. Definition at line 151 of file ifx-protocol.h.
| 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).
| [in] | self | Protocol object to be initialized. |
IFX_SUCCESS if successful, any other value in case of error.