summaryrefslogtreecommitdiffstats
path: root/src/bloombucket.h
blob: b69ee5eb6c6802816b35c677222e148a576c6901 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2019 Matt Dunwoodie <ncon@noconroy.net>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef __BLOOMBUCKET_H__
#define __BLOOMBUCKET_H__

#include <sys/types.h>
#include <sys/timeout.h>
#include <crypto/siphash.h>

struct bloom_bucket {
	int type;
	size_t size, nkeys;
	uint8_t *bucket, interval, thresh;
	SIPHASH_KEY *keys;
	struct timeout tick;
};

void bb_init(struct bloom_bucket *, size_t, size_t, uint8_t, uint8_t, int, int);
void bb_destroy(struct bloom_bucket *);
void bb_tick(void *);
int bb_recv(struct bloom_bucket *, uint8_t *, size_t);
uint8_t bb_load(struct bloom_bucket *);

#endif /* __BLOOMBUCKET_H__ */