• 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 UDP_CHANNEL_H
17 #define UDP_CHANNEL_H
18 
19 #include <stdbool.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /* Connects to the peer and returns a socket descriptor. */
26 int UdpConnect(const char *targetIP, const int targetPort);
27 
28 /* listen */
29 int UdpBind(const int localPort);
30 
31 /* accept */
32 int UdpAccept(char *ip, int listenFd, bool isBlock, bool needClose);
33 
34 /* write */
35 int32_t UdpFrameWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen);
36 
37 void UdpClose(int sd);
38 
39 /* Default UDP method based on Linux */
40 void *UdpGetDefaultMethod(void);
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #endif  // UDP_CHANNEL_H
47