diff --git a/components/lwip/include/lwip/netdb.h b/components/lwip/include/lwip/netdb.h index 8a9ec4d3164..6fabf707aa3 100644 --- a/components/lwip/include/lwip/netdb.h +++ b/components/lwip/include/lwip/netdb.h @@ -16,6 +16,22 @@ extern "C" { #endif +#if LWIP_NETDB_HAS_GAI_STRERROR +/** + * @brief If `LWIP_NETDB_HAS_GAI_STRERROR=1` lwip can declare gai_strerror() + * since it will be defined in en external dependency of lwip + */ + +/** +* @brief Returns a string representing the `getaddrinfo()` error code. +* +* @param[in] ecode Error code returned by `getaddrinfo()`. +* +* @return A pointer to a string describing the error. +*/ +const char * gai_strerror(int ecode); +#endif + 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) diff --git a/components/lwip/include/lwip/sockets.h b/components/lwip/include/lwip/sockets.h index b0f3a6febe4..12625ddfb36 100644 --- a/components/lwip/include/lwip/sockets.h +++ b/components/lwip/include/lwip/sockets.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,6 +12,28 @@ extern "C" { #endif +#if LWIP_SOCKET_HAS_SOCKETPAIR +/** + * @brief If `LWIP_SOCKET_HAS_SOCKETPAIR=1` lwip can declare socketpair() + * since it will be defined in en external dependency of lwip + */ +#define AF_UNIX 1 +#define PF_LOCAL AF_UNIX +/** + * @brief Creates a pair of connected sockets. + * + * @param[in] domain Communication domain (e.g., PF_LOCAL). + * @param[in] type Socket type (e.g., SOCK_STREAM). + * @param[in] protocol Protocol to be used (usually 0). + * @param[out] sv Array of two integers to store the file descriptors of the created sockets. + * + * @return + * - 0 on success. + * - -1 on failure, with `errno` set to indicate the error. + */ +int socketpair(int domain, int type, int protocol, int sv[2]); +#endif + 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) @@ -42,8 +64,8 @@ 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 ssize_t sendto(int s,const void *dataptr,size_t size,int flags,const struct sockaddr *to,socklen_t to_len) +{ return lwip_sendto(s,dataptr,size,flags,to,to_len); } 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)