API参考
载入中...
搜索中...
未找到
alert.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
16#ifndef ALTER_H
17#define ALTER_H
18
19#include <stdbool.h>
20#include <stdint.h>
21#include "hitls_build.h"
22#include "tls.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef enum {
29 ALERT_FLAG_NO = 0, /* no alert message */
30 ALERT_FLAG_RECV, /* received the alert message */
31 ALERT_FLAG_SEND, /* the alert message needs to be sent */
32} ALERT_FLAG;
33
35typedef struct {
36 uint8_t flag; /* send and receive flags, see ALERT_FLAG */
37 uint8_t level; /* Alert level. For details, see ALERT_Level. */
38 uint8_t description; /* Alert description. For details, see ALERT_Description. */
39 uint8_t reverse; /* reserve, 4-byte aligned */
41
52int32_t ALERT_Init(TLS_Ctx *ctx);
53
61void ALERT_Deinit(TLS_Ctx *ctx);
62
73bool ALERT_GetFlag(const TLS_Ctx *ctx);
74
83void ALERT_GetInfo(const TLS_Ctx *ctx, ALERT_Info *info);
84
91void ALERT_CleanInfo(const TLS_Ctx *ctx);
92
102void ALERT_Send(const TLS_Ctx *ctx, ALERT_Level level, ALERT_Description description);
103
113int32_t ALERT_Flush(TLS_Ctx *ctx);
114
124int32_t ProcessDecryptedAlert(TLS_Ctx *ctx, const uint8_t *data, uint32_t dataLen);
125
135int32_t ProcessPlainAlert(TLS_Ctx *ctx, const uint8_t *data, uint32_t dataLen);
136
144void ALERT_ClearWarnCount(TLS_Ctx *ctx, uint32_t recordType);
145
154bool ALERT_HaveExceeded(TLS_Ctx *ctx, uint8_t threshold);
155
156#ifdef HITLS_BSL_LOG
157int32_t ReturnAlertProcess(TLS_Ctx *ctx, int32_t err, uint32_t logId, const void *logStr,
158 ALERT_Description description);
159
160#define RETURN_ALERT_PROCESS(ctx, err, logId, logStr, description) \
161 ReturnAlertProcess(ctx, err, logId, LOG_STR(logStr), description)
162
163#else
164
165#define RETURN_ALERT_PROCESS(ctx, err, logId, logStr, description) \
166 (ctx)->method.sendAlert(ctx, ALERT_LEVEL_FATAL, description), (err)
167#endif /* HITLS_BSL_LOG */
168
169#ifdef __cplusplus
170}
171#endif
172
173#endif /* ALTER_H */
定义 alert.h:35