From 53a9740d1dcbad6be4b4c1a10a5f3fcbb97a5be9 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 25 Feb 2024 17:13:38 -0800 Subject: fixes #1496 Provide NNG_ENABLE_IPV6 option (disabled by default) This also checks if the build system has the definitions for AF_INET6, which might help in some embedded IPv4 only settings. The resolver test is enhanced to include a check for IPv6 enabled in the kernel. IPv6 support is enabled by default, of course. --- tests/udp.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/udp.c b/tests/udp.c index c2772048..d11123fe 100644 --- a/tests/udp.c +++ b/tests/udp.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -57,8 +57,8 @@ TestMain("UDP support", { char rbuf[1024]; nng_sockaddr to; nng_sockaddr from; - nng_aio * aio1; - nng_aio * aio2; + nng_aio *aio1; + nng_aio *aio2; nng_iov iov1; nng_iov iov2; @@ -102,7 +102,7 @@ TestMain("UDP support", { Convey("Sending without an address fails", { nng_aio *aio1; - char * msg = "nope"; + char *msg = "nope"; nng_iov iov; So(nng_aio_alloc(&aio1, NULL, NULL) == 0); @@ -126,10 +126,10 @@ TestMain("UDP support", { nng_sockaddr to2; nng_sockaddr from1; nng_sockaddr from2; - nng_aio * aio1; - nng_aio * aio2; - nng_aio * aio3; - nng_aio * aio4; + nng_aio *aio1; + nng_aio *aio2; + nng_aio *aio3; + nng_aio *aio4; nng_iov iov1; nng_iov iov2; nng_iov iov3; @@ -192,7 +192,7 @@ TestMain("UDP support", { Convey("Sending without an address fails", { nng_aio *aio1; - char * msg = "nope"; + char *msg = "nope"; nng_iov iov; So(nng_aio_alloc(&aio1, NULL, NULL) == 0); @@ -206,9 +206,10 @@ TestMain("UDP support", { nng_aio_free(aio1); }); +#ifdef NNG_ENABLE_IPV6 Convey("Sending to an IPv6 address on IPv4 fails", { - nng_aio * aio1; - char * msg = "nope"; + nng_aio *aio1; + char *msg = "nope"; nng_sockaddr sa; int rv; nng_iov iov; @@ -231,19 +232,17 @@ TestMain("UDP support", { rv == NNG_EUNREACHABLE || rv == NNG_EINVAL); nng_aio_free(aio1); }); +#endif Convey("Sending to an IPC address fails", { - nng_aio * aio1; - char * msg = "nope"; + nng_aio *aio1; + char *msg = "nope"; nng_sockaddr sa; int rv; nng_iov iov; - sa.s_in6.sa_family = NNG_AF_INET6; - // address is for google.com - inet_ntop(AF_INET6, "2607:f8b0:4007:804::200e", - (void *) sa.s_in6.sa_addr, 16); - sa.s_in6.sa_port = 80; + sa.s_ipc.sa_family = NNG_AF_IPC; + strcat(sa.s_ipc.sa_path, "/tmp/junk"); So(nng_aio_alloc(&aio1, NULL, NULL) == 0); iov.iov_buf = msg; iov.iov_len = strlen(msg) + 1; -- cgit v1.2.3-70-g09d2