Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emulation on host: fix incorrect lwIP DNS implementation #8627

Merged
merged 3 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/host/common/MocklwIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include "MocklwIP.h"

#include <lwip/dns.h>
#include <arpa/inet.h>

esp8266::AddressListImplementation::AddressList addrList;

extern "C"
Expand Down Expand Up @@ -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
d-a-v marked this conversation as resolved.
Show resolved Hide resolved
return &addr;
}

} // extern "C"
28 changes: 7 additions & 21 deletions tests/host/common/user_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 <smartconfig.h>
bool smartconfig_start(sc_callback_t cb, ...)
{
Expand Down