Mercurial > dovecot > core-2.2
diff src/lib/network.c @ 10789:a4666cc8cb7b HEAD
liblib: Added net_ip_cmp().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 20 Feb 2010 16:19:19 +0200 |
parents | 615eef3139c2 |
children | 260e190306b0 |
line wrap: on
line diff
--- a/src/lib/network.c Sat Feb 20 16:19:00 2010 +0200 +++ b/src/lib/network.c Sat Feb 20 16:19:19 2010 +0200 @@ -30,17 +30,20 @@ bool net_ip_compare(const struct ip_addr *ip1, const struct ip_addr *ip2) { + return net_ip_cmp(ip1, ip2) == 0; +} + +int net_ip_cmp(const struct ip_addr *ip1, const struct ip_addr *ip2) +{ if (ip1->family != ip2->family) - return 0; + return ip1->family - ip2->family; #ifdef HAVE_IPV6 - if (ip1->family == AF_INET6) { - return memcmp(&ip1->u.ip6, &ip2->u.ip6, - sizeof(ip1->u.ip6)) == 0; - } + if (ip1->family == AF_INET6) + return memcmp(&ip1->u.ip6, &ip2->u.ip6, sizeof(ip1->u.ip6)); #endif - return memcmp(&ip1->u.ip4, &ip2->u.ip4, sizeof(ip1->u.ip4)) == 0; + return memcmp(&ip1->u.ip4, &ip2->u.ip4, sizeof(ip1->u.ip4)); } unsigned int net_ip_hash(const struct ip_addr *ip)