Tor 0.4.9.0-alpha-dev
bloomfilt.h
Go to the documentation of this file.
1/* Copyright (c) 2003-2004, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2021, The Tor Project, Inc. */
4/* See LICENSE for licensing information */
5
6#ifndef TOR_BLOOMFILT_H
7#define TOR_BLOOMFILT_H
8
9/**
10 * \file bloomfilt.h
11 *
12 * \brief Header for bloomfilt.c
13 **/
14
15#include "orconfig.h"
16#include "lib/cc/torint.h"
18
19/** A set of elements, implemented as a Bloom filter. */
20typedef struct bloomfilt_t bloomfilt_t;
21
22/** How many 64-bit siphash values to extract per item. */
23#define BLOOMFILT_N_HASHES 2
24
25/** How much key material do we need to randomize hashes? */
26#define BLOOMFILT_KEY_LEN (BLOOMFILT_N_HASHES * 16)
27
28struct sipkey;
29typedef uint64_t (*bloomfilt_hash_fn)(const struct sipkey *key,
30 const void *item);
31
32void bloomfilt_add(bloomfilt_t *set, const void *item);
33int bloomfilt_probably_contains(const bloomfilt_t *set, const void *item);
34
35bloomfilt_t *bloomfilt_new(int max_elements,
36 bloomfilt_hash_fn hashfn,
37 const uint8_t *random_key);
39#define bloomfilt_free(set) FREE_AND_NULL(bloomfilt_t, bloomfilt_free_, (set))
40
41#endif /* !defined(TOR_BLOOMFILT_H) */
Implements a variable-sized (but non-resizeable) bit-array.
bloomfilt_t * bloomfilt_new(int max_elements, bloomfilt_hash_fn hashfn, const uint8_t *random_key)
Definition: bloomfilt.c:78
void bloomfilt_add(bloomfilt_t *set, const void *item)
Definition: bloomfilt.c:38
int bloomfilt_probably_contains(const bloomfilt_t *set, const void *item)
Definition: bloomfilt.c:54
void bloomfilt_free_(bloomfilt_t *set)
Definition: bloomfilt.c:107
Definition: siphash.h:6
Integer definitions used throughout Tor.