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 listen.c rfc1413.c util_script.c
Date Wed, 08 Nov 2000 14:48:02 GMT
dreid       00/11/08 06:47:54

  Modified:    src/lib/apr/include apr_network_io.h
               src/lib/apr/network_io/beos sockaddr.c
               src/lib/apr/network_io/unix sockaddr.c
               src/lib/apr/network_io/win32 sockaddr.c
               src/lib/apr/test client.c server.c
               src/main http_core.c http_vhost.c listen.c rfc1413.c
                        util_script.c
  Log:
  This adds the APR_LOCAL/APR_REMOTE to APR and changes the apr_get/set_port
  functions to use it.  This is onyl the start and I'll pause a while before
  I continue in case people really hate this.  The patch can be backed out and
  all evidence will be removed, but I think this makes maintaining/developing
  the code easier in the long term.
  
  Revision  Changes    Path
  1.63      +12 -20    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.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- apr_network_io.h	2000/11/08 10:59:59	1.62
  +++ apr_network_io.h	2000/11/08 14:45:18	1.63
  @@ -113,6 +113,12 @@
   }
   #endif
   
  +/* Enum to tell us if we're interested in remote or local socket */
  +typedef enum {
  +    APR_LOCAL,
  +    APR_REMOTE
  +} apr_interface_e;
  +
   /* I guess not everybody uses inet_addr.  This defines apr_inet_addr
    * appropriately.
    */
  @@ -382,37 +388,23 @@
   apr_status_t apr_getsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t* on);
   
   /**
  - * Associate a local port with a socket.
  + * 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.
  - */
  -apr_status_t apr_set_local_port(apr_socket_t *sock, apr_port_t port);
  -
  -/**
  - * Associate a remote port with a socket.
  - * @param sock The socket to set.
  - * @param port The local port this socket will be dealing with.
  - * @tip This does not make a connection to the remote port, it is just 
  - *      telling apr which port apr_connect() should attempt to connect to.
    */
  -apr_status_t apr_set_remote_port(apr_socket_t *sock, apr_port_t port);
  +apr_status_t apr_set_port(apr_socket_t *sock, apr_interface_e which, apr_port_t port);
   
   /**
  - * Return the local port with a socket.
  + * Return the port associated with a socket.
    * @param port The local port this socket is associated with.
  - * @param sock The socket to enquire about.
  - */
  -apr_status_t apr_get_local_port(apr_port_t *port, apr_socket_t *sock);
  -
  -/**
  - * Return the remote port associated with a socket.
  - * @param port The remote port this socket is associated with.
  + * @param which Which interface are we getting the port for?
    * @param sock The socket to enquire about.
    */
  -apr_status_t apr_get_remote_port(apr_port_t *port, apr_socket_t *sock);
  +apr_status_t apr_get_port(apr_port_t *port, apr_interface_e which, apr_socket_t *sock);
   
   /**
    * Associate a local socket addr with an apr socket.
  
  
  
  1.16      +16 -26    apache-2.0/src/lib/apr/network_io/beos/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockaddr.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- sockaddr.c	2000/11/08 11:00:00	1.15
  +++ sockaddr.c	2000/11/08 14:45:55	1.16
  @@ -58,39 +58,29 @@
   #else
   #include "networkio.h"
   
  -apr_status_t apr_set_local_port(apr_socket_t *sock, apr_port_t port)
  +apr_status_t apr_set_port(apr_socket_t *sock, apr_interface_e which, apr_port_t port)
   {
  -    if (!sock) {
  +    if (!sock) 
           return APR_EBADF;
  -    }
  -    sock->local_addr->sin_port = htons(port);
  +    if (which == APR_LOCAL) 
  +        sock->local_addr->sin_port = htons(port);
  +    else if (APR == APR_REMOTE)
  +        sock->remote_addr->sin_port = htons(port);
  +    else
  +        return APR_EINVAL;
       return APR_SUCCESS;
   }
   
  -apr_status_t apr_set_remote_port(apr_socket_t *sock, apr_port_t port)
  +apr_status_t apr_get_port(apr_port_t *port, apr_interface_e which, apr_socket_t *sock)
   {
  -    if (!sock) {
  +    if (!sock)
           return APR_EBADF;
  -    }
  -    sock->remote_addr->sin_port = htons(port);
  -    return APR_SUCCESS;
  -}
  -
  -apr_status_t apr_get_local_port(apr_port_t *port, apr_socket_t *sock)
  -{
  -    if (!sock) {
  -        return APR_EBADF;
  -    }
  -    *port = ntohs(sock->local_addr->sin_port);
  -    return APR_SUCCESS;
  -}
  -
  -apr_status_t apr_get_remote_port(apr_port_t *port, apr_socket_t *sock)
  -{
  -    if (!sock) {
  -        return APR_EBADF;
  -    }
  -    *port = ntohs(sock->remote_addr->sin_port);
  +    if (which == APR_LOCAL)
  +        *port = ntohs(sock->local_addr->sin_port);
  +    else if (which == APR_REMOTE)
  +        *port = ntohs(sock->remote_addr->sin_port);
  +    else
  +        return APR_EINVAL;
       return APR_SUCCESS;
   }
   
  
  
  
  1.18      +21 -28    apache-2.0/src/lib/apr/network_io/unix/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockaddr.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- sockaddr.c	2000/11/08 11:00:02	1.17
  +++ sockaddr.c	2000/11/08 14:46:04	1.18
  @@ -55,22 +55,18 @@
   #include "networkio.h"
   #include "apr_strings.h"
   
  -apr_status_t apr_set_local_port(apr_socket_t *sock, apr_port_t port)
  +apr_status_t apr_set_port(apr_socket_t *sock, apr_interface_e which, 
  +                         apr_port_t port)
   {
  -    sock->local_addr->sin_port = htons(port);
  +    if (which == APR_LOCAL)
  +        sock->local_addr->sin_port = htons(port);
  +    else if (which == APR_REMOTE)
  +        sock->remote_addr->sin_port = htons(port);
  +    else
  +        return APR_EINVAL;
       return APR_SUCCESS;
   }
   
  -
  -
  -apr_status_t apr_set_remote_port(apr_socket_t *sock, apr_port_t port)
  -{
  -    sock->remote_addr->sin_port = htons(port);
  -    return APR_SUCCESS;
  -}
  -
  -
  -
   static apr_status_t get_local_addr(apr_socket_t *sock)
   {
       apr_socklen_t namelen = sizeof(*sock->local_addr);
  @@ -87,25 +83,22 @@
   
   
   
  -apr_status_t apr_get_local_port(apr_port_t *port, apr_socket_t *sock)
  +apr_status_t apr_get_port(apr_port_t *port, apr_interface_e which, apr_socket_t *sock)
   {
  -    if (sock->local_port_unknown) {
  -        apr_status_t rv = get_local_addr(sock);
  -
  -        if (rv != APR_SUCCESS) {
  -            return rv;
  +    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->sin_port);
  -    return APR_SUCCESS;
  -}
  -
   
  -
  -apr_status_t apr_get_remote_port(apr_port_t *port, apr_socket_t *sock)
  -{
  -    *port = ntohs(sock->remote_addr->sin_port);
  +        *port = ntohs(sock->local_addr->sin_port);
  +    } else if (which == APR_REMOTE)
  +        *port = ntohs(sock->remote_addr->sin_port);
  +    else
  +        return APR_EINVAL;
       return APR_SUCCESS;
   }
   
  
  
  
  1.14      +20 -29    apache-2.0/src/lib/apr/network_io/win32/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sockaddr.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- sockaddr.c	2000/11/08 11:00:04	1.13
  +++ sockaddr.c	2000/11/08 14:46:23	1.14
  @@ -74,44 +74,35 @@
   
   
   
  -apr_status_t apr_set_local_port(apr_socket_t *sock, apr_port_t port)
  +apr_status_t apr_set_port(apr_socket_t *sock, apr_interface_e which, apr_port_t port)
   {
  -    sock->local_addr->sin_port = htons(port);
  +    if (which == APR_LOCAL)
  +        sock->local_addr->sin_port = htons(port);
  +    else if (which == APR_REMOTE)
  +        sock->remote_addr->sin_port = htons(port);
  +    else
  +        return APR_EINVAL;
       return APR_SUCCESS;
   }
   
  -
  -
  -apr_status_t apr_set_remote_port(apr_socket_t *sock, apr_port_t port)
  -{
  -    sock->remote_addr->sin_port = htons(port);
  -    return APR_SUCCESS;
  -}
  -
  -
  -
  -apr_status_t apr_get_local_port(apr_port_t *port, apr_socket_t *sock)
  +apr_status_t apr_get_port(apr_port_t *port, apr_interface_e which, apr_socket_t *sock)
   {
  -    if (sock->local_port_unknown) {
  -        apr_status_t rv = get_local_addr(sock);
  -
  -        if (rv != APR_SUCCESS) {
  -            return rv;
  +    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->sin_port);
  -    return APR_SUCCESS;
  -}
  +        *port = ntohs(sock->local_addr->sin_port);
  +    } else if (which == APR_REMOTE)
  +        *port = ntohs(sock->remote_addr->sin_port);
  +    else
  +        return APR_EINVAL;
   
  -
  -
  -apr_status_t apr_get_remote_port(apr_port_t *port, apr_socket_t *sock)
  -{
  -    *port = ntohs(sock->remote_addr->sin_port);
       return APR_SUCCESS;
   }
  -
   
   
   apr_status_t apr_set_local_ipaddr(apr_socket_t *sock, const char *addr)
  
  
  
  1.16      +3 -3      apache-2.0/src/lib/apr/test/client.c
  
  Index: client.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/test/client.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- client.c	2000/11/08 11:02:12	1.15
  +++ client.c	2000/11/08 14:46:50	1.16
  @@ -116,7 +116,7 @@
       }
   
       fprintf(stdout, "\tClient:  Setting port for socket.......");
  -    if (apr_set_remote_port(sock, 8021) != APR_SUCCESS) {
  +    if (apr_set_port(sock, APR_REMOTE, 8021) != APR_SUCCESS) {
           apr_close_socket(sock);
           fprintf(stderr, "Couldn't set the port correctly\n");
           exit(-1);
  @@ -137,9 +137,9 @@
       fprintf(stdout, "OK\n");
   
       apr_get_remote_ipaddr(&remote_ipaddr, sock);
  -    apr_get_remote_port(&remote_port, sock);
  +    apr_get_port(&remote_port, APR_REMOTE, sock);
       apr_get_local_ipaddr(&local_ipaddr, sock);
  -    apr_get_local_port(&local_port, sock);
  +    apr_get_port(&local_port, APR_LOCAL, sock);
       fprintf(stdout, "\tClient socket: %s:%u -> %s:%u\n", local_ipaddr, local_port, remote_ipaddr,
remote_port);
   
       fprintf(stdout, "\tClient:  Trying to send data over socket.......");
  
  
  
  1.15      +3 -3      apache-2.0/src/lib/apr/test/server.c
  
  Index: server.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/test/server.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- server.c	2000/11/08 11:02:13	1.14
  +++ server.c	2000/11/08 14:47:05	1.15
  @@ -111,7 +111,7 @@
       fprintf(stdout, "OK\n");
   
       fprintf(stdout, "\tServer:  Setting port for socket.......");
  -    if (apr_set_local_port(sock, 8021) != APR_SUCCESS) {
  +    if (apr_set_port(sock, APR_LOCAL, 8021) != APR_SUCCESS) {
           apr_close_socket(sock);
           fprintf(stderr, "Couldn't set the port correctly\n");
           exit(-1);
  @@ -162,9 +162,9 @@
       fprintf(stdout, "OK\n");
   
       apr_get_remote_ipaddr(&remote_ipaddr, sock2);
  -    apr_get_remote_port(&remote_port, sock2);
  +    apr_get_port(&remote_port, APR_REMOTE, sock2);
       apr_get_local_ipaddr(&local_ipaddr, sock2);
  -    apr_get_local_port(&local_port, sock2);
  +    apr_get_port(&local_port, APR_LOCAL, sock2);
       fprintf(stdout, "\tServer socket: %s:%u -> %s:%u\n", local_ipaddr, local_port, remote_ipaddr,
remote_port);
   
       length = STRLEN;
  
  
  
  1.209     +1 -1      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.208
  retrieving revision 1.209
  diff -u -r1.208 -r1.209
  --- http_core.c	2000/11/08 11:48:08	1.208
  +++ http_core.c	2000/11/08 14:47:18	1.209
  @@ -775,7 +775,7 @@
       if (d->use_canonical_name == USE_CANONICAL_NAME_OFF
   	|| d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
           if (r->hostname)
  -           apr_get_local_port(&port, r->connection->client_socket);
  +           apr_get_port(&port, APR_LOCAL, r->connection->client_socket);
       }
       /* default */
       return port;
  
  
  
  1.34      +3 -3      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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- http_vhost.c	2000/11/08 12:07:27	1.33
  +++ http_vhost.c	2000/11/08 14:47:25	1.34
  @@ -860,7 +860,7 @@
       name_chain *src;
   
       last_s = NULL;
  -    apr_get_local_port(&port, r->connection->client_socket);
  +    apr_get_port(&port, APR_LOCAL, r->connection->client_socket);
   
       /* Recall that the name_chain is a list of server_addr_recs, some of
        * whose ports may not match.  Also each server may appear more than
  @@ -915,7 +915,7 @@
       server_rec *last_s;
       name_chain *src;
       apr_port_t port;
  -    apr_get_local_port(&port, r->connection->client_socket);
  +    apr_get_port(&port, APR_LOCAL, r->connection->client_socket);
      
       /*
        * This is in conjunction with the ServerPath code in http_core, so we
  @@ -976,7 +976,7 @@
   {
       ipaddr_chain *trav;
       apr_port_t port;
  -    apr_get_local_port(&port, conn->client_socket);
  +    apr_get_port(&port, APR_LOCAL, conn->client_socket);
   
       /* scan the hash apr_table_t for an exact match first */
       trav = find_ipaddr(&conn->local_addr.sin_addr, port);
  
  
  
  1.34      +3 -3      apache-2.0/src/main/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/listen.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- listen.c	2000/11/08 11:35:10	1.33
  +++ listen.c	2000/11/08 14:47:28	1.34
  @@ -86,7 +86,7 @@
       apr_port_t port;
       char *ipaddr;
   
  -    apr_get_local_port(&port,s);
  +    apr_get_port(&port, APR_LOCAL, s);
       apr_get_local_ipaddr(&ipaddr,s);
       apr_snprintf(addr, sizeof(addr), "address %s port %u", ipaddr,
   		(unsigned) port);
  @@ -182,7 +182,7 @@
   
       /* see if we've got an old listener for this address:port */
       for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
  -        apr_get_local_port(&oldport, (*walk)->sd);
  +        apr_get_port(&oldport, APR_LOCAL, (*walk)->sd);
   	apr_get_local_ipaddr(&oldaddr,(*walk)->sd);
   	if (!strcmp(oldaddr, addr) && port == oldport) {
   	    /* re-use existing record */
  @@ -202,7 +202,7 @@
                    "make_sock: failed to get a socket for %s", addr);
           return;
       }
  -    apr_set_local_port(new->sd, port);
  +    apr_set_port(new->sd, APR_LOCAL, port);
       apr_set_local_ipaddr(new->sd, addr);
       new->next = ap_listeners;
       ap_listeners = new;
  
  
  
  1.26      +4 -4      apache-2.0/src/main/rfc1413.c
  
  Index: rfc1413.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/rfc1413.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- rfc1413.c	2000/11/08 11:35:11	1.25
  +++ rfc1413.c	2000/11/08 14:47:30	1.26
  @@ -129,7 +129,7 @@
        * addresses from the query socket.
        */
   
  -    apr_set_local_port(sock, ANY_PORT);
  +    apr_set_port(sock, APR_LOCAL, ANY_PORT);
       apr_set_local_ipaddr(sock, local_ip);
   
       if ((status = apr_bind(sock)) != APR_SUCCESS) {
  @@ -142,13 +142,13 @@
    * errors from connect usually imply the remote machine doesn't support
    * the service
    */
  -    apr_set_remote_port(sock, RFC1413_PORT);
  +    apr_set_port(sock, APR_REMOTE, RFC1413_PORT);
       apr_set_remote_ipaddr(sock, rmt_ip);
                       
       if (apr_connect(sock, NULL) != APR_SUCCESS)
           return -1;
  -    apr_get_local_port(&sav_our_port, sock);
  -    apr_get_remote_port(&sav_rmt_port, sock);
  +    apr_get_port(&sav_our_port, APR_LOCAL, sock);
  +    apr_get_port(&sav_rmt_port, APR_REMOTE, sock);
   
   /* send the data */
       buflen = apr_snprintf(buffer, sizeof(buffer), "%u,%u\r\n", sav_rmt_port,
  
  
  
  1.48      +1 -1      apache-2.0/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_script.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- util_script.c	2000/11/08 11:35:14	1.47
  +++ util_script.c	2000/11/08 14:47:33	1.48
  @@ -257,7 +257,7 @@
       apr_table_addn(e, "SERVER_ADMIN", s->server_admin);	/* Apache */
       apr_table_addn(e, "SCRIPT_FILENAME", r->filename);	/* Apache */
   
  -    apr_get_remote_port(&rport, c->client_socket);
  +    apr_get_port(&rport, APR_REMOTE, c->client_socket);
       apr_table_addn(e, "REMOTE_PORT", apr_psprintf(r->pool, "%d", rport));
   
       if (r->user) {
  
  
  

Mime
View raw message