backport bugfix lwip for v3.2

This commit is contained in:
xueyunfei 2020-03-19 11:24:06 +08:00
parent ce955de719
commit ebf7dd5dcc
5 changed files with 75 additions and 20 deletions

View file

@ -55,6 +55,20 @@ config USE_ONLY_LWIP_SELECT
will be redirected to lwip_select(), therefore, select can be used will be redirected to lwip_select(), therefore, select can be used
for sockets only. 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 config LWIP_SO_REUSE
bool "Enable SO_REUSEADDR option" bool "Enable SO_REUSEADDR option"
default y default y
@ -91,18 +105,31 @@ config LWIP_DHCP_MAX_NTP_SERVERS
First argument of sntp_setserver/sntp_setservername functions First argument of sntp_setserver/sntp_setservername functions
is limited to this value. is limited to this value.
config LWIP_IP_FRAG config LWIP_IP4_FRAG
bool "Enable fragment outgoing IP packets" bool "Enable fragment outgoing IP4 packets"
default y default y
help 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. exceeds MTU.
config LWIP_IP_REASSEMBLY config LWIP_IP6_FRAG
bool "Enable reassembly incoming fragmented IP packets" 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 default n
help 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 config LWIP_STATS
bool "Enable LWIP statistics" bool "Enable LWIP statistics"

@ -1 +1 @@
Subproject commit f02243aa5f04f6e453e83ecad4700691b9f919d0 Subproject commit e4503a79cc62b6912467e22fc3603b1b1cb06d49

View file

@ -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 * this option does not affect outgoing packet sizes, which can be controlled
* via IP_FRAG. * 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 * that this option does not affect incoming packet sizes, which can be
* controlled via IP_REASSEMBLY. * 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) * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
@ -551,6 +565,11 @@
*/ */
#define LWIP_TCP_KEEPALIVE 1 #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. * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
*/ */
@ -767,6 +786,7 @@
#define ESP_LWIP 1 #define ESP_LWIP 1
#define ESP_LWIP_ARP 1 #define ESP_LWIP_ARP 1
#define ESP_IPV6 1
#define ESP_PER_SOC_TCP_WND 0 #define ESP_PER_SOC_TCP_WND 0
#define ESP_THREAD_SAFE 1 #define ESP_THREAD_SAFE 1
#define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF #define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF

View file

@ -81,6 +81,12 @@ low_level_init(struct netif *netif)
#endif #endif
#endif #endif
#if ESP_IPV6
#if LWIP_IPV6 && LWIP_IPV6_MLD
netif->flags |= NETIF_FLAG_MLD6;
#endif
#endif
#if !ESP_L2_TO_L3_COPY #if !ESP_L2_TO_L3_COPY
netif->l2_buffer_free_notify = esp_wifi_internal_free_rx_buffer; netif->l2_buffer_free_notify = esp_wifi_internal_free_rx_buffer;
#endif #endif

View file

@ -34,18 +34,20 @@ typedef struct {
static int resolve_dns(const char *host, struct sockaddr_in *ip) { static int resolve_dns(const char *host, struct sockaddr_in *ip) {
struct hostent *he; const struct addrinfo hints = {
struct in_addr **addr_list; .ai_family = AF_INET,
he = gethostbyname(host); .ai_socktype = SOCK_STREAM,
if (he == NULL) { };
return ESP_FAIL; struct addrinfo *res;
}
addr_list = (struct in_addr **)he->h_addr_list; int err = getaddrinfo(host, NULL, &hints, &res);
if (addr_list[0] == NULL) { if(err != 0 || res == NULL) {
ESP_LOGE(TAG, "DNS lookup failed err=%d res=%p", err, res);
return ESP_FAIL; return ESP_FAIL;
} }
ip->sin_family = AF_INET; 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; return ESP_OK;
} }