• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @defgroup bsl_userdata
18  * @ingroup bsl
19  * @brief user data module
20  */
21 
22 #ifndef BSL_USER_DATA_H
23 #define BSL_USER_DATA_H
24 
25 #include <stdint.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /**
32  * @ingroup bsl_userdata
33  *
34  * Modify the BSL_MAX_EX_TYPE if a new index is added.
35  */
36 #define BSL_USER_DATA_EX_INDEX_SSL              0
37 #define BSL_USER_DATA_EX_INDEX_X509_STORE_CTX   1
38 #define BSL_USER_DATA_EX_INDEX_SSL_CTX          2
39 #define BSL_USER_DATA_EX_INDEX_X509_STORE       3
40 #define BSL_USER_DATA_EX_INDEX_UIO              4
41 
42 #define BSL_MAX_EX_TYPE 5
43 #define BSL_MAX_EX_DATA 20
44 
45 typedef struct {
46     void *sk[BSL_MAX_EX_DATA];
47 } BSL_USER_ExData;
48 
49 typedef void BSL_USER_ExDataNew(void *parent, void *ptr, BSL_USER_ExData *ad, int idx, long argl, void *argp);
50 typedef void BSL_USER_ExDataFree(void *parent, void *ptr, BSL_USER_ExData *ad, int idx, long argl, void *argp);
51 typedef int BSL_USER_ExDataDup(BSL_USER_ExData *to, const BSL_USER_ExData *from, void **fromD, int idx, long argl,
52     void *argp);
53 
54 int BSL_USER_SetExData(BSL_USER_ExData *ad, int32_t idx, void *val);
55 
56 void *BSL_USER_GetExData(const BSL_USER_ExData *ad, int32_t idx);
57 
58 int BSL_USER_GetExDataNewIndex(int32_t index, int64_t argl, const void *argp, const void *newFunc, const void *dupFunc,
59     void *freeFunc);
60 
61 void BSL_USER_FreeExDataIndex(int32_t index, void *obj, BSL_USER_ExData *ad);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif // BSL_USER_DATA_H
68