From 2cc8c91ad8e676d2d8f8ba32d1297b7b85034897 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 10 Jul 2017 17:22:56 +0800 Subject: [PATCH] lwip: Remove undocumented CONFIG_MDNS macro flag All options that were enabled via CONFIG_MDNS are now in menuconfig, with the default values set the same as with CONFIG_MDNS enabled (meaning existing projects that were using CONFIG_MDNS do not need to change). --- components/lwip/Kconfig | 90 ++++++++++++++++++-- components/lwip/include/lwip/lwip/autoip.h | 9 +- components/lwip/include/lwip/lwip/opt.h | 16 ++++ components/lwip/include/lwip/port/lwipopts.h | 22 ++--- examples/protocols/udp_multicast/Makefile | 2 - 5 files changed, 110 insertions(+), 29 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index c9c796f87..250dc9b4e 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -35,11 +35,25 @@ config LWIP_THREAD_LOCAL_STORAGE_INDEX config LWIP_SO_REUSE bool "Enable SO_REUSEADDR option" - default n + default y help Enabling this option allows binding to a port which remains in TIME_WAIT. +config LWIP_SO_REUSE_RXTOALL + bool "SO_REUSEADDR copies broadcast/multicast to all matches" + depends on LWIP_SO_REUSE + default y + help + Enabling this option means that any incoming broadcast or multicast + packet will be copied to all of the local sockets that it matches + (may be more than one if SO_REUSEADDR is set on the socket.) + + This increases memory overhead as the packets need to be copied, + however they are only copied per matching socket. You can safely + disable it if you don't plan to receive broadcast or multicast + traffic on more than one socket at a time. + config LWIP_SO_RCVBUF bool "Enable SO_RCVBUF option" default n @@ -88,7 +102,6 @@ config LWIP_ETHARP_TRUST_IP_MAC 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! - config TCPIP_RECVMBOX_SIZE int "TCPIP receive mail box size" @@ -98,6 +111,72 @@ config TCPIP_RECVMBOX_SIZE Set TCPIP receive mail box size. Generally bigger value means higher throughput but more memory. The value should be bigger than UDP/TCP mail box size. +config LWIP_DHCP_DOES_ARP_CHECK + bool "DHCP: Perform ARP check on any offered address" + default y + help + Enabling this option performs a check (via ARP request) if the offered IP address + is not already in use by another host on the network. + +menuconfig LWIP_AUTOIP + bool "Enable IPV4 Link-Local Addressing (AUTOIP)" + default y + help + Enabling this option allows the device to self-assign an address + in the 169.256/16 range if none is assigned statically or via DHCP. + + See RFC 3927. + +config LWIP_AUTOIP_TRIES + int "DHCP Probes before self-assigning IPv4 LL address" + range 1 100 + default 2 + depends on LWIP_AUTOIP + help + DHCP client will send this many probes before self-assigning a + link local address. + + From LWIP help: "This can be set as low as 1 to get an AutoIP + address very quickly, but you should be prepared to handle a + changing IP address when DHCP overrides AutoIP." (In the case of + ESP-IDF, this means multiple SYSTEM_EVENT_STA_GOT_IP events.) + +config LWIP_AUTOIP_MAX_CONFLICTS + int "Max IP conflicts before rate limiting" + range 1 100 + default 9 + depends on LWIP_AUTOIP + help + If the AUTOIP functionality detects this many IP conflicts while + self-assigning an address, it will go into a rate limited mode. + +config LWIP_AUTOIP_RATE_LIMIT_INTERVAL + int "Rate limited interval (seconds)" + range 5 120 + default 20 + depends on LWIP_AUTOIP + help + If rate limiting self-assignment requests, wait this long between + each request. + +menuconfig LWIP_NETIF_LOOPBACK + bool "Support per-interface loopback" + default y + help + 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. + +config LWIP_LOOPBACK_MAX_PBUFS + int "Max queued loopback packets per interface" + range 0 16 + default 8 + depends on LWIP_NETIF_LOOPBACK + help + Configure the maximum number of packets which can be queued for + loopback on a given interface. Reducing this number may cause packets + to be dropped, but will avoid filling memory with queued packet data. + menu "TCP" config TCP_MAXRTX @@ -234,13 +313,6 @@ config UDP_RECVMBOX_SIZE endmenu # UDP -config LWIP_DHCP_DOES_ARP_CHECK - bool "Enable an ARP check on the offered address" - default y - help - Enabling this option allows check if the offered IP address is not already - in use by another host on the network. - config TCPIP_TASK_STACK_SIZE int "TCP/IP Task Stack Size" default 2560 diff --git a/components/lwip/include/lwip/lwip/autoip.h b/components/lwip/include/lwip/lwip/autoip.h index 3bb413f49..16eac510e 100755 --- a/components/lwip/include/lwip/lwip/autoip.h +++ b/components/lwip/include/lwip/lwip/autoip.h @@ -68,13 +68,8 @@ extern "C" { #define ANNOUNCE_NUM 2 /* (number of announcement packets) */ #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ -#if CONFIG_MDNS -#define MAX_CONFLICTS 9 /* (max conflicts before rate limiting) */ -#define RATE_LIMIT_INTERVAL 20 /* seconds (delay between successive attempts) */ -#else -#define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ -#define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ -#endif +#define MAX_CONFLICTS LWIP_AUTOIP_MAX_CONFLICTS /* (max conflicts before rate limiting) */ +#define RATE_LIMIT_INTERVAL LWIP_AUTOIP_RATE_LIMIT_INTERVAL /* seconds (delay between successive attempts) */ #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ /* AutoIP client states */ diff --git a/components/lwip/include/lwip/lwip/opt.h b/components/lwip/include/lwip/lwip/opt.h index 4d8d6bf70..6ea556ac1 100755 --- a/components/lwip/include/lwip/lwip/opt.h +++ b/components/lwip/include/lwip/lwip/opt.h @@ -823,6 +823,22 @@ #define LWIP_DHCP_AUTOIP_COOP_TRIES 9 #endif +/** + * LWIP_AUTOIP_MAX_CONFLICTS: + * Maximum number of AutoIP IP conflicts before rate limiting is enabled. + */ +#ifndef LWIP_AUTOIP_MAX_CONFLICTS +#define LWIP_AUTOIP_MAX_CONFLICTS 10 +#endif + +/** + * LWIP_AUTOIP_RATE_LIMIT_INTERVAL: + * Rate limited request interval, in seconds. + */ +#ifndef LWIP_AUTOIP_RATE_LIMIT_INTERVAL +#define LWIP_AUTOIP_RATE_LIMIT_INTERVAL 60 +#endif + /* ---------------------------------- ----- SNMP MIB2 support ----- diff --git a/components/lwip/include/lwip/port/lwipopts.h b/components/lwip/include/lwip/port/lwipopts.h index 89d09d2d7..47b80ff61 100644 --- a/components/lwip/include/lwip/port/lwipopts.h +++ b/components/lwip/include/lwip/port/lwipopts.h @@ -221,10 +221,7 @@ ---------- AUTOIP options ---------- ------------------------------------ */ -#if CONFIG_MDNS - /** - * LWIP_AUTOIP==1: Enable AUTOIP module. - */ +#ifdef CONFIG_LWIP_AUTOIP #define LWIP_AUTOIP 1 /** @@ -240,8 +237,13 @@ * be prepared to handle a changing IP address when DHCP overrides * AutoIP. */ -#define LWIP_DHCP_AUTOIP_COOP_TRIES 2 -#endif +#define LWIP_DHCP_AUTOIP_COOP_TRIES CONFIG_LWIP_AUTOIP_TRIES + +#define LWIP_AUTOIP_MAX_CONFLICTS CONFIG_LWIP_AUTOIP_MAX_CONFLICTS + +#define LWIP_AUTOIP_RATE_LIMIT_INTERVAL CONFIG_LWIP_AUTOIP_RATE_LIMIT_INTERVAL + +#endif /* CONFIG_LWIP_AUTOIP */ /* ---------------------------------- @@ -367,7 +369,7 @@ ---------- LOOPIF options ---------- ------------------------------------ */ -#if CONFIG_MDNS +#ifdef CONFIG_LWIP_NETIF_LOOPBACK /** * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP * address equal to the netif IP address, looping them back up the stack. @@ -378,7 +380,7 @@ * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback * sending for each netif (0 = disabled) */ -#define LWIP_LOOPBACK_MAX_PBUFS 8 +#define LWIP_LOOPBACK_MAX_PBUFS CONFIG_LWIP_LOOPBACK_MAX_PBUFS #endif /* @@ -506,14 +508,12 @@ */ #define SO_REUSE CONFIG_LWIP_SO_REUSE -#if CONFIG_MDNS /** * 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 1 -#endif +#define SO_REUSE_RXTOALL CONFIG_LWIP_SO_REUSE_RXTOALL /* ---------------------------------------- diff --git a/examples/protocols/udp_multicast/Makefile b/examples/protocols/udp_multicast/Makefile index 35474e5d4..60f3d59db 100644 --- a/examples/protocols/udp_multicast/Makefile +++ b/examples/protocols/udp_multicast/Makefile @@ -5,7 +5,5 @@ PROJECT_NAME := udp-multicast -CFLAGS := -DCONFIG_MDNS - include $(IDF_PATH)/make/project.mk