compile the tables and such we need to do the run-time vhost lookups */
| 571 | |
| 572 | /* compile the tables and such we need to do the run-time vhost lookups */ |
| 573 | AP_DECLARE(void) ap_fini_vhost_config(apr_pool_t *p, server_rec *main_s) |
| 574 | { |
| 575 | server_addr_rec *sar; |
| 576 | int has_default_vhost_addr; |
| 577 | server_rec *s; |
| 578 | int i; |
| 579 | ipaddr_chain **iphash_table_tail[IPHASH_TABLE_SIZE]; |
| 580 | |
| 581 | /* Main host first */ |
| 582 | s = main_s; |
| 583 | |
| 584 | if (!s->server_hostname) { |
| 585 | s->server_hostname = ap_get_local_host(p); |
| 586 | } |
| 587 | |
| 588 | /* initialize the tails */ |
| 589 | for (i = 0; i < IPHASH_TABLE_SIZE; ++i) { |
| 590 | iphash_table_tail[i] = &iphash_table[i]; |
| 591 | } |
| 592 | |
| 593 | /* The next things to go into the hash table are the virtual hosts |
| 594 | * themselves. They're listed off of main_s->next in the reverse |
| 595 | * order they occurred in the config file, so we insert them at |
| 596 | * the iphash_table_tail but don't advance the tail. |
| 597 | */ |
| 598 | |
| 599 | for (s = main_s->next; s; s = s->next) { |
| 600 | server_addr_rec *sar_prev = NULL; |
| 601 | has_default_vhost_addr = 0; |
| 602 | for (sar = s->addrs; sar; sar = sar->next) { |
| 603 | ipaddr_chain *ic; |
| 604 | char inaddr_any[16] = {0}; /* big enough to handle IPv4 or IPv6 */ |
| 605 | /* XXX: this treats 0.0.0.0 as a "default" server which matches no-exact-match for IPv6 */ |
| 606 | if (!memcmp(sar->host_addr->ipaddr_ptr, inaddr_any, sar->host_addr->ipaddr_len)) { |
| 607 | ic = find_default_server(sar->host_port); |
| 608 | |
| 609 | if (ic && sar->host_port == ic->sar->host_port) { /* we're a match for an existing "default server" */ |
| 610 | if (!sar_prev || memcmp(sar_prev->host_addr->ipaddr_ptr, inaddr_any, sar_prev->host_addr->ipaddr_len) |
| 611 | || sar_prev->host_port != sar->host_port) { |
| 612 | add_name_vhost_config(p, main_s, s, sar, ic); |
| 613 | } |
| 614 | } |
| 615 | else { |
| 616 | /* No default server, or we found a default server but |
| 617 | ** exactly one of us is a wildcard port, which means we want |
| 618 | ** two ip-based vhosts not an NVH with two names |
| 619 | */ |
| 620 | ic = new_ipaddr_chain(p, s, sar); |
| 621 | ic->next = default_list; |
| 622 | default_list = ic; |
| 623 | add_name_vhost_config(p, main_s, s, sar, ic); |
| 624 | } |
| 625 | has_default_vhost_addr = 1; |
| 626 | } |
| 627 | else { |
| 628 | /* see if it matches something we've already got */ |
| 629 | ic = find_ipaddr(sar->host_addr); |
| 630 |
no test coverage detected