summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/resolve/resolved-dns-server.c')
-rw-r--r--src/resolve/resolved-dns-server.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index 30d9c8b34e..043f6b637d 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -19,6 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "siphash24.h"
+
#include "resolved-dns-server.h"
int dns_server_new(
@@ -97,3 +99,24 @@ DnsServer* dns_server_free(DnsServer *s) {
return NULL;
}
+
+unsigned long dns_server_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
+ const DnsServer *s = p;
+ uint64_t u;
+
+ siphash24((uint8_t*) &u, &s->address, FAMILY_ADDRESS_SIZE(s->family), hash_key);
+ u = u * hash_key[0] + u + s->family;
+
+ return u;
+}
+
+int dns_server_compare_func(const void *a, const void *b) {
+ const DnsServer *x = a, *y = b;
+
+ if (x->family < y->family)
+ return -1;
+ if (x->family > y->family)
+ return 1;
+
+ return memcmp(&x->address, &y->address, FAMILY_ADDRESS_SIZE(x->family));
+}