• 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 SAL_NETIMPL_H
17 #define SAL_NETIMPL_H
18 
19 #include "hitls_build.h"
20 #ifdef HITLS_BSL_SAL_NET
21 
22 #include <stdint.h>
23 #include "bsl_sal.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif // __cplusplus
28 
29 typedef struct {
30     BslSalWrite pfWrite;
31     BslSalRead pfRead;
32     BslSalSocket pfSocket;
33     BslSalSockClose pfSockClose;
34     BslSalSetSockopt pfSetSockopt;
35     BslSalGetSockopt pfGetSockopt;
36     BslSalSockListen pfSockListen;
37     BslSalSockBind pfSockBind;
38     BslSalSockConnect pfSockConnect;
39     BslSalSockSend pfSockSend;
40     BslSalSockRecv pfSockRecv;
41     BslSalSelect pfSelect;
42     BslSalIoctlsocket pfIoctlsocket;
43     BslSalSockGetLastSocketError pfSockGetLastSocketError;
44     BslSalSockAddrNew pfSockAddrNew;
45     BslSalSockAddrFree pfSockAddrFree;
46     BslSalSockAddrSize pfSockAddrSize;
47     BslSalSockAddrCopy pfSockAddrCopy;
48     BslSalNetSendTo pfSendTo;
49     BslSalNetRecvFrom pfRecvFrom;
50 } BSL_SAL_NetCallback;
51 
52 int32_t SAL_NetCallback_Ctrl(BSL_SAL_CB_FUNC_TYPE type, void *funcCb);
53 
54 #ifdef HITLS_BSL_SAL_LINUX
55 int32_t SAL_NET_Write(int32_t fd, const void *buf, uint32_t len, int32_t *err);
56 int32_t SAL_NET_Read(int32_t fd, void *buf, uint32_t len, int32_t *err);
57 int32_t SAL_NET_SockAddrNew(BSL_SAL_SockAddr *sockAddr);
58 void SAL_NET_SockAddrFree(BSL_SAL_SockAddr sockAddr);
59 uint32_t SAL_NET_SockAddrSize(const BSL_SAL_SockAddr sockAddr);
60 void SAL_NET_SockAddrCopy(BSL_SAL_SockAddr dst, BSL_SAL_SockAddr src);
61 int32_t SAL_NET_Sendto(int32_t sock, const void *buf, size_t len, int32_t flags, void *address, int32_t addrLen,
62                        int32_t *err);
63 int32_t SAL_NET_RecvFrom(int32_t sock, void *buf, size_t len, int32_t flags, void *address, int32_t *addrLen,
64                          int32_t *err);
65 
66 int32_t SAL_Socket(int32_t af, int32_t type, int32_t protocol);
67 int32_t SAL_SockClose(int32_t sockId);
68 int32_t SAL_SetSockopt(int32_t sockId, int32_t level, int32_t name, const void *val, int32_t len);
69 int32_t SAL_GetSockopt(int32_t sockId, int32_t level, int32_t name, void *val, int32_t *len);
70 int32_t SAL_SockListen(int32_t sockId, int32_t backlog);
71 int32_t SAL_SockBind(int32_t sockId, BSL_SAL_SockAddr addr, size_t len);
72 int32_t SAL_SockConnect(int32_t sockId, BSL_SAL_SockAddr addr, size_t len);
73 int32_t SAL_SockSend(int32_t sockId, const void *msg, size_t len, int32_t flags);
74 int32_t SAL_SockRecv(int32_t sockfd, void *buff, size_t len, int32_t flags);
75 int32_t SAL_Select(int32_t nfds, void *readfds, void *writefds, void *exceptfds, void *timeout);
76 int32_t SAL_Ioctlsocket(int32_t sockId, long cmd, unsigned long *arg);
77 int32_t SAL_SockGetLastSocketError(void);
78 
79 #endif
80 
81 #ifdef __cplusplus
82 }
83 #endif // __cplusplus
84 
85 #endif // HITLS_BSL_SAL_NET
86 #endif // SAL_NETIMPL_H
87