Merge 63d25d3ad040207b3cebd2f7da175005d9eec819 into 03e1438089654fb884ac48e0f3cd0049cfe2c102

This commit is contained in:
Deomid Ryabkov 2026-10-27 10:46:09 -04:00 committed by GitHub
commit ffd0d295da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,2 @@
Features
* Add lwIP implementation of x509_inet_pton_ipv4/6.

View File

@ -2689,7 +2689,44 @@ find_parent:
#if __has_include(<arpa/inet.h>)
#include <arpa/inet.h>
#endif
#if __has_include("lwip/ip_addr.h")
#define MBEDTLS_LWIP_INET_PTON
#endif
#endif
#if defined(MBEDTLS_LWIP_INET_PTON)
#include "lwip/ip_addr.h"
static int x509_inet_pton_ipv6(const char *src, void *dst)
{
int ret = -1;
#if LWIP_IPV6
ip6_addr_t addr;
if (ip6addr_aton(src, &addr)) {
memcpy(dst, &addr.addr, sizeof(addr.addr));
ret = 0;
}
#else
(void) src;
(void) dst;
#endif
return ret;
}
static int x509_inet_pton_ipv4(const char *src, void *dst)
{
int ret = -1;
#if LWIP_IPV4
if (ip4addr_aton(src, (ip4_addr_t *) dst)) {
ret = 0;
}
#else
(void) src;
(void) dst;
#endif
return ret;
}
/* Use whether or not AF_INET6 is defined to indicate whether or not to use
* the platform inet_pton() or a local implementation (below). The local
@ -2703,7 +2740,7 @@ find_parent:
* provided by headers included (or not) via __has_include() above.
* MBEDTLS_TEST_SW_INET_PTON is a bypass define to force testing of this code //no-check-names
* despite having a platform that has inet_pton. */
#if !defined(AF_INET6) || defined(MBEDTLS_TEST_SW_INET_PTON) //no-check-names
#elif !defined(AF_INET6) || defined(MBEDTLS_TEST_SW_INET_PTON) //no-check-names
/* Definition located further below to possibly reduce compiler inlining */
static int x509_inet_pton_ipv4(const char *src, void *dst);