1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

emulation on host: fix incorrect lwIP DNS implementation (#8627)

* emulation on host: fix incorrect lwIP DNS implementation
+initialize netif0, make ipv6 example unfail
This commit is contained in:
david gauchard 2022-07-09 12:36:35 +02:00 committed by GitHub
parent a8e3786d38
commit 00f5f2acc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 21 deletions

View File

@ -3,6 +3,8 @@
#include "MocklwIP.h"
#include <lwip/dns.h>
esp8266::AddressListImplementation::AddressList addrList;
extern "C"
@ -57,4 +59,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;
IP4_ADDR(&addr, 127, 0, 0, 1);
return &addr;
}
} // extern "C"

View File

@ -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,13 +178,13 @@ 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;
}
return true;
}
@ -418,19 +417,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 <smartconfig.h>
bool smartconfig_start(sc_callback_t cb, ...)
{