xiaoxiang781216 commented on code in PR #10319:
URL: https://github.com/apache/nuttx/pull/10319#discussion_r1302732083
##########
net/inet/ipv4_setsockopt.c:
##########
@@ -208,10 +208,84 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
}
break;
- /* The following IPv4 socket options are defined, but not implemented */
-
case IP_MULTICAST_IF: /* Set local device for a multicast
* socket */
+#ifdef NET_UDP_HAVE_STACK
+ {
+ FAR struct udp_conn_s *conn;
+ FAR struct net_driver_s *dev;
+ struct ip_mreqn mreq;
+
+ conn = psock->s_conn;
+ if (value == NULL || value_len == 0)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ if (value_len >= sizeof(struct ip_mreqn))
+ {
+ memcpy(&mreq, value, sizeof(mreq));
+ }
+ else
+ {
+ memset(&mreq, 0, sizeof(mreq));
+ if (value_len >= sizeof(struct ip_mreq))
+ {
+ memcpy(&mreq, value, sizeof(struct ip_mreq));
+ }
+ else if (value_len >= sizeof(struct in_addr))
+ {
+ memcpy(&mreq.imr_multiaddr,
+ value, sizeof(struct in_addr));
Review Comment:
```suggestion
value, sizeof(struct in_addr));
```
--
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]