From bea5140156641217086ae89fbc87d6bb2b01ef94 Mon Sep 17 00:00:00 2001 From: Roland Takacs Date: Mon, 19 Jun 2017 12:52:48 +0200 Subject: [PATCH] Support listening sockets in the getsockname function --- net/socket/getsockname.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/socket/getsockname.c b/net/socket/getsockname.c index ba7cc76434..a8d02552db 100644 --- a/net/socket/getsockname.c +++ b/net/socket/getsockname.c @@ -157,6 +157,10 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, #ifdef CONFIG_NETDEV_MULTINIC /* Find the device matching the IPv4 address in the connection structure */ + if (ripaddr == 0) + { + ripaddr = lipaddr; + } dev = netdev_findby_ipv4addr(lipaddr, ripaddr); #else @@ -280,6 +284,10 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, #ifdef CONFIG_NETDEV_MULTINIC /* Find the device matching the IPv6 address in the connection structure */ + if (*ripaddr == 0) + { + ripaddr = lipaddr; + } dev = netdev_findby_ipv6addr(*lipaddr, *ripaddr); #else