• 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 #ifndef PACK_COMMON_H
17 #define PACK_COMMON_H
18 
19 #include <stdint.h>
20 #include "hs_msg.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /**
27  * @brief   Pack session ID
28  *
29  * @param   id [IN] Session ID
30  * @param   idSize [IN] Session ID length
31  * @param   buf [OUT] Message buffer
32  * @param   bufLen [IN] Maximum message length
33  * @param   usedLen [OUT] Length of message
34  *
35  * @retval  HITLS_SUCCESS
36  * @retval  HITLS_PACK_SESSIONID_ERR Failed to pack sessionId
37  * @retval  HITLS_MEMCPY_FAIL Memory Copy Failed
38  */
39 int32_t PackSessionId(const uint8_t *id, uint32_t idSize, uint8_t *buf, uint32_t bufLen, uint32_t *usedLen);
40 
41 /**
42  * @brief   Pack DTLS message header
43  *
44  * @param   type [IN] Message type
45  * @param   sequence [IN] Sequence number (only in DTLS)
46  * @param   length [IN] Length of message body
47  * @param   buf [OUT] Message header
48  */
49 void PackDtlsMsgHeader(HS_MsgType type, uint16_t sequence, uint32_t length, uint8_t *buf);
50 
51 /**
52  * @brief   Error processing function in pack module
53  *
54  * @param   logId [IN] binlogid
55  * @param   format [IN] Message for log function
56 
57  * @retval  error code
58  */
59 int32_t PackBufLenError(uint32_t logId, const void *format);
60 #ifdef __cplusplus
61 }
62 #endif /* end __cplusplus */
63 
64 #endif /* end PACK_COMMON_H */