• 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_errno
18  * @ingroup bsl
19  * @brief error number module
20  */
21 
22 #ifndef BSL_ERRNO_H
23 #define BSL_ERRNO_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /**
30  * @ingroup bsl_errno
31  * @brief   Return success
32  */
33 #define BSL_SUCCESS 0
34 
35 /**
36  * @ingroup bsl_errno
37  *
38  * Return values of the BSL module range from 0x03000001 to 0x03ffffff.
39  */
40 enum BSL_ERROR {
41     /* Common return value start from 0x03000001. */
42     BSL_NULL_INPUT = 0x03000000,            /**< NULL input. */
43     BSL_INTERNAL_EXCEPTION,                 /**< Error occurs when calling internal BSL functions */
44     BSL_MALLOC_FAIL,                        /**< Error occurs when allocating memory */
45     BSL_MEMCPY_FAIL,                        /**< Error occurs when calling memcpy_s. */
46     BSL_MEMMOVE_FAIL,                       /**< Error occurs when calling memmove. */
47     BSL_INVALID_ARG,                        /**< Invalid arguments. */
48     BSL_DUMP_FAIL,                          /**< Error occurs when duplicating memory */
49 
50     /* The return value of the SAL submodule starts from 0x03010001. */
51     BSL_SAL_ERR_UNKNOWN = 0x03010001,        /**< Unknown error. */
52     BSL_SAL_ERR_BAD_PARAM,                   /**< Parameter incorrect. */
53 
54     BSL_SAL_ERR_FILE_OPEN,                   /**< Open file error. */
55     BSL_SAL_ERR_FILE_READ,                   /**< File reading error. */
56     BSL_SAL_ERR_FILE_WRITE,                  /**< File writing error. */
57     BSL_SAL_ERR_FILE_LENGTH,                 /**< Obtaining the file length error. */
58     BSL_SAL_ERR_FILE_TELL,                   /**< Error in obtaining the file pointer offset. */
59     BSL_SAL_ERR_FILE_SEEK,                   /**< Failed to set pointer position of file. */
60     BSL_SAL_ERR_FILE_SET_ATTR,               /**< Setting file attribute failed. */
61     BSL_SAL_ERR_FILE_GET_ATTR,               /**< Error in obtaining file attributes. */
62     BSL_SAL_FILE_NO_REG_FUNC,
63 
64     BSL_SAL_ERR_DL_NOT_FOUND,                /**< dl not found. */
65     BSL_SAL_ERR_DL_LOAD_FAIL,                /**< Error occured when loading dynamic library. */
66     BSL_SAL_ERR_DL_UNLOAAD_FAIL,             /**< Error occured when unloading dynamic library. */
67     BSL_SAL_ERR_DL_NON_FUNCTION,             /**< dl doesn't find function. */
68     BSL_SAL_ERR_DL_LOOKUP_METHOD,            /**< Error occurred when looking up dl method. */
69     BSL_SAL_ERR_DL_PATH_EXCEED,              /**< Path exceeds the maximum length. */
70     BSL_SAL_DL_NO_REG_FUNC,                  /**< No registration function. */
71 
72     /* The return value of the LOG submodule starts from 0x03020001. */
73     BSL_LOG_ERR_BAD_PARAM = 0x03020001,      /**< Bad parameter. */
74 
75     /* The return value of the TLV submodule starts from 0x03030001. */
76     BSL_TLV_ERR_BAD_PARAM = 0x03030001,      /**< Bad parameter. */
77     BSL_TLV_ERR_NO_WANT_TYPE,                /**< No TLV found. */
78 
79     /* The return value of the ERR submodule starts from 0x03040001. */
80     BSL_ERR_ERR_ACQUIRE_READ_LOCK_FAIL = 0x03040001,  /**< Failed to obtain the read lock. */
81     BSL_ERR_ERR_ACQUIRE_WRITE_LOCK_FAIL,              /**< Failed to obtain the write lock. */
82     BSL_ERR_ERR_NO_STACK,                             /**< Error stack is empty. */
83     BSL_ERR_ERR_NO_ERROR,                             /**< Error stack is NULL.  */
84     BSL_ERR_ERR_NO_MARK,                              /**< Error stack has no mark. */
85 
86     BSL_SAL_TIME_NO_REG_FUNC = 0x03050001,
87 
88     /* The return value of the UIO submodule starts from 0x03060001. */
89     BSL_UIO_FAIL = 0x03060001,              /**< Invalid parameters. */
90     BSL_UIO_IO_EXCEPTION,                   /**< I/O is abnormal. */
91     BSL_UIO_IO_BUSY,                        /**< I/O is busy. */
92     BSL_UIO_MEM_GROW_FAIL,
93     BSL_UIO_REF_MAX,                        /**< The number of UIO objects has reached the maximum. */
94     BSL_UIO_MEM_ALLOC_FAIL,
95     BSL_UIO_IO_EOF,                         /**< I/O object has reached EOF */
96     BSL_UIO_WRITE_NOT_ALLOWED,
97     BSL_UIO_UNINITIALIZED,                  /**< UIO object is uninitialized */
98     BSL_UIO_MEM_NOT_NULL,
99 
100     /* The return value of the LIST submodule starts from 0x03070001. */
101     BSL_LIST_INVALID_LIST_CURRENT = 0x03070001, /**< Current node pointer is NULL */
102     BSL_LIST_MALLOC_FAIL,
103     BSL_LIST_DATA_NOT_AVAILABLE,                /**< Data of current node is NULL */
104     BSL_LIST_FULL,                              /**< Number of nodes has reached its limit */
105 
106     /* The return value of the BASE64 submodule starts from 0x030a0001. */
107     BSL_BASE64_INVALID = 0x030a0001,
108     BSL_BASE64_BUF_NOT_ENOUGH,
109     BSL_BASE64_DATA_NOT_ENOUGH,
110     BSL_BASE64_WRITE_FAILED,
111     BSL_BASE64_READ_FAILED,
112     BSL_BASE64_DATA_AFTER_PADDING,
113     BSL_BASE64_ILLEGALLY_MODIFIED,
114     BSL_BASE64_ENCODE_FAILED,
115     BSL_BASE64_DECODE_FAILED,
116     BSL_BASE64_HEADER,
117     BSL_BASE64_INVALID_CHARACTER,
118     BSL_BASE64_INVALID_ENCODE,
119 
120     BSL_SAL_ERR_NET_NOBLOCK = 0x030b0001,
121     BSL_SAL_ERR_NET_SOCKCLOSE,               /**< Error occured when closing a socket. */
122     BSL_SAL_ERR_NET_SETSOCKOPT,              /**< Error occured when setting a socket option. */
123     BSL_SAL_ERR_NET_GETSOCKOPT,              /**< Error occured when getting a socket option. */
124     BSL_SAL_ERR_NET_LISTEN,                  /**< Error occured when listening a socket. */
125     BSL_SAL_ERR_NET_BIND,                    /**< Error occured when binding a socket */
126     BSL_SAL_ERR_NET_CONNECT,                 /**< Error occured when building a connection. */
127     BSL_SAL_ERR_NET_IOCTL,                   /**< Error occured when calling ioctl. */
128     BSL_SAL_NET_NO_REG_FUNC,
129 
130     BSL_PARAMS_INVALID_KEY = 0x030f0001,
131     BSL_PARAMS_INVALID_TYPE,
132     BSL_PARAMS_LEN_NOT_ENOUGH,
133     BSL_PARAMS_MISMATCH,
134 
135     BSL_ASN1_FAIL = 0x03100001,
136     BSL_ASN1_ERR_DECODE_BOOL,
137     BSL_ASN1_ERR_NO_CALLBACK,
138     BSL_ASN1_ERR_MAX_DEPTH,
139     BSL_ASN1_ERR_OVERFLOW,
140     BSL_ASN1_ERR_TAG_EXPECTED,
141     BSL_ASN1_ERR_DECODE_LEN,
142     BSL_ASN1_ERR_MAX_LEN_NUM,
143     BSL_ASN1_ERR_DECODE_INT,
144     BSL_ASN1_ERR_DECODE_BIT_STRING,
145     BSL_ASN1_ERR_DECODE_UTC_TIME,
146     BSL_ASN1_ERR_DECODE_TIME,
147     BSL_ASN1_ERR_DECODE_GENERAL_TIME,
148     BSL_ASN1_ERR_CHECK_TIME,
149     BSL_ASN1_ERR_EXCEED_LIST_DEPTH,
150     BSL_ASN1_ERR_MISMATCH_TAG,
151     BSL_ASN1_ERR_BUFF_NOT_ENOUGH,
152     BSL_ASN1_ERR_ENCODE_FAIL,
153     BSL_ASN1_ERR_ENCODE_ASN_LACK,
154     BSL_ASN1_ERR_ENCODE_ASN_TOO_MUCH,
155     BSL_ASN1_ERR_ENCODE_BOOL,
156     BSL_ASN1_ERR_ENCODE_INT,
157     BSL_ASN1_ERR_ENCODE_BIT_STRING,
158     BSL_ASN1_ERR_ENCODE_UTC_TIME,
159     BSL_ASN1_ERR_ENCODE_GENERALIZED_TIME,
160     BSL_ASN1_ERR_PRINTF,
161     BSL_ASN1_ERR_PRINTF_IO_ERR,
162     BSL_ASN1_ERR_LEN_OVERFLOW,
163 
164     BSL_PEM_INVALID = 0x03110001,
165     BSL_PEM_DATA_NOT_ENOUGH,
166     BSL_PEM_SYMBOL_NOT_FOUND,
167 
168     BSL_OBJ_ERR_INSERT_HASH_TABLE = 0x03130001,
169     BSL_OBJ_ERR_FIND_HASH_TABLE,
170     BSL_OBJ_INVALID_HASH_TABLE,
171 };
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif // BSL_ERRNO_H
178