This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 3eff81856750867ad3acc08b0decd49668cff8a6 Author: Marco Casaroli <[email protected]> AuthorDate: Sat Nov 21 17:10:57 2026 +0100 testing/nettest: Add a case for connect() of IPv6 TCP to a mapped address. test_udp_v6only_tcp_mapped: a TCP socket of AF_INET6 is IPv6-only, so connect() to ::ffff:127.0.0.1 fails with ENETUNREACH, as test_udp_v6only_send checks for a UDP socket with IPV6_V6ONLY. The socket is non-blocking, so a connect() that sends a SYN does not wait. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- testing/nettest/udp/test_udp.c | 1 + testing/nettest/udp/test_udp.h | 1 + testing/nettest/udp/test_udp_v6only.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/testing/nettest/udp/test_udp.c b/testing/nettest/udp/test_udp.c index 584af4f4b..4e68efd66 100644 --- a/testing/nettest/udp/test_udp.c +++ b/testing/nettest/udp/test_udp.c @@ -60,6 +60,7 @@ int main(int argc, FAR char *argv[]) TEST_UDP(test_udp_v6only_tcp_set0), TEST_UDP(test_udp_v6only_tcp_ipv4), TEST_UDP(test_udp_v6only_tcp_bound), + TEST_UDP(test_udp_v6only_tcp_mapped), #endif TEST_UDP(test_udp_family_alone), TEST_UDP(test_udp_family_both), diff --git a/testing/nettest/udp/test_udp.h b/testing/nettest/udp/test_udp.h index f7860054d..34fd8d00e 100644 --- a/testing/nettest/udp/test_udp.h +++ b/testing/nettest/udp/test_udp.h @@ -126,6 +126,7 @@ void test_udp_v6only_tcp_set1(FAR void **state); void test_udp_v6only_tcp_set0(FAR void **state); void test_udp_v6only_tcp_ipv4(FAR void **state); void test_udp_v6only_tcp_bound(FAR void **state); +void test_udp_v6only_tcp_mapped(FAR void **state); #endif /**************************************************************************** diff --git a/testing/nettest/udp/test_udp_v6only.c b/testing/nettest/udp/test_udp_v6only.c index 8d10fe671..d281f841b 100644 --- a/testing/nettest/udp/test_udp_v6only.c +++ b/testing/nettest/udp/test_udp_v6only.c @@ -292,6 +292,41 @@ void test_udp_v6only_tcp_ipv4(FAR void **state) assert_int_equal(ret, -1); } +/**************************************************************************** + * Name: test_udp_v6only_tcp_mapped + * + * Description: + * connect() of a TCP socket of AF_INET6 to ::ffff:127.0.0.1 fails with + * ENETUNREACH, as for a UDP socket with the option. + * + ****************************************************************************/ + +void test_udp_v6only_tcp_mapped(FAR void **state) +{ + struct sockaddr_in6 addr; + int ret; + int err; + int sd; + + /* Non-blocking: a connect() that goes out does not wait here */ + + sd = test_udp_socket(state, AF_INET6, SOCK_STREAM | SOCK_NONBLOCK, -1, + false); + + memset(&addr, 0, sizeof(addr)); + addr.sin6_family = AF_INET6; + addr.sin6_port = htons(TEST_UDP_PORT + 8); + addr.sin6_addr.s6_addr[10] = 0xff; + addr.sin6_addr.s6_addr[11] = 0xff; + addr.sin6_addr.s6_addr[12] = 127; + addr.sin6_addr.s6_addr[15] = 1; + + ret = connect(sd, (FAR struct sockaddr *)&addr, sizeof(addr)); + err = ret < 0 ? errno : 0; + assert_int_equal(ret, -1); + assert_int_equal(err, ENETUNREACH); +} + /**************************************************************************** * Name: test_udp_v6only_tcp_bound *
