From b1e8b050e9f11e3e3302b5eeb11ad8170128e2c2 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Thu, 14 Dec 2000 18:47:30 +0000 Subject: [PATCH] The local_addr and remote_addr fields in the conn_rec are now apr_sockaddr_t * instead of sockaddr_in. This is a small step towards IPv6 support. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87342 13f79535-47bb-0310-9956-ffa450edef68 --- include/httpd.h | 8 ++------ modules/aaa/mod_access.c | 4 +++- modules/dav/main/util.c | 3 ++- modules/http/http_core.c | 2 +- server/connection.c | 11 ++++------- server/vhost.c | 7 +++---- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/include/httpd.h b/include/httpd.h index 138e908d1c..3451a141a0 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -86,10 +86,6 @@ extern "C" { #include "apr_time.h" #include "apr_network_io.h" -#ifdef HAVE_NETINET_IN_H -#include -#endif - #ifdef CORE_PRIVATE /* ----------------------------- config dir ------------------------------ */ @@ -839,9 +835,9 @@ struct conn_rec { /* Who is the client? */ /** local address */ - struct sockaddr_in local_addr; + apr_sockaddr_t *local_addr; /** remote address */ - struct sockaddr_in remote_addr; + apr_sockaddr_t *remote_addr; /** Client's IP address */ char *remote_ip; /** Client's DNS name, if known. NULL if DNS hasn't been checked, diff --git a/modules/aaa/mod_access.c b/modules/aaa/mod_access.c index 4efa4b87aa..35c9f4430a 100644 --- a/modules/aaa/mod_access.c +++ b/modules/aaa/mod_access.c @@ -334,8 +334,10 @@ static int find_allowdeny(request_rec *r, apr_array_header_t *a, int method) return 1; case T_IP: + /* XXX handle IPv6 with separate T_IP6 type or add common + * address masking operations to APR */ if (ap[i].x.ip.net != APR_INADDR_NONE - && (r->connection->remote_addr.sin_addr.s_addr + && (r->connection->remote_addr->sa.sin.sin_addr.s_addr & ap[i].x.ip.mask) == ap[i].x.ip.net) { return 1; } diff --git a/modules/dav/main/util.c b/modules/dav/main/util.c index e4946d9a89..9aa6a4f237 100644 --- a/modules/dav/main/util.c +++ b/modules/dav/main/util.c @@ -183,7 +183,7 @@ dav_lookup_result dav_lookup_uri(const char *uri, request_rec * r) { dav_lookup_result result = { 0 }; const char *scheme; - unsigned short port = ntohs(r->connection->local_addr.sin_port); + apr_port_t port; uri_components comp; char *new_file; const char *domain; @@ -215,6 +215,7 @@ dav_lookup_result dav_lookup_uri(const char *uri, request_rec * r) the port, must match our port. the URI must not have a query (args) or a fragment */ + apr_get_port(&port, r->connection->local_addr); if (strcasecmp(comp.scheme, scheme) != 0 || comp.port != port) { result.err.status = HTTP_BAD_GATEWAY; diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 344b0b62e1..04fc4dfb12 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -603,7 +603,7 @@ static apr_inline void do_double_reverse (conn_rec *conn) for (haddr = hptr->h_addr_list; *haddr; haddr++) { if (((struct in_addr *)(*haddr))->s_addr - == conn->remote_addr.sin_addr.s_addr) { + == conn->remote_addr->sa.sin.sin_addr.s_addr) { conn->double_reverse = 1; return; } diff --git a/server/connection.c b/server/connection.c index e86a037ad5..8f27f67e8d 100644 --- a/server/connection.c +++ b/server/connection.c @@ -272,7 +272,6 @@ conn_rec *ap_new_connection(apr_pool_t *p, server_rec *server, apr_socket_t *inout, long id) { conn_rec *conn = (conn_rec *) apr_pcalloc(p, sizeof(conn_rec)); - apr_sockaddr_t *sa; /* Got a connection structure, so initialize what fields we can * (the rest are zeroed out by pcalloc). @@ -282,15 +281,13 @@ conn_rec *ap_new_connection(apr_pool_t *p, server_rec *server, conn->notes = apr_make_table(p, 5); conn->pool = p; - apr_get_sockaddr(&sa, APR_LOCAL, inout); - conn->local_addr = sa->sa.sin; - apr_get_ipaddr(&conn->local_ip, sa); + apr_get_sockaddr(&conn->local_addr, APR_LOCAL, inout); + apr_get_ipaddr(&conn->local_ip, conn->local_addr); + apr_get_sockaddr(&conn->remote_addr, APR_REMOTE, inout); + apr_get_ipaddr(&conn->remote_ip, conn->remote_addr); conn->base_server = server; conn->client_socket = inout; - apr_get_sockaddr(&sa, APR_REMOTE, inout); - conn->remote_addr = sa->sa.sin; - apr_get_ipaddr(&conn->remote_ip, sa); conn->id = id; return conn; diff --git a/server/vhost.c b/server/vhost.c index a5f83b0288..4a2d784445 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -967,13 +967,12 @@ void ap_update_vhost_given_ip(conn_rec *conn) { ipaddr_chain *trav; apr_port_t port; - apr_sockaddr_t *localsa; - apr_get_sockaddr(&localsa, APR_LOCAL, conn->client_socket); - apr_get_port(&port, localsa); + apr_get_port(&port, conn->local_addr); /* scan the hash apr_table_t for an exact match first */ - trav = find_ipaddr(&conn->local_addr.sin_addr, port); + /* XXX IPv6 issues handled in an uncommitted patch */ + trav = find_ipaddr(&conn->local_addr->sa.sin.sin_addr, port); if (trav) { /* save the name_chain for later in case this is a name-vhost */ conn->vhost_lookup_data = trav->names; -- 2.50.1