1#ifndef __VSF_LINUX_SYS_SOCKET_H__
2#define __VSF_LINUX_SYS_SOCKET_H__
6#if VSF_LINUX_CFG_RELATIVE_PATH == ENABLED
7# include "../sys/types.h"
20#define SCM_RIGHTS 0x01
21#define SCM_CREDENTIALS 0x02
22#define SCM_SECURITY 0x03
28#define PF_UNIX PF_LOCAL
35#define AF_UNSPEC PF_UNSPEC
36#define AF_LOCAL PF_LOCAL
37#define AF_UNIX PF_UNIX
38#define AF_FILE PF_FILE
39#define AF_INET PF_INET
40#define AF_INET6 PF_INET6
41#define AF_NETLINK PF_NETLINK
42#define AF_PACKET PF_PACKET
44#define SOL_IP IPPROTO_IP
45#define SOL_TCP IPPROTO_TCP
46#define SOL_UDP IPPROTO_UDP
61#define SOCK_MAX (SOCK_PACKET + 1)
64#define SOCK_CLOEXEC O_CLOEXEC
65#define SOCK_NONBLOCK O_NONBLOCK
67#define INVALID_SOCKET -1
68#define SOCKET_ERROR -1
71#define __socklen_t_defined
89#if VSF_LINUX_SOCKET_CFG_WRAPPER == ENABLED
90#define VSF_LINUX_SOCKET_WRAPPER(__api) VSF_SHELL_WRAPPER(vsf_linux_socket, __api)
92#define setsockopt VSF_LINUX_SOCKET_WRAPPER(setsockopt)
93#define getsockopt VSF_LINUX_SOCKET_WRAPPER(getsockopt)
95#define getpeername VSF_LINUX_SOCKET_WRAPPER(getpeername)
96#define getsockname VSF_LINUX_SOCKET_WRAPPER(getsockname)
98#define accept VSF_LINUX_SOCKET_WRAPPER(accept)
99#define accept4 VSF_LINUX_SOCKET_WRAPPER(accept4)
100#define bind VSF_LINUX_SOCKET_WRAPPER(bind)
101#define connect VSF_LINUX_SOCKET_WRAPPER(connect)
102#define listen VSF_LINUX_SOCKET_WRAPPER(listen)
103#define recv VSF_LINUX_SOCKET_WRAPPER(recv)
104#define recvmsg VSF_LINUX_SOCKET_WRAPPER(recvmsg)
105#define recvfrom VSF_LINUX_SOCKET_WRAPPER(recvfrom)
106#define send VSF_LINUX_SOCKET_WRAPPER(send)
107#define sendmsg VSF_LINUX_SOCKET_WRAPPER(sendmsg)
108#define sendto VSF_LINUX_SOCKET_WRAPPER(sendto)
109#define shutdown VSF_LINUX_SOCKET_WRAPPER(shutdown)
110#define socket VSF_LINUX_SOCKET_WRAPPER(socket)
111#define socketpair VSF_LINUX_SOCKET_WRAPPER(socketpair)
116#define __NR_connect connect
117#define __NR_accept accept
118#define __NR_accept4 accept4
119#define __NR_bind bind
122#define SOL_SOCKET 0xFFFF
126#define SO_REUSEADDR 2
129#define SO_DONTROUTE 5
130#define SO_BROADCAST 6
133#define SO_KEEPALIVE 9
134#define SO_OOBINLINE 10
135#define SO_NO_CHECK 11
136#define SO_PRIORITY 12
138#define SO_BSDCOMPAT 14
139#define SO_REUSEPORT 15
143#define SO_RCVLOWAT 18
144#define SO_SNDLOWAT 19
145#define SO_RCVTIMEO 20
146#define SO_SNDTIMEO 21
147#define SO_BINDTODEVICE 25
148#define SO_MAX_PACING_RATE 47
149#define SO_NONBLOCK 100
160#define IP_MULTICAST_IF 32
161#define IP_MULTICAST_TTL 33
162#define IP_MULTICAST_LOOP 34
163#define IP_ADD_MEMBERSHIP 35
164#define IP_DROP_MEMBERSHIP 36
165#define IP_MULTICAST_ALL 49
167#define IPV6_UNICAST_HOPS 16
168#define IPV6_MULTICAST_IF 17
169#define IPV6_MULTICAST_HOPS 18
170#define IPV6_MULTICAST_LOOP 19
171#define IPV6_JOIN_GROUP 20
172#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
173#define IPV6_LEAVE_GROUP 21
174#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
175#define IPV6_V6ONLY 26
180#define MSG_OOB MSG_OOB
182#define MSG_PEEK MSG_PEEK
184#define MSG_DONTROUTE MSG_DONTROUTE
186#define MSG_CTRUNC MSG_CTRUNC
188#define MSG_TRUNC MSG_TRUNC
190#define MSG_DONTWAIT MSG_DONTWAIT
192#define MSG_WAITALL MSG_WAITALL
194#define MSG_NOSIGNAL MSG_NOSIGNAL
207#define CMSG_ALIGN(len) (((len)+sizeof(long)-1) & ~(sizeof(long)-1))
208#define CMSG_SPACE(len) (sizeof(struct cmsghdr) + CMSG_ALIGN(len))
209#define CMSG_LEN(len) (sizeof(struct cmsghdr) + (len))
210#define CMSG_DATA(cmsg) (void *)((uint8_t *)(cmsg) + sizeof(struct cmsghdr))
211#define CMSG_FIRSTHDR(msg) \
212 ((msg)->msg_controllen >= sizeof(struct cmsghdr) ? \
213 (struct cmsghdr *)(msg)->msg_control \
214 : (struct cmsghdr *)NULL)
221#if __IS_COMPILER_GCC__
222# pragma GCC diagnostic push
223# pragma GCC diagnostic ignored "-Wcast-align"
224#elif __IS_COMPILER_LLVM__ || __IS_COMPILER_ARM_COMPILER_6__
225# pragma clang diagnostic push
226# pragma clang diagnostic ignored "-Wcast-align"
240#if __IS_COMPILER_GCC__
241# pragma GCC diagnostic pop
242#elif __IS_COMPILER_LLVM__ || __IS_COMPILER_ARM_COMPILER_6__
243# pragma clang diagnostic pop
253#if VSF_LINUX_APPLET_USE_SYS_SOCKET == ENABLED
283# ifndef __VSF_APPLET__
288#if defined(__VSF_APPLET__) && (defined(__VSF_APPLET_LIB__) || defined(__VSF_APPLET_LINUX_SYS_SOCKET_LIB__))\
289 && VSF_APPLET_CFG_ABI_PATCH != ENABLED && VSF_LINUX_APPLET_USE_SYS_SOCKET == ENABLED
291#ifndef VSF_LINUX_APPLET_SYS_SOCKET_VPLT
292# if VSF_LINUX_USE_APPLET == ENABLED
293# define VSF_LINUX_APPLET_SYS_SOCKET_VPLT \
294 ((vsf_linux_sys_socket_vplt_t *)(VSF_LINUX_APPLET_VPLT->sys_socket_vplt))
296# define VSF_LINUX_APPLET_SYS_SOCKET_VPLT \
297 ((vsf_linux_sys_socket_vplt_t *)vsf_vplt((void *)0))
301#define VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(__NAME) \
302 VSF_APPLET_VPLT_ENTRY_FUNC_ENTRY(VSF_LINUX_APPLET_SYS_SOCKET_VPLT, __NAME)
303#define VSF_LINUX_APPLET_SYS_SOCKET_IMP(...) \
304 VSF_APPLET_VPLT_ENTRY_FUNC_IMP(VSF_LINUX_APPLET_SYS_SOCKET_VPLT, __VA_ARGS__)
306VSF_LINUX_APPLET_SYS_SOCKET_IMP(
setsockopt,
int,
int sockfd,
int level,
int optname,
const void *optval,
socklen_t optlen) {
308 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
setsockopt)(sockfd, level, optname, optval, optlen);
310VSF_LINUX_APPLET_SYS_SOCKET_IMP(
getsockopt,
int,
int sockfd,
int level,
int optname,
void *optval,
socklen_t *optlen) {
312 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
getsockopt)(sockfd, level, optname, optval, optlen);
316 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
getpeername)(sockfd, addr, addrlen);
320 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
getsockname)(sockfd, addr, addrlen);
324 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
accept)(sockfd, addr, addrlen);
326VSF_LINUX_APPLET_SYS_SOCKET_IMP(
bind,
int,
int sockfd,
const struct sockaddr *addr,
socklen_t addrlen) {
328 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
bind)(sockfd, addr, addrlen);
332 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
connect)(sockfd, addr, addrlen);
334VSF_LINUX_APPLET_SYS_SOCKET_IMP(
listen,
int,
int sockfd,
int backlog) {
336 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
listen)(sockfd, backlog);
338VSF_LINUX_APPLET_SYS_SOCKET_IMP(
recv,
ssize_t,
int sockfd,
void *buffer,
size_t length,
int flags) {
340 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
recv)(sockfd, buffer,
length, flags);
344 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
recvmsg)(sockfd, msg, flags);
348 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
recvfrom)(sockfd, buffer,
length, flags, src_addr, addrlen);
350VSF_LINUX_APPLET_SYS_SOCKET_IMP(
send,
ssize_t,
int sockfd,
const void *buffer,
size_t length,
int flags) {
352 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
send)(sockfd, buffer,
length, flags);
354VSF_LINUX_APPLET_SYS_SOCKET_IMP(
sendmsg,
ssize_t,
int sockfd,
const struct msghdr *msg,
int flags) {
356 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
sendmsg)(sockfd, msg, flags);
360 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
sendto)(sockfd, buffer,
length, flags, dest_addr, addrlen);
362VSF_LINUX_APPLET_SYS_SOCKET_IMP(
shutdown,
int,
int sockfd,
int how) {
364 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
shutdown)(sockfd, how);
366VSF_LINUX_APPLET_SYS_SOCKET_IMP(
socket,
int,
int domain,
int type,
int protocol) {
368 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
socket)(domain,
type, protocol);
370VSF_LINUX_APPLET_SYS_SOCKET_IMP(
socketpair,
int,
int domain,
int type,
int protocol,
int socket_vector[2]) {
372 return VSF_LINUX_APPLET_SYS_SOCKET_ENTRY(
socketpair)(domain,
type, protocol, socket_vector);
377int setsockopt(
int sockfd,
int level,
int optname,
const void *optval,
379int getsockopt(
int sockfd,
int level,
int optname,
void *optval,
389int listen(
int sockfd,
int backlog);
401int socket(
int domain,
int type,
int protocol);
402int socketpair(
int domain,
int type,
int protocol,
int socket_vector[2]);
const struct in6_addr in6addr_loopback
Definition vsf_linux_socket.c:72
const struct in6_addr in6addr_any
Definition vsf_linux_socket.c:70
int ssize_t
Definition types.h:68
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
@ SHUT_RD
Definition socket.h:248
@ SHUT_WR
Definition socket.h:249
@ SHUT_RDWR
Definition socket.h:250
sock_type
Definition socket.h:53
@ SOCK_DGRAM
Definition socket.h:55
@ SOCK_RDM
Definition socket.h:57
@ SOCK_SEQPACKET
Definition socket.h:58
@ SOCK_RAW
Definition socket.h:56
@ SOCK_PACKET
Definition socket.h:59
@ SOCK_STREAM
Definition socket.h:54
#define MSG_WAITALL
Definition socket.h:192
#define getpeername
Definition socket.h:95
uint16_t sa_family_t
Definition socket.h:73
#define listen
Definition socket.h:102
#define sendmsg
Definition socket.h:107
#define setsockopt
Definition socket.h:92
#define accept
Definition socket.h:98
#define recvfrom
Definition socket.h:105
uint32_t socklen_t
Definition socket.h:70
#define sendto
Definition socket.h:108
__VSF_VPLT_DECORATOR__ vsf_linux_sys_socket_vplt_t vsf_linux_sys_socket_vplt
Definition vsf_linux_socket.c:792
#define MSG_PEEK
Definition socket.h:182
#define recvmsg
Definition socket.h:104
#define MSG_TRUNC
Definition socket.h:188
#define getsockopt
Definition socket.h:93
#define accept4
Definition socket.h:99
#define CMSG_ALIGN(len)
Definition socket.h:207
#define MSG_DONTROUTE
Definition socket.h:184
#define MSG_OOB
Definition socket.h:180
#define MSG_NOSIGNAL
Definition socket.h:194
#define getsockname
Definition socket.h:96
#define MSG_CTRUNC
Definition socket.h:186
#define socket
Definition socket.h:110
#define MSG_DONTWAIT
Definition socket.h:190
#define socketpair
Definition socket.h:111
#define shutdown
Definition socket.h:109
#define connect
Definition socket.h:101
#define recv
Definition socket.h:103
#define bind
Definition socket.h:100
#define send
Definition socket.h:106
int cmsg_type
Definition socket.h:218
size_t cmsg_len
Definition socket.h:216
int cmsg_level
Definition socket.h:217
int l_linger
Definition socket.h:86
int l_onoff
Definition socket.h:85
struct iovec * msg_iov
Definition socket.h:200
socklen_t msg_namelen
Definition socket.h:199
void * msg_name
Definition socket.h:198
int msg_flags
Definition socket.h:204
size_t msg_controllen
Definition socket.h:203
size_t msg_iovlen
Definition socket.h:201
void * msg_control
Definition socket.h:202
sa_family_t ss_family
Definition socket.h:79
char sa_data[32]
Definition socket.h:81
char sa_data[32]
Definition socket.h:76
sa_family_t sa_family
Definition socket.h:75
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(socketpair)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(accept)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(setsockopt)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(bind)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(send)
vsf_vplt_info_t info
Definition socket.h:255
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(connect)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(recvmsg)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(shutdown)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(getsockopt)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(recv)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(getpeername)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(sendto)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(recvfrom)
VSF_APPLET_VPLT_ENTRY_VAR_DEF(in6addr_loopback)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(getsockname)
VSF_APPLET_VPLT_ENTRY_VAR_DEF(in6addr_any)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(sendmsg)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(socket)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(listen)
vk_av_control_type_t type
Definition vsf_audio.h:170
#define __VSF_VPLT_DECORATOR__
Definition vsf_cfg.h:93
#define VSF_APPLET_VPLT_ENTRY_FUNC_TRACE()
Definition vsf_cfg.h:165
uint_fast8_t length
Definition vsf_pbuf.c:38