diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2007-10-15 20:13:31 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2007-10-15 20:13:31 +0000 |
commit | c71736581d6256dc598f0ef6e535e31f464c0925 (patch) | |
tree | c771c717902415dbd02e7b9516327c9b3a6dd9ff | |
parent | ad6922626170cd4a57ccee1471245840937d6af0 (diff) | |
download | libapr-c71736581d6256dc598f0ef6e535e31f464c0925.tar.gz |
Apply the Unix fix to Win32 (gee thanks Joe ;-)
Enhance the test introduced by Joe in 467600 to also invert
the original IP structure as an IPv6 entity for IPv4 tests,
if IPv6 is present. I settled on a test IP which Win32 just
happens to tollerate if an IPv6 adapter isn't present.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584885 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | network_io/win32/sendrecv.c | 5 | ||||
-rw-r--r-- | test/testsockets.c | 20 |
3 files changed, 20 insertions, 8 deletions
@@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes for APR 1.3.0 + *) Fix apr_socket_recvfrom() to ensure the peer's address is returned + through the "from" parameter on Win32. [William Rowe] + *) Introduce apr_file_pipe_create_ex() to portably permit one pipe end or another to be entirely blocking for non-APR applications (e.g. stdio streams) and the other (or both ends) non blocking, diff --git a/network_io/win32/sendrecv.c b/network_io/win32/sendrecv.c index c9d7dced5..80adccdd1 100644 --- a/network_io/win32/sendrecv.c +++ b/network_io/win32/sendrecv.c @@ -190,6 +190,8 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, { apr_ssize_t rv; + from->salen = sizeof(from->sa); + rv = recvfrom(sock->socketdes, buf, (int)*len, flags, (struct sockaddr*)&from->sa, &from->salen); if (rv == SOCKET_ERROR) { @@ -197,7 +199,8 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, return apr_get_netos_error(); } - from->port = ntohs(from->sa.sin.sin_port); + apr_sockaddr_vars_set(from, from->sa.sin.sin_family, + ntohs(from->sa.sin.sin_port)); (*len) = rv; if (rv == 0 && sock->type == SOCK_STREAM) diff --git a/test/testsockets.c b/test/testsockets.c index f88a77c7c..2c0bb576a 100644 --- a/test/testsockets.c +++ b/test/testsockets.c @@ -88,8 +88,8 @@ static void udp6_socket(abts_case *tc, void *data) } #endif -static void sendto_receivefrom_helper(abts_case *tc, const char *addr, - const char *junkaddr, int family) +static void sendto_receivefrom_helper(abts_case *tc, const char *addr, + int family) { apr_status_t rv; apr_socket_t *sock = NULL; @@ -142,9 +142,15 @@ static void sendto_receivefrom_helper(abts_case *tc, const char *addr, ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_SIZE_EQUAL(tc, STRLEN, len); - /* fill the "from" sockaddr with a random address to ensure that - * recvfrom sets it up properly. */ - rv = apr_sockaddr_info_get(&from, junkaddr, family, 4242, 0, p); + /* fill the "from" sockaddr with a random address from another + * family to ensure that recvfrom sets it up properly. */ +#if APR_HAVE_IPV6 + if (family == APR_INET) + rv = apr_sockaddr_info_get(&from, "3ffE:816e:abcd:1234::1", + APR_INET6, 4242, 0, p); + else +#endif + rv = apr_sockaddr_info_get(&from, "127.1.2.3", APR_INET, 4242, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); len = 80; @@ -165,7 +171,7 @@ static void sendto_receivefrom_helper(abts_case *tc, const char *addr, static void sendto_receivefrom(abts_case *tc, void *data) { int failed; - sendto_receivefrom_helper(tc, "127.0.0.1", "127.1.2.3", APR_INET); + sendto_receivefrom_helper(tc, "127.0.0.1", APR_INET); failed = tc->failed; tc->failed = 0; ABTS_TRUE(tc, !failed); } @@ -174,7 +180,7 @@ static void sendto_receivefrom(abts_case *tc, void *data) static void sendto_receivefrom6(abts_case *tc, void *data) { int failed; - sendto_receivefrom_helper(tc, "::1", "FA0E::1234:127.1.2.3", APR_INET6); + sendto_receivefrom_helper(tc, "::1", APR_INET6); failed = tc->failed; tc->failed = 0; ABTS_TRUE(tc, !failed); } |