mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-26 20:53:11 +00:00
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
This commit is contained in:
committed by
David Čermák
parent
0bfffa0160
commit
b2af4d9689
65
components/lwip/port/linux/vfs_lwip.c
Normal file
65
components/lwip/port/linux/vfs_lwip.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user