From efb6749230c9ca61872b5036309f6480d767c15f Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 5 Jul 2022 22:52:02 +0200 Subject: [PATCH 1/2] emulation on host: fix incorrect lwIP DNS implementation +initialize netif0, make ipv6 example unfail --- tests/host/common/MocklwIP.cpp | 17 +++++++++++++++++ tests/host/common/user_interface.cpp | 28 +++++++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tests/host/common/MocklwIP.cpp b/tests/host/common/MocklwIP.cpp index 47b62ebb46..57f9d4ad50 100644 --- a/tests/host/common/MocklwIP.cpp +++ b/tests/host/common/MocklwIP.cpp @@ -3,6 +3,9 @@ #include "MocklwIP.h" +#include +#include + esp8266::AddressListImplementation::AddressList addrList; extern "C" @@ -57,4 +60,18 @@ extern "C" return &netif0; } + void dns_setserver(u8_t numdns, const ip_addr_t* dnsserver) + { + (void)numdns; + (void)dnsserver; + } + + const ip_addr_t* dns_getserver(u8_t numdns) + { + (void)numdns; + static ip_addr_t addr; + addr.addr = htonl(0x7f000001); // 127.0.0.1 + return &addr; + } + } // extern "C" diff --git a/tests/host/common/user_interface.cpp b/tests/host/common/user_interface.cpp index c35a7cc236..6edc9bdbc5 100644 --- a/tests/host/common/user_interface.cpp +++ b/tests/host/common/user_interface.cpp @@ -136,8 +136,7 @@ extern "C" for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) { mockverbose("host: interface: %s", ifa->ifa_name); - if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET // ip_info is IPv4 only - ) + if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) // ip_info is IPv4 only { auto test_ipv4 = lwip_ntohl(*(uint32_t*)&((struct sockaddr_in*)ifa->ifa_addr)->sin_addr); @@ -179,14 +178,14 @@ extern "C" info->ip.addr = ipv4; info->netmask.addr = mask; info->gw.addr = ipv4; - - netif0.ip_addr.addr = ipv4; - netif0.netmask.addr = mask; - netif0.gw.addr = ipv4; - netif0.flags = NETIF_FLAG_IGMP | NETIF_FLAG_UP | NETIF_FLAG_LINK_UP; - netif0.next = nullptr; } + netif0.ip_addr.addr = ipv4; + netif0.netmask.addr = mask; + netif0.gw.addr = ipv4; + netif0.flags = NETIF_FLAG_IGMP | NETIF_FLAG_UP | NETIF_FLAG_LINK_UP; + netif0.next = nullptr; + return true; } @@ -416,19 +415,6 @@ extern "C" (void)intr; } - void dns_setserver(u8_t numdns, ip_addr_t* dnsserver) - { - (void)numdns; - (void)dnsserver; - } - - ip_addr_t dns_getserver(u8_t numdns) - { - (void)numdns; - ip_addr_t addr = { 0x7f000001 }; - return addr; - } - #include bool smartconfig_start(sc_callback_t cb, ...) { From 293db496b902a219cebc3d3ba021133cb5ad8991 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Wed, 6 Jul 2022 22:54:32 +0200 Subject: [PATCH 2/2] rage against lazyness --- tests/host/common/MocklwIP.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/host/common/MocklwIP.cpp b/tests/host/common/MocklwIP.cpp index 57f9d4ad50..8df8929d98 100644 --- a/tests/host/common/MocklwIP.cpp +++ b/tests/host/common/MocklwIP.cpp @@ -4,7 +4,6 @@ #include "MocklwIP.h" #include -#include esp8266::AddressListImplementation::AddressList addrList; @@ -70,7 +69,7 @@ extern "C" { (void)numdns; static ip_addr_t addr; - addr.addr = htonl(0x7f000001); // 127.0.0.1 + IP4_ADDR(&addr, 127, 0, 0, 1); return &addr; }