]> granicus.if.org Git - pdns/commitdiff
add ability to store comboaddress in a hashed container
authorbert hubert <bert.hubert@powerdns.com>
Tue, 19 Jan 2016 14:44:10 +0000 (15:44 +0100)
committerbert hubert <bert.hubert@powerdns.com>
Tue, 19 Jan 2016 14:44:10 +0000 (15:44 +0100)
pdns/iputils.hh

index ff2a87cfcb0595d70e6a779504d8fdff527a5689..abdc4e96f0afc1a6325bb6a3e5b33a88bb4b8828 100644 (file)
@@ -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<ComboAddress, ComboAddress, bool>
   {
     bool operator()(const ComboAddress& a, const ComboAddress& b) const