esp-tls: Fix esp-tls component to resolve esp_http_client example failure for Linux target.

esp_http_client does not use lwip component when building for linux target. Using lwip configs directly in esp-tls caused the test failures
pull/10982/head
Harshit Malpani 2023-03-03 10:20:49 +05:30
rodzic fc9538c63d
commit 866e6b0d6b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: FF1193D150EF75C3
1 zmienionych plików z 21 dodań i 4 usunięć

Wyświetl plik

@ -13,6 +13,7 @@
#include <netdb.h>
#include <http_parser.h>
#include "sdkconfig.h"
#include "esp_tls.h"
#include "esp_tls_private.h"
#include "esp_tls_error_capture_internal.h"
@ -25,8 +26,16 @@
#include <linux/if.h>
#include <sys/time.h>
#define ipaddr_ntoa(ipaddr) inet_ntoa(*ipaddr)
typedef struct in_addr ip_addr_t;
typedef struct in6_addr ip6_addr_t;
#define ipaddr_ntoa(ipaddr) inet_ntoa(*ipaddr)
static inline char *ip6addr_ntoa(const ip6_addr_t *addr)
{
static char str[40];
return (char *)inet_ntop(AF_INET6, addr->s6_addr, str, 40);
}
#endif
static const char *TAG = "esp-tls";
@ -85,6 +94,14 @@ static const char *TAG = "esp-tls";
#error "No TLS stack configured"
#endif
#if CONFIG_IDF_TARGET_LINUX
#define IPV4_ENABLED 1
#define IPV6_ENABLED 1
#else // CONFIG_IDF_TARGET_LINUX
#define IPV4_ENABLED CONFIG_LWIP_IPV4
#define IPV6_ENABLED CONFIG_LWIP_IPV6
#endif // !CONFIG_IDF_TARGET_LINUX
#define ESP_TLS_DEFAULT_CONN_TIMEOUT (10) /*!< Default connection timeout in seconds */
static esp_err_t create_ssl_handle(const char *hostname, size_t hostlen, const void *cfg, esp_tls_t *tls)
@ -182,7 +199,7 @@ static esp_err_t esp_tls_hostname_to_fd(const char *host, size_t hostlen, int po
return ESP_ERR_ESP_TLS_CANNOT_CREATE_SOCKET;
}
#if CONFIG_LWIP_IPV4
#if IPV4_ENABLED
if (address_info->ai_family == AF_INET) {
struct sockaddr_in *p = (struct sockaddr_in *)address_info->ai_addr;
p->sin_port = htons(port);
@ -191,11 +208,11 @@ static esp_err_t esp_tls_hostname_to_fd(const char *host, size_t hostlen, int po
}
#endif
#if defined(CONFIG_LWIP_IPV4) && defined(CONFIG_LWIP_IPV6)
#if IPV4_ENABLED && IPV6_ENABLED
else
#endif
#if CONFIG_LWIP_IPV6
#if IPV6_ENABLED
if (address_info->ai_family == AF_INET6) {
struct sockaddr_in6 *p = (struct sockaddr_in6 *)address_info->ai_addr;
p->sin6_port = htons(port);