This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 5c21bfdb8 testing/nettest: Test short IPv6 multicast options.
5c21bfdb8 is described below

commit 5c21bfdb8d5908e2bef46a2afd2c30d020c525ab
Author: Marco Casaroli <[email protected]>
AuthorDate: Thu Nov 26 06:26:35 2026 +0100

    testing/nettest: Test short IPv6 multicast options.
    
    test_mcast_optlen_ipv6 now also gives IPV6_JOIN_GROUP and
    IPV6_LEAVE_GROUP an option one byte shorter than struct ipv6_mreq, and
    IPV6_MULTICAST_IF an option one byte shorter than an int.  Each call
    must fail with EINVAL, as MCAST_JOIN_GROUP does.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 testing/nettest/mcast/test_mcast_ipv6.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/testing/nettest/mcast/test_mcast_ipv6.c 
b/testing/nettest/mcast/test_mcast_ipv6.c
index b725de60d..483b8183b 100644
--- a/testing/nettest/mcast/test_mcast_ipv6.c
+++ b/testing/nettest/mcast/test_mcast_ipv6.c
@@ -183,12 +183,18 @@ void test_mcast_leave_ipv6(FAR void **state)
 
 /****************************************************************************
  * Name: test_mcast_optlen_ipv6
+ *
+ * Description:
+ *   A multicast option shorter than its structure fails with EINVAL.
+ *
  ****************************************************************************/
 
 void test_mcast_optlen_ipv6(FAR void **state)
 {
   FAR struct nettest_mcast_state_s *mcast_state = *state;
+  struct ipv6_mreq mreq;
   struct group_req gr;
+  int ifindex = 0;
   int ret;
 
   test_mcast_ipv6_group(&gr, mcast_state->ifindex);
@@ -196,6 +202,24 @@ void test_mcast_optlen_ipv6(FAR void **state)
                    &gr, sizeof(gr) - 1);
   assert_int_equal(ret, -1);
   assert_int_equal(errno, EINVAL);
+
+  memset(&mreq, 0, sizeof(mreq));
+  inet_pton(AF_INET6, TEST_GROUP, &mreq.ipv6mr_multiaddr);
+  mreq.ipv6mr_interface = mcast_state->ifindex;
+  ret = setsockopt(mcast_state->rfd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+                   &mreq, sizeof(mreq) - 1);
+  assert_int_equal(ret, -1);
+  assert_int_equal(errno, EINVAL);
+
+  ret = setsockopt(mcast_state->rfd, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
+                   &mreq, sizeof(mreq) - 1);
+  assert_int_equal(ret, -1);
+  assert_int_equal(errno, EINVAL);
+
+  ret = setsockopt(mcast_state->sfd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+                   &ifindex, sizeof(ifindex) - 1);
+  assert_int_equal(ret, -1);
+  assert_int_equal(errno, EINVAL);
 }
 
 /****************************************************************************

Reply via email to