2015-05-01 16:19:52 +08:00
|
|
|
/*
|
2021-03-08 18:19:04 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2015-05-01 16:19:52 +08:00
|
|
|
*
|
2018-10-15 01:23:33 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-05-01 16:19:52 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2015-02-17 Bernard First version
|
2018-07-17 20:29:33 +08:00
|
|
|
* 2018-05-17 ChenYong Add socket abstraction layer
|
2015-05-01 16:19:52 +08:00
|
|
|
*/
|
|
|
|
|
2018-07-17 20:29:33 +08:00
|
|
|
#ifndef SYS_SOCKET_H_
|
|
|
|
#define SYS_SOCKET_H_
|
|
|
|
|
2018-08-27 19:50:37 +08:00
|
|
|
#include <rtthread.h>
|
2018-07-17 20:29:33 +08:00
|
|
|
#include <sal_socket.h>
|
2018-11-15 14:39:31 +08:00
|
|
|
#ifdef SAL_USING_TLS
|
|
|
|
#include <sal_tls.h>
|
|
|
|
#endif
|
2015-05-01 16:19:52 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-08-27 19:50:37 +08:00
|
|
|
#ifdef SAL_USING_POSIX
|
2015-05-01 16:19:52 +08:00
|
|
|
int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
|
|
|
|
int bind(int s, const struct sockaddr *name, socklen_t namelen);
|
|
|
|
int shutdown(int s, int how);
|
2018-08-27 19:50:37 +08:00
|
|
|
int getpeername(int s, struct sockaddr *name, socklen_t *namelen);
|
|
|
|
int getsockname(int s, struct sockaddr *name, socklen_t *namelen);
|
|
|
|
int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
|
|
|
|
int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);
|
2015-05-01 16:19:52 +08:00
|
|
|
int connect(int s, const struct sockaddr *name, socklen_t namelen);
|
|
|
|
int listen(int s, int backlog);
|
|
|
|
int recv(int s, void *mem, size_t len, int flags);
|
|
|
|
int recvfrom(int s, void *mem, size_t len, int flags,
|
|
|
|
struct sockaddr *from, socklen_t *fromlen);
|
|
|
|
int send(int s, const void *dataptr, size_t size, int flags);
|
|
|
|
int sendto(int s, const void *dataptr, size_t size, int flags,
|
|
|
|
const struct sockaddr *to, socklen_t tolen);
|
|
|
|
int socket(int domain, int type, int protocol);
|
2017-10-15 22:44:53 +08:00
|
|
|
int closesocket(int s);
|
|
|
|
int ioctlsocket(int s, long cmd, void *arg);
|
2018-08-27 19:50:37 +08:00
|
|
|
#else
|
|
|
|
#define accept(s, addr, addrlen) sal_accept(s, addr, addrlen)
|
|
|
|
#define bind(s, name, namelen) sal_bind(s, name, namelen)
|
|
|
|
#define shutdown(s, how) sal_shutdown(s, how)
|
|
|
|
#define getpeername(s, name, namelen) sal_getpeername(s, name, namelen)
|
|
|
|
#define getsockname(s, name, namelen) sal_getsockname(s, name, namelen)
|
|
|
|
#define getsockopt(s, level, optname, optval, optlen) sal_getsockopt(s, level, optname, optval, optlen)
|
|
|
|
#define setsockopt(s, level, optname, optval, optlen) sal_setsockopt(s, level, optname, optval, optlen)
|
|
|
|
#define connect(s, name, namelen) sal_connect(s, name, namelen)
|
|
|
|
#define listen(s, backlog) sal_listen(s, backlog)
|
|
|
|
#define recv(s, mem, len, flags) sal_recvfrom(s, mem, len, flags, NULL, NULL)
|
|
|
|
#define recvfrom(s, mem, len, flags, from, fromlen) sal_recvfrom(s, mem, len, flags, from, fromlen)
|
|
|
|
#define send(s, dataptr, size, flags) sal_sendto(s, dataptr, size, flags, NULL, NULL)
|
|
|
|
#define sendto(s, dataptr, size, flags, to, tolen) sal_sendto(s, dataptr, size, flags, to, tolen)
|
|
|
|
#define socket(domain, type, protocol) sal_socket(domain, type, protocol)
|
|
|
|
#define closesocket(s) sal_closesocket(s)
|
|
|
|
#define ioctlsocket(s, cmd, arg) sal_ioctlsocket(s, cmd, arg)
|
|
|
|
#endif /* SAL_USING_POSIX */
|
2015-05-01 16:19:52 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-07-17 20:29:33 +08:00
|
|
|
#endif /* _SYS_SOCKET_H_ */
|