From 95e85c74e7310a595aa6bd57dbbc69ec3516e9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20St=C3=B6r?= Date: Sat, 20 Aug 2016 22:06:40 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"with=20this=20small=20fix,=20the=20DN?= =?UTF-8?q?S=20engine=20is=20RFC=205452=20compliant=20because=20it=20?= =?UTF-8?q?=E2=80=A6"=20(#1465)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/include/lwip/udp.h | 5 ----- app/lwip/core/dns.c | 10 ++-------- app/lwip/core/udp.c | 4 ++++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/app/include/lwip/udp.h b/app/include/lwip/udp.h index 760b24cf..cb53d33e 100644 --- a/app/include/lwip/udp.h +++ b/app/include/lwip/udp.h @@ -156,11 +156,6 @@ void udp_input (struct pbuf *p, struct netif *inp)ICACHE_FLASH_ #define udp_init() /* Compatibility define, not init needed. */ -#ifndef UDP_LOCAL_PORT_RANGE_START -#define UDP_LOCAL_PORT_RANGE_START 4096 -#define UDP_LOCAL_PORT_RANGE_END 0x7fff -#endif - #if UDP_DEBUG void udp_debug_print(struct udp_hdr *udphdr)ICACHE_FLASH_ATTR; #else diff --git a/app/lwip/core/dns.c b/app/lwip/core/dns.c index 72a31995..c0d616f2 100644 --- a/app/lwip/core/dns.c +++ b/app/lwip/core/dns.c @@ -254,14 +254,8 @@ dns_init() LWIP_ASSERT("For implicit initialization to work, DNS_STATE_UNUSED needs to be 0", DNS_STATE_UNUSED == 0); - /* initialize DNS client, try to get RFC 5452 random source port */ - u16_t port = UDP_LOCAL_PORT_RANGE_START + (os_random() % (UDP_LOCAL_PORT_RANGE_END - UDP_LOCAL_PORT_RANGE_START)); - for(;;) { - if(udp_bind(dns_pcb, IP_ADDR_ANY, port) == ERR_OK) - break; - LWIP_ASSERT("Unable to get a PCB for DNS", port != 0); - port=0; // try again with random source - } + /* initialize DNS client */ + udp_bind(dns_pcb, IP_ADDR_ANY, 0); udp_recv(dns_pcb, dns_recv, NULL); /* initialize default DNS primary server */ diff --git a/app/lwip/core/udp.c b/app/lwip/core/udp.c index 2d794818..e44d7f38 100644 --- a/app/lwip/core/udp.c +++ b/app/lwip/core/udp.c @@ -758,6 +758,10 @@ udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) /* no port specified? */ if (port == 0) { +#ifndef UDP_LOCAL_PORT_RANGE_START +#define UDP_LOCAL_PORT_RANGE_START 4096 +#define UDP_LOCAL_PORT_RANGE_END 0x7fff +#endif port = UDP_LOCAL_PORT_RANGE_START; ipcb = udp_pcbs; while ((ipcb != NULL) && (port != UDP_LOCAL_PORT_RANGE_END)) {