From: bert hubert Date: Tue, 19 Jan 2016 14:44:10 +0000 (+0100) Subject: add ability to store comboaddress in a hashed container X-Git-Tag: dnsdist-1.0.0-alpha2~53^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=545725f29f2ef0d5250282eb554907302c30aac7;p=pdns add ability to store comboaddress in a hashed container --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index ff2a87cfc..abdc4e96f 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -1,6 +1,6 @@ /* PowerDNS Versatile Database Driven Nameserver - Copyright (C) 2002 - 2014 PowerDNS.COM BV + Copyright (C) 2002 - 2016 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 @@ -119,6 +119,24 @@ union ComboAddress { return memcmp(&sin6.sin6_addr.s6_addr, &rhs.sin6.sin6_addr.s6_addr, 16) > 0; } + struct addressOnlyHash + { + uint32_t operator()(const ComboAddress& ca) const + { + const unsigned char* start; + int len; + if(ca.sin4.sin_family == AF_INET) { + start =(const unsigned char*)&ca.sin4.sin_addr.s_addr; + len=4; + } + else { + start =(const unsigned char*)&ca.sin6.sin6_addr.s6_addr; + len=16; + } + return burtle(start, len, 0); + } + }; + struct addressOnlyLessThan: public std::binary_function { bool operator()(const ComboAddress& a, const ComboAddress& b) const