Skip to content

Commit 45feadc

Browse files
authored
emulation on host: various fixes (#7355)
(trying to compile LEAmDNS2)
1 parent 23febc1 commit 45feadc

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

tests/host/common/MockWiFiServerSocket.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ void WiFiServer::begin (uint16_t port, uint8_t backlog)
6767
{
6868
if (!backlog)
6969
return;
70-
_port = port;
71-
return begin();
70+
_port = port;
71+
return begin();
7272
}
7373

7474
void WiFiServer::begin ()

tests/host/common/MocklwIP.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,31 @@ err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr)
3333
return ERR_OK;
3434
}
3535

36+
err_t igmp_start(struct netif* netif)
37+
{
38+
(void)netif;
39+
return ERR_OK;
40+
}
41+
42+
err_t igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
43+
{
44+
(void)netif;
45+
(void)groupaddr;
46+
return ERR_OK;
47+
}
48+
49+
err_t igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
50+
{
51+
(void)netif;
52+
(void)groupaddr;
53+
return ERR_OK;
54+
}
55+
56+
struct netif* netif_get_by_index(u8_t idx)
57+
{
58+
(void)idx;
59+
return &netif0;
60+
}
61+
62+
3663
} // extern "C"

tests/host/common/include/UdpContext.h

+15-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class UdpContext;
2828
#define GET_IP_HDR(pb) reinterpret_cast<ip_hdr*>(((uint8_t*)((pb)->payload)) - UDP_HLEN - IP_HLEN);
2929
#define GET_UDP_HDR(pb) reinterpret_cast<udp_hdr*>(((uint8_t*)((pb)->payload)) - UDP_HLEN);
3030

31+
extern netif netif0;
32+
3133
class UdpContext
3234
{
3335
public:
@@ -86,12 +88,24 @@ class UdpContext
8688
_dst.addr = staticMCastAddr;
8789
}
8890

91+
void setMulticastInterface(netif* p_pNetIf)
92+
{
93+
(void)p_pNetIf;
94+
// user multicast, and this is how it works with posix: send to multicast address:
95+
_dst.addr = staticMCastAddr;
96+
}
97+
8998
void setMulticastTTL(int ttl)
9099
{
91100
(void)ttl;
92101
//mockverbose("TODO: UdpContext::setMulticastTTL\n");
93102
}
94103

104+
netif* getInputNetif() const
105+
{
106+
return &netif0;
107+
}
108+
95109
// warning: handler is called from tcp stack context
96110
// esp_yield and non-reentrant functions which depend on it will fail
97111
void onRx(rxhandler_t handler) {
@@ -246,7 +260,7 @@ class UdpContext
246260
uint8_t addr[16];
247261
};
248262

249-
inline err_t igmp_joingroup (const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
263+
extern "C" inline err_t igmp_joingroup (const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
250264
{
251265
(void)ifaddr;
252266
UdpContext::staticMCastAddr = groupaddr->addr;

tests/host/sys/pgmspace.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ inline int vsnprintf_P(char *str, size_t size, const char *format, va_list ap) {
6767
#define snprintf_P snprintf
6868
#define sprintf_P sprintf
6969
#define strncmp_P strncmp
70+
#define strcat_P strcat
7071

7172
#endif

0 commit comments

Comments
 (0)