You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2019/12/24 16:46:28 UTC
[incubator-nuttx] 01/01: tcp_conn: Check if the remote address is
unspecified
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 86cdfd59a0f7000386ef271eef1df571dbbbfd78
Author: chao.an <an...@xiaomi.com>
AuthorDate: Tue Dec 24 18:00:54 2019 +0800
tcp_conn: Check if the remote address is unspecified
Change-Id: I6f547bb4bfb3bb621573db9097a531ce2260e794
Signed-off-by: chao.an <an...@xiaomi.com>
---
net/tcp/tcp_finddev.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/net/tcp/tcp_finddev.c b/net/tcp/tcp_finddev.c
index ed4cfc9..581ac72 100644
--- a/net/tcp/tcp_finddev.c
+++ b/net/tcp/tcp_finddev.c
@@ -71,7 +71,8 @@
****************************************************************************/
#ifdef CONFIG_NET_IPv4
-static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr)
+static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn,
+ in_addr_t addr, bool local)
{
/* Do nothing if a device is already bound to the connection */
@@ -88,7 +89,7 @@ static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr)
if (net_ipv4addr_cmp(addr, INADDR_ANY))
{
- return OK;
+ return local ? OK : -EINVAL;
}
/* We need to select the device that is going to route the TCP packet
@@ -121,7 +122,7 @@ static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr)
#ifdef CONFIG_NET_IPv6
static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
- const net_ipv6addr_t addr)
+ const net_ipv6addr_t addr, bool local)
{
/* Do nothing if a device is already bound to the connection */
@@ -138,7 +139,7 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
if (net_ipv6addr_cmp(addr, g_ipv6_unspecaddr))
{
- return OK;
+ return local ? OK : -EINVAL;
}
/* We need to select the device that is going to route the TCP packet
@@ -177,7 +178,7 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
#ifdef CONFIG_NET_IPv4
int tcp_local_ipv4_device(FAR struct tcp_conn_s *conn)
{
- return tcp_find_ipv4_device(conn, conn->u.ipv4.laddr);
+ return tcp_find_ipv4_device(conn, conn->u.ipv4.laddr, true);
}
#endif /* CONFIG_NET_IPv4 */
@@ -201,7 +202,7 @@ int tcp_local_ipv4_device(FAR struct tcp_conn_s *conn)
#ifdef CONFIG_NET_IPv4
int tcp_remote_ipv4_device(FAR struct tcp_conn_s *conn)
{
- return tcp_find_ipv4_device(conn, conn->u.ipv4.raddr);
+ return tcp_find_ipv4_device(conn, conn->u.ipv4.raddr, false);
}
#endif
@@ -224,7 +225,7 @@ int tcp_remote_ipv4_device(FAR struct tcp_conn_s *conn)
#ifdef CONFIG_NET_IPv6
int tcp_local_ipv6_device(FAR struct tcp_conn_s *conn)
{
- return tcp_find_ipv6_device(conn, conn->u.ipv6.laddr);
+ return tcp_find_ipv6_device(conn, conn->u.ipv6.laddr, true);
}
#endif /* CONFIG_NET_IPv6 */
@@ -248,7 +249,7 @@ int tcp_local_ipv6_device(FAR struct tcp_conn_s *conn)
#ifdef CONFIG_NET_IPv6
int tcp_remote_ipv6_device(FAR struct tcp_conn_s *conn)
{
- return tcp_find_ipv6_device(conn, conn->u.ipv6.raddr);
+ return tcp_find_ipv6_device(conn, conn->u.ipv6.raddr, false);
}
#endif /* CONFIG_NET_IPv6 */