From: bert hubert Date: Tue, 16 Jun 2015 11:14:32 +0000 (+0200) Subject: implement a canonical ordering mode for DNSName plus add testcases for it. Preliminar... X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~58^2~21^2~5^2~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1b0f079f9190c54b2a885ce77a4c88f6e02b726;p=pdns implement a canonical ordering mode for DNSName plus add testcases for it. Preliminary slow but correct implementation. --- diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index 28b281ff9..530a209a1 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -188,7 +188,6 @@ vector DNSName::getRawLabels() const return ret; } - bool DNSName::canonCompare(const DNSName& rhs) const { auto ours=getRawLabels(), rhsLabels = rhs.getRawLabels(); diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 15d830bd3..a3f3d3296 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -78,6 +78,9 @@ public: ar & d_storage; ar & d_empty; } + + bool canonCompare(const DNSName& rhs) const; + private: // typedef __gnu_cxx::__sso_string string_t; typedef std::string string_t; @@ -99,6 +102,14 @@ struct CanonDNSNameCompare: public std::binary_function }; size_t hash_value(DNSName const& d); +struct CanonDNSNameCompare: public std::binary_function +{ + bool operator()(const DNSName&a, const DNSName& b) const + { + return a.canonCompare(b); + } +}; + inline DNSName operator+(const DNSName& lhs, const DNSName& rhs) { DNSName ret=lhs;