diff --git a/include/apr_network_io.h b/include/apr_network_io.h index 0d34a84..d322bd3 100644 --- a/include/apr_network_io.h +++ b/include/apr_network_io.h @@ -101,6 +101,9 @@ extern "C" { */ #define APR_SO_BROADCAST 65536 /**< Allow broadcast */ +#define APR_FREEBIND 131072 /**< Allow binding to addresses not owned + * by any interface + */ /** @} */ diff --git a/network_io/unix/sockopt.c b/network_io/unix/sockopt.c index 6ce4b91..a343a2b 100644 --- a/network_io/unix/sockopt.c +++ b/network_io/unix/sockopt.c @@ -330,6 +330,17 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, return APR_ENOTIMPL; #endif break; + case APR_FREEBIND: +#ifdef IP_FREEBIND + if (setsockopt(sock->socketdes, SOL_IP, IP_FREEBIND, + (void *)&one, sizeof(int)) == -1) { + return errno; + } + apr_set_option(sock, APR_FREEBIND, on); +#else + return APR_ENOTIMPL; +#endif + break; default: return APR_EINVAL; }