• 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 SCTP_CHANNEL_H
17 #define SCTP_CHANNEL_H
18 
19 #include <netinet/in.h>
20 #include <stdint.h>
21 #include "hitls.h"
22 #include "bsl_uio.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * @brief  Initiate an SCTP connection
30  */
31 int32_t SctpConnect(char *targetIP, int32_t targetPort, bool isBlock);
32 
33 /**
34  * @brief  Waiting for SCTP connection
35  */
36 int32_t SctpAccept(char *ip, int listenFd, bool isBlock);
37 
38 /**
39  * @brief  Disable the SCTP connection
40  */
41 void SctpClose(int fd);
42 
43 /**
44  * @brief  Obtain the default SCTP method
45  */
46 BSL_UIO_Method *SctpGetDefaultMethod(void);
47 
48 /**
49  * @brief  Set the Ctrl command for registering the hook
50  */
51 void SetNeedCbSctpCtrlCmd(int cmd);
52 
53 int32_t SctpBind(int port);
54 
55 // Default SCTP connection method
56 int32_t SctpDefaultWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen);
57 int32_t SctpDefaultRead(BSL_UIO *uio, void *buf, uint32_t len, uint32_t *readLen);
58 int32_t SctpDefaultCtrl(BSL_UIO *uio, int32_t cmd, int32_t larg, void *param);
59 
60 // Change the SCTP connection of the message
61 int32_t SctpFrameWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen);
62 int32_t SctpFrameRead(BSL_UIO *uio, void *buf, uint32_t len, uint32_t *readLen);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif // SCTP_CHANNEL_H
69