diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/socket/socket_test.c | 21 | ||||
-rw-r--r-- | tests/socket/socket_test.err | 2 | ||||
-rw-r--r-- | tests/socket/socket_test.ok | 4 |
3 files changed, 27 insertions, 0 deletions
diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c index 37e02819..e68243c6 100644 --- a/tests/socket/socket_test.c +++ b/tests/socket/socket_test.c @@ -120,6 +120,27 @@ static int test_sockinit2(void) * FreeBSD 10 or 11 VM at home */ OSMO_ASSERT(!strncmp(name, "(r=127.0.0.1:53<->l=127.0.0.1", 29)); #endif + + printf("Checking osmo_sock_init2(AF_UNSPEC) must fail on mixed IPv4 & IPv6\n"); + fd = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "127.0.0.1", 0, "::1", 53, + OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT); + OSMO_ASSERT(fd < 0); + + printf("Checking osmo_sock_init2(AF_UNSPEC) must fail on mixed IPv6 & IPv4\n"); + fd = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "::1", 0, "127.0.0.1", 53, + OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT); + OSMO_ASSERT(fd < 0); + + printf("Checking osmo_sock_init2(AF_UNSPEC) BIND + CONNECT on IPv4\n"); + fd = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "127.0.0.1", 0, "127.0.0.1", 53, + OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT); + OSMO_ASSERT(fd >= 0); + + printf("Checking osmo_sock_init2(AF_UNSPEC) BIND + CONNECT on IPv6\n"); + fd = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "::1", 0, "::1", 53, + OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT); + OSMO_ASSERT(fd >= 0); + talloc_free(name); return 0; diff --git a/tests/socket/socket_test.err b/tests/socket/socket_test.err index ed6e1865..0f0f8da8 100644 --- a/tests/socket/socket_test.err +++ b/tests/socket/socket_test.err @@ -1,2 +1,4 @@ invalid: both bind and connect flags set: 0.0.0.0:0 invalid: you have to specify either BIND or CONNECT flags +Unable to find a common protocol (IPv4 or IPv6) for local host: 127.0.0.1 and remote host: ::1. +Unable to find a common protocol (IPv4 or IPv6) for local host: ::1 and remote host: 127.0.0.1. diff --git a/tests/socket/socket_test.ok b/tests/socket/socket_test.ok index 4b24fbce..4265be8d 100644 --- a/tests/socket/socket_test.ok +++ b/tests/socket/socket_test.ok @@ -5,3 +5,7 @@ Checking osmo_sock_init2() with bind to a random local UDP port Checking osmo_sock_init2() for OSMO_SOCK_F_NONBLOCK Checking osmo_sock_init2() for invalid flags Checking osmo_sock_init2() for combined BIND + CONNECT +Checking osmo_sock_init2(AF_UNSPEC) must fail on mixed IPv4 & IPv6 +Checking osmo_sock_init2(AF_UNSPEC) must fail on mixed IPv6 & IPv4 +Checking osmo_sock_init2(AF_UNSPEC) BIND + CONNECT on IPv4 +Checking osmo_sock_init2(AF_UNSPEC) BIND + CONNECT on IPv6 |