#include <boost/functional/hash.hpp>
+const DNSName g_rootdnsname("."), g_wildcarddnsname("*");
+
/* raw storage
in DNS label format, with trailing 0. W/o trailing 0, we are 'empty'
www.powerdns.com = 3www8powerdns3com0
;
}
-bool DNSName::operator==(const DNSName& rhs) const
-{
- if(rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size())
- return false;
-
- auto us = d_storage.crbegin();
- auto p = rhs.d_storage.crbegin();
- for(; us != d_storage.crend() && p != rhs.d_storage.crend(); ++us, ++p) { // why does this go backward?
- if(dns2_tolower(*p) != dns2_tolower(*us))
- return false;
- }
- return true;
-}
size_t hash_value(DNSName const& d)
{
inline char dns2_tolower(char c)
{
if(c>='A' && c<='Z')
- c+='a'-'A';
+ return c+('a'-'A');
return c;
}
DNSName(const char* p, int len, int offset, bool uncompress, uint16_t* qtype=0, uint16_t* qclass=0, unsigned int* consumed=0, uint16_t minOffset=0); //!< Construct from a DNS Packet, taking the first question if offset=12
bool isPartOf(const DNSName& rhs) const; //!< Are we part of the rhs name?
- bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive) - empty compares to empty
+ inline bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive) - empty compares to empty
bool operator!=(const DNSName& other) const { return !(*this == other); }
std::string toString(const std::string& separator=".", const bool trailing=true) const; //!< Our human-friendly, escaped, representation
#else
typedef std::string string_t;
#endif
-
+ const string_t& getStorage() const {
+ return d_storage;
+ }
private:
string_t d_storage;
}
DNSName::string_t segmentDNSNameRaw(const char* input); // from ragel
+bool DNSName::operator==(const DNSName& rhs) const
+{
+ if(rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size())
+ return false;
+
+ auto us = d_storage.cbegin();
+ auto p = rhs.d_storage.cbegin();
+ for(; us != d_storage.cend() && p != rhs.d_storage.cend(); ++us, ++p) {
+ if(dns2_tolower(*p) != dns2_tolower(*us))
+ return false;
+ }
+ return true;
+}
+
+extern const DNSName g_rootdnsname, g_wildcarddnsname;