apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r584885 - in /apr/apr/trunk: CHANGES network_io/win32/sendrecv.c test/testsockets.c
Date Mon, 15 Oct 2007 20:13:33 GMT
Author: wrowe
Date: Mon Oct 15 13:13:31 2007
New Revision: 584885

URL: http://svn.apache.org/viewvc?rev=584885&view=rev
Log:
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.

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/network_io/win32/sendrecv.c
    apr/apr/trunk/test/testsockets.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=584885&r1=584884&r2=584885&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Mon Oct 15 13:13:31 2007
@@ -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,

Modified: apr/apr/trunk/network_io/win32/sendrecv.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/win32/sendrecv.c?rev=584885&r1=584884&r2=584885&view=diff
==============================================================================
--- apr/apr/trunk/network_io/win32/sendrecv.c (original)
+++ apr/apr/trunk/network_io/win32/sendrecv.c Mon Oct 15 13:13:31 2007
@@ -190,6 +190,8 @@
 {
     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 @@
         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)

Modified: apr/apr/trunk/test/testsockets.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testsockets.c?rev=584885&r1=584884&r2=584885&view=diff
==============================================================================
--- apr/apr/trunk/test/testsockets.c (original)
+++ apr/apr/trunk/test/testsockets.c Mon Oct 15 13:13:31 2007
@@ -88,8 +88,8 @@
 }
 #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 @@
     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(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_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);
 }



Mime
View raw message