httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_core.c http_vhost.c
Date Fri, 10 Nov 2000 16:11:14 GMT
dreid       00/11/10 08:11:14

  Modified:    src/lib/apr/include apr_network_io.h
               src/lib/apr/network_io/unix sa_common.c sockopt.c
               src/lib/apr/network_io/win32 sockopt.c
               src/main http_core.c http_vhost.c
  Log:
  More local/remote changes and tidy up http_vhost a bit.
  
  Also add a new function to get an ap_ina_addr_t from a socket.
  
  Revision  Changes    Path
  1.66      +13 -10    apache-2.0/src/lib/apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_network_io.h,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- apr_network_io.h	2000/11/10 00:58:25	1.65
  +++ apr_network_io.h	2000/11/10 16:11:13	1.66
  @@ -224,20 +224,14 @@
   apr_status_t apr_connect(apr_socket_t *sock, const char *hostname);
   
   /**
  - * Get name of the machine we are currently connected to.
  + * Get name of a machine we are currently connected to.
    * @param name A buffer to store the hostname in.
  + * @param which Which interface do we wnt the hostname for?
    * @param sock The socket to examine.
    */
  -apr_status_t apr_get_remote_hostname(char **name, apr_socket_t *sock);
  +apr_status_t apr_get_hostname(char **name, apr_interface_e which, apr_socket_t *sock);
   
   /**
  - * Get name of the local machine via it's ip address.
  - * @param name A buffer to store the hostname in.
  - * @param sock The socket to examine.
  - */
  -apr_status_t apr_get_local_hostname(char **name, apr_socket_t *sock);
  -
  -/**
    * Get name of the current machine
    * @param buf A buffer to store the hostname in.
    * @param len The maximum length of the hostname that can be stored in the
  @@ -558,10 +552,19 @@
   
   /**
    * Given a hostname and a port, create an apr_in_addr for it...
  - * @param addr The apr_in_addr structure to return.
  + * @param addr The apr_in_addr_t structure to return.
    * @param hostname The hostname to lookup.
    */
   apr_status_t apr_get_inaddr(apr_in_addr_t *addr, char *hostname);
  +
  +/**
  + * Given an apr_socket_t get the apr_in_addr_t for the requested interface
  + * @param addr The apr_in_addr_t structure to return
  + * @param which The interface to return for
  + * @param sock The apr_socket_t to use
  + */
  +apr_status_t apr_get_socket_inaddr(apr_in_addr_t *addr, apr_interface_e which,
  +                  apr_socket_t *sock);
   
   #ifdef __cplusplus
   }
  
  
  
  1.3       +21 -0     apache-2.0/src/lib/apr/network_io/unix/sa_common.c
  
  Index: sa_common.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sa_common.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sa_common.c	2000/11/10 00:58:25	1.2
  +++ sa_common.c	2000/11/10 16:11:13	1.3
  @@ -135,3 +135,24 @@
       return APR_SUCCESS;
   }
   
  +apr_status_t apr_get_socket_inaddr(apr_in_addr_t *addr, apr_interface_e which,
  +                        apr_socket_t *sock)
  +{
  +    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_in_addr_t*)&sock->local_addr->sin_addr;
  +    } else if (which == APR_REMOTE) {
  +        *addr = *(apr_in_addr_t*)&sock->remote_addr->sin_addr;
  +    } else {
  +        return APR_EINVAL;
  +    }
  +    return APR_SUCCESS;
  +}
  +
  
  
  
  1.36      +10 -20    apache-2.0/src/lib/apr/network_io/unix/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockopt.c,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- sockopt.c	2000/11/03 19:24:12	1.35
  +++ sockopt.c	2000/11/10 16:11:13	1.36
  @@ -202,30 +202,20 @@
           return APR_SUCCESS;
   }
   
  -apr_status_t apr_get_remote_hostname(char **name, apr_socket_t *sock)
  +apr_status_t apr_get_hostname(char **name, apr_interface_e which, apr_socket_t *sock)
   {
       struct hostent *hptr;
  -    
  -    hptr = gethostbyaddr((char *)&(sock->remote_addr->sin_addr), 
  -                         sizeof(struct in_addr), AF_INET);
  -    if (hptr != NULL) {
  -        *name = apr_pstrdup(sock->cntxt, hptr->h_name);
  -        if (*name) {
  -            return APR_SUCCESS;
  -        }
  -        return APR_ENOMEM;
  -    }
  +    apr_in_addr_t sa_ptr;
   
  -    /* XXX - Is referencing h_errno threadsafe? */
  -    return (h_errno + APR_OS_START_SYSERR);
  -}
  +    if (which == APR_LOCAL)
  +        sa_ptr = sock->local_addr->sin_addr;
  +    else if (which == APR_REMOTE)
  +        sa_ptr = sock->remote_addr->sin_addr;
  +    else
  +        return APR_EINVAL;
   
  -apr_status_t apr_get_local_hostname(char **name, apr_socket_t *sock)
  -{
  -    struct hostent *hptr;
  -    
  -    hptr = gethostbyaddr((char *)&(sock->local_addr->sin_addr), 
  -                         sizeof(struct in_addr), AF_INET);
  +    hptr = gethostbyaddr((char *)&sa_ptr, sizeof(struct in_addr), AF_INET);
  +
       if (hptr != NULL) {
           *name = apr_pstrdup(sock->cntxt, hptr->h_name);
           if (*name) {
  
  
  
  1.27      +10 -3     apache-2.0/src/lib/apr/network_io/win32/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sockopt.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- sockopt.c	2000/10/06 17:24:40	1.26
  +++ sockopt.c	2000/11/10 16:11:13	1.27
  @@ -201,12 +201,19 @@
           return APR_SUCCESS;
   }
   
  -apr_status_t apr_get_remote_hostname(char **name, apr_socket_t *sock)
  +apr_status_t apr_get_hostname(char **name, apr_interface_e which, apr_socket_t *sock)
   {
       struct hostent *hptr;
  +    apr_in_addr_t sa_ptr;
   
  -    hptr = gethostbyaddr((char *)&(sock->local_addr->sin_addr),
  -                         sizeof(struct in_addr), AF_INET);
  +    if (which == APR_LOCAL)
  +        sa_ptr = sock->local_addr->sin_addr;
  +    else if (which == APR_REMOTE)
  +        sa_ptr = sock->remote_addr->sin_addr;
  +    else
  +        return APR_EINVAL;
  +
  +    hptr = gethostbyaddr((char *)&sa_ptr), sizeof(struct in_addr), AF_INET);
   
       if (hptr != NULL) {
           *name = apr_pstrdup(sock->cntxt, hptr->h_name);
  
  
  
  1.213     +6 -16     apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.212
  retrieving revision 1.213
  diff -u -r1.212 -r1.213
  --- http_core.c	2000/11/09 22:05:40	1.212
  +++ http_core.c	2000/11/10 16:11:13	1.213
  @@ -631,7 +631,7 @@
   	&& conn->remote_host == NULL
   	&& (type == REMOTE_DOUBLE_REV
   	    || hostname_lookups != HOSTNAME_LOOKUP_OFF)) {
  -	if (apr_get_remote_hostname(&conn->remote_host, conn->client_socket)
  +	if (apr_get_hostname(&conn->remote_host, APR_REMOTE, conn->client_socket)
               == APR_SUCCESS){
   	    ap_str_tolower(conn->remote_host);
   	   
  @@ -718,21 +718,11 @@
       }
       if (d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
           if (conn->local_host == NULL) {
  -	    struct in_addr *iaddr;
  -	    struct hostent *hptr;
  -	    iaddr = &(conn->local_addr.sin_addr);
  -	    hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr),
  -				 AF_INET);
  -	    if (hptr != NULL) {
  -	        conn->local_host = apr_pstrdup(conn->pool,
  -					      (void *)hptr->h_name);
  -		ap_str_tolower(conn->local_host);
  -	    }
  -	    else {
  -	        conn->local_host = apr_pstrdup(conn->pool,
  -					      r->server->server_hostname);
  -	    }
  -	}
  +            if (apr_get_hostname(&conn->local_host, APR_LOCAL, conn->client_socket)
!= APR_SUCCESS)
  +                conn->local_host = apr_pstrdup(conn->pool, r->server->server_hostname);
  +            else
  +                ap_str_tolower(conn->local_host);
  +        }
   	return conn->local_host;
       }
       /* default */
  
  
  
  1.38      +7 -45     apache-2.0/src/main/http_vhost.c
  
  Index: http_vhost.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_vhost.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- http_vhost.c	2000/11/10 01:34:46	1.37
  +++ http_vhost.c	2000/11/10 16:11:14	1.38
  @@ -186,11 +186,10 @@
   static const char *get_addresses(apr_pool_t *p, const char *w_,
   				 server_addr_rec ***paddr, apr_port_t port)
   {
  -    struct hostent *hep;
       apr_in_addr_t my_addr;
       server_addr_rec *sar;
       char *t;
  -    int i, is_an_ip_addr;
  +    int i;
       char *w;
   
       if (*w_ == 0)
  @@ -222,49 +221,12 @@
           }
       }
   
  -/*        
  -   is_an_ip_addr = 0;
  -    if (strcmp(w, "*") == 0) {
  -	my_addr.s_addr = htonl(INADDR_ANY);
  -	is_an_ip_addr = 1;
  -    }
  -    else if (strcasecmp(w, "_default_") == 0
  -	     || strcmp(w, "255.255.255.255") == 0) {
  -	my_addr.s_addr = DEFAULT_VHOST_ADDR;
  -	is_an_ip_addr = 1;
  -    }
  -    else if ((my_addr.s_addr = apr_inet_addr(w)) != INADDR_NONE) {
  -	is_an_ip_addr = 1;
  -    }
  -    if (is_an_ip_addr) {
  -*/
  -	sar = apr_pcalloc(p, sizeof(server_addr_rec));
  -	**paddr = sar;
  -	*paddr = &sar->next;
  -	sar->host_addr = my_addr;
  -	sar->host_port = port;
  -	sar->virthost = apr_pstrdup(p, w);
  -	return NULL;
  -/*
  -    }
  -
  -    hep = gethostbyname(w);
  -
  -    if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) {
  -	ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, NULL,
  -	    "Cannot resolve host name %s --- ignoring!", w);
  -	return NULL;
  -    }
  -
  -    for (i = 0; hep->h_addr_list[i]; ++i) {
  -	sar = apr_pcalloc(p, sizeof(server_addr_rec));
  -	**paddr = sar;
  -	*paddr = &sar->next;
  -	sar->host_addr = *(struct in_addr *) hep->h_addr_list[i];
  -	sar->host_port = port;
  -	sar->virthost = apr_pstrdup(p, w);
  -    }
  -*/
  +    sar = apr_pcalloc(p, sizeof(server_addr_rec));
  +    **paddr = sar;
  +    *paddr = &sar->next;
  +    sar->host_addr = my_addr;
  +    sar->host_port = port;
  +    sar->virthost = apr_pstrdup(p, w);
       return NULL;
   }
   
  
  
  

Mime
View raw message