tor  0.4.2.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-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
6 #ifndef TOR_BLOOMFILT_H
7 #define TOR_BLOOMFILT_H
8 
15 #include "orconfig.h"
16 #include "lib/cc/torint.h"
17 #include "lib/container/bitarray.h"
18 
20 typedef struct bloomfilt_t bloomfilt_t;
21 
23 #define BLOOMFILT_N_HASHES 2
24 
26 #define BLOOMFILT_KEY_LEN (BLOOMFILT_N_HASHES * 16)
27 
28 struct sipkey;
29 typedef uint64_t (*bloomfilt_hash_fn)(const struct sipkey *key,
30  const void *item);
31 
32 void bloomfilt_add(bloomfilt_t *set, const void *item);
33 int bloomfilt_probably_contains(const bloomfilt_t *set, const void *item);
34 
35 bloomfilt_t *bloomfilt_new(int max_elements,
36  bloomfilt_hash_fn hashfn,
37  const uint8_t *random_key);
38 void bloomfilt_free_(bloomfilt_t* set);
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.
int bloomfilt_probably_contains(const bloomfilt_t *set, const void *item)
Definition: bloomfilt.c:54
Integer definitions used throughout Tor.
void bloomfilt_add(bloomfilt_t *set, const void *item)
Definition: bloomfilt.c:38
void bloomfilt_free_(bloomfilt_t *set)
Definition: bloomfilt.c:107
bloomfilt_t * bloomfilt_new(int max_elements, bloomfilt_hash_fn hashfn, const uint8_t *random_key)
Definition: bloomfilt.c:78