Merge branch 'feat/lwip_extern_decl_sockutls' into 'master'

feat(lwip): Declare additional POSIX API if available

Closes IDFGH-14028 and IDFGH-12794

See merge request espressif/esp-idf!35683
This commit is contained in:
David Čermák
2024-12-19 18:14:17 +08:00
3 changed files with 51 additions and 3 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -455,3 +455,13 @@
-
re: "Configuration descriptor larger than control transfer max length"
hint: "Connected USB device has a large Configuration descriptor.\nTo increase the transfer size, go to 'idf.py menuconfig' -> 'Component config' -> 'USB-OTG' -> 'Largest size of transfers to/from default endpoints' and set appropriate size."
-
re: "error: implicit declaration of function '(socketpair|gai_strerror|getifaddrs|freeifaddrs)'"
hint: "{}() is not supported in IDF.\nTo use a simplified implementation of this function, add a dependency to sock_utils library 'idf.py add-dependency espressif/sock_utils'"
match_to_output: True
-
re: "undefined reference to `(socketpair|gai_strerror|gethostname|getnameinfo|pipe|getifaddrs|freeifaddrs)'"
hint: "{}() is not supported in IDF.\nTo use a simplified implementation of this function, add a dependency to sock_utils library 'idf.py add-dependency espressif/sock_utils'"
match_to_output: True