Skip to content

Commit 3941b3a

Browse files
authored
IPv4 ONLY listenMulticast()
1 parent 3c0b406 commit 3941b3a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libraries/AsyncUDP/src/AsyncUDP.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ bool AsyncUDP::listen(const ip_addr_t *addr, uint16_t port) {
582582
}
583583
close();
584584
if (addr) {
585-
IP_SET_TYPE_VAL(_pcb->local_ip, addr->type);
586-
IP_SET_TYPE_VAL(_pcb->remote_ip, addr->type);
585+
IP_SET_TYPE_VAL(_pcb->local_ip, IP_GET_TYPE(addr));
586+
IP_SET_TYPE_VAL(_pcb->remote_ip, IP_GET_TYPE(addr));
587587
}
588588
if (_udp_bind(_pcb, addr, port) != ERR_OK) {
589589
return false;
@@ -682,6 +682,8 @@ static esp_err_t joinMulticastGroup(const ip_addr_t *addr, bool join, tcpip_adap
682682
}
683683

684684
bool AsyncUDP::listenMulticast(const ip_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
return false;
687689
}
@@ -690,7 +692,9 @@ bool AsyncUDP::listenMulticast(const ip_addr_t *addr, uint16_t port, uint8_t ttl
690692
return false;
691693
}
692694

693-
if (!listen(NULL, port)) {
695+
IP_SET_TYPE(&bind_addr, IP_GET_TYPE(addr));
696+
ip_addr_set_any(IP_IS_V6(addr), &bind_addr);
697+
if (!listen(&bind_addr, port)) {
694698
return false;
695699
}
696700

0 commit comments

Comments
 (0)