Networking: Fix several build errors/warning with IPv4 + IPv6 + multiple networks are enabled.
This commit is contained in:
parent
a564872487
commit
a82b8fd71f
net
@ -155,8 +155,8 @@ static inline FAR struct tcp_conn_s *tcp_ipv4_listener(in_addr_t ipaddr,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC)
|
#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC)
|
||||||
static inline FAR struct tcp_conn_s *tcp_ipv6_ listener(net_ipv6addr_t ipaddr,
|
static inline FAR struct tcp_conn_s *
|
||||||
uint16_t portno)
|
tcp_ipv6_listener(const net_ipv6addr_t ipaddr, uint16_t portno)
|
||||||
{
|
{
|
||||||
FAR struct tcp_conn_s *conn;
|
FAR struct tcp_conn_s *conn;
|
||||||
int i;
|
int i;
|
||||||
@ -436,7 +436,7 @@ static inline FAR struct tcp_conn_s *
|
|||||||
FAR struct tcp_conn_s *conn;
|
FAR struct tcp_conn_s *conn;
|
||||||
net_ipv6addr_t *srcipaddr;
|
net_ipv6addr_t *srcipaddr;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
net_ipv6addr_t destipaddr;
|
net_ipv6addr_t *destipaddr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head;
|
conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head;
|
||||||
@ -575,10 +575,16 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn,
|
|||||||
/* Verify or select a local port */
|
/* Verify or select a local port */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
|
/* The port number must be unique for this address binding */
|
||||||
|
|
||||||
port = tcp_selectport(PF_INET6,
|
port = tcp_selectport(PF_INET6,
|
||||||
(FAR const union ip_addr_u ipaddr *)addr->sin6_addr.in6_u.u6_addr16,
|
(FAR const union ip_addr_u *)addr->sin6_addr.in6_u.u6_addr16,
|
||||||
ntohs(addr->sin6_port));
|
ntohs(addr->sin6_port));
|
||||||
#else
|
#else
|
||||||
|
/* There is only one network device; the port number can be globally
|
||||||
|
* unique.
|
||||||
|
*/
|
||||||
|
|
||||||
port = tcp_selectport(ntohs(addr->sin6_port));
|
port = tcp_selectport(ntohs(addr->sin6_port));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1099,19 +1105,56 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
flags = net_lock();
|
flags = net_lock();
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
/* If there are multiple network devices, then we need to pass the local,
|
||||||
port = tcp_selectport(conn->domain, &conn->u, ntohs(conn->lport));
|
* bound address. This is needed because port unique-ness is only for a
|
||||||
#elif defined(CONFIG_NET_IPv4)
|
* given network.
|
||||||
port = tcp_selectport(PF_INET, &conn->u, ntohs(conn->lport));
|
*
|
||||||
#else
|
* This is complicated by the fact that the local address may be either an
|
||||||
port = tcp_selectport(PF_INET6, &conn->u, ntohs(conn->lport));
|
* IPv4 or an IPv6 address.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
if (conn->domain == PF_INET)
|
||||||
#endif
|
#endif
|
||||||
#else
|
{
|
||||||
|
/* Select a port that is unique for this IPv4 local address */
|
||||||
|
|
||||||
|
port = tcp_selectport(PF_INET,
|
||||||
|
(FAR const union ip_addr_u *)&conn->u.ipv4.laddr,
|
||||||
|
ntohs(conn->lport));
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Select a port that is unique for this IPv6 local address */
|
||||||
|
|
||||||
|
port = tcp_selectport(PF_INET6,
|
||||||
|
(FAR const union ip_addr_u *)conn->u.ipv6.laddr,
|
||||||
|
ntohs(conn->lport));
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
#else /* CONFIG_NETDEV_MULTINIC */
|
||||||
|
/* Select the next available port number. This is only one network device
|
||||||
|
* so we do not have to bother with all of the IPv4/IPv6 local address
|
||||||
|
* silliness.
|
||||||
|
*/
|
||||||
|
|
||||||
port = tcp_selectport(ntohs(conn->lport));
|
port = tcp_selectport(ntohs(conn->lport));
|
||||||
#endif
|
|
||||||
|
#endif /* CONFIG_NETDEV_MULTINIC */
|
||||||
|
|
||||||
net_unlock(flags);
|
net_unlock(flags);
|
||||||
|
|
||||||
|
/* Did we have a port assignment? */
|
||||||
|
|
||||||
if (port < 0)
|
if (port < 0)
|
||||||
{
|
{
|
||||||
return port;
|
return port;
|
||||||
|
@ -619,7 +619,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
|
|||||||
* interfaces for receiving (Sending will use the default port).
|
* interfaces for receiving (Sending will use the default port).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
net_ipv6addr_copy(conn->u.ipv6.laddr, ipaddr->sin6_addr.in6_u.u6_addr16);
|
net_ipv6addr_copy(conn->u.ipv6.laddr, inaddr->sin6_addr.in6_u.u6_addr16);
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
#endif /* CONFIG_NETDEV_MULTINIC */
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
Loading…
Reference in New Issue
Block a user