From cfc52bacbc3ecc25c94157b37f2ef766fb8503ce Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 17 Sep 2021 12:36:16 +0200 Subject: [PATCH 1/6] lwip: Cleanup lwipopts flags and options * Removed unused and flags * Fixed comments * Order of flags lwip/esp-specific * Used 1/0 logic for boolean flags --- components/lwip/Kconfig | 49 +- components/lwip/port/esp32/include/lwipopts.h | 817 ++++++++++++------ components/lwip/port/esp32/netif/wlanif.c | 12 +- components/lwip/sdkconfig.rename | 1 - 4 files changed, 550 insertions(+), 329 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index e8466df288..b644b2f2be 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -81,19 +81,6 @@ menu "LWIP" the maximum amount of sockets here. The valid value is from 1 to 16. - config LWIP_USE_ONLY_LWIP_SELECT - bool "Support LWIP socket select() only (DEPRECATED)" - default n - help - This option is deprecated. Use VFS_SUPPORT_SELECT instead, which is - the inverse of this option. - - The virtual filesystem layer of select() redirects sockets to - lwip_select() and non-socket file descriptors to their respective driver - implementations. If this option is enabled then all calls of 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 @@ -190,32 +177,6 @@ menu "LWIP" help Enabling this option allows LWIP statistics - config LWIP_ETHARP_TRUST_IP_MAC - bool "Enable LWIP ARP trust" - default n - help - Enabling this option allows ARP table to be updated. - - If this option is enabled, the incoming IP packets cause the ARP table to be - updated with the source MAC and IP addresses supplied in the packet. - You may want to disable this if you do not trust LAN peers to have the - correct addresses, or as a limited approach to attempt to handle - spoofing. If disabled, lwIP will need to make a new ARP request if - the peer is not already in the ARP table, adding a little latency. - The peer *is* in the ARP table if it requested our address before. - Also notice that this slows down input processing of every IP packet! - - There are two known issues in real application if this feature is enabled: - - The LAN peer may have bug to update the ARP table after the ARP entry is aged out. - If the ARP entry on the LAN peer is aged out but failed to be updated, all IP packets - sent from LWIP to the LAN peer will be dropped by LAN peer. - - The LAN peer may not be trustful, the LAN peer may send IP packets to LWIP with - two different MACs, but the same IP address. If this happens, the LWIP has problem - to receive IP packets from LAN peer. - - So the recommendation is to disable this option. - Here the LAN peer means the other side to which the ESP station or soft-AP is connected. - config LWIP_ESP_GRATUITOUS_ARP bool "Send gratuitous ARP periodically" default y @@ -420,6 +381,7 @@ menu "LWIP" Enabling this option means that if a packet is sent with a destination address equal to the interface's own IP address, it will "loop back" and be received by this interface. + Disabling this option disables support of loopback interface in lwIP config LWIP_LOOPBACK_MAX_PBUFS int "Max queued loopback packets per interface" @@ -575,15 +537,6 @@ menu "LWIP" help TCP will support sending selective acknowledgements (SACKs). - config LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES - bool "Keep TCP connections when IP changed" - default n - help - This option is enabled when the following scenario happen: - network dropped and reconnected, IP changes is like: 192.168.0.2->0.0.0.0->192.168.0.2 - - Disable this option to keep consistent with the original LWIP code behavior. - choice LWIP_TCP_OVERSIZE prompt "Pre-allocate transmit PBUF size" diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index 47215e99da..9dc70286d9 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -5,9 +5,8 @@ * * SPDX-FileContributor: 2015-2021 Espressif Systems (Shanghai) CO LTD */ - -#ifndef __LWIPOPTS_H__ -#define __LWIPOPTS_H__ +#ifndef LWIP_HDR_ESP_LWIPOPTS_H +#define LWIP_HDR_ESP_LWIPOPTS_H #include #include @@ -21,13 +20,26 @@ #include "netif/dhcp_state.h" #include "sntp/sntp_get_set_time.h" -/* Enable all Espressif-only options */ /* ----------------------------------------------- ---------- Platform specific locking ---------- ----------------------------------------------- */ +/** + * LWIP_TCPIP_CORE_LOCKING + * Creates a global mutex that is held during TCPIP thread operations. + * Can be locked by client code to perform lwIP operations without changing + * into TCPIP thread using callbacks. See LOCK_TCPIP_CORE() and + * UNLOCK_TCPIP_CORE(). + * Your system should provide mutexes supporting priority inversion to use this. + */ +#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING +#define LWIP_TCPIP_CORE_LOCKING 1 +#else +#define LWIP_TCPIP_CORE_LOCKING 0 +#endif + /** * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain * critical regions during buffer allocation, deallocation and memory @@ -59,7 +71,7 @@ * instead of the lwip internal allocator. Can save code size if you * already use it. */ -#define MEM_LIBC_MALLOC 1 +#define MEM_LIBC_MALLOC 1 /** * MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator. @@ -73,7 +85,7 @@ * 4 byte alignment -> #define MEM_ALIGNMENT 4 * 2 byte alignment -> #define MEM_ALIGNMENT 2 */ -#define MEM_ALIGNMENT 4 +#define MEM_ALIGNMENT 4 /* ------------------------------------------------ @@ -131,33 +143,54 @@ ---------- IP options ---------- -------------------------------- */ +/** + * LWIP_IPV4==1: Enable IPv4 + */ +#define LWIP_IPV4 1 + /** * 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_IP4_REASSEMBLY - -/** - * 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 +#ifdef CONFIG_LWIP_IP4_REASSEMBLY +#define IP_REASSEMBLY 1 +#else +#define IP_REASSEMBLY 0 +#endif /** * 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_IP4_FRAG +#ifdef CONFIG_LWIP_IP4_FRAG +#define IP_FRAG 1 +#else +#define IP_FRAG 0 +#endif /** - * 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. + * IP_FORWARD==1: Enables the ability to forward IP packets across network + * interfaces. If you are going to run lwIP on a device with only one network + * interface, define this to 0. */ -#define LWIP_IPV6_FRAG CONFIG_LWIP_IP6_FRAG +#ifdef CONFIG_LWIP_IP_FORWARD +#define IP_FORWARD 1 +#else +#define IP_FORWARD 0 +#endif + +/** + * IP_NAPT==1: Enables IPv4 Network Address and Port Translation. + * Note that both CONFIG_LWIP_IP_FORWARD and CONFIG_LWIP_L2_TO_L3_COPY options + * need to be enabled in system configuration for the NAPT to work on ESP platform + */ +#ifdef CONFIG_LWIP_IPV4_NAPT +#define IP_NAPT 1 +#else +#define IP_NAPT 0 +#endif /** * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) @@ -174,30 +207,38 @@ */ #define IP_REASS_MAX_PBUFS 10 -/** - * IP_FORWARD==1: Enables the ability to forward IP packets across network - * interfaces. If you are going to run lwIP on a device with only one network - * interface, define this to 0. - */ -#define IP_FORWARD CONFIG_LWIP_IP_FORWARD - -/** - * IP_NAPT==1: Enables IPv4 Network Address and Port Translation. - * Note that both CONFIG_LWIP_IP_FORWARD and CONFIG_LWIP_L2_TO_L3_COPY options - * need to be enabled in system configuration for the NAPT to work on ESP platform - */ -#define IP_NAPT CONFIG_LWIP_IPV4_NAPT - /* ---------------------------------- ---------- ICMP options ---------- ---------------------------------- */ -#define LWIP_ICMP CONFIG_LWIP_ICMP +/** + * LWIP_ICMP==1: Enable ICMP module inside the IP stack. + * Be careful, disable that make your product non-compliant to RFC1122 + */ +#ifdef CONFIG_LWIP_ICMP +#define LWIP_ICMP 1 +#else +#define LWIP_ICMP 0 +#endif -#define LWIP_BROADCAST_PING CONFIG_LWIP_BROADCAST_PING +/** + * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) + */ +#ifdef CONFIG_LWIP_BROADCAST_PING +#define LWIP_BROADCAST_PING 1 +#else +#define LWIP_BROADCAST_PING 0 +#endif -#define LWIP_MULTICAST_PING CONFIG_LWIP_MULTICAST_PING +/** + * LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only) + */ +#ifdef CONFIG_LWIP_MULTICAST_PING +#define LWIP_MULTICAST_PING 1 +#else +#define LWIP_MULTICAST_PING 0 +#endif /* --------------------------------- @@ -219,29 +260,56 @@ */ #define LWIP_DHCP 1 -#define DHCP_MAXRTX 0 - /** * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address. */ -#define DHCP_DOES_ARP_CHECK CONFIG_LWIP_DHCP_DOES_ARP_CHECK +#ifdef CONFIG_LWIP_DHCP_DOES_ARP_CHECK +#define DHCP_DOES_ARP_CHECK 1 +#else +#define DHCP_DOES_ARP_CHECK 0 +#endif /** + * LWIP_DHCP_GETS_NTP==1: Request NTP servers with discover/select. For each + * response packet, an callback is called, which has to be provided by the port: + * void dhcp_set_ntp_servers(u8_t num_ntp_servers, ip_addr_t* ntp_server_addrs); +*/ +#ifdef CONFIG_LWIP_DHCP_GET_NTP_SRV +#define LWIP_DHCP_GET_NTP_SRV 1 +#else +#define LWIP_DHCP_GET_NTP_SRV 0 +#endif + +/** + * ESP specific option only applicable if ESP_DHCP=1 * LWIP_DHCP_DISABLE_CLIENT_ID==1: Do not add option 61 (client-id) to DHCP packets + * */ -#define ESP_DHCP_DISABLE_CLIENT_ID CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID +#ifdef CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID +#define ESP_DHCP_DISABLE_CLIENT_ID 1 +#else +#define ESP_DHCP_DISABLE_CLIENT_ID 0 +#endif /** + * ESP specific option only applicable if ESP_DHCP=1 * CONFIG_LWIP_DHCP_RESTORE_LAST_IP==1: Last valid IP address obtained from DHCP server * is restored after reset/power-up. */ -#if CONFIG_LWIP_DHCP_RESTORE_LAST_IP - +#ifdef CONFIG_LWIP_DHCP_RESTORE_LAST_IP #define LWIP_DHCP_IP_ADDR_RESTORE() dhcp_ip_addr_restore(netif) #define LWIP_DHCP_IP_ADDR_STORE() dhcp_ip_addr_store(netif) #define LWIP_DHCP_IP_ADDR_ERASE(esp_netif) dhcp_ip_addr_erase(esp_netif) +#else +#define LWIP_DHCP_IP_ADDR_RESTORE() 0 +#define LWIP_DHCP_IP_ADDR_STORE() +#define LWIP_DHCP_IP_ADDR_ERASE(esp_netif) +#endif /* CONFIG_LWIP_DHCP_RESTORE_LAST_IP */ -#endif +/** + * The maximum of NTP servers requested + */ +#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS /** * CONFIG_LWIP_DHCP_OPTIONS_LEN: The total length of outgoing DHCP option msg. If you have many options @@ -259,6 +327,9 @@ ---------- AUTOIP options ---------- ------------------------------------ */ +/** + * LWIP_AUTOIP==1: Enable AUTOIP module. + */ #ifdef CONFIG_LWIP_AUTOIP #define LWIP_AUTOIP 1 @@ -277,17 +348,20 @@ */ #define LWIP_DHCP_AUTOIP_COOP_TRIES CONFIG_LWIP_AUTOIP_TRIES +/** + * ESP specific option only applicable if ESP_DHCP=1 + * LWIP_AUTOIP_MAX_CONFLICTS: Defines max conflicts before rate limiting + */ #define LWIP_AUTOIP_MAX_CONFLICTS CONFIG_LWIP_AUTOIP_MAX_CONFLICTS +/** + * ESP specific option only applicable if ESP_DHCP=1 + * LWIP_AUTOIP_RATE_LIMIT_INTERVAL: Delay in seconds between successive attempts + */ #define LWIP_AUTOIP_RATE_LIMIT_INTERVAL CONFIG_LWIP_AUTOIP_RATE_LIMIT_INTERVAL #endif /* CONFIG_LWIP_AUTOIP */ -/* - ---------------------------------- - ---------- SNMP options ---------- - ---------------------------------- -*/ /* ---------------------------------- ---------- IGMP options ---------- @@ -309,55 +383,65 @@ */ #define LWIP_DNS 1 +/** The maximum of DNS servers + */ #define DNS_MAX_SERVERS 3 -#define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1) + +/** ESP specific option only applicable if ESP_DNS=1 + * + * The last server can be initialized automatically by defining + * FALLBACK_DNS_SERVER_ADDRESS(ipaddr), where 'ipaddr' is an 'ip_addr_t*' + */ +#define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1) + +/** + * LWIP_DNS_SUPPORT_MDNS_QUERIES==1: Enable mDNS queries in hostname resolution. + * This option is set via menuconfig. + */ +#ifdef CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES +#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1 +#else +#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0 +#endif /* --------------------------------- ---------- UDP options ---------- --------------------------------- */ +/** + * LWIP_UDP==1: Turn on UDP. + */ +#define LWIP_UDP 1 + +/** + * LWIP_NETBUF_RECVINFO==1: Enable IP_PKTINFO option. + * This option is set via menuconfig. + */ +#ifdef CONFIG_LWIP_NETBUF_RECVINFO +#define LWIP_NETBUF_RECVINFO 1 +#else +#define LWIP_NETBUF_RECVINFO 0 +#endif + /* --------------------------------- ---------- TCP options ---------- --------------------------------- */ - +/** + * LWIP_TCP==1: Turn on TCP. + */ +#define LWIP_TCP 1 /** - * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order. - * Define to 0 if your device is low on memory. + * TCP_WND: The size of a TCP window. This must be at least + * (2 * TCP_MSS) for things to work well. + * ATTENTION: when using TCP_RCV_SCALE, TCP_WND is the total size + * with scaling applied. Maximum window value in the TCP header + * will be TCP_WND >> TCP_RCV_SCALE */ -#define TCP_QUEUE_OOSEQ CONFIG_LWIP_TCP_QUEUE_OOSEQ - -/** - * LWIP_TCP_SACK_OUT==1: TCP will support sending selective acknowledgements (SACKs). - */ -#define LWIP_TCP_SACK_OUT CONFIG_LWIP_TCP_SACK_OUT - -/** - * ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES==1: Keep TCP connection when IP changed - * scenario happens: 192.168.0.2 -> 0.0.0.0 -> 192.168.0.2 or 192.168.0.2 -> 0.0.0.0 - */ - -#define ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES -/* - * LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all - * events (accept, sent, etc) that happen in the system. - * LWIP_CALLBACK_API==1: The PCB callback function is called directly - * for the event. This is the default. -*/ -#define TCP_MSS CONFIG_LWIP_TCP_MSS - -/** - * TCP_TMR_INTERVAL: TCP timer interval - */ -#define TCP_TMR_INTERVAL CONFIG_LWIP_TCP_TMR_INTERVAL - -/** - * TCP_MSL: The maximum segment lifetime in milliseconds - */ -#define TCP_MSL CONFIG_LWIP_TCP_MSL +#define TCP_WND CONFIG_LWIP_TCP_WND_DEFAULT /** * TCP_MAXRTX: Maximum number of retransmissions of data segments. @@ -369,12 +453,46 @@ */ #define TCP_SYNMAXRTX CONFIG_LWIP_TCP_SYNMAXRTX +/** + * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order. + * Define to 0 if your device is low on memory. + */ +#ifdef CONFIG_LWIP_TCP_QUEUE_OOSEQ +#define TCP_QUEUE_OOSEQ 1 +#else +#define TCP_QUEUE_OOSEQ 0 +#endif + +/** + * LWIP_TCP_SACK_OUT==1: TCP will support sending selective acknowledgements (SACKs). + */ +#ifdef CONFIG_LWIP_TCP_SACK_OUT +#define LWIP_TCP_SACK_OUT 1 +#else +#define LWIP_TCP_SACK_OUT 0 +#endif + +/** + * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, + * you might want to increase this.) + * For the receive side, this MSS is advertised to the remote side + * when opening a connection. For the transmit size, this MSS sets + * an upper limit on the MSS advertised by the remote host. + */ +#define TCP_MSS CONFIG_LWIP_TCP_MSS + +/** + * TCP_SND_BUF: TCP sender buffer space (bytes). + * To achieve good performance, this should be at least 2 * TCP_MSS. + */ +#define TCP_SND_BUF CONFIG_LWIP_TCP_SND_BUF_DEFAULT + + /** * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb. */ #define TCP_LISTEN_BACKLOG 1 - /** * TCP_OVERSIZE: The maximum number of bytes that tcp_write may * allocate ahead of time @@ -392,6 +510,26 @@ #error "One of CONFIG_TCP_OVERSIZE_xxx options should be set by sdkconfig" #endif +/** + * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1. + * LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all + * events (accept, sent, etc) that happen in the system. + * LWIP_CALLBACK_API==1: The PCB callback function is called directly + * for the event. This is the default. + */ +#define LWIP_EVENT_API 0 +#define LWIP_CALLBACK_API 1 + +/** + * TCP_TMR_INTERVAL: TCP timer interval + */ +#define TCP_TMR_INTERVAL CONFIG_LWIP_TCP_TMR_INTERVAL + +/** + * TCP_MSL: The maximum segment lifetime in milliseconds + */ +#define TCP_MSL CONFIG_LWIP_TCP_MSL + /** * LWIP_WND_SCALE and TCP_RCV_SCALE: * Set LWIP_WND_SCALE to 1 to enable window scaling. @@ -403,20 +541,18 @@ #ifdef CONFIG_LWIP_WND_SCALE #define LWIP_WND_SCALE 1 #define TCP_RCV_SCALE CONFIG_LWIP_TCP_RCV_SCALE -#endif +#else +#define LWIP_WND_SCALE 0 +#define TCP_RCV_SCALE 0 +#endif /* CONFIG_LWIP_WND_SCALE */ /** + * ESP specific option only applicable if ESP_LWIP=1 * LWIP_TCP_RTO_TIME: TCP rto time. * Default is 3 second. */ #define LWIP_TCP_RTO_TIME CONFIG_LWIP_TCP_RTO_TIME -/* - ---------------------------------- - ---------- Pbuf options ---------- - ---------------------------------- -*/ - /* ------------------------------------------------ ---------- Network Interfaces options ---------- @@ -430,29 +566,56 @@ #define LWIP_NETIF_HOSTNAME 1 /** - * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data + * LWIP_NETIF_API==1: Support netif api (in netifapi.c) + */ +#ifdef CONFIG_LWIP_NETIF_API +#define LWIP_NETIF_API 1 +#else +#define LWIP_NETIF_API 0 +#endif + +/** + * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface + * changes its up/down status (i.e., due to DHCP IP acquisition) + */ +#ifdef CONFIG_LWIP_NETIF_STATUS_CALLBACK +#define LWIP_NETIF_STATUS_CALLBACK 1 +#else +#define LWIP_NETIF_STATUS_CALLBACK 0 +#endif + +/** + * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP *tries* to put all data * to be sent into one single pbuf. This is for compatibility with DMA-enabled * MACs that do not support scatter-gather. * Beware that this might involve CPU-memcpy before transmitting that would not * be needed without this flag! Use this only if you need to! * - * @todo: TCP and IP-frag do not work with this, yet: + * ATTENTION: a driver should *NOT* rely on getting single pbufs but check TX + * pbufs for being in one piece. If not, @ref pbuf_clone can be used to get + * a single pbuf: + * if (p->next != NULL) { + * struct pbuf *q = pbuf_clone(PBUF_RAW, PBUF_RAM, p); + * if (q == NULL) { + * return ERR_MEM; + * } + * p = q; ATTENTION: do NOT free the old 'p' as the ref belongs to the caller! + * } */ -#define LWIP_NETIF_TX_SINGLE_PBUF 1 - -/** - * LWIP_NETIF_API==1: Enable usage of standard POSIX APIs in LWIP. - */ -#define LWIP_NETIF_API CONFIG_LWIP_NETIF_API - -#define LWIP_NETIF_STATUS_CALLBACK CONFIG_LWIP_NETIF_STATUS_CALLBACK +#define LWIP_NETIF_TX_SINGLE_PBUF 1 /* ------------------------------------ ---------- LOOPIF options ---------- ------------------------------------ */ +/** + * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1). + * This is only needed when no real netifs are available. If at least one other +*/ #ifdef CONFIG_LWIP_NETIF_LOOPBACK +#define LWIP_HAVE_LOOPIF 1 + /** * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP * address equal to the netif IP address, looping them back up the stack. @@ -464,6 +627,8 @@ * sending for each netif (0 = disabled) */ #define LWIP_LOOPBACK_MAX_PBUFS CONFIG_LWIP_LOOPBACK_MAX_PBUFS +#else +#define LWIP_HAVE_LOOPIF 0 #endif /* @@ -473,7 +638,6 @@ */ #ifdef CONFIG_LWIP_SLIP_SUPPORT - /** * Enable SLIP receive from ISR functions and disable Rx thread * @@ -487,18 +651,14 @@ #define SLIP_USE_RX_THREAD 0 /** - * PPP_DEBUG: Enable debugging for PPP. + * SLIP_DEBUG: Enable debugging for SLIP. */ -#define SLIP_DEBUG_ON CONFIG_LWIP_SLIP_DEBUG_ON - -#if SLIP_DEBUG_ON +#ifdef CONFIG_LWIP_SLIP_DEBUG_ON #define SLIP_DEBUG LWIP_DBG_ON #else #define SLIP_DEBUG LWIP_DBG_OFF #endif - - -#endif +#endif /* CONFIG_LWIP_SLIP_SUPPORT */ /* ------------------------------------ @@ -579,16 +739,78 @@ ---------------------------------------------- */ /** - * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!) - * Don't use it if you're not an active lwIP project member + * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) */ -#define LWIP_TCPIP_CORE_LOCKING CONFIG_LWIP_TCPIP_CORE_LOCKING +#define LWIP_NETCONN 1 + +/** LWIP_NETCONN_SEM_PER_THREAD==1: Use one (thread-local) semaphore per + * thread calling socket/netconn functions instead of allocating one + * semaphore per netconn (and per select etc.) + * ATTENTION: a thread-local semaphore for API calls is needed: + * - LWIP_NETCONN_THREAD_SEM_GET() returning a sys_sem_t* + * - LWIP_NETCONN_THREAD_SEM_ALLOC() creating the semaphore + * - LWIP_NETCONN_THREAD_SEM_FREE() freeing the semaphore + * The latter 2 can be invoked up by calling netconn_thread_init()/netconn_thread_cleanup(). + * Ports may call these for threads created with sys_thread_new(). + */ +#if LWIP_TCPIP_CORE_LOCKING +#define LWIP_NETCONN_SEM_PER_THREAD 0 +#else +#define LWIP_NETCONN_SEM_PER_THREAD 1 +#endif + +/** LWIP_NETCONN_FULLDUPLEX==1: Enable code that allows reading from one thread, + * writing from a 2nd thread and closing from a 3rd thread at the same time. + * ATTENTION: This is currently really alpha! Some requirements: + * - LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from + * multiple threads at once + * - sys_mbox_free() has to unblock receive tasks waiting on recvmbox/acceptmbox + * and prevent a task pending on this during/after deletion + */ +#define LWIP_NETCONN_FULLDUPLEX 1 /* ------------------------------------ ---------- Socket options ---------- ------------------------------------ */ +/** + * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) + */ +#define LWIP_SOCKET 1 + +/** + * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names through defines. + * LWIP_COMPAT_SOCKETS==2: Same as ==1 but correctly named functions are created. + * While this helps code completion, it might conflict with existing libraries. + * (only used if you use sockets.c) + */ +#define LWIP_COMPAT_SOCKETS 1 + +/** + * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names. + * Disable this option if you use a POSIX operating system that uses the same + * names (read, write & close). (only used if you use sockets.c) + * + * POSIX I/O functions are mapped to LWIP via the VFS layer + * (see port/vfs_lwip.c) + */ +/** + */ +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +/** + * LWIP_SOCKET_OFFSET==n: Increases the file descriptor number created by LwIP with n. + * + * FD_SETSIZE from sys/types.h is the maximum number of supported file + * descriptors and CONFIG_LWIP_MAX_SOCKETS defines the number of sockets; + * LWIP_SOCKET_OFFSET is configured to use the largest numbers of file + * descriptors for sockets. File descriptors from 0 to LWIP_SOCKET_OFFSET-1 + * are non-socket descriptors and from LWIP_SOCKET_OFFSET to FD_SETSIZE are + * socket descriptors. + */ +#define LWIP_SOCKET_OFFSET (FD_SETSIZE - CONFIG_LWIP_MAX_SOCKETS) + /** * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and * SO_SNDTIMEO processing. @@ -610,38 +832,48 @@ /** * LWIP_SO_LINGER==1: Enable SO_LINGER processing. + * This option is set via menuconfig. */ -#define LWIP_SO_LINGER CONFIG_LWIP_SO_LINGER +#ifdef CONFIG_LWIP_SO_LINGER +#define LWIP_SO_LINGER 1 +#else +#define LWIP_SO_LINGER 0 +#endif /** * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing. + * This option is set via menuconfig. */ -#define LWIP_SO_RCVBUF CONFIG_LWIP_SO_RCVBUF +#ifdef CONFIG_LWIP_SO_RCVBUF +#define LWIP_SO_RCVBUF 1 +#else +#define LWIP_SO_RCVBUF 0 +#endif /** * SO_REUSE==1: Enable SO_REUSEADDR option. * This option is set via menuconfig. */ -#define SO_REUSE CONFIG_LWIP_SO_REUSE +#ifdef CONFIG_LWIP_SO_REUSE +#define SO_REUSE 1 +#else +#define SO_REUSE 0 +#endif - -/** - * LWIP_DNS_SUPPORT_MDNS_QUERIES==1: Enable mDNS queries in hostname resolution. - * This option is set via menuconfig. - */ -#define LWIP_DNS_SUPPORT_MDNS_QUERIES CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES /** * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets * to all local matches if SO_REUSEADDR is turned on. * WARNING: Adds a memcpy for every packet if passing to more than one pcb! */ -#define SO_REUSE_RXTOALL CONFIG_LWIP_SO_REUSE_RXTOALL +#ifdef CONFIG_LWIP_SO_REUSE_RXTOALL +#define SO_REUSE_RXTOALL 1 +#else +#define SO_REUSE_RXTOALL 0 +#endif -/** - * LWIP_NETBUF_RECVINFO==1: Enable IP_PKTINFO option. - * This option is set via menuconfig. - */ -#define LWIP_NETBUF_RECVINFO CONFIG_LWIP_NETBUF_RECVINFO +/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided + * by your system, set this to 0 and include in cc.h */ +#define LWIP_TIMEVAL_PRIVATE 0 /* ---------------------------------------- @@ -652,16 +884,18 @@ /** * LWIP_STATS==1: Enable statistics collection in lwip_stats. */ -#define LWIP_STATS CONFIG_LWIP_STATS - -#if LWIP_STATS +#ifdef CONFIG_LWIP_STATS +#define LWIP_STATS 1 +#define ESP_STATS_MEM 1 /** * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions. */ -#define LWIP_STATS_DISPLAY CONFIG_LWIP_STATS -#endif - +#define LWIP_STATS_DISPLAY 1 +#else +#define LWIP_STATS 0 +#define ESP_STATS_MEM 0 +#endif /* CONFIG_LWIP_STATS */ /* --------------------------------- @@ -672,9 +906,8 @@ /** * PPP_SUPPORT==1: Enable PPP. */ -#define PPP_SUPPORT CONFIG_LWIP_PPP_SUPPORT - -#if PPP_SUPPORT +#ifdef CONFIG_LWIP_PPP_SUPPORT +#define PPP_SUPPORT 1 /** * PPP_IPV6_SUPPORT == 1: Enable IPV6 support for local link @@ -719,27 +952,7 @@ #define PPP_MAXIDLEFLAG 0 -/** - * PPP_DEBUG: Enable debugging for PPP. - */ -#define PPP_DEBUG_ON CONFIG_LWIP_PPP_DEBUG_ON - -#if PPP_DEBUG_ON -#define PPP_DEBUG LWIP_DBG_ON -#define PRINTPKT_SUPPORT 1 -#define PPP_PROTOCOLNAME 1 -#else -#define PPP_DEBUG LWIP_DBG_OFF -#endif - -#endif /* PPP SUPPORT */ - -/* - ------------------------------------ - --------- LCP Echo options --------- - ------------------------------------ -*/ -#if CONFIG_LWIP_ENABLE_LCP_ECHO +#ifdef CONFIG_LWIP_ENABLE_LCP_ECHO /** * LCP_ECHOINTERVAL: Interval in seconds between keepalive LCP echo requests, 0 to disable. */ @@ -751,12 +964,53 @@ #define LCP_MAXECHOFAILS CONFIG_LWIP_LCP_MAXECHOFAILS #endif /* CONFIG_LWIP_ENABLE_LCP_ECHO */ +/** + * PPP_DEBUG: Enable debugging for PPP. + */ +#ifdef CONFIG_LWIP_PPP_DEBUG_ON +#define PPP_DEBUG LWIP_DBG_ON +#define PRINTPKT_SUPPORT 1 +#define PPP_PROTOCOLNAME 1 +#else +#define PPP_DEBUG LWIP_DBG_OFF +#endif /* CONFIG_LWIP_PPP_DEBUG_ON */ +#else +#define PPP_SUPPORT 0 +#endif /* CONFIG_LWIP_PPP_SUPPORT */ + /* -------------------------------------- ---------- Checksum options ---------- -------------------------------------- */ +/** + * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. + */ +#ifdef CONFIG_LWIP_CHECKSUM_CHECK_IP +#define CHECKSUM_CHECK_IP 1 +#else +#define CHECKSUM_CHECK_IP 0 +#endif + +/** + * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets. + */ +#ifdef CONFIG_LWIP_CHECKSUM_CHECK_UDP +#define CHECKSUM_CHECK_UDP 1 +#else +#define CHECKSUM_CHECK_UDP 0 +#endif + +/** + * CHECKSUM_CHECK_ICMP==1: Check checksums in software for incoming ICMP packets. + */ +#ifdef CONFIG_LWIP_CHECKSUM_CHECK_ICMP +#define CHECKSUM_CHECK_ICMP 1 +#else +#define CHECKSUM_CHECK_ICMP 0 +#endif + /* --------------------------------------- ---------- IPv6 options --------------- @@ -765,7 +1019,72 @@ /** * LWIP_IPV6==1: Enable IPv6 */ -#define LWIP_IPV6 CONFIG_LWIP_IPV6 +#ifdef CONFIG_LWIP_IPV6 +#define LWIP_IPV6 1 +#else +#define LWIP_IPV6 0 +#endif + +/** + * LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif. + */ +#define LWIP_IPV6_NUM_ADDRESSES CONFIG_LWIP_IPV6_NUM_ADDRESSES + +/** + * LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs + */ +#ifdef CONFIG_LWIP_IPV6_FORWARD +#define LWIP_IPV6_FORWARD 1 +#else +#define LWIP_IPV6_FORWARD 0 +#endif + +/** + * 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 IP6_REASSEMBLY. + */ +#ifdef CONFIG_LWIP_IP6_FRAG +#define LWIP_IPV6_FRAG 1 +#else +#define LWIP_IPV6_FRAG 0 +#endif + +/** + * 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_IP6_FRAG. + */ +#ifdef CONFIG_LWIP_IP6_REASSEMBLY +#define LWIP_IPV6_REASS 1 +#else +#define LWIP_IPV6_REASS 0 +#endif + +/** + * LWIP_IPV6_AUTOCONFIG==1: Enable stateless address autoconfiguration as per RFC 4862. + */ +#ifdef CONFIG_LWIP_IPV6_AUTOCONFIG +#define ESP_IPV6_AUTOCONFIG 1 +#else +#define ESP_IPV6_AUTOCONFIG 0 +#endif + +/** + * LWIP_ND6_RDNSS_MAX_DNS_SERVERS > 0: Use IPv6 Router Advertisement Recursive + * DNS Server Option (as per RFC 6106) to copy a defined maximum number of DNS + * servers to the DNS module. + */ +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS + +/** + * LWIP_IPV6_DHCP6==1: enable DHCPv6 stateful/stateless address autoconfiguration. + */ +#ifdef CONFIG_LWIP_IPV6_DHCP6 +#define LWIP_IPV6_DHCP6 1 +#else +#define LWIP_IPV6_DHCP6 0 +#endif /** * MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC resolution. @@ -793,6 +1112,15 @@ ---------- Debugging options ---------- --------------------------------------- */ +/** + * LWIP_DEBUG: Enable lwip debugging in other modules. + */ +#ifdef CONFIG_LWIP_DEBUG +#define LWIP_DEBUG LWIP_DBG_ON +#else +#undef LWIP_DEBUG +#endif + /** * ETHARP_DEBUG: Enable debugging in etharp.c. */ @@ -802,7 +1130,6 @@ #define ETHARP_DEBUG LWIP_DBG_OFF #endif - /** * NETIF_DEBUG: Enable debugging in netif.c. */ @@ -830,7 +1157,6 @@ #define API_LIB_DEBUG LWIP_DBG_OFF #endif - /** * SOCKETS_DEBUG: Enable debugging in sockets.c. */ @@ -931,44 +1257,60 @@ */ #define TCP_OOSEQ_DEBUG LWIP_DBG_OFF +/* + -------------------------------------- + ------------ SNTP options ------------ + -------------------------------------- +*/ /** - * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be - * updated with the source MAC and IP addresses supplied in the packet. - * You may want to disable this if you do not trust LAN peers to have the - * correct addresses, or as a limited approach to attempt to handle - * spoofing. If disabled, lwIP will need to make a new ARP request if - * the peer is not already in the ARP table, adding a little latency. - * The peer *is* in the ARP table if it requested our address before. - * Also notice that this slows down input processing of every IP packet! + * Max number of SNTP servers handled (default equal to LWIP_DHCP_MAX_NTP_SERVERS) */ -#define ETHARP_TRUST_IP_MAC CONFIG_LWIP_ETHARP_TRUST_IP_MAC +#ifdef CONFIG_LWIP_SNTP_MAX_SERVERS +#define SNTP_MAX_SERVERS CONFIG_LWIP_SNTP_MAX_SERVERS +#endif /* CONFIG_LWIP_SNTP_MAX_SERVERS */ +/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers + * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: + * \#define SNTP_SERVER_ADDRESS "pool.ntp.org" + */ +#define SNTP_SERVER_DNS 1 /** - * POSIX I/O functions are mapped to LWIP via the VFS layer - * (see port/vfs_lwip.c) + * It disables a check of SNTP_UPDATE_DELAY it is done in sntp_set_sync_interval */ -#define LWIP_POSIX_SOCKETS_IO_NAMES 0 +#define SNTP_SUPPRESS_DELAY_CHECK + +#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) +#define SNTP_SET_SYSTEM_TIME_US(sec, us) (sntp_set_system_time(sec, us)) +#define SNTP_GET_SYSTEM_TIME(sec, us) (sntp_get_system_time(&(sec), &(us))) + +/* + --------------------------------------- + --------- ESP specific options -------- + --------------------------------------- +*/ +/** + * ESP_LWIP_IGMP_TIMERS_ONDEMAND==1: Start IGMP timers only if used + * ESP_LWIP_MLD6_TIMERS_ONDEMAND==1: Start MLD6 timers only if used + * Timers will only be activated when joining groups/receiving queries + */ +#ifdef CONFIG_LWIP_TIMERS_ONDEMAND +#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 1 +#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 1 +#else +#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 0 +#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 0 +#endif /** - * FD_SETSIZE from sys/types.h is the maximum number of supported file - * descriptors and CONFIG_LWIP_MAX_SOCKETS defines the number of sockets; - * LWIP_SOCKET_OFFSET is configured to use the largest numbers of file - * descriptors for sockets. File descriptors from 0 to LWIP_SOCKET_OFFSET-1 - * are non-socket descriptors and from LWIP_SOCKET_OFFSET to FD_SETSIZE are - * socket descriptors. + * ESP_GRATUITOUS_ARP==1: This option allows to send gratuitous ARP periodically. */ -#define LWIP_SOCKET_OFFSET (FD_SETSIZE - CONFIG_LWIP_MAX_SOCKETS) - -#define LWIP_IPV6_FORWARD CONFIG_LWIP_IPV6_FORWARD - -#define LWIP_IPV6_NUM_ADDRESSES CONFIG_LWIP_IPV6_NUM_ADDRESSES - -#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS - -#define LWIP_IPV6_DHCP6 CONFIG_LWIP_IPV6_DHCP6 - -/* Enable all Espressif-only options */ +#ifdef CONFIG_LWIP_ESP_GRATUITOUS_ARP +#define ESP_GRATUITOUS_ARP 1 +#define ESP_GRATUITOUS_ARP_INTERVAL (CONFIG_LWIP_GARP_TMR_INTERVAL*1000UL) +#else +#define ESP_GRATUITOUS_ARP 0 +#endif #define ESP_LWIP 1 #define ESP_LWIP_ARP 1 @@ -977,27 +1319,10 @@ #define ESP_THREAD_SAFE_DEBUG LWIP_DBG_OFF #define ESP_DHCP 1 #define ESP_DNS 1 -#define ESP_PERF 0 -#define ESP_RANDOM_TCP_PORT 1 -#define ESP_IP4_ATON 1 -#define ESP_LIGHT_SLEEP 1 -#define ESP_L2_TO_L3_COPY CONFIG_LWIP_L2_TO_L3_COPY -#define LWIP_NETIF_API CONFIG_LWIP_NETIF_API -#define ESP_STATS_MEM CONFIG_LWIP_STATS -#define ESP_STATS_DROP CONFIG_LWIP_STATS #define ESP_STATS_TCP 0 -#ifdef CONFIG_LWIP_DHCPS -#define ESP_DHCPS 1 -#define ESP_DHCPS_TIMER 1 -#else -#define ESP_DHCPS 0 -#define ESP_DHCPS_TIMER 0 -#endif /* CONFIG_LWIP_DHCPS */ #define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__) #define ESP_PING 1 #define ESP_HAS_SELECT 1 -#define ESP_AUTO_RECV 1 -#define ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP #define ESP_IP4_ROUTE 1 #define ESP_AUTO_IP 1 #define ESP_PBUF 1 @@ -1008,77 +1333,21 @@ #define ESP_LWIP_LOCK 1 #define ESP_THREAD_PROTECTION 1 -#ifdef CONFIG_LWIP_IPV6_AUTOCONFIG -#define ESP_IPV6_AUTOCONFIG CONFIG_LWIP_IPV6_AUTOCONFIG -#endif - -#ifdef ESP_IRAM_ATTR -#undef ESP_IRAM_ATTR -#endif -#define ESP_IRAM_ATTR - -#ifdef CONFIG_LWIP_TIMERS_ONDEMAND -#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 1 -#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 1 -#else -#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 0 -#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 0 -#endif - -#define TCP_SND_BUF CONFIG_LWIP_TCP_SND_BUF_DEFAULT -#define TCP_WND CONFIG_LWIP_TCP_WND_DEFAULT - -/** - * LWIP_DEBUG: Enable lwip debugging in other modules. - */ -#ifdef CONFIG_LWIP_DEBUG -#define LWIP_DEBUG LWIP_DBG_ON -#else -#undef LWIP_DEBUG -#endif - -#define CHECKSUM_CHECK_UDP CONFIG_LWIP_CHECKSUM_CHECK_UDP -#define CHECKSUM_CHECK_IP CONFIG_LWIP_CHECKSUM_CHECK_IP -#define CHECKSUM_CHECK_ICMP CONFIG_LWIP_CHECKSUM_CHECK_ICMP - -#define LWIP_NETCONN_FULLDUPLEX 1 -#if LWIP_TCPIP_CORE_LOCKING -#define LWIP_NETCONN_SEM_PER_THREAD 0 -#else -#define LWIP_NETCONN_SEM_PER_THREAD 1 -#endif /* LWIP_TCPIP_CORE_LOCKING */ - -#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS -#define LWIP_TIMEVAL_PRIVATE 0 - /* - -------------------------------------- - ------------ SNTP options ------------ - -------------------------------------- + ----------------------------------------- + ---------- DHCP Server options ---------- + ----------------------------------------- */ - -// Max number of SNTP servers handled (default equal to LWIP_DHCP_MAX_NTP_SERVERS) -#if defined CONFIG_LWIP_SNTP_MAX_SERVERS -#define SNTP_MAX_SERVERS CONFIG_LWIP_SNTP_MAX_SERVERS -#endif // CONFIG_LWIP_SNTP_MAX_SERVERS - -#ifdef CONFIG_LWIP_DHCP_GET_NTP_SRV -#define LWIP_DHCP_GET_NTP_SRV CONFIG_LWIP_DHCP_GET_NTP_SRV -#endif // CONFIG_LWIP_DHCP_GET_NTP_SRV - -/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers - * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: - * \#define SNTP_SERVER_ADDRESS "pool.ntp.org" +/** + * ESP_DHCPS==1: Enable the DHCP server */ -#define SNTP_SERVER_DNS 1 +#ifdef CONFIG_LWIP_DHCPS +#define ESP_DHCPS 1 +#define ESP_DHCPS_TIMER 1 +#else +#define ESP_DHCPS 0 +#define ESP_DHCPS_TIMER 0 +#endif /* CONFIG_LWIP_DHCPS */ -// It disables a check of SNTP_UPDATE_DELAY it is done in sntp_set_sync_interval -#define SNTP_SUPPRESS_DELAY_CHECK -#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) -#define SNTP_SET_SYSTEM_TIME_US(sec, us) (sntp_set_system_time(sec, us)) -#define SNTP_GET_SYSTEM_TIME(sec, us) (sntp_get_system_time(&(sec), &(us))) - -#define SOC_SEND_LOG //printf - -#endif /* __LWIPOPTS_H__ */ +#endif /* LWIP_HDR_ESP_LWIPOPTS_H */ diff --git a/components/lwip/port/esp32/netif/wlanif.c b/components/lwip/port/esp32/netif/wlanif.c index a11fc6323e..f927e2f58a 100644 --- a/components/lwip/port/esp32/netif/wlanif.c +++ b/components/lwip/port/esp32/netif/wlanif.c @@ -54,7 +54,7 @@ #include "esp_netif_net_stack.h" #include "esp_compiler.h" -#if !ESP_L2_TO_L3_COPY +#ifndef CONFIG_LWIP_L2_TO_L3_COPY /** * @brief Free resources allocated in L2 layer * @@ -102,7 +102,7 @@ low_level_init(struct netif *netif) #endif #endif -#if !ESP_L2_TO_L3_COPY +#ifndef CONFIG_LWIP_L2_TO_L3_COPY netif->l2_buffer_free_notify = lwip_netif_wifi_free_rx_buffer; #endif } @@ -122,7 +122,7 @@ low_level_init(struct netif *netif) * to become availale since the stack doesn't retry to send a packet * dropped because of memory failure (except for the TCP timers). */ -static err_t ESP_IRAM_ATTR +static err_t low_level_output(struct netif *netif, struct pbuf *p) { esp_netif_t *esp_netif = esp_netif_get_handle_from_netif_impl(netif); @@ -170,7 +170,7 @@ low_level_output(struct netif *netif, struct pbuf *p) * * @param netif the lwip network interface structure for this ethernetif */ -void ESP_IRAM_ATTR +void wlanif_input(void *h, void *buffer, size_t len, void* eb) { struct netif * netif = h; @@ -184,7 +184,7 @@ wlanif_input(void *h, void *buffer, size_t len, void* eb) return; } -#if (ESP_L2_TO_L3_COPY == 1) +#ifdef CONFIG_LWIP_L2_TO_L3_COPY p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM); if (p == NULL) { esp_netif_free_rx_buffer(esp_netif, eb); @@ -202,7 +202,7 @@ wlanif_input(void *h, void *buffer, size_t len, void* eb) p->payload = buffer; p->l2_owner = netif; p->l2_buf = eb; -#endif +#endif /* CONFIG_LWIP_L2_TO_L3_COPY */ /* full packet send to tcpip_thread to process */ if (unlikely(netif->input(p, netif) != ERR_OK)) { diff --git a/components/lwip/sdkconfig.rename b/components/lwip/sdkconfig.rename index 4c2dd3148c..da63c8e079 100644 --- a/components/lwip/sdkconfig.rename +++ b/components/lwip/sdkconfig.rename @@ -2,7 +2,6 @@ # CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION CONFIG_L2_TO_L3_COPY CONFIG_LWIP_L2_TO_L3_COPY -CONFIG_USE_ONLY_LWIP_SELECT CONFIG_LWIP_USE_ONLY_LWIP_SELECT CONFIG_ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP CONFIG_GARP_TMR_INTERVAL CONFIG_LWIP_GARP_TMR_INTERVAL CONFIG_TCPIP_RECVMBOX_SIZE CONFIG_LWIP_TCPIP_RECVMBOX_SIZE From 10dc8543c58a0307afe396655c518fbad1badd39 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Mon, 20 Sep 2021 10:32:05 +0200 Subject: [PATCH 2/6] vfs/lwip: Fix docs on select() referencing wrong config CONFIG_LWIP_USE_ONLY_LWIP_SELECT was deprecated long time ago and removed (~ in v4.x). Used CONFIG_VFS_SUPPORT_SELECT instead (and reverted the logic as this is ON by default and needs to be explicitly turned off for socket only select) --- docs/en/api-guides/lwip.rst | 2 +- docs/en/api-reference/storage/vfs.rst | 2 +- docs/zh_CN/api-reference/storage/vfs.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/api-guides/lwip.rst b/docs/en/api-guides/lwip.rst index 62db8d248c..af8d2da009 100644 --- a/docs/en/api-guides/lwip.rst +++ b/docs/en/api-guides/lwip.rst @@ -417,7 +417,7 @@ The :example_file:`wifi/iperf/sdkconfig.defaults` file for the iperf example con - If a lot of tasks are competing for CPU time on the system, consider that the lwIP task has configurable CPU affinity (:ref:`CONFIG_LWIP_TCPIP_TASK_AFFINITY`) and runs at fixed priority ``ESP_TASK_TCPIP_PRIO`` (18). Configure competing tasks to be pinned to a different core, or to run at a lower priority. See also :ref:`built-in-task-priorities`. -- If using ``select()`` function with socket arguments only, setting :ref:`CONFIG_LWIP_USE_ONLY_LWIP_SELECT` will make ``select()`` calls faster. +- If using ``select()`` function with socket arguments only, disabling :ref:`CONFIG_VFS_SUPPORT_SELECT` will make ``select()`` calls faster. - If there is enough free IRAM, select :ref:`CONFIG_LWIP_IRAM_OPTIMIZATION` to improve TX/RX throughput diff --git a/docs/en/api-reference/storage/vfs.rst b/docs/en/api-reference/storage/vfs.rst index 0107155dde..71ed4d8755 100644 --- a/docs/en/api-reference/storage/vfs.rst +++ b/docs/en/api-reference/storage/vfs.rst @@ -140,7 +140,7 @@ A socket VFS driver needs to be registered with the following functions defined: Please see :component_file:`lwip/port/esp32/vfs_lwip.c` for a reference socket driver implementation using LWIP. .. note:: - If :cpp:func:`select` is only used on socket file descriptors, you can enable the :envvar:`CONFIG_LWIP_USE_ONLY_LWIP_SELECT` option to reduce the code size and improve performance. + If you use :cpp:func:`select` for socket file descriptors only then you can disable the :envvar:`CONFIG_VFS_SUPPORT_SELECT` option to reduce the code size and improve performance. You should not change the socket driver during an active :cpp:func:`select` call or you might experience some undefined behavior. Paths diff --git a/docs/zh_CN/api-reference/storage/vfs.rst b/docs/zh_CN/api-reference/storage/vfs.rst index 092125951c..8e8ae5a735 100644 --- a/docs/zh_CN/api-reference/storage/vfs.rst +++ b/docs/zh_CN/api-reference/storage/vfs.rst @@ -140,7 +140,7 @@ VFS 组件支持通过 :cpp:func:`select` 进行同步输入/输出多路复用 请参考 :component_file:`lwip/port/esp32/vfs_lwip.c` 以了解使用 LWIP 的套接字驱动参考实现。 .. note:: - 如果 :cpp:func:`select` 只用于套接字文件描述符,您可以启用 :envvar:`CONFIG_LWIP_USE_ONLY_LWIP_SELECT` 选项来减少代码量,提高性能。 + 如果 :cpp:func:`select` 用于套接字文件描述符,您可以禁用 :envvar:`CONFIG_VFS_SUPPORT_SELECT` 选项来减少代码量,提高性能。 不要在 :cpp:func:`select` 调用过程中更改套接字驱动,否则会出现一些未定义行为。 路径 From 338938461361318307056fef81ff5742c8a395ca Mon Sep 17 00:00:00 2001 From: David Cermak Date: Mon, 20 Sep 2021 10:36:26 +0200 Subject: [PATCH 3/6] lwip/docs: Removed unsupported CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES --- docs/en/api-guides/lwip.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/en/api-guides/lwip.rst b/docs/en/api-guides/lwip.rst index af8d2da009..c3c9ba8d14 100644 --- a/docs/en/api-guides/lwip.rst +++ b/docs/en/api-guides/lwip.rst @@ -368,11 +368,6 @@ The following API functions are supported. For full details see :component_file: - ``sys_timeouts_init()`` - ``sys_timeouts_deinit()`` -Abort TCP connections when IP changes -+++++++++++++++++++++++++++++++++++++ - -:ref:`CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES` is disabled by default. This disables the default lwIP behaviour of keeping TCP connections open if an interface IP changes, in case the interface IP changes back (for example, if an interface connection goes down and comes back up). Enable this option to keep TCP connections open in this case, until they time out normally. This may increase the number of sockets in use if a network interface goes down temporarily. - Additional Socket Options +++++++++++++++++++++++++ From b597dbff7c03b4a5b345b85bd21701e9ab7fa8fd Mon Sep 17 00:00:00 2001 From: David Cermak Date: Mon, 20 Sep 2021 16:17:59 +0200 Subject: [PATCH 4/6] vfs: Warn aobut using deprecated select option Add LWIP_USE_ONLY_LWIP_SELECT for compatibility, as the dependency may break backward compatibility if LWIP_USE_ONLY_LWIP_SELECT=y. --- components/lwip/Kconfig | 6 ++++++ components/vfs/vfs.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index b644b2f2be..9d1d7561d3 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -81,6 +81,12 @@ menu "LWIP" the maximum amount of sockets here. The valid value is from 1 to 16. + config LWIP_USE_ONLY_LWIP_SELECT + bool "Support LWIP socket select() only (DEPRECATED)" + default n + help + This option is deprecated. Do not use this option, use VFS_SUPPORT_SELECT instead. + config LWIP_SO_LINGER bool "Enable SO_LINGER processing" default n diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index 9ca3689d26..ad38c0edd4 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -21,6 +21,11 @@ #include "esp_vfs_private.h" #include "sdkconfig.h" +// Warn about using deprecated option +#ifdef CONFIG_LWIP_USE_ONLY_LWIP_SELECT +#warning LWIP_USE_ONLY_LWIP_SELECT is deprecated: Please use VFS_SUPPORT_SELECT instead +#endif + #ifdef CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT #define LOG_LOCAL_LEVEL ESP_LOG_NONE #endif //CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT From 5d7489eae4db6630aeaa3313382a615838f35a28 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Mon, 11 Oct 2021 17:14:03 +0200 Subject: [PATCH 5/6] lwip: Fix minor lwip dependency issue Clean-up config option rename file --- components/lwip/Kconfig | 1 + components/lwip/port/esp32/include/lwipopts.h | 2 +- components/lwip/sdkconfig.rename | 1 - components/vfs/vfs.c | 2 +- tools/ci/check_copyright_config.yaml | 1 + 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 9d1d7561d3..5b2e6398ce 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -540,6 +540,7 @@ menu "LWIP" config LWIP_TCP_SACK_OUT bool "Support sending selective acknowledgements" default n + depends on LWIP_TCP_QUEUE_OOSEQ help TCP will support sending selective acknowledgements (SACKs). diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index 9dc70286d9..89f7210645 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: BSD-3-Clause * - * SPDX-FileContributor: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2015-2022 Espressif Systems (Shanghai) CO LTD */ #ifndef LWIP_HDR_ESP_LWIPOPTS_H #define LWIP_HDR_ESP_LWIPOPTS_H diff --git a/components/lwip/sdkconfig.rename b/components/lwip/sdkconfig.rename index da63c8e079..527363f64b 100644 --- a/components/lwip/sdkconfig.rename +++ b/components/lwip/sdkconfig.rename @@ -15,7 +15,6 @@ CONFIG_TCP_SND_BUF_DEFAULT CONFIG_LWIP_TCP_SND_BUF_DEFAULT CONFIG_TCP_WND_DEFAULT CONFIG_LWIP_TCP_WND_DEFAULT CONFIG_TCP_RECVMBOX_SIZE CONFIG_LWIP_TCP_RECVMBOX_SIZE CONFIG_TCP_QUEUE_OOSEQ CONFIG_LWIP_TCP_QUEUE_OOSEQ -CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES CONFIG_TCP_OVERSIZE CONFIG_LWIP_TCP_OVERSIZE CONFIG_TCP_OVERSIZE_MSS CONFIG_LWIP_TCP_OVERSIZE_MSS CONFIG_TCP_OVERSIZE_QUARTER_MSS CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index ad38c0edd4..27986e7af3 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -23,7 +23,7 @@ // Warn about using deprecated option #ifdef CONFIG_LWIP_USE_ONLY_LWIP_SELECT -#warning LWIP_USE_ONLY_LWIP_SELECT is deprecated: Please use VFS_SUPPORT_SELECT instead +#warning CONFIG_LWIP_USE_ONLY_LWIP_SELECT is deprecated: Please use CONFIG_VFS_SUPPORT_SELECT instead #endif #ifdef CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT diff --git a/tools/ci/check_copyright_config.yaml b/tools/ci/check_copyright_config.yaml index 80cfd5e6d6..29d1dabb63 100644 --- a/tools/ci/check_copyright_config.yaml +++ b/tools/ci/check_copyright_config.yaml @@ -79,3 +79,4 @@ ignore: - '!components/bt/host/bluedroid/api/' - '!components/bt/host/bluedroid/btc/' - examples/zigbee/ + - components/lwip/port/esp32/include/lwipopts.h From 66438366a21e0d145a4b5c5c6044c345e44a4798 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 14 Jan 2022 16:44:44 +0100 Subject: [PATCH 6/6] ci: Create a copyright entry for lwip-component --- tools/ci/check_copyright_config.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/ci/check_copyright_config.yaml b/tools/ci/check_copyright_config.yaml index 29d1dabb63..856aeebdfa 100644 --- a/tools/ci/check_copyright_config.yaml +++ b/tools/ci/check_copyright_config.yaml @@ -65,6 +65,14 @@ freemodbus_component: - BSD-3-Clause license_for_new_files: Apache-2.0 +lwip_component: + include: + - 'components/lwip/**' + allowed_licenses: + - Apache-2.0 + - BSD-3-Clause + license_for_new_files: Apache-2.0 + # files matching this section do not perform the check # file patterns starting with ! are negated, meaning files matching them won't match the section. ignore: @@ -79,4 +87,3 @@ ignore: - '!components/bt/host/bluedroid/api/' - '!components/bt/host/bluedroid/btc/' - examples/zigbee/ - - components/lwip/port/esp32/include/lwipopts.h