udp: Ipv4/6 can be bound to the same port

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2022-08-24 15:06:59 +08:00 committed by Petro Karashchenko
parent 82e2e4124a
commit 1857a4a3c8

View File

@ -124,7 +124,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain,
if (domain == PF_INET)
#endif
{
if (conn->lport == portno &&
if (conn->domain == PF_INET && conn->lport == portno &&
(net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr->ipv4.laddr) ||
net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY)))
{
@ -138,7 +138,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain,
else
#endif
{
if (conn->lport == portno &&
if (conn->domain == PF_INET6 && conn->lport == portno &&
(net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr->ipv6.laddr) ||
net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr)))
{