apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apr CHANGES
Date Tue, 21 Nov 2000 19:08:32 GMT
trawick     00/11/21 11:08:30

  Modified:    include  apr_network_io.h
               network_io/beos sockaddr.c
               network_io/unix sa_common.c sockaddr.c
               network_io/win32 sockaddr.c
               .        CHANGES
  Log:
  Some of the forewarned APR network_io interface changes:
  
  apr_set_port(), apr_get_port(), apr_set_ipaddr(), and apr_get_ipaddr()
  now take apr_sockaddr_t as a parameter instead of apr_socket_t +
  apr_interface_e.  This will allow the same routines to be used with
  datagram APIs to be added later.  Note that code which calls
  apr_set_ipaddr() should probably be changed to call apr_getaddrinfo()
  for protocol independence.
  
  Revision  Changes    Path
  1.78      +16 -23    apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_network_io.h,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- apr_network_io.h	2000/11/21 00:30:43	1.77
  +++ apr_network_io.h	2000/11/21 19:08:22	1.78
  @@ -457,41 +457,34 @@
   apr_status_t apr_get_sockaddr(apr_sockaddr_t **sa, apr_interface_e which, apr_socket_t
*sock);
    
   /**
  - * Associate a port with a socket.
  - * @param sock The socket to set.
  - * @param which Which socket do we want to set the port for?
  - * @param port The local port this socket will be dealing with.
  - * @tip This does not bind the two together, it is just telling apr 
  - *      that this socket is going to use this port if possible.  If
  - *      the port is already used, we won't find out about it here.
  + * Set the port in an APR socket address.
  + * @param sockaddr The socket address to set.
  + * @param port The port to be stored in the socket address.
    */
  -apr_status_t apr_set_port(apr_socket_t *sock, apr_interface_e which, apr_port_t port);
  +apr_status_t apr_set_port(apr_sockaddr_t *sockaddr, apr_port_t port);
   
   /**
  - * Return the port associated with a socket.
  - * @param port The local port this socket is associated with.
  - * @param which Which interface are we getting the port for?
  - * @param sock The socket to enquire about.
  + * Return the port in an APR socket address.
  + * @param port The port from the socket address.
  + * @param sock The socket address to reference.
    */
  -apr_status_t apr_get_port(apr_port_t *port, apr_interface_e which, apr_socket_t *sock);
  +apr_status_t apr_get_port(apr_port_t *port, apr_sockaddr_t *sockaddr);
   
   /**
  - * Associate a socket addr with an apr socket.
  - * @param sock The socket to use 
  - * @param which Which interface should we set?
  + * Set the IP address in an APR socket address.
  + * @param sockaddr The socket address to use 
    * @param addr The IP address to attach to the socket.
    *             Use APR_ANYADDR to use any IP addr on the machine.
  - * @tip This does not bind the two together, it is just telling apr 
  - *      that this socket is going to use this address if possible. 
    */
  -apr_status_t apr_set_ipaddr(apr_socket_t *sock, apr_interface_e which, const char *addr);
  +apr_status_t apr_set_ipaddr(apr_sockaddr_t *sockaddr, const char *addr);
   
   /**
  - * Return the IP address associated with an apr socket.
  - * @param addr The local IP address associated with the socket.
  - * @param sock The socket to use 
  + * Return the IP address (in numeric address string format) in
  + * an APR socket address.
  + * @param addr The IP address.
  + * @param sock The socket address to reference.
    */
  -apr_status_t apr_get_ipaddr(char **addr, apr_interface_e which, apr_socket_t *sock);
  +apr_status_t apr_get_ipaddr(char **addr, apr_sockaddr_t *sockaddr);
   
   /**
    * Return the local socket name as a BSD style struct sockaddr_in.
  
  
  
  1.18      +0 -27     apr/network_io/beos/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/beos/sockaddr.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- sockaddr.c	2000/11/09 15:01:25	1.17
  +++ sockaddr.c	2000/11/21 19:08:24	1.18
  @@ -75,33 +75,6 @@
   /* Include this here so we already have get_local_addr... */
   #include "../unix/sa_common.c"
   
  -apr_status_t apr_set_ipaddr(apr_socket_t *sock, apr_interface_e which, const char *addr)
  -{
  -    u_long ipaddr;
  -    struct sockaddr_in *ptr;
  -
  -    if (which == APR_LOCAL)
  -        ptr = sock->local_addr;
  -    else if (which == APR_REMOTE)
  -        ptr = sock->remote_addr;
  -    else 
  -        return APR_EINVAL;
  -    
  -    if (!strcmp(addr, APR_ANYADDR)) {
  -        ptr->sin_addr.s_addr = htonl(INADDR_ANY);
  -        return APR_SUCCESS;
  -    }
  -    
  -    ipaddr = inet_addr(addr);
  -    
  -    if (ipaddr == -1) {
  -        return errno;
  -    }
  -    
  -    ptr->sin_addr.s_addr = ipaddr;
  -    return APR_SUCCESS;
  -}
  -
   apr_status_t get_local_name(struct sockaddr_in **name, apr_socket_t *sock)
   {
       if (!sock) {
  
  
  
  1.11      +44 -48    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- sa_common.c	2000/11/19 01:21:11	1.10
  +++ sa_common.c	2000/11/21 19:08:25	1.11
  @@ -65,65 +65,54 @@
   
   #include "apr.h"
   
  -apr_status_t apr_set_port(apr_socket_t *sock, apr_interface_e which, 
  -                         apr_port_t port)
  +apr_status_t apr_set_port(apr_sockaddr_t *sockaddr, apr_port_t port)
   {
       /* XXX IPv6: assumes sin_port and sin6_port at same offset */
  -    if (which == APR_LOCAL)
  -        sock->local_addr->sa.sin.sin_port = htons(port);
  -    else if (which == APR_REMOTE)
  -        sock->remote_addr->sa.sin.sin_port = htons(port);
  -    else
  -        return APR_EINVAL;
  +    sockaddr->sa.sin.sin_port = htons(port);
  +    sockaddr->sa.sin.sin_port = htons(port);
       return APR_SUCCESS;
   }
   
  -apr_status_t apr_get_port(apr_port_t *port, apr_interface_e which, apr_socket_t *sock)
  +/* XXX assumes IPv4... I don't think this function is needed anyway
  + * since we have apr_getaddrinfo(), but we need to clean up Apache's 
  + * listen.c a bit more first.
  + */
  +apr_status_t apr_set_ipaddr(apr_sockaddr_t *sockaddr, const char *addr)
   {
  -    /* XXX IPv6: assumes sin_port and sin6_port at same offset */
  -    if (which == APR_LOCAL)
  -    {
  -        if (sock->local_port_unknown) {
  -            apr_status_t rv = get_local_addr(sock);
  -
  -            if (rv != APR_SUCCESS) {
  -                return rv;
  -            }
  -        }
  -        *port = ntohs(sock->local_addr->sa.sin.sin_port);
  -    } else if (which == APR_REMOTE)
  -        *port = ntohs(sock->remote_addr->sa.sin.sin_port);
  -    else
  -        return APR_EINVAL;
  +    u_long ipaddr;
  +    
  +    if (!strcmp(addr, APR_ANYADDR)) {
  +        sockaddr->sa.sin.sin_addr.s_addr = htonl(INADDR_ANY);
  +        return APR_SUCCESS;
  +    }
  +    
  +    ipaddr = inet_addr(addr);
  +    if (ipaddr == (u_long)-1) {
  +#ifdef WIN32
  +        return WSAEADDRNOTAVAIL;
  +#else
  +        return errno;
  +#endif
  +    }
  +    
  +    sockaddr->sa.sin.sin_addr.s_addr = ipaddr;
       return APR_SUCCESS;
   }
   
  -apr_status_t apr_get_ipaddr(char **addr, apr_interface_e which, apr_socket_t *sock)
  +apr_status_t apr_get_port(apr_port_t *port, apr_sockaddr_t *sockaddr)
   {
  -    if (which == APR_LOCAL) {
  -        if (sock->local_interface_unknown) {
  -            apr_status_t rv = get_local_addr(sock);
  -
  -            if (rv != APR_SUCCESS) {
  -                return rv;
  -            }
  -        }
  -        *addr = apr_palloc(sock->cntxt, sock->local_addr->addr_str_len);
  -        apr_inet_ntop(sock->local_addr->sa.sin.sin_family,
  -                      sock->local_addr->ipaddr_ptr,
  -                      *addr,
  -                      sock->local_addr->addr_str_len);
  -    } 
  -    else if (which == APR_REMOTE) {
  -        *addr = apr_palloc(sock->cntxt, sock->remote_addr->addr_str_len);
  -        apr_inet_ntop(sock->remote_addr->sa.sin.sin_family,
  -                      sock->remote_addr->ipaddr_ptr,
  -                      *addr,
  -                      sock->remote_addr->addr_str_len);
  -    }
  -    else 
  -        return APR_EINVAL;
  +    /* XXX IPv6 - assumes sin_port and sin6_port at same offset */
  +    *port = ntohs(sockaddr->sa.sin.sin_port);
  +    return APR_SUCCESS;
  +}
   
  +apr_status_t apr_get_ipaddr(char **addr, apr_sockaddr_t *sockaddr)
  +{
  +    *addr = apr_palloc(sockaddr->pool, sockaddr->addr_str_len);
  +    apr_inet_ntop(sockaddr->sa.sin.sin_family,
  +                  sockaddr->ipaddr_ptr,
  +                  *addr,
  +                  sockaddr->addr_str_len);
       return APR_SUCCESS;
   }
   
  @@ -194,6 +183,13 @@
   apr_status_t apr_get_sockaddr(apr_sockaddr_t **sa, apr_interface_e which, apr_socket_t
*sock)
   {
       if (which == APR_LOCAL) {
  +        if (sock->local_interface_unknown || sock->local_port_unknown) {
  +            apr_status_t rv = get_local_addr(sock);
  +
  +            if (rv != APR_SUCCESS) {
  +                return rv;
  +            }
  +        }
           *sa = sock->local_addr;
       }
       else if (which == APR_REMOTE) {
  
  
  
  1.23      +0 -28     apr/network_io/unix/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockaddr.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- sockaddr.c	2000/11/16 16:04:33	1.22
  +++ sockaddr.c	2000/11/21 19:08:26	1.23
  @@ -71,34 +71,6 @@
   /* included here to allow us to use local_addr */
   #include "sa_common.c"
   
  -apr_status_t apr_set_ipaddr(apr_socket_t *sock, apr_interface_e which, const char *addr)
  -{
  -    u_long ipaddr;
  -    struct sockaddr_in *sa_ptr;
  -
  -    /* XXX IPv6 */
  -    if (which == APR_LOCAL)
  -        sa_ptr = &sock->local_addr->sa.sin;
  -    else if (which == APR_REMOTE)
  -        sa_ptr = &sock->remote_addr->sa.sin;
  -    else
  -        return APR_EINVAL;
  -    
  -    if (!strcmp(addr, APR_ANYADDR)) {
  -        sa_ptr->sin_addr.s_addr = htonl(INADDR_ANY);
  -        return APR_SUCCESS;
  -    }
  -    
  -    ipaddr = inet_addr(addr);
  -    
  -    if (ipaddr == -1) {
  -        return errno;
  -    }
  -    
  -    sa_ptr->sin_addr.s_addr = ipaddr;
  -    return APR_SUCCESS;
  -}
  -
   #if APR_HAVE_NETINET_IN_H
   /* XXX IPv6 */
   apr_status_t apr_get_local_name(struct sockaddr_in **name, apr_socket_t *sock)
  
  
  
  1.21      +0 -27     apr/network_io/win32/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockaddr.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- sockaddr.c	2000/11/16 16:04:33	1.20
  +++ sockaddr.c	2000/11/21 19:08:27	1.21
  @@ -74,33 +74,6 @@
   /* Include this here so we have get_local_addr defined... */
   #include "../unix/sa_common.c"
   
  -apr_status_t apr_set_ipaddr(apr_socket_t *sock, apr_interface_e which, const char *addr)
  -{
  -    u_long ipaddr;
  -    struct sockaddr_in *ptr;
  -
  -    if (which == APR_LOCAL)
  -        ptr = &sock->local_addr->sa.sin;
  -    else if (which == APR_REMOTE)
  -        ptr = &sock->remote_addr->sa.sin;
  -    else
  -        return APR_EINVAL;
  - 
  -    if (!strcmp(addr, APR_ANYADDR)) {
  -        ptr->sin_addr.s_addr = htonl(INADDR_ANY);
  -        return APR_SUCCESS;
  -    }
  -    
  -    ipaddr = inet_addr(addr);
  -    
  -    if (ipaddr == APR_INADDR_NONE) {
  -        return WSAEADDRNOTAVAIL;
  -    }
  -    
  -    ptr->sin_addr.s_addr = ipaddr;
  -    return APR_SUCCESS;
  -}
  -
   apr_status_t apr_get_local_name(struct sockaddr_in **name, apr_socket_t *sock)
   {
       if (sock->local_port_unknown || sock->local_interface_unknown) {
  
  
  
  1.3       +7 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CHANGES	2000/11/21 00:30:42	1.2
  +++ CHANGES	2000/11/21 19:08:29	1.3
  @@ -1,4 +1,11 @@
   Changes with APR a8
  +  *) apr_set_port(), apr_get_port(), apr_set_ipaddr(), and apr_get_ipaddr()
  +     now take apr_sockaddr_t as a parameter instead of apr_socket_t +
  +     apr_interface_e.  This will allow the same routines to be used with
  +     datagram APIs to be added later.  Note that code which calls 
  +     apr_set_ipaddr() should probably be changed to call apr_getaddrinfo()
  +     for protocol independence.  [Jeff Trawick]
  +
     *) apr_create_tcp_socket() has been removed.  Use apr_create_socket()
        instead.  [Jeff Trawick]
   
  
  
  

Mime
View raw message