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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* Copyright (c) 2012, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* \file replaycache.h
* \brief Header file for replaycache.c.
**/
#ifndef _TOR_REPLAYCACHE_H
#define _TOR_REPLAYCACHE_H
typedef struct replaycache_s replaycache_t;
#ifdef REPLAYCACHE_PRIVATE
struct replaycache_s {
/* Scrub interval */
time_t scrub_interval;
/* Last scrubbed */
time_t scrubbed;
/*
* Horizon
* (don't return true on digests in the cache but older than this)
*/
time_t horizon;
/*
* Digest map: keys are digests, values are times the digest was last seen
*/
digestmap_t *digests_seen;
};
#endif /* REPLAYCACHE_PRIVATE */
/* replaycache_t free/new */
void replaycache_free(replaycache_t *r);
replaycache_t * replaycache_new(time_t horizon, time_t interval);
#ifdef REPLAYCACHE_PRIVATE
/*
* replaycache_t internal functions:
*
* These take the time to treat as the present as an argument for easy unit
* testing. For everything else, use the wrappers below instead.
*/
int replaycache_add_and_test_internal(
time_t present, replaycache_t *r, const void *data, int len,
time_t *elapsed);
void replaycache_scrub_if_needed_internal(
time_t present, replaycache_t *r);
#endif /* REPLAYCACHE_PRIVATE */
/*
* replaycache_t methods
*/
int replaycache_add_and_test(replaycache_t *r, const void *data, int len);
int replaycache_add_test_and_elapsed(
replaycache_t *r, const void *data, int len, time_t *elapsed);
void replaycache_scrub_if_needed(replaycache_t *r);
#endif
|