xiaoxiang781216 commented on code in PR #10319:
URL: https://github.com/apache/nuttx/pull/10319#discussion_r1301852587
##########
net/udp/udp_send.c:
##########
@@ -146,7 +159,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct
udp_conn_s *conn)
* header size
*/
- dev->d_len = dev->d_sndlen + UDP_HDRLEN;
+ dev->d_len = dev->d_sndlen + UDP_HDRLEN;
ipv6_build_header(IPv6BUF, dev->d_len, IP_PROTO_UDP,
dev->d_ipv6addr, conn->u.ipv6.raddr,
Review Comment:
should we modify dev->d_ipv6addr too?
##########
net/udp/udp_send.c:
##########
@@ -115,15 +116,27 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct
udp_conn_s *conn)
raddr = conn->u.ipv4.raddr;
}
+#ifdef CONFIG_NET_IGMP
+ if (IN_MULTICAST(NTOHL(raddr)) &&
+ net_ipv4addr_cmp(dev->d_ipaddr, INADDR_ANY))
Review Comment:
why check d_ipaddr?
##########
net/udp/udp_finddev.c:
##########
@@ -186,43 +199,57 @@ udp_find_raddr_device(FAR struct udp_conn_s *conn,
else
#endif
{
- net_ipv6addr_t raddr;
-
- if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
+ struct in6_addr raddr;
+ if (remote)
{
- /* If the socket is bound to some non-zero, local address.
- * Normal lookup using the verified local address.
- */
-
- return netdev_findby_lipv6addr(conn->u.ipv6.laddr);
+ FAR const struct sockaddr_in6 *inaddr =
+ (FAR const struct sockaddr_in6 *)remote;
+ net_ipv6addr_copy(raddr.in6_u.u6_addr16,
+ inaddr->sin6_addr.s6_addr16);
}
-
-#ifdef CONFIG_NET_BINDTODEVICE
- if (conn->sconn.s_boundto != 0)
+ else
{
- /* If the socket is bound to a local network device.
- * Select the network device that has been bound.
- * If the index is invalid, return NULL.
- */
-
- return netdev_findbyindex(conn->sconn.s_boundto);
+ net_ipv6addr_copy(raddr.in6_u.u6_addr16, conn->u.ipv6.raddr);
}
-#endif
- if (remote)
+#if defined(CONFIG_NET_MLD) && defined(CONFIG_NET_BINDTODEVICE)
+ if (IN6_IS_ADDR_MULTICAST(&raddr))
{
- FAR const struct sockaddr_in6 *inaddr =
- (FAR const struct sockaddr_in6 *)remote;
- net_ipv6addr_copy(raddr, inaddr->sin6_addr.s6_addr16);
+ if ((conn->sconn.s_boundto == 0) &&
+ (conn->mreq.imr_ifindex != 0))
+ {
+ return netdev_findbyindex(conn->mreq.imr_ifindex);
+ }
}
else
+#endif
{
- net_ipv6addr_copy(raddr, conn->u.ipv6.raddr);
+ if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
+ {
+ /* If the socket is bound to some non-zero, local address.
+ * Normal lookup using the verified local address.
+ */
+
+ return netdev_findby_lipv6addr(conn->u.ipv6.laddr);
+ }
+
+#ifdef CONFIG_NET_BINDTODEVICE
+ if (conn->sconn.s_boundto != 0)
+ {
+ /* If the socket is bound to a local network device.
+ * Select the network device that has been bound.
+ * If the index is invalid, return NULL.
+ */
+
+ return netdev_findbyindex(conn->sconn.s_boundto);
+ }
+#endif
}
/* Normal lookup using the verified remote address */
- return netdev_findby_ripv6addr(conn->u.ipv6.laddr, raddr);
+ return netdev_findby_ripv6addr(conn->u.ipv6.laddr,
+ raddr.in6_u.u6_addr16);
Review Comment:
```suggestion
raddr.in6_u.u6_addr16);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]