]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd/sd-bus/bus-bloom.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / libsystemd / sd-bus / bus-bloom.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
a56f19c4
LP
2#pragma once
3
4/***
5 This file is part of systemd.
6
7 Copyright 2013 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
c1ff5570 23#include <stdbool.h>
ab5dfda7 24#include <stddef.h>
c1ff5570 25#include <stdint.h>
a56f19c4 26
b28ff39f
LP
27/*
28 * Our default bloom filter has the following parameters:
29 *
30 * m=512 (bits in the filter)
31 * k=8 (hash functions)
32 *
33 * We use SipHash24 as hash function with a number of (originally
34 * randomized) but fixed hash keys.
35 *
36 */
37
38#define DEFAULT_BLOOM_SIZE (512/8) /* m: filter size */
39#define DEFAULT_BLOOM_N_HASH 8 /* k: number of hash functions */
40
41void bloom_add_pair(uint64_t filter[], size_t size, unsigned n_hash, const char *a, const char *b);
42void bloom_add_prefixes(uint64_t filter[], size_t size, unsigned n_hash, const char *a, const char *b, char sep);
43
44bool bloom_validate_parameters(size_t size, unsigned n_hash);