* This file is part of the openHiTLS project.
*
* openHiTLS is licensed under the Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
* @defgroup hitls_crypt_reg
* @ingroup tls
* @brief hitls maintenance and debugging
*/
#ifndef HITLS_DEBUG_H
#define HITLS_DEBUG_H
#include <stdint.h>
#include "hitls_type.h"
#ifdef __cplusplus
extern "C" {
#endif
#define INDICATE_VALUE_SUCCESS 1u
#define INDICATE_EVENT_LOOP 0x01
#define INDICATE_EVENT_EXIT 0x02
#define INDICATE_EVENT_READ 0x04
#define INDICATE_EVENT_WRITE 0x08
#define INDICATE_EVENT_HANDSHAKE_START 0x10
#define INDICATE_EVENT_HANDSHAKE_DONE 0x20
#define INDICATE_EVENT_STATE_CONNECT 0x1000
#define INDICATE_EVENT_STATE_ACCEPT 0x2000
#define INDICATE_EVENT_ALERT 0x4000
#define INDICATE_EVENT_READ_ALERT (INDICATE_EVENT_ALERT | INDICATE_EVENT_READ)
#define INDICATE_EVENT_WRITE_ALERT (INDICATE_EVENT_ALERT | INDICATE_EVENT_WRITE)
#define INDICATE_EVENT_STATE_ACCEPT_LOOP (INDICATE_EVENT_STATE_ACCEPT | INDICATE_EVENT_LOOP)
#define INDICATE_EVENT_STATE_ACCEPT_EXIT (INDICATE_EVENT_STATE_ACCEPT | INDICATE_EVENT_EXIT)
#define INDICATE_EVENT_STATE_CONNECT_LOOP (INDICATE_EVENT_STATE_CONNECT | INDICATE_EVENT_LOOP)
#define INDICATE_EVENT_STATE_CONNECT_EXIT (INDICATE_EVENT_STATE_CONNECT | INDICATE_EVENT_EXIT)
* @ingroup hitls_debug
* @attention The message prompt callback function does not return a value
* @brief Information prompt callback prototype
* @param ctx [IN] Ctx context
* @param eventType [IN] EventType Event type
* @param value [IN] Value Function return value or Alert type that matches the event type
* @return No value is returned.
*/
typedef void (*HITLS_InfoCb)(const HITLS_Ctx *ctx, int32_t eventType, int32_t value);
* @ingroup hitls_debug
* @brief Set the callback for prompt information.
*
* @param ctx [OUT] Ctx context
* @param callback [IN] Callback function for prompting information
* @return HITLS_SUCCESS, if successful.
* For other error codes, see hitls_error.h.
*/
int32_t HITLS_SetInfoCb(HITLS_Ctx *ctx, HITLS_InfoCb callback);
* @ingroup hitls_debug
* @brief Callback for obtaining information
*
* @param ctx [IN] Ctx context
* @return Callback function of the current information prompt.
* If this parameter is not set, NULL is returned.
*/
HITLS_InfoCb HITLS_GetInfoCb(const HITLS_Ctx *ctx);
* @ingroup hitls_debug
* @brief Set the callback function for prompting information.
*
* @param config [OUT] Config Context
* @param callback [IN] Client callback
* @return HITLS_SUCCESS, if successful.
* For details about other error codes, see hitls_error.h.
*/
int32_t HITLS_CFG_SetInfoCb(HITLS_Config *config, HITLS_InfoCb callback);
* @ingroup hitls_debug
* @brief Callback function for obtaining information prompts
*
* @param config [IN] config Context
* @return Callback function of the current information prompt.
* If this parameter is not set, NULL is returned.
*/
HITLS_InfoCb HITLS_CFG_GetInfoCb(const HITLS_Config *config);
* @ingroup hitls_debug
* @attention: The callback function for messages in the retention protocol does not return any value.
* @brief Callback prototype of a protocol message
* @param writePoint [IN] writePoint Message direction in the callback ">>>" or "<<<"
* @param tlsVersion [IN] tlsVersion TLS version, for example, HITLS_VERSION_TLS12.
* @param contentType [IN] contentType Type of the processed message body.
* @param msg [IN] msg callback internal message processing instruction data
* @param msgLen [IN] msgLen Processing instruction data length
* @param ctx [IN] ctx HITLS context
* @param arg [IN] arg User data, for example, BIO
* @return No value is returned.
*/
typedef void (*HITLS_MsgCb) (int32_t writePoint, int32_t tlsVersion, int32_t contentType, const void *msg,
uint32_t msgLen, HITLS_Ctx *ctx, void *arg);
* @ingroup hitls_debug
* @brief Set the protocol message callback function, cb can be NULL.
*
* @param ctx [OUT] Ctx context
* @param callback [IN] Protocol message callback function
* @return HITLS_SUCCESS, if successful.
* For details about other error codes, see hitls_error.h.
*/
int32_t HITLS_SetMsgCb(HITLS_Ctx *ctx, HITLS_MsgCb callback);
* @ingroup hitls_debug
* @brief Set the protocol message callback function, cb can be NULL.
*
* @param config [OUT] Config Context
* @param callback [IN] Protocol message callback
* @return HITLS_SUCCESS, if successful.
* For details about other error codes, see hitls_error.h.
*/
int32_t HITLS_CFG_SetMsgCb(HITLS_Config *config, HITLS_MsgCb callback);
* @ingroup hitls_debug
* @brief Set the related parameters arg required by the protocol message callback function.
* @param ctx [OUT] Ctx context
* @param arg [IN] Related parameters arg.
* @return HITLS_SUCCESS, if successful.
* For details about other error codes, see hitls_error.h.
*/
int32_t HITLS_SetMsgCbArg(HITLS_Ctx *ctx, void *arg);
* @ingroup hitls_debug
* @brief Set the related parameters arg required by the protocol message callback function.
*
* @param config [OUT] Config Context.
* @param arg [IN] Related parameters arg.
* @return HITLS_SUCCESS, if successful.
* For details about other error codes, see hitls_error.h.
*/
int32_t HITLS_CFG_SetMsgCbArg(HITLS_Config *config, void *arg);
#ifdef __cplusplus
}
#endif
#endif