vhost.c revision bbbf8f0e622ad5a37ccf70f35660fc755575278a
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina/* ====================================================================
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * The Apache Software License, Version 1.1
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * Copyright (c) 2000 The Apache Software Foundation. All rights
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * Redistribution and use in source and binary forms, with or without
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * modification, are permitted provided that the following conditions
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * 1. Redistributions of source code must retain the above copyright
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * notice, this list of conditions and the following disclaimer.
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * 2. Redistributions in binary form must reproduce the above copyright
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * notice, this list of conditions and the following disclaimer in
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * the documentation and/or other materials provided with the
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * distribution.
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * 3. The end-user documentation included with the redistribution,
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * if any, must include the following acknowledgment:
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * "This product includes software developed by the
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * Apache Software Foundation (http://www.apache.org/)."
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * Alternately, this acknowledgment may appear in the software itself,
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * if and wherever such third-party acknowledgments normally appear.
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * 4. The names "Apache" and "Apache Software Foundation" must
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * not be used to endorse or promote products derived from this
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * software without prior written permission. For written
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * permission, please contact apache@apache.org.
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * 5. Products derived from this software may not be called "Apache",
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * nor may "Apache" appear in their name, without prior written
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * permission of the Apache Software Foundation.
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3f32406640d89face5e79244b4d8dab34adb6c7cPavel Březina * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* http_vhost.c: functions pertaining to virtual host addresses
#define CORE_PRIVATE
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "http_vhost.h"
#include "http_protocol.h"
#include "http_core.h"
#include "apr_strings.h"
#ifdef HAVE_ARPA_INET_H
#ifdef HAVE_NETINET_IN_H
#ifdef HAVE_SYS_SOCKET_H
#ifdef HAVE_NETDB_H
#include <netdb.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
struct name_chain {
struct ipaddr_chain {
#ifndef IPHASH_TABLE_SIZE
int wild_port;
return NULL;
wild_port = 0;
if (scope_id) {
return NULL;
return NULL;
const char *err;
while (hostname[0]) {
if (err) {
return err;
if (s->addrs) {
return NULL;
const char *arg)
#ifdef IPHASH_STATISTICS
static int iphash_compare(const void *a, const void *b)
unsigned total;
total = 0;
for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
count[i] = 0;
++count[i];
if (i < IPHASH_TABLE_SIZE) {
++total;
++total;
unsigned key;
return new;
return new;
unsigned bucket;
return trav;
return NULL;
return trav;
return NULL;
int len;
for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
if (default_list) {
while (*pic) {
server_rec *s;
s = main_s;
if (!s->server_hostname) {
for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
if (!ic) {
if (!s->server_hostname) {
if (has_default_vhost_addr) {
else if (!s->addrs) {
s->server_hostname =
char *hostname;
char *ipaddr_str;
s->server_hostname =
for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
#ifdef IPHASH_STATISTICS
char *dst;
goto bad;
while (*dst) {
dst++;
goto bad;
goto bad;
dst++;
bad:
if (names) {
if(!name[i]) continue;
if (names) {
if(!name[i]) continue;
server_rec *s;
s = r->server;
server_rec *s;
* do the full ServerName/ServerAlias comparisons once for each
goto found;
if (s == last_s) {
last_s = s;
goto found;
r->server = s;
server_rec *s;
if (s == last_s) {
last_s = s;
r->server = s;
fix_hostname(r);
if (r->hostname)
check_hostalias(r);
check_serverpath(r);
if (trav) {
if (trav) {