esp-idf/components/lwip/port/linux/vfs_lwip.c
David Cermak b2af4d9689 lwip/linux: Add lwip support for networking component under linux
linux/lwip: Wrap some IO posix functions
* to workaourd the FreeRTOS EINTR issue (when building without lwip)
* to correctly choose the sub-system based on fd (when building with
lwip) -- passing control to either linux/system or to lwip
This commit also addapts tapio-if to provide DHCP client by default and
configurable settings for static IP
2023-05-05 05:03:39 +00:00

66 lines
1.6 KiB
C

/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/socket.h>
#include <stdarg.h>
extern int __real_fcntl(int s, int cmd, ...);
extern int __real_close(int s);
extern ssize_t __real_write (int fd, const void *buf, size_t n);
extern ssize_t __real_read (int fd, void *buf, size_t n);
extern int __real_select (int fd, fd_set * rfds, fd_set * wfds, fd_set *efds, struct timeval *tval);
ssize_t __wrap_write (int fd, const void *buf, size_t n)
{
#ifdef CONFIG_LWIP_MAX_SOCKETS
if (fd >= LWIP_SOCKET_OFFSET)
return lwip_write(fd, buf, n);
#endif
return __real_write(fd, buf, n);
}
ssize_t __wrap_read (int fd, void *buf, size_t n)
{
#ifdef CONFIG_LWIP_MAX_SOCKETS
if (fd >= LWIP_SOCKET_OFFSET)
return lwip_read(fd, buf, n);
#endif
return __real_read(fd, buf, n);
}
int __wrap_select (int fd, fd_set * rds, fd_set * wfds, fd_set *efds, struct timeval *tval)
{
#ifdef CONFIG_LWIP_MAX_SOCKETS
if (fd >= LWIP_SOCKET_OFFSET)
return lwip_select(fd, rds, wfds, efds, tval);
#endif
return __real_select(fd, rds, wfds, efds, tval);
}
int __wrap_fcntl(int fd, int cmd, ...)
{
va_list args;
#ifdef CONFIG_LWIP_MAX_SOCKETS
if (fd >= LWIP_SOCKET_OFFSET) {
va_start(args, cmd);
int arg = va_arg(args, int);
va_end(args);
return lwip_fcntl(fd, cmd, arg);
}
#endif
return __real_fcntl(fd, cmd, args);
}
int __wrap_close(int fd)
{
#ifdef CONFIG_LWIP_MAX_SOCKETS
if (fd >= LWIP_SOCKET_OFFSET)
return lwip_close(fd);
#endif
return __real_close(fd);
}