Merge branch 'feature/add_macro_to_disable_esp_tlc_ipv6' into 'master'

Add macro to disable ipv6 configuration

See merge request sdk/ESP8266_RTOS_SDK!674
This commit is contained in:
Wu Jian Gang
2018-12-26 12:51:17 +08:00

View File

@ -23,6 +23,10 @@
#include "esp_tls.h"
#include <errno.h>
#if LWIP_IPV6
#define ESP_TLS_IPV6
#endif
static const char *TAG = "esp-tls";
static mbedtls_x509_crt *global_cacert = NULL;
@ -101,11 +105,13 @@ static int esp_tcp_connect(const char *host, int hostlen, int port, int *sockfd,
struct sockaddr_in *p = (struct sockaddr_in *)res->ai_addr;
p->sin_port = htons(port);
addr_ptr = p;
#ifdef ESP_TLS_IPV6
} else if (res->ai_family == AF_INET6) {
struct sockaddr_in6 *p = (struct sockaddr_in6 *)res->ai_addr;
p->sin6_port = htons(port);
p->sin6_family = AF_INET6;
addr_ptr = p;
#endif
} else {
ESP_LOGE(TAG, "Unsupported protocol family %d", res->ai_family);
goto err_freesocket;