1 /* Copyright (c) 2012-2017, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
6 * \brief Header file for replaycache.c.
9 #ifndef TOR_REPLAYCACHE_H
10 #define TOR_REPLAYCACHE_H
12 typedef struct replaycache_s replaycache_t
;
14 #ifdef REPLAYCACHE_PRIVATE
16 struct replaycache_s
{
18 time_t scrub_interval
;
23 * (don't return true on digests in the cache but older than this)
27 * Digest map: keys are digests, values are times the digest was last seen
29 digest256map_t
*digests_seen
;
32 #endif /* defined(REPLAYCACHE_PRIVATE) */
34 /* replaycache_t free/new */
36 void replaycache_free(replaycache_t
*r
);
37 replaycache_t
* replaycache_new(time_t horizon
, time_t interval
);
39 #ifdef REPLAYCACHE_PRIVATE
42 * replaycache_t internal functions:
44 * These take the time to treat as the present as an argument for easy unit
45 * testing. For everything else, use the wrappers below instead.
48 STATIC
int replaycache_add_and_test_internal(
49 time_t present
, replaycache_t
*r
, const void *data
, size_t len
,
51 STATIC
void replaycache_scrub_if_needed_internal(
52 time_t present
, replaycache_t
*r
);
54 #endif /* defined(REPLAYCACHE_PRIVATE) */
57 * replaycache_t methods
60 int replaycache_add_and_test(replaycache_t
*r
, const void *data
, size_t len
);
61 int replaycache_add_test_and_elapsed(
62 replaycache_t
*r
, const void *data
, size_t len
, time_t *elapsed
);
63 void replaycache_scrub_if_needed(replaycache_t
*r
);
65 #endif /* !defined(TOR_REPLAYCACHE_H) */