diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index a95771bed..5a1a616c6 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -55,6 +55,20 @@ config USE_ONLY_LWIP_SELECT will be redirected to lwip_select(), therefore, select can be used for sockets only. +config LWIP_SO_LINGER + bool "Enable SO_LINGER processing" + default n + help + Enabling this option allows SO_LINGER processing. + l_onoff = 1,l_linger can set the timeout. + + If l_linger=0, When a connection is closed, TCP will terminate the connection. + This means that TCP will discard any data packets stored in the socket send buffer + and send an RST to the peer. + + If l_linger!=0,Then closesocket() calls to block the process until + the remaining data packets has been sent or timed out. + config LWIP_SO_REUSE bool "Enable SO_REUSEADDR option" default y @@ -91,18 +105,31 @@ config LWIP_DHCP_MAX_NTP_SERVERS First argument of sntp_setserver/sntp_setservername functions is limited to this value. -config LWIP_IP_FRAG - bool "Enable fragment outgoing IP packets" +config LWIP_IP4_FRAG + bool "Enable fragment outgoing IP4 packets" default y help - Enabling this option allows fragmenting outgoing IP packets if their size + Enabling this option allows fragmenting outgoing IP4 packets if their size exceeds MTU. -config LWIP_IP_REASSEMBLY - bool "Enable reassembly incoming fragmented IP packets" +config LWIP_IP6_FRAG + bool "Enable fragment outgoing IP6 packets" + default y + help + Enabling this option allows fragmenting outgoing IP6 packets if their size + exceeds MTU. + +config LWIP_IP4_REASSEMBLY + bool "Enable reassembly incoming fragmented IP4 packets" default n help - Enabling this option allows reassemblying incoming fragmented IP packets. + Enabling this option allows reassemblying incoming fragmented IP4 packets. + +config LWIP_IP6_REASSEMBLY + bool "Enable reassembly incoming fragmented IP6 packets" + default n + help + Enabling this option allows reassemblying incoming fragmented IP6 packets. config LWIP_STATS bool "Enable LWIP statistics" diff --git a/components/lwip/lwip b/components/lwip/lwip index f02243aa5..e4503a79c 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit f02243aa5f04f6e453e83ecad4700691b9f919d0 +Subproject commit e4503a79cc62b6912467e22fc3603b1b1cb06d49 diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index aabd24fcf..642ab7334 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -157,18 +157,32 @@ -------------------------------- */ /** - * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that + * IP_REASSEMBLY==1: Reassemble incoming fragmented IP4 packets. Note that * this option does not affect outgoing packet sizes, which can be controlled * via IP_FRAG. */ -#define IP_REASSEMBLY CONFIG_LWIP_IP_REASSEMBLY +#define IP_REASSEMBLY CONFIG_LWIP_IP4_REASSEMBLY /** - * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note + * LWIP_IPV6_REASS==1: reassemble incoming IP6 packets that fragmented. Note that + * this option does not affect outgoing packet sizes, which can be controlled + * via LWIP_IPV6_FRAG. + */ +#define LWIP_IPV6_REASS CONFIG_LWIP_IP6_REASSEMBLY + +/** + * IP_FRAG==1: Fragment outgoing IP4 packets if their size exceeds MTU. Note * that this option does not affect incoming packet sizes, which can be * controlled via IP_REASSEMBLY. */ -#define IP_FRAG CONFIG_LWIP_IP_FRAG +#define IP_FRAG CONFIG_LWIP_IP4_FRAG + +/** + * LWIP_IPV6_FRAG==1: Fragment outgoing IP6 packets if their size exceeds MTU. Note + * that this option does not affect incoming packet sizes, which can be + * controlled via IP_REASSEMBLY. + */ +#define LWIP_IPV6_FRAG CONFIG_LWIP_IP6_FRAG /** * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) @@ -551,6 +565,11 @@ */ #define LWIP_TCP_KEEPALIVE 1 +/** + * LWIP_SO_LINGER==1: Enable SO_LINGER processing. + */ +#define LWIP_SO_LINGER CONFIG_LWIP_SO_LINGER + /** * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing. */ @@ -767,6 +786,7 @@ #define ESP_LWIP 1 #define ESP_LWIP_ARP 1 +#define ESP_IPV6 1 #define ESP_PER_SOC_TCP_WND 0 #define ESP_THREAD_SAFE 1 #define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF diff --git a/components/lwip/port/esp32/netif/wlanif.c b/components/lwip/port/esp32/netif/wlanif.c index 7c60b6934..ed5e13ed1 100644 --- a/components/lwip/port/esp32/netif/wlanif.c +++ b/components/lwip/port/esp32/netif/wlanif.c @@ -81,6 +81,12 @@ low_level_init(struct netif *netif) #endif #endif +#if ESP_IPV6 +#if LWIP_IPV6 && LWIP_IPV6_MLD + netif->flags |= NETIF_FLAG_MLD6; +#endif +#endif + #if !ESP_L2_TO_L3_COPY netif->l2_buffer_free_notify = esp_wifi_internal_free_rx_buffer; #endif diff --git a/components/tcp_transport/transport_tcp.c b/components/tcp_transport/transport_tcp.c index 9ccc79c5f..8bd429eab 100644 --- a/components/tcp_transport/transport_tcp.c +++ b/components/tcp_transport/transport_tcp.c @@ -34,18 +34,20 @@ typedef struct { static int resolve_dns(const char *host, struct sockaddr_in *ip) { - struct hostent *he; - struct in_addr **addr_list; - he = gethostbyname(host); - if (he == NULL) { - return ESP_FAIL; - } - addr_list = (struct in_addr **)he->h_addr_list; - if (addr_list[0] == NULL) { + const struct addrinfo hints = { + .ai_family = AF_INET, + .ai_socktype = SOCK_STREAM, + }; + struct addrinfo *res; + + int err = getaddrinfo(host, NULL, &hints, &res); + if(err != 0 || res == NULL) { + ESP_LOGE(TAG, "DNS lookup failed err=%d res=%p", err, res); return ESP_FAIL; } ip->sin_family = AF_INET; - memcpy(&ip->sin_addr, addr_list[0], sizeof(ip->sin_addr)); + memcpy(&ip->sin_addr, &((struct sockaddr_in *)(res->ai_addr))->sin_addr, sizeof(ip->sin_addr)); + freeaddrinfo(res); return ESP_OK; }