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 SOCKET_COMMON_H 17 #define SOCKET_COMMON_H 18 19 #include <stdint.h> 20 #include "hlt_type.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * @brief Sock Set the block 28 */ 29 int32_t SetBlockMode(int32_t sd, bool isBlock); 30 31 /** 32 * @brief Check whether there are fatal I/O errors 33 */ 34 bool IsNonFatalErr(int32_t err); 35 36 /** 37 * @brief Set the message injection parameter, which must be used with the CleantFrameHandle 38 */ 39 int32_t SetFrameHandle(HLT_FrameHandle *frameHandle); 40 41 /** 42 * @brief Clear message injection parameters 43 */ 44 void CleanFrameHandle(void); 45 46 /** 47 * @brief Obtain message injection parameters 48 */ 49 HLT_FrameHandle *GetFrameHandle(void); 50 51 /** 52 * @brief Obtain the newbuf by parsing the buf. Constraint: The input parameter of packLen cannot be empty 53 */ 54 uint8_t *GetNewBuf(const void *buf, uint32_t len, uint32_t *packLen); 55 56 /** 57 * @brief Release the newbuf applied by GetNewBuf 58 */ 59 void FreeNewBuf(void *newBuf); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif // SOCKET_COMMON_H