Skip to content

Commit 241e257

Browse files
authored
fix(async): Update IP setup in AsyncUDP (#11569)
* fix(async): Update IP setup in AsyncUDP * fix(udp): Revert to IP_SET_TYPE_VAL in connect
1 parent 040e0ca commit 241e257

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

libraries/AsyncUDP/src/AsyncUDP.cpp

Lines changed: 4 additions & 13 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;
@@ -692,17 +692,8 @@ bool AsyncUDP::listenMulticast(const ip_addr_t *addr, uint16_t port, uint8_t ttl
692692
return false;
693693
}
694694

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
695+
IP_SET_TYPE(&bind_addr, IP_GET_TYPE(addr));
696+
ip_addr_set_any(IP_IS_V6(addr), &bind_addr);
706697
if (!listen(&bind_addr, port)) {
707698
return false;
708699
}

0 commit comments

Comments
 (0)