--- server/core.c.orig Thu Sep 29 01:47:05 2005 +++ server/core.c Fri Oct 21 16:31:15 2005 @@ -1965,6 +1965,78 @@ } } +static const char *start_ifbind(cmd_parms *cmd, void *dummy, const char *arg) +{ + const char *endp; + int ipconfigured = 0; + int not = 0; + char *host, *scope_id; + apr_port_t port; + apr_status_t rv; + apr_socket_t *tmp_sock; + apr_sockaddr_t *sa; + + endp = ap_strrchr_c(arg, '>'); + if (endp == NULL) { + return unclosed_directive(cmd); + } + + arg = apr_pstrndup(cmd->pool, arg, endp - arg); + + if (arg[0] == '!') { + not = 1; + arg++; + } + + rv = apr_parse_addr_port(&host, &scope_id, &port, arg, cmd->pool); + if (rv != APR_SUCCESS) { + return "Invalid address or port"; + } + + if (!host || !strcmp(host, "*")) { + return "A host IP address must be set"; + } + + if (scope_id) { + /* XXX scope id support is useful with link-local IPv6 addresses */ + return "Scope id is not supported"; + } + + if ((rv = apr_sockaddr_info_get(&sa, host, APR_UNSPEC, 0, 0, cmd->pool)) == APR_SUCCESS) { + if ((rv = apr_socket_create(&tmp_sock, sa->family, SOCK_STREAM, cmd->pool)) + == APR_SUCCESS) { + if ((rv = apr_bind(tmp_sock, sa)) == APR_SUCCESS) { + ipconfigured = 1; + } + apr_socket_close(tmp_sock); + } + } + + if (ipconfigured) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, cmd->server, + "IfBind: IP %s exists on network interface", arg); + } + else { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, rv, cmd->server, + "IfBind: IP %s does not exist on network interface", arg); + } + + if ((!not && ipconfigured) || (not && !ipconfigured)) { + ap_directive_t *parent = NULL; + ap_directive_t *current = NULL; + const char *retval; + + retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd, + ¤t, &parent, " business */ static const char *virtualhost_section(cmd_parms *cmd, void *dummy, @@ -3170,6 +3242,8 @@ "Container for directives based on existance of specified modules"), AP_INIT_TAKE1("