net/tcp: Return -EINVAL if bind is called more than once

Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
wangchen
2023-08-03 10:58:45 +08:00
committed by Xiang Xiao
parent da3a75da2c
commit bdf82d2087
+12
View File
@@ -325,6 +325,12 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn,
net_lock();
if (conn->lport != 0)
{
net_unlock();
return -EINVAL;
}
/* Verify or select a local port (network byte order) */
port = tcp_selectport(PF_INET,
@@ -390,6 +396,12 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn,
net_lock();
if (conn->lport != 0)
{
net_unlock();
return -EINVAL;
}
/* Verify or select a local port (network byte order) */
/* The port number must be unique for this address binding */