* 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.
*/
#include "hitls_build.h"
#ifdef HITLS_TLS_FEATURE_INDICATOR
#include <stddef.h>
#include "tls.h"
#include "hitls_error.h"
#include "bsl_err_internal.h"
#include "hitls_debug.h"
* @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 succeeded.
* For other error codes, see hitls_error.h.
*/
int32_t HITLS_SetInfoCb(HITLS_Ctx *ctx, HITLS_InfoCb callback)
{
if (ctx == NULL) {
return HITLS_NULL_INPUT;
}
ctx->config.tlsConfig.infoCb = callback;
return HITLS_SUCCESS;
}
* @ingroup hitls_debug
* @brief Callback for obtaining information.
* @param ctx [IN] ctx context
* @return Callback function of the current information prompt
*/
HITLS_InfoCb HITLS_GetInfoCb(const HITLS_Ctx *ctx)
{
if (ctx == NULL) {
return NULL;
}
return ctx->config.tlsConfig.infoCb;
}
* @ingroup hitls_debug
* @brief Set the callback function for prompting information.
* @param config [OUT] config Context
* @param callback [IN] Client callback
* @return HITLS_SUCCESS succeeded.
* For other error codes, see hitls_error.h.
*/
int32_t HITLS_CFG_SetInfoCb(HITLS_Config *config, HITLS_InfoCb callback)
{
if (config == NULL) {
return HITLS_NULL_INPUT;
}
config->infoCb = callback;
return HITLS_SUCCESS;
}
* @ingroup hitls_debug
* @brief Callback function for obtaining information prompts
* @param config [IN] config Context
* @return Callback function of the current information prompt
*/
HITLS_InfoCb HITLS_CFG_GetInfoCb(const HITLS_Config *config)
{
if (config == NULL) {
return NULL;
}
return config->infoCb;
}
* @ingroup hitls_debug
* @brief Set the protocol message callback function.
* @param ctx [OUT] ctx context
* @param callback [IN] Protocol message callback function
* @return HITLS_SUCCESS succeeded.
* For details about other error codes, see hitls_error.h
*/
int32_t HITLS_SetMsgCb(HITLS_Ctx *ctx, HITLS_MsgCb callback)
{
if (ctx == NULL) {
return HITLS_NULL_INPUT;
}
return HITLS_CFG_SetMsgCb(&(ctx->config.tlsConfig), callback);
}
* @ingroup hitls_debug
* @brief Set the protocol message callback function.
* @param config [OUT] config Context
* @param callback [IN] Protocol message callback
* @return HITLS_SUCCESS succeeded.
* For details about other error codes, see hitls_error.h
*/
int32_t HITLS_CFG_SetMsgCb(HITLS_Config *config, HITLS_MsgCb callback)
{
if (config == NULL) {
return HITLS_NULL_INPUT;
}
config->msgCb = callback;
return HITLS_SUCCESS;
}
* @ingroup hitls_debug
* @brief Set the parameters required by the protocol message callback function. arg
* @param ctx [OUT] ctx context
* @param arg [IN] Related parameters arg
* @return HITLS_SUCCESS succeeded.
* For details about other error codes, see hitls_error.h
*/
int32_t HITLS_SetMsgCbArg(HITLS_Ctx *ctx, void *arg)
{
if (ctx == NULL) {
return HITLS_NULL_INPUT;
}
return HITLS_CFG_SetMsgCbArg(&(ctx->config.tlsConfig), arg);
}
* @ingroup hitls_debug
* @brief Set the parameters required by the protocol message callback function. arg
* @param config [OUT] config Context
* @param arg [IN] Related parameters arg
* @return HITLS_SUCCESS succeeded.
* For details about other error codes, see hitls_error.h
*/
int32_t HITLS_CFG_SetMsgCbArg(HITLS_Config *config, void *arg)
{
if (config == NULL) {
return HITLS_NULL_INPUT;
}
config->msgArg = arg;
return HITLS_SUCCESS;
}
#endif