mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-15 19:34:03 +00:00
lwip: Update socket API to include port-version of sockets/netdb
Added socket extention to the lwip hooks for implementing non-vanilla
{get/set}sockopts()
This commit is contained in:
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "sys/poll.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "netdb.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG) || defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
|
||||
|
||||
// lwIP's socket API is mostly implemented as macros,
|
||||
// but ASIO uses the same symbols in different namespaces, where macros wouldn't work.
|
||||
// Here we have to undefined the symbols for ASIO build and declare as standard functions
|
||||
#undef getaddrinfo
|
||||
#undef gethostbyname_r
|
||||
#undef gethostbyname
|
||||
#undef freeaddrinfo
|
||||
#undef accept
|
||||
#undef bind
|
||||
#undef shutdown
|
||||
#undef getpeername
|
||||
#undef getsockname
|
||||
#undef setsockopt
|
||||
#undef setsockopt
|
||||
#undef getsockopt
|
||||
#undef closesocket
|
||||
#undef connect
|
||||
#undef listen
|
||||
#undef recvmsg
|
||||
#undef recv
|
||||
#undef recvfrom
|
||||
#undef sendmsg
|
||||
#undef send
|
||||
#undef sendto
|
||||
#undef socket
|
||||
#undef inet_ntop
|
||||
#undef inet_pton
|
||||
#undef poll
|
||||
#undef select
|
||||
|
||||
static inline int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
|
||||
{ return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop); }
|
||||
static inline struct hostent *gethostbyname(const char *name)
|
||||
{ return lwip_gethostbyname(name); }
|
||||
static inline void freeaddrinfo(struct addrinfo *ai)
|
||||
{ lwip_freeaddrinfo(ai); }
|
||||
static inline int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
|
||||
{ return lwip_getaddrinfo(nodename, servname, hints, res); }
|
||||
static inline int accept(int s,struct sockaddr *addr,socklen_t *addrlen)
|
||||
{ return lwip_accept(s,addr,addrlen); }
|
||||
static inline int bind(int s,const struct sockaddr *name, socklen_t namelen)
|
||||
{ return lwip_bind(s,name,namelen); }
|
||||
static inline int shutdown(int s,int how)
|
||||
{ return lwip_shutdown(s,how); }
|
||||
static inline int getpeername(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getpeername(s,name,namelen); }
|
||||
static inline int getsockname(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getsockname(s,name,namelen); }
|
||||
static inline int setsockopt(int s,int level,int optname,const void *opval,socklen_t optlen)
|
||||
{ return lwip_setsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int getsockopt(int s,int level,int optname,void *opval,socklen_t *optlen)
|
||||
{ return lwip_getsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int closesocket(int s)
|
||||
{ return lwip_close(s); }
|
||||
static inline int connect(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_connect(s,name,namelen); }
|
||||
static inline int listen(int s,int backlog)
|
||||
{ return lwip_listen(s,backlog); }
|
||||
static inline ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
|
||||
{ return lwip_recvmsg(sockfd, msg, flags); }
|
||||
static inline ssize_t recv(int s,void *mem,size_t len,int flags)
|
||||
{ return lwip_recv(s,mem,len,flags); }
|
||||
static inline ssize_t recvfrom(int s,void *mem,size_t len,int flags,struct sockaddr *from,socklen_t *fromlen)
|
||||
{ return lwip_recvfrom(s,mem,len,flags,from,fromlen); }
|
||||
static inline ssize_t send(int s,const void *dataptr,size_t size,int flags)
|
||||
{ return lwip_send(s,dataptr,size,flags); }
|
||||
static inline ssize_t sendmsg(int s,const struct msghdr *message,int flags)
|
||||
{ return lwip_sendmsg(s,message,flags); }
|
||||
static inline ssize_t sendto(int s,const void *dataptr,size_t size,int flags,const struct sockaddr *to,socklen_t tolen)
|
||||
{ return lwip_sendto(s,dataptr,size,flags,to,tolen); }
|
||||
static inline int socket(int domain,int type,int protocol)
|
||||
{ return lwip_socket(domain,type,protocol); }
|
||||
static inline const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
|
||||
{ return lwip_inet_ntop(af, src, dst, size); }
|
||||
static inline int inet_pton(int af, const char *src, void *dst)
|
||||
{ return lwip_inet_pton(af, src, dst); }
|
||||
#endif // CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG || CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -804,7 +804,7 @@
|
||||
* While this helps code completion, it might conflict with existing libraries.
|
||||
* (only used if you use sockets.c)
|
||||
*/
|
||||
#define LWIP_COMPAT_SOCKETS 1
|
||||
#define LWIP_COMPAT_SOCKETS 0
|
||||
|
||||
/**
|
||||
* LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names.
|
||||
|
||||
24
components/lwip/port/esp32/include/sockets_ext.h
Normal file
24
components/lwip/port/esp32/include/sockets_ext.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IPV6_MULTICAST_IF 0x300
|
||||
#define IPV6_MULTICAST_HOPS 0x301
|
||||
#define IPV6_MULTICAST_LOOP 0x302
|
||||
|
||||
struct lwip_sock;
|
||||
|
||||
bool lwip_setsockopt_impl_ext(struct lwip_sock* sock, int level, int optname, const void *optval, uint32_t optlen, int *err);
|
||||
bool lwip_getsockopt_impl_ext(struct lwip_sock* sock, int level, int optname, void *optval, uint32_t *optlen, int *err);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -30,7 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "esp_cpp_sockets.h"
|
||||
#include "lwip/sockets.h"
|
||||
/*
|
||||
SOMAXCONN is expected to be found in this header too,
|
||||
|
||||
Reference in New Issue
Block a user