API参考
载入中...
搜索中...
未找到
sal_netimpl.h
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
26extern "C" {
27#endif // __cplusplus
28
29typedef struct {
30 BslSalNetWrite pfWrite;
31 BslSalNetRead pfRead;
32 BslSalSocket pfSocket;
33 BslSalSockClose pfSockClose;
34 BslSalSetSockopt pfSetSocketopt;
35 BslSalGetSockopt pfGetSocketopt;
36 BslSalSockListen pfSockListen;
37 BslSalSockBind pfSockBind;
38 BslSalSockConnect pfSockConnect;
39 BslSalSockSend pfSockSend;
40 BslSalSockRecv pfSockRecv;
41 BslSelect pfSelect;
42 BslIoctlSocket pfIoctlsocket;
43 BslGetErrno pfGetErrno;
44 BslSalSockAddrNew pfSockAddrNew;
45 BslSalSockAddrFree pfSockAddrFree;
46 BslSalSockAddrSize pfSockAddrSize;
47 BslSalSockAddrCopy pfSockAddrCopy;
48 BslSalNetSendTo pfSendTo;
49 BslSalNetRecvFrom pfRecvFrom;
50 BslSalSockAddrGetFamily pfSockAddrGetFamily;
51} BSL_SAL_NetCallback;
52
53#if defined(HITLS_BSL_SAL_LINUX) || defined(HITLS_BSL_SAL_DARWIN)
54int32_t SAL_NET_SockAddrNew(BSL_SAL_SockAddr *sockAddr);
55void SAL_NET_SockAddrFree(BSL_SAL_SockAddr sockAddr);
56uint32_t SAL_NET_SockAddrSize(const BSL_SAL_SockAddr sockAddr);
57void SAL_NET_SockAddrCopy(BSL_SAL_SockAddr dst, BSL_SAL_SockAddr src);
58int32_t SAL_NET_SockAddrGetFamily(const BSL_SAL_SockAddr sockAddr);
59
60int32_t SAL_NET_Write(int32_t fd, const void *buf, uint32_t len, int32_t *err);
61
62int32_t SAL_NET_Read(int32_t fd, void *buf, uint32_t len, int32_t *err);
63int32_t SAL_NET_Socket(int32_t af, int32_t type, int32_t protocol);
64
65int32_t SAL_NET_SockClose(int32_t sockId);
66
67int32_t SAL_NET_SetSockopt(int32_t sockId, int32_t level, int32_t name, const void *val, int32_t len);
68
69int32_t SAL_NET_GetSockopt(int32_t sockId, int32_t level, int32_t name, void *val, int32_t *len);
70
71int32_t SAL_NET_SockListen(int32_t sockId, int32_t backlog);
72
73int32_t SAL_NET_SockBind(int32_t sockId, BSL_SAL_SockAddr addr, size_t len);
74
75int32_t SAL_NET_SockConnect(int32_t sockId, BSL_SAL_SockAddr addr, size_t len);
76
77int32_t SAL_NET_SockSend(int32_t sockId, const void *msg, size_t len, int32_t flags);
78
79int32_t SAL_NET_SockRecv(int32_t sockfd, void *buff, size_t len, int32_t flags);
80
81int32_t SAL_NET_Select(int32_t nfds, void *readfds, void *writefds, void *exceptfds, void *timeout);
82
83int32_t SAL_NET_Ioctlsocket(int32_t sockId, long cmd, unsigned long *arg);
84
85int32_t SAL_NET_SockGetErrno(void);
86
87int32_t SAL_NET_Sendto(int32_t sock, const void *buf, size_t len, int32_t flags, void *address, int32_t addrLen,
88 int32_t *err);
89int32_t SAL_NET_Recvfrom(int32_t sock, void *buf, size_t len, int32_t flags, void *address, int32_t *addrLen,
90 int32_t *err);
91
92#endif
93
94int32_t SAL_NetCallBack_Ctrl(BSL_SAL_CB_FUNC_TYPE type, void *funcCb);
95#ifdef __cplusplus
96}
97#endif // __cplusplus
98
99#endif // HITLS_BSL_SAL_NET
100#endif // SAL_NETIMPL_H
void(* BslSalSockAddrCopy)(BSL_SAL_SockAddr dst, const BSL_SAL_SockAddr src)
Copy the BSL_SAL_SockAddr address.
定义 bsl_sal.h:843
int32_t(* BslSalSockListen)(int32_t sockId, int32_t backlog)
Listen socket.
定义 bsl_sal.h:1247
int32_t(* BslSalNetRead)(int32_t fd, void *buf, uint32_t len, int32_t *err)
Read data from file descriptor.
定义 bsl_sal.h:1104
int32_t(* BslSalSockBind)(int32_t sockId, BSL_SAL_SockAddr addr, size_t len)
Binding a socket.
定义 bsl_sal.h:1263
int32_t(* BslSalSocket)(int32_t af, int32_t type, int32_t protocol)
Socket creation interface.
定义 bsl_sal.h:1165
int32_t(* BslSalNetRecvFrom)(int32_t sock, void *buf, size_t len, int32_t flags, void *address, int32_t *addrLen, int32_t *err)
Same as linux function "recvfrom"
定义 bsl_sal.h:1372
int32_t(* BslSalSockAddrNew)(BSL_SAL_SockAddr *sockAddr)
Create a BSL_SAL_SockAddr
定义 bsl_sal.h:773
int32_t(* BslGetErrno)(void)
return "errno"
定义 bsl_sal.h:1419
int32_t(* BslSalSetSockopt)(int32_t sockId, int32_t level, int32_t name, const void *val, int32_t len)
Set the socket.
定义 bsl_sal.h:1197
int32_t(* BslSalNetWrite)(int32_t fd, const void *buf, uint32_t len, int32_t *err)
Write data to file descriptor.
定义 bsl_sal.h:1086
int32_t(* BslSalSockAddrGetFamily)(const BSL_SAL_SockAddr sockAddr)
Obtain the UIO_Addr protocal family
定义 bsl_sal.h:824
int32_t(* BslSelect)(int32_t nfds, void *readfds, void *writefds, void *exceptfds, void *timeout)
Same as linux function "select"
定义 bsl_sal.h:1391
int32_t(* BslSalSockRecv)(int32_t sockfd, void *buff, size_t len, int32_t flags)
Receive the message
定义 bsl_sal.h:1331
int32_t(* BslIoctlSocket)(int32_t sockId, long cmd, unsigned long *arg)
Same as linux function "ioctl"
定义 bsl_sal.h:1407
int32_t(* BslSalSockClose)(int32_t sockId)
Socket close interface.
定义 bsl_sal.h:1179
int32_t(* BslSalGetSockopt)(int32_t sockId, int32_t level, int32_t name, void *val, int32_t *len)
Get socket.
定义 bsl_sal.h:1215
int32_t(* BslSalNetSendTo)(int32_t sock, const void *buf, size_t len, int32_t flags, void *address, int32_t addrLen, int32_t *err)
Same as linux function "sendto"
定义 bsl_sal.h:1351
int32_t(* BslSalSockSend)(int32_t sockId, const void *msg, size_t len, int32_t flags)
Send a message.
定义 bsl_sal.h:1313
uint32_t(* BslSalSockAddrSize)(const BSL_SAL_SockAddr sockAddr)
Obtain the size of the BSL_SAL_SockAddr address.
定义 bsl_sal.h:834
void(* BslSalSockAddrFree)(BSL_SAL_SockAddr sockAddr)
Release the UIO_Addr object.
定义 bsl_sal.h:781
int32_t(* BslSalSockConnect)(int32_t sockId, BSL_SAL_SockAddr addr, size_t len)
Initiate a connection.
定义 bsl_sal.h:1279