tor  0.4.2.0-alpha-dev
Macros | Functions | Variables
hs_cache.c File Reference
#include "core/or/or.h"
#include "app/config/config.h"
#include "lib/crypt_ops/crypto_format.h"
#include "lib/crypt_ops/crypto_util.h"
#include "feature/hs/hs_ident.h"
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_client.h"
#include "feature/hs/hs_descriptor.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/rend/rendcache.h"
#include "feature/hs/hs_cache.h"
#include "feature/nodelist/networkstatus_st.h"

Go to the source code of this file.

Macros

#define HS_CACHE_PRIVATE
 
#define cache_dir_desc_free(val)   FREE_AND_NULL(hs_cache_dir_descriptor_t, cache_dir_desc_free_, (val))
 
#define cache_client_desc_free(val)   FREE_AND_NULL(hs_cache_client_descriptor_t, cache_client_desc_free_, (val))
 
#define cache_intro_state_free(val)   FREE_AND_NULL(hs_cache_intro_state_t, cache_intro_state_free_, (val))
 
#define cache_client_intro_state_free(val)
 

Functions

static int cached_client_descriptor_has_expired (time_t now, const hs_cache_client_descriptor_t *cached_desc)
 
static void remove_v3_desc_as_dir (const hs_cache_dir_descriptor_t *desc)
 
static void store_v3_desc_as_dir (hs_cache_dir_descriptor_t *desc)
 
static hs_cache_dir_descriptor_tlookup_v3_desc_as_dir (const uint8_t *key)
 
static void cache_dir_desc_free_ (hs_cache_dir_descriptor_t *desc)
 
static void cache_dir_desc_free_void (void *ptr)
 
static hs_cache_dir_descriptor_tcache_dir_desc_new (const char *desc)
 
static size_t cache_get_dir_entry_size (const hs_cache_dir_descriptor_t *entry)
 
static int cache_store_v3_as_dir (hs_cache_dir_descriptor_t *desc)
 
static int cache_lookup_v3_as_dir (const char *query, const char **desc_out)
 
STATIC size_t cache_clean_v3_as_dir (time_t now, time_t global_cutoff)
 
int hs_cache_store_as_dir (const char *desc)
 
int hs_cache_lookup_as_dir (uint32_t version, const char *query, const char **desc_out)
 
void hs_cache_clean_as_dir (time_t now)
 
static size_t cache_get_client_entry_size (const hs_cache_client_descriptor_t *entry)
 
static void remove_v3_desc_as_client (const hs_cache_client_descriptor_t *desc)
 
static void store_v3_desc_as_client (hs_cache_client_descriptor_t *desc)
 
STATIC hs_cache_client_descriptor_t * lookup_v3_desc_as_client (const uint8_t *key)
 
static hs_cache_client_descriptor_t * cache_client_desc_new (const char *desc_str, const ed25519_public_key_t *service_identity_pk)
 
static void cache_client_desc_free_ (hs_cache_client_descriptor_t *desc)
 
static void cache_client_desc_free_void (void *ptr)
 
static hs_cache_intro_state_tcache_intro_state_new (void)
 
static void cache_intro_state_free_ (hs_cache_intro_state_t *state)
 
static void cache_intro_state_free_void (void *state)
 
static hs_cache_client_intro_state_tcache_client_intro_state_new (void)
 
static void cache_client_intro_state_free_ (hs_cache_client_intro_state_t *cache)
 
static void cache_client_intro_state_free_void (void *entry)
 
static int cache_client_intro_state_lookup (const ed25519_public_key_t *service_pk, const ed25519_public_key_t *auth_key, hs_cache_intro_state_t **entry)
 
static void cache_client_intro_state_note (hs_cache_intro_state_t *state, rend_intro_point_failure_t failure)
 
static void cache_client_intro_state_add (const ed25519_public_key_t *service_pk, const ed25519_public_key_t *auth_key, hs_cache_intro_state_t **state)
 
static void cache_client_intro_state_clean (time_t cutoff, hs_cache_client_intro_state_t *cache)
 
static int cache_client_intro_state_is_empty (const hs_cache_client_intro_state_t *cache)
 
static int cache_store_as_client (hs_cache_client_descriptor_t *client_desc)
 
static size_t cache_clean_v3_as_client (time_t now)
 
const char * hs_cache_lookup_encoded_as_client (const ed25519_public_key_t *key)
 
const hs_descriptor_ths_cache_lookup_as_client (const ed25519_public_key_t *key)
 
int hs_cache_store_as_client (const char *desc_str, const ed25519_public_key_t *identity_pk)
 
void hs_cache_clean_as_client (time_t now)
 
void hs_cache_purge_as_client (void)
 
void hs_cache_client_intro_state_note (const ed25519_public_key_t *service_pk, const ed25519_public_key_t *auth_key, rend_intro_point_failure_t failure)
 
const hs_cache_intro_state_ths_cache_client_intro_state_find (const ed25519_public_key_t *service_pk, const ed25519_public_key_t *auth_key)
 
void hs_cache_client_intro_state_clean (time_t now)
 
void hs_cache_client_intro_state_purge (void)
 
size_t hs_cache_handle_oom (time_t now, size_t min_remove_bytes)
 
unsigned int hs_cache_get_max_descriptor_size (void)
 
void hs_cache_init (void)
 
void hs_cache_free_all (void)
 

Variables

static digest256map_t * hs_cache_v3_dir
 
static digest256map_t * hs_cache_v3_client
 
static digest256map_t * hs_cache_client_intro_state
 

Detailed Description

Handle hidden service descriptor caches.

Definition in file hs_cache.c.

Macro Definition Documentation

◆ cache_client_intro_state_free

#define cache_client_intro_state_free (   val)
Value:
cache_client_intro_state_free_, (val))

Definition at line 487 of file hs_cache.c.

Function Documentation

◆ cache_client_desc_free_()

static void cache_client_desc_free_ ( hs_cache_client_descriptor_t *  desc)
static

Free memory allocated by desc.

Definition at line 431 of file hs_cache.c.

◆ cache_client_desc_free_void()

static void cache_client_desc_free_void ( void *  ptr)
static

Helper function: Use by the free all function to clear the client cache

Definition at line 445 of file hs_cache.c.

◆ cache_store_as_client()

static int cache_store_as_client ( hs_cache_client_descriptor_t *  client_desc)
static

Check whether client_desc is useful for us, and store it in the client-side HS cache if so. The client_desc is freed if we already have a fresher (higher revision counter count) in the cache.

Definition at line 628 of file hs_cache.c.

References tor_assert().

◆ hs_cache_lookup_as_client()

const hs_descriptor_t* hs_cache_lookup_as_client ( const ed25519_public_key_t key)

Public API: Given the HS ed25519 identity public key in key, return its HS descriptor if it's stored in our cache, or NULL if not.

Definition at line 757 of file hs_cache.c.

References tor_assert().

◆ hs_cache_lookup_encoded_as_client()

const char* hs_cache_lookup_encoded_as_client ( const ed25519_public_key_t key)

Public API: Given the HS ed25519 identity public key in key, return its HS encoded descriptor if it's stored in our cache, or NULL if not.

Definition at line 739 of file hs_cache.c.

References tor_assert().

◆ hs_cache_store_as_client()

int hs_cache_store_as_client ( const char *  desc_str,
const ed25519_public_key_t identity_pk 
)

Public API: Given an encoded descriptor, store it in the client HS cache. Return -1 on error, 0 on success .

Definition at line 775 of file hs_cache.c.

References tor_assert().