Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd6a76da

Browse files
authored
fix(libraries/asyncudp): IPv4 ONLY listenMulticast() (#11444)
AsyncUDP::listenMulticast() properly receives packets sent to IPv4multicast addresses like 239.1.2.3, but it is not receiving packets sentto IPv6 multicast addresses like ff12::6ood:cafe.The root cause is a bit hidden: listen(NULL, port) would matchAsyncUDP::listen(const ip_addr_t *addr, uint16_t port), which calls_udp_bind(_pcb, addr, port), which uses the lwIP API to calludp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) atthe end. If lwIP has LWIP_IPV4 enabled, it checks if ipaddr == NULL andsets it to IP4_ADDR_ANY. So an IPv6 address is never bound.This fix checks the IP address passed to AsyncUDP::listenMulticast(). Ifit is an IPv6 address, it constructs and passes the IPv6 any address(::); otherwise (IPv4), it constructs and passes the IPv4 any address(0.0.0.0).
1 parent0aada09 commitd6a76da

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎libraries/AsyncUDP/src/AsyncUDP.cpp‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@ static esp_err_t joinMulticastGroup(const ip_addr_t *addr, bool join, tcpip_adap
682682
}
683683

684684
boolAsyncUDP::listenMulticast(constip_addr_t *addr,uint16_t port,uint8_t ttl,tcpip_adapter_if_t tcpip_if) {
685+
ip_addr_t bind_addr;
686+
685687
if (!ip_addr_ismulticast(addr)) {
686688
returnfalse;
687689
}
@@ -690,7 +692,18 @@ bool AsyncUDP::listenMulticast(const ip_addr_t *addr, uint16_t port, uint8_t ttl
690692
returnfalse;
691693
}
692694

693-
if (!listen(NULL, port)) {
695+
#if CONFIG_LWIP_IPV6
696+
if (IP_IS_V6(addr)) {
697+
IP_SET_TYPE(&bind_addr, IPADDR_TYPE_V6);
698+
ip6_addr_set_any(&bind_addr.u_addr.ip6);
699+
}else {
700+
#endif
701+
IP_SET_TYPE(&bind_addr, IPADDR_TYPE_V4);
702+
ip4_addr_set_any(&bind_addr.u_addr.ip4);
703+
#if CONFIG_LWIP_IPV6
704+
}
705+
#endif
706+
if (!listen(&bind_addr, port)) {
694707
returnfalse;
695708
}
696709

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp