mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
Networking: Drivers can have both IPv4 and IPv6 addesses, but a socket can only only one or the other; The socket connnection structures need to include a union of IPv4 and IPv6 addresses for the local address binding and for the remote address connections
This commit is contained in:
+2
-2
@@ -112,7 +112,7 @@ static inline void accept_tcpsender(FAR struct tcp_conn_s *conn,
|
||||
{
|
||||
addr->sin_family = AF_INET6;
|
||||
addr->sin_port = conn->rport;
|
||||
net_ipaddr_copy(addr->sin6_addr.s6_addr, conn->ripaddr);
|
||||
net_ipaddr_copy(addr->sin6_addr.s6_addr, conn->u.ipv4.raddr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -123,7 +123,7 @@ static inline void accept_tcpsender(FAR struct tcp_conn_s *conn,
|
||||
{
|
||||
addr->sin_family = AF_INET;
|
||||
addr->sin_port = conn->rport;
|
||||
net_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr);
|
||||
net_ipaddr_copy(addr->sin_addr.s_addr, conn->u.ipv4.raddr);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
+10
-11
@@ -121,8 +121,8 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR struct tcp_conn_s *tcp_conn = (FAR struct tcp_conn_s *)psock->s_conn;
|
||||
outaddr->sin_port = tcp_conn->lport; /* Already in network byte order */
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
lipaddr = tcp_conn->lipaddr;
|
||||
ripaddr = tcp_conn->ripaddr;
|
||||
lipaddr = tcp_conn->u.ipv4.laddr;
|
||||
ripaddr = tcp_conn->u.ipv4.raddr;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@@ -134,8 +134,8 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR struct udp_conn_s *udp_conn = (FAR struct udp_conn_s *)psock->s_conn;
|
||||
outaddr->sin_port = udp_conn->lport; /* Already in network byte order */
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
lipaddr = udp_conn->lipaddr;
|
||||
ripaddr = udp_conn->ripaddr;
|
||||
lipaddr = udp_conn->u.ipv4.laddr;
|
||||
ripaddr = udp_conn->u.ipv4.raddr;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@@ -244,8 +244,8 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR struct tcp_conn_s *tcp_conn = (FAR struct tcp_conn_s *)psock->s_conn;
|
||||
outaddr->sin_port = tcp_conn->lport; /* Already in network byte order */
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
lipaddr = tcp_conn->lipaddr;
|
||||
ripaddr = tcp_conn->ripaddr;
|
||||
lipaddr = &tcp_conn->u.ipv6.laddr;
|
||||
ripaddr = &tcp_conn->u.ipv6.raddr;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@@ -257,16 +257,15 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR struct udp_conn_s *udp_conn = (FAR struct udp_conn_s *)psock->s_conn;
|
||||
outaddr->sin_port = udp_conn->lport; /* Already in network byte order */
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
lipaddr = &udp_conn->lipaddr;
|
||||
ripaddr = &udp_conn->ripaddr;
|
||||
lipaddr = &udp_conn->u.ipv6.laddr;
|
||||
ripaddr = &udp_conn->u.ipv6.raddr;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
err = EOPNOTSUPP;
|
||||
goto errout;
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* The socket/connection does not know its IP address unless
|
||||
@@ -296,7 +295,7 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
|
||||
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
|
||||
outaddr->sin_family = AF_INET6;
|
||||
memcpy(outaddr->sin6_addr.in6_u.u6_addr8, dev->d_ipaddr, 16);
|
||||
memcpy(outaddr->sin6_addr.in6_u.u6_addr8, dev->d_ipv6addr, 16);
|
||||
*addrlen = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
netdev_semgive();
|
||||
|
||||
@@ -358,9 +358,9 @@ static inline int netclose_disconnect(FAR struct socket *psock)
|
||||
/* Notify the device driver of the availability of TX data */
|
||||
|
||||
#ifdef CONFIG_NET_MULTILINK
|
||||
netdev_txnotify(conn->lipaddr, conn->ripaddr);
|
||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||
#else
|
||||
netdev_txnotify(conn->ripaddr);
|
||||
netdev_txnotify(conn->u.ipv4.raddr);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_SOLINGER
|
||||
|
||||
@@ -330,7 +330,7 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon
|
||||
|
||||
#if defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_ARP_IPIN) && \
|
||||
!defined(CONFIG_NET_ARP_SEND)
|
||||
if (pstate->snd_sent != 0 || arp_find(conn->ripaddr) != NULL)
|
||||
if (pstate->snd_sent != 0 || arp_find(conn->u.ipv4.raddr) != NULL)
|
||||
#endif
|
||||
{
|
||||
/* Update the amount of data sent (but not necessarily ACKed) */
|
||||
@@ -484,7 +484,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
|
||||
/* Make sure that the IP address mapping is in the ARP table */
|
||||
|
||||
#ifdef CONFIG_NET_ARP_SEND
|
||||
ret = arp_send(conn->ripaddr);
|
||||
ret = arp_send(conn->u.ipv4.raddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
ndbg("ERROR: Not reachable\n");
|
||||
@@ -565,9 +565,9 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
|
||||
/* Notify the device driver of the availability of TX data */
|
||||
|
||||
#ifdef CONFIG_NET_MULTILINK
|
||||
netdev_txnotify(conn->lipaddr, conn->ripaddr);
|
||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||
#else
|
||||
netdev_txnotify(conn->ripaddr);
|
||||
netdev_txnotify(conn->u.ipv4.raddr);
|
||||
#endif
|
||||
net_lockedwait(&state.snd_sem);
|
||||
}
|
||||
|
||||
@@ -1097,9 +1097,9 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
|
||||
#if 0 /* No */
|
||||
#ifdef CONFIG_NET_MULTILINK
|
||||
netdev_rxnotify(conn->lipaddr, conn->ripaddr);
|
||||
netdev_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||
#else
|
||||
netdev_rxnotify(conn->ripaddr);
|
||||
netdev_rxnotify(conn->u.ipv4.raddr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1196,9 +1196,9 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
/* Notify the device driver of the receive call */
|
||||
|
||||
#ifdef CONFIG_NET_MULTILINK
|
||||
netdev_rxnotify(conn->lipaddr, conn->ripaddr);
|
||||
netdev_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||
#else
|
||||
netdev_rxnotify(conn->ripaddr);
|
||||
netdev_rxnotify(conn->u.ipv4.raddr);
|
||||
#endif
|
||||
|
||||
/* Wait for either the receive to complete or for an error/timeout to occur.
|
||||
|
||||
+2
-2
@@ -420,9 +420,9 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
/* Notify the device driver of the availability of TX data */
|
||||
|
||||
#ifdef CONFIG_NET_MULTILINK
|
||||
netdev_txnotify(conn->lipaddr, conn->ripaddr);
|
||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||
#else
|
||||
netdev_txnotify(conn->ripaddr);
|
||||
netdev_txnotify(conn->u.ipv4.raddr);
|
||||
#endif
|
||||
|
||||
/* Wait for either the receive to complete or for an error/timeout to occur.
|
||||
|
||||
Reference in New Issue
Block a user