Pelle Windestam Pelle.Windestam@tagmaster.com [nuttx]
2018-02-08 13:02:08 UTC
Hi,
We have previously used the getsockname() function on a UDP socket to get our local ip address. When we upgraded to NuttX 7.23 (from 7.21) this stopped working. I traced this down to a change in net/socket/getsockname.c, where the function ipv4_getsockname() was moved to net/inet/ipv4_getsockname.c. The function was also changed such that if the local address (upd_conn.u.ipv4.laddr) is set to 0 (i.e. INADDR_ANY) the returned IP-address is also 0. In the previous version, a local address of zero (for the socket) returned the IP address of the first ethernet device. I was wondering if this is intentional? From the posix spec:
"If the socket has not been bound to a local name, the value stored in the object pointed to by address is unspecified."
We do not bind the socket specifically, but send on it using sendto() which eventually calls udp_connect() which binds the socket to a local port. Not sure if this counts as binding it to a local name or not?
//Pelle
We have previously used the getsockname() function on a UDP socket to get our local ip address. When we upgraded to NuttX 7.23 (from 7.21) this stopped working. I traced this down to a change in net/socket/getsockname.c, where the function ipv4_getsockname() was moved to net/inet/ipv4_getsockname.c. The function was also changed such that if the local address (upd_conn.u.ipv4.laddr) is set to 0 (i.e. INADDR_ANY) the returned IP-address is also 0. In the previous version, a local address of zero (for the socket) returned the IP address of the first ethernet device. I was wondering if this is intentional? From the posix spec:
"If the socket has not been bound to a local name, the value stored in the object pointed to by address is unspecified."
We do not bind the socket specifically, but send on it using sendto() which eventually calls udp_connect() which binds the socket to a local port. Not sure if this counts as binding it to a local name or not?
//Pelle