From: David Reid Date: Thu, 9 Nov 2000 15:09:50 +0000 (+0000) Subject: Change the code to reflect the recent API changes... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6bd7d2c70aa7949bd3a99212dad765d05950bc8;p=apache Change the code to reflect the recent API changes... Alter http_vhost.c to use the new apr_get_inaddr fucntion. Old code is still there just in case it breaks. can someone check it who knows this stuff? git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86890 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/connection.c b/server/connection.c index 50ce7cbe5b..6f07ec763b 100644 --- a/server/connection.c +++ b/server/connection.c @@ -284,12 +284,12 @@ conn_rec *ap_new_connection(apr_pool_t *p, server_rec *server, conn->pool = p; conn->local_addr = *saddr; - apr_get_local_ipaddr(&conn->local_ip, inout); + apr_get_ipaddr(&conn->local_ip, APR_LOCAL, inout); conn->base_server = server; conn->client_socket = inout; conn->remote_addr = *remaddr; - apr_get_remote_ipaddr(&conn->remote_ip, inout); + apr_get_ipaddr(&conn->remote_ip, APR_REMOTE, inout); conn->id = id; return conn; diff --git a/server/listen.c b/server/listen.c index 673ac4351f..a3b964642b 100644 --- a/server/listen.c +++ b/server/listen.c @@ -87,7 +87,7 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server) char *ipaddr; apr_get_port(&port, APR_LOCAL, s); - apr_get_local_ipaddr(&ipaddr,s); + apr_get_ipaddr(&ipaddr, APR_LOCAL, s); apr_snprintf(addr, sizeof(addr), "address %s port %u", ipaddr, (unsigned) port); @@ -183,7 +183,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_port(&oldport, APR_LOCAL, (*walk)->sd); - apr_get_local_ipaddr(&oldaddr,(*walk)->sd); + apr_get_ipaddr(&oldaddr, APR_LOCAL, (*walk)->sd); if (!strcmp(oldaddr, addr) && port == oldport) { /* re-use existing record */ new = *walk; @@ -203,7 +203,7 @@ static void alloc_listener(process_rec *process, char *addr, unsigned int port) return; } apr_set_port(new->sd, APR_LOCAL, port); - apr_set_local_ipaddr(new->sd, addr); + apr_set_ipaddr(new->sd, APR_LOCAL, addr); new->next = ap_listeners; ap_listeners = new; } diff --git a/server/rfc1413.c b/server/rfc1413.c index 8e5d3430bd..a7a90c2ba5 100644 --- a/server/rfc1413.c +++ b/server/rfc1413.c @@ -130,7 +130,7 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip, */ apr_set_port(sock, APR_LOCAL, ANY_PORT); - apr_set_local_ipaddr(sock, local_ip); + apr_set_ipaddr(sock, APR_LOCAL, local_ip); if ((status = apr_bind(sock)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, status, srv, @@ -143,7 +143,7 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip, * the service */ apr_set_port(sock, APR_REMOTE, RFC1413_PORT); - apr_set_remote_ipaddr(sock, rmt_ip); + apr_set_ipaddr(sock, APR_REMOTE, rmt_ip); if (apr_connect(sock, NULL) != APR_SUCCESS) return -1; diff --git a/server/vhost.c b/server/vhost.c index 2078e07416..edf9e0289c 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -187,7 +187,7 @@ static const char *get_addresses(apr_pool_t *p, const char *w_, server_addr_rec ***paddr, apr_port_t port) { struct hostent *hep; - unsigned long my_addr; + apr_in_addr my_addr; server_addr_rec *sar; char *t; int i, is_an_ip_addr; @@ -211,27 +211,41 @@ static const char *get_addresses(apr_pool_t *p, const char *w_, *t = 0; } - is_an_ip_addr = 0; + if (strcasecmp(w, "_default_") == 0 + || strcmp(w, "255.255.255.255") == 0) { + my_addr.s_addr = DEFAULT_VHOST_ADDR; + } else { + if (apr_get_inaddr(&my_addr, w) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, NULL, + "Cannot resolve host name %s --- ignoring!", w); + return NULL; + } + } + +/* + is_an_ip_addr = 0; if (strcmp(w, "*") == 0) { - my_addr = htonl(INADDR_ANY); + 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 = DEFAULT_VHOST_ADDR; + my_addr.s_addr = DEFAULT_VHOST_ADDR; is_an_ip_addr = 1; } - else if ((my_addr = apr_inet_addr(w)) != INADDR_NONE) { + 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.s_addr = my_addr; + sar->host_addr = my_addr; sar->host_port = port; sar->virthost = apr_pstrdup(p, w); return NULL; +/* } hep = gethostbyname(w); @@ -250,7 +264,7 @@ static const char *get_addresses(apr_pool_t *p, const char *w_, sar->host_port = port; sar->virthost = apr_pstrdup(p, w); } - +*/ return NULL; }