diff options
Diffstat (limited to 'contrib/apr/network_io/unix/sockaddr.c')
-rw-r--r-- | contrib/apr/network_io/unix/sockaddr.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/contrib/apr/network_io/unix/sockaddr.c b/contrib/apr/network_io/unix/sockaddr.c index 9253a27..0dd1a2d 100644 --- a/contrib/apr/network_io/unix/sockaddr.c +++ b/contrib/apr/network_io/unix/sockaddr.c @@ -839,6 +839,35 @@ APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, return 0; /* not equal */ } +APR_DECLARE(int) apr_sockaddr_is_wildcard(const apr_sockaddr_t *addr) +{ + static const char inaddr_any[ +#if APR_HAVE_IPV6 + sizeof(struct in6_addr) +#else + sizeof(struct in_addr) +#endif + ] = {0}; + + if (addr->ipaddr_ptr /* IP address initialized */ + && addr->ipaddr_len <= sizeof inaddr_any) { /* else bug elsewhere? */ + if (!memcmp(inaddr_any, addr->ipaddr_ptr, addr->ipaddr_len)) { + return 1; + } +#if APR_HAVE_IPV6 + if (addr->family == AF_INET6 + && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)addr->ipaddr_ptr)) { + struct in_addr *v4 = (struct in_addr *)&((apr_uint32_t *)addr->ipaddr_ptr)[3]; + + if (!memcmp(inaddr_any, v4, sizeof *v4)) { + return 1; + } + } +#endif + } + return 0; +} + static apr_status_t parse_network(apr_ipsubnet_t *ipsub, const char *network) { /* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */ |