summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-bloom.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-01-28 00:57:38 +0100
committerLennart Poettering <lennart@poettering.net>2014-01-28 00:57:38 +0100
commitb28ff39f42877daef31383748fd2f313d7fd67c1 (patch)
treecae837d424b95ef5057b3c48cab8c4280073fbb8 /src/libsystemd/sd-bus/bus-bloom.h
parentaf08d2f9cde8f46d9d3e731dbd1f06ffb3b08942 (diff)
bus: rework bloom filter logic to operate with variable bloom filter
sizes and numbers of hash functions In order to make the bloom filter logic more future proof communicate bloom filter parameters from the original bus creator to the clients, and allow them to be variable within certain ranges.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-bloom.h')
-rw-r--r--src/libsystemd/sd-bus/bus-bloom.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/libsystemd/sd-bus/bus-bloom.h b/src/libsystemd/sd-bus/bus-bloom.h
index 422eb4e01a..0dad5db78d 100644
--- a/src/libsystemd/sd-bus/bus-bloom.h
+++ b/src/libsystemd/sd-bus/bus-bloom.h
@@ -23,7 +23,21 @@
#include <sys/types.h>
-#define BLOOM_SIZE 64
-
-void bloom_add_pair(uint64_t filter[BLOOM_SIZE/8], const char *a, const char *b);
-void bloom_add_prefixes(uint64_t filter[BLOOM_SIZE/8], const char *a, const char *b, char sep);
+/*
+ * Our default bloom filter has the following parameters:
+ *
+ * m=512 (bits in the filter)
+ * k=8 (hash functions)
+ *
+ * We use SipHash24 as hash function with a number of (originally
+ * randomized) but fixed hash keys.
+ *
+ */
+
+#define DEFAULT_BLOOM_SIZE (512/8) /* m: filter size */
+#define DEFAULT_BLOOM_N_HASH 8 /* k: number of hash functions */
+
+void bloom_add_pair(uint64_t filter[], size_t size, unsigned n_hash, const char *a, const char *b);
+void bloom_add_prefixes(uint64_t filter[], size_t size, unsigned n_hash, const char *a, const char *b, char sep);
+
+bool bloom_validate_parameters(size_t size, unsigned n_hash);