apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/network_io/win32 sockets.c
Date Fri, 25 Oct 2002 17:15:37 GMT
trawick     2002/10/25 10:15:37

  Modified:    .        CHANGES
               include/arch/os2 networkio.h
               include/arch/unix networkio.h
               include/arch/win32 networkio.h
               network_io/os2 sockets.c
               network_io/unix sa_common.c sockaddr.c sockets.c
               network_io/win32 sockets.c
  Log:
  Fix a problem retrieving the remote socket address for sockets
  created via apr_os_sock_put() or apr_s_sock_make()
  
  Revision  Changes    Path
  1.350     +3 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.349
  retrieving revision 1.350
  diff -u -r1.349 -r1.350
  --- CHANGES	22 Oct 2002 20:05:34 -0000	1.349
  +++ CHANGES	25 Oct 2002 17:15:36 -0000	1.350
  @@ -1,5 +1,8 @@
   Changes with APR 0.9.2
   
  +  *) Fix a problem retrieving the remote socket address for sockets
  +     created via apr_os_sock_put() or apr_os_sock_make().  [Jeff Trawick]
  +
     *) Add recognition of and socket API support for the SCTP protocol.
        [Randall Stewart <randall@stewart.chicago.il.us>]
   
  
  
  
  1.28      +1 -0      apr/include/arch/os2/networkio.h
  
  Index: networkio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/os2/networkio.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- networkio.h	18 Oct 2002 12:03:59 -0000	1.27
  +++ networkio.h	25 Oct 2002 17:15:36 -0000	1.28
  @@ -74,6 +74,7 @@
       int nonblock;
       int local_port_unknown;
       int local_interface_unknown;
  +    int remote_addr_unknown;
       apr_int32_t netmask;
       apr_int32_t inherit;
   };
  
  
  
  1.57      +1 -0      apr/include/arch/unix/networkio.h
  
  Index: networkio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/networkio.h,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- networkio.h	22 Oct 2002 20:05:35 -0000	1.56
  +++ networkio.h	25 Oct 2002 17:15:36 -0000	1.57
  @@ -135,6 +135,7 @@
   #endif
       int local_port_unknown;
       int local_interface_unknown;
  +    int remote_addr_unknown;
       apr_int32_t netmask;
       apr_int32_t inherit;
   };
  
  
  
  1.30      +1 -0      apr/include/arch/win32/networkio.h
  
  Index: networkio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/networkio.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- networkio.h	18 Oct 2002 12:03:59 -0000	1.29
  +++ networkio.h	25 Oct 2002 17:15:37 -0000	1.30
  @@ -70,6 +70,7 @@
       apr_int32_t         disconnected;
       int                 local_port_unknown;
       int                 local_interface_unknown;
  +    int                 remote_addr_unknown;
       apr_int32_t         netmask;
       apr_int32_t         inherit;
   };
  
  
  
  1.60      +4 -0      apr/network_io/os2/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/os2/sockets.c,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- sockets.c	18 Oct 2002 15:08:08 -0000	1.59
  +++ sockets.c	25 Oct 2002 17:15:37 -0000	1.60
  @@ -283,6 +283,9 @@
           /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */
           (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port);
       }
  +    else {
  +        (*apr_sock)->remote_addr_unknown = 1;
  +    }
           
       apr_pool_cleanup_register((*apr_sock)->cntxt, (void *)(*apr_sock), 
                           socket_cleanup, apr_pool_cleanup_null);
  @@ -302,6 +305,7 @@
       }
   
       (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1;
  +    (*sock)->remote_addr_unknown = 1;
       (*sock)->socketdes = *thesock;
       return APR_SUCCESS;
   }
  
  
  
  1.69      +7 -0      apr/network_io/unix/sa_common.c
  
  Index: sa_common.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sa_common.c,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- sa_common.c	15 Oct 2002 12:27:38 -0000	1.68
  +++ sa_common.c	25 Oct 2002 17:15:37 -0000	1.69
  @@ -209,6 +209,13 @@
           *sa = sock->local_addr;
       }
       else if (which == APR_REMOTE) {
  +        if (sock->remote_addr_unknown) {
  +            apr_status_t rv = get_remote_addr(sock);
  +
  +            if (rv != APR_SUCCESS) {
  +                return rv;
  +            }
  +        }
           *sa = sock->remote_addr;
       }
       else {
  
  
  
  1.30      +15 -0     apr/network_io/unix/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockaddr.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- sockaddr.c	5 Apr 2002 22:15:04 -0000	1.29
  +++ sockaddr.c	25 Oct 2002 17:15:37 -0000	1.30
  @@ -70,6 +70,21 @@
       }
   }
   
  +static apr_status_t get_remote_addr(apr_socket_t *sock)
  +{
  +    sock->remote_addr->salen = sizeof(sock->remote_addr->sa);
  +    if (getpeername(sock->socketdes, (struct sockaddr *)&sock->remote_addr->sa,
  +                    &sock->remote_addr->salen) < 0) {
  +        return errno;
  +    }
  +    else {
  +        sock->remote_addr_unknown = 0;
  +        /* XXX assumes sin_port and sin6_port at same offset */
  +        sock->remote_addr->port = ntohs(sock->remote_addr->sa.sin.sin_port);
  +        return APR_SUCCESS;
  +    }
  +}
  +
   /* included here to allow us to use get_local_addr().
   
      NOTE: this file (sockaddr.c) can be included from other directories. If
  
  
  
  1.104     +4 -0      apr/network_io/unix/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- sockets.c	18 Oct 2002 14:13:38 -0000	1.103
  +++ sockets.c	25 Oct 2002 17:15:37 -0000	1.104
  @@ -362,6 +362,9 @@
           /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */
           (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port);
       }
  +    else {
  +        (*apr_sock)->remote_addr_unknown = 1;
  +    }
           
       (*apr_sock)->inherit = 0;
       apr_pool_cleanup_register((*apr_sock)->cntxt, (void *)(*apr_sock), 
  @@ -381,6 +384,7 @@
           (*sock)->timeout = -1;
       }
       (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1;
  +    (*sock)->remote_addr_unknown = 1;
       (*sock)->socketdes = *thesock;
       return APR_SUCCESS;
   }
  
  
  
  1.91      +4 -0      apr/network_io/win32/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- sockets.c	22 Oct 2002 03:35:47 -0000	1.90
  +++ sockets.c	25 Oct 2002 17:15:37 -0000	1.91
  @@ -451,6 +451,9 @@
           /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */
           (*apr_sock)->remote_addr->port = ntohs((*apr_sock)->remote_addr->sa.sin.sin_port);
       }
  +    else {
  +        (*apr_sock)->remote_addr_unknown = 1;
  +    }
           
       apr_pool_cleanup_register((*apr_sock)->cntxt, (void *)(*apr_sock), 
                           socket_cleanup, apr_pool_cleanup_null);
  @@ -471,6 +474,7 @@
           (*sock)->disconnected = 0;
       }
       (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1;
  +    (*sock)->remote_addr_unknown = 1;
       (*sock)->socketdes = *thesock;
       return APR_SUCCESS;
   }
  
  
  

Mime
View raw message