Do not search net device when all-zeros address is used.

This commit is contained in:
Roland Takacs 2017-06-22 09:06:04 +02:00
parent a8282c0c39
commit a353602aa9

View File

@ -153,6 +153,17 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
* a single network device and only the network device knows the IP address.
*/
if (lipaddr == 0)
{
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
outaddr->sin_family = AF_INET;
outaddr->sin_addr.s_addr = 0;
*addrlen = sizeof(struct sockaddr_in);
#endif
return OK;
}
net_lock();
#ifdef CONFIG_NETDEV_MULTINIC
@ -160,7 +171,7 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
* NOTE: listening sockets have no ripaddr. Work around is to use the
* lipaddr when ripaddr is not available.
*/
`
if (ripaddr == 0)
{
ripaddr = lipaddr;
@ -284,6 +295,17 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
* a single network device and only the network device knows the IP address.
*/
if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
{
#if defined(NET_TCP_HAVE_STACK) || defined(NET_UDP_HAVE_STACK)
outaddr->sin6_family = AF_INET6;
memcpy(outaddr->sin6_addr.in6_u.u6_addr8, g_ipv6_allzeroaddr, 16);
*addrlen = sizeof(struct sockaddr_in6);
#endif
return OK;
}
net_lock();
#ifdef CONFIG_NETDEV_MULTINIC