From: David Reid Date: Wed, 8 Nov 2000 14:47:33 +0000 (+0000) Subject: This adds the APR_LOCAL/APR_REMOTE to APR and changes the apr_get/set_port X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9512cb16f073fbed6b629eaabf494e54ebfb9948;p=apache 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86870 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 00aacf44d0..5d7ff22a76 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -775,7 +775,7 @@ AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r) 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; diff --git a/server/listen.c b/server/listen.c index 997a2e0eb8..673ac4351f 100644 --- a/server/listen.c +++ b/server/listen.c @@ -86,7 +86,7 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server) 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 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port) /* 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 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port) "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; diff --git a/server/rfc1413.c b/server/rfc1413.c index 9535d9eb0d..a981c77d34 100644 --- a/server/rfc1413.c +++ b/server/rfc1413.c @@ -129,7 +129,7 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip, * 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 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip, * 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, diff --git a/server/util_script.c b/server/util_script.c index 4eb861742f..225a898fcb 100644 --- a/server/util_script.c +++ b/server/util_script.c @@ -257,7 +257,7 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r) 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) { diff --git a/server/vhost.c b/server/vhost.c index 3206af3024..2078e07416 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -860,7 +860,7 @@ static void check_hostalias(request_rec *r) 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 @@ static void check_serverpath(request_rec *r) 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 @@ void ap_update_vhost_given_ip(conn_rec *conn) { 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);