Tor  0.4.7.0-alpha-dev
Macros | Typedefs | Functions
replaycache.h File Reference

Header file for replaycache.c. More...

Go to the source code of this file.

Macros

#define replaycache_free(r)    FREE_AND_NULL(replaycache_t, replaycache_free_, (r))
 

Typedefs

typedef struct replaycache_t replaycache_t
 

Functions

void replaycache_free_ (replaycache_t *r)
 
replaycache_t * replaycache_new (time_t horizon, time_t interval)
 
int replaycache_add_and_test (replaycache_t *r, const void *data, size_t len)
 
int replaycache_add_test_and_elapsed (replaycache_t *r, const void *data, size_t len, time_t *elapsed)
 
void replaycache_scrub_if_needed (replaycache_t *r)
 

Detailed Description

Header file for replaycache.c.

Definition in file replaycache.h.

Macro Definition Documentation

◆ replaycache_free

#define replaycache_free (   r)     FREE_AND_NULL(replaycache_t, replaycache_free_, (r))

Free the replaycache r and all of its entries.

Additionally, set the pointer r to NULL.

Definition at line 42 of file replaycache.h.

Function Documentation

◆ replaycache_add_and_test()

int replaycache_add_and_test ( replaycache_t *  r,
const void *  data,
size_t  len 
)

Test the buffer of length len point to by data against the replay cache r; the digest of the buffer will be added to the cache at the current time, and the function will return 1 if it was already seen within the cache's horizon, or 0 otherwise.

Definition at line 186 of file replaycache.c.

◆ replaycache_add_test_and_elapsed()

int replaycache_add_test_and_elapsed ( replaycache_t *  r,
const void *  data,
size_t  len,
time_t *  elapsed 
)

Like replaycache_add_and_test(), but if it's a hit also return the time elapsed since this digest was last seen.

Definition at line 195 of file replaycache.c.

Referenced by hs_circ_handle_introduce2().

◆ replaycache_free_()

void replaycache_free_ ( replaycache_t *  r)

Free the replaycache r and all of its entries.

Definition at line 30 of file replaycache.c.

◆ replaycache_new()

replaycache_t* replaycache_new ( time_t  horizon,
time_t  interval 
)

Allocate a new, empty replay detection cache, where horizon is the time for entries to age out and interval is the time after which the cache should be scrubbed for old entries.

Definition at line 47 of file replaycache.c.

◆ replaycache_scrub_if_needed()

void replaycache_scrub_if_needed ( replaycache_t *  r)

Scrub aged entries out of r if sufficiently long has elapsed since r was last scrubbed.

Definition at line 205 of file replaycache.c.