tor  0.4.0.0-alpha-dev
Macros | Functions | Variables
shared_random_state.c File Reference
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/confparse.h"
#include "lib/crypt_ops/crypto_util.h"
#include "feature/dirauth/dirvote.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/relay/router.h"
#include "feature/dirauth/shared_random.h"
#include "feature/hs_common/shared_random_client.h"
#include "feature/dirauth/shared_random_state.h"
#include "feature/dircommon/voting_schedule.h"
#include "lib/encoding/confline.h"
#include "lib/version/torversion.h"
#include "app/config/or_state_st.h"

Go to the source code of this file.

Macros

#define SHARED_RANDOM_STATE_PRIVATE
 
#define VAR(name, conftype, member, initvalue)
 
#define V(member, conftype, initvalue)   VAR(#member, conftype, member, initvalue)
 
#define SR_DISK_STATE_MAGIC   0x98AB1254
 
#define state_free(val)   FREE_AND_NULL(sr_state_t, state_free_, (val))
 
#define disk_state_free(val)   FREE_AND_NULL(sr_disk_state_t, disk_state_free_, (val))
 

Functions

 DUMMY_TYPECHECK_INSTANCE (sr_disk_state_t)
 
static int disk_state_validate_cb (void *old_state, void *state, void *default_state, int from_setconf, char **msg)
 
static void disk_state_free_cb (void *)
 
STATIC const char * get_phase_str (sr_phase_t phase)
 
STATIC time_t get_state_valid_until_time (time_t now)
 
STATIC sr_phase_t get_sr_protocol_phase (time_t valid_after)
 
static void commit_add_to_state (sr_commit_t *commit, sr_state_t *state)
 
static void commit_free_ (void *p)
 
static void state_free_ (sr_state_t *state)
 
static sr_state_tstate_new (const char *fname, time_t now)
 
static void state_set (sr_state_t *state)
 
static void disk_state_free_ (sr_disk_state_t *state)
 
static sr_disk_state_tdisk_state_new (time_t now)
 
static void disk_state_set (sr_disk_state_t *state)
 
static int disk_state_validate (const sr_disk_state_t *state)
 
static int disk_state_parse_commits (sr_state_t *state, const sr_disk_state_t *disk_state)
 
static int disk_state_parse_srv (const char *value, sr_srv_t *dst)
 
static int disk_state_parse_sr_values (sr_state_t *state, const sr_disk_state_t *disk_state)
 
static sr_state_tdisk_state_parse (const sr_disk_state_t *new_disk_state)
 
static void disk_state_put_commit_line (const sr_commit_t *commit, config_line_t *line)
 
static void disk_state_put_srv_line (const sr_srv_t *srv, config_line_t *line)
 
static void disk_state_reset (void)
 
static void disk_state_update (void)
 
static int disk_state_load_from_disk (void)
 
STATIC int disk_state_load_from_disk_impl (const char *fname)
 
static int disk_state_save_to_disk (void)
 
STATIC void reset_state_for_new_protocol_run (time_t valid_after)
 
STATIC void new_protocol_run (time_t valid_after)
 
STATIC int is_phase_transition (sr_phase_t next_phase)
 
static sr_commit_tstate_query_get_commit (const char *rsa_fpr)
 
static void * state_query_get_ (sr_state_object_t obj_type, const void *data)
 
static void state_query_put_ (sr_state_object_t obj_type, void *data)
 
static void state_query_del_all_ (sr_state_object_t obj_type)
 
static void state_query_del_ (sr_state_object_t obj_type, void *data)
 
static void state_query (sr_state_action_t action, sr_state_object_t obj_type, void *data, void **out)
 
static void state_del_current_srv (void)
 
static void state_del_previous_srv (void)
 
STATIC void state_rotate_srv (void)
 
void sr_state_set_valid_after (time_t valid_after)
 
sr_phase_t sr_state_get_phase (void)
 
const sr_srv_tsr_state_get_previous_srv (void)
 
void sr_state_set_previous_srv (const sr_srv_t *srv)
 
const sr_srv_tsr_state_get_current_srv (void)
 
void sr_state_set_current_srv (const sr_srv_t *srv)
 
void sr_state_clean_srvs (void)
 
digestmap_t * sr_state_get_commits (void)
 
void sr_state_update (time_t valid_after)
 
sr_commit_tsr_state_get_commit (const char *rsa_identity)
 
void sr_state_add_commit (sr_commit_t *commit)
 
void sr_state_delete_commits (void)
 
void sr_state_copy_reveal_info (sr_commit_t *saved_commit, const sr_commit_t *commit)
 
void sr_state_set_fresh_srv (void)
 
void sr_state_unset_fresh_srv (void)
 
unsigned int sr_state_srv_is_fresh (void)
 
void sr_state_free_all (void)
 
void sr_state_save (void)
 
int sr_state_is_initialized (void)
 
int sr_state_init (int save_to_disk, int read_from_disk)
 

Variables

static const char default_fname [] = "sr-state"
 
static const char * phase_str [] = { "unknown", "commit", "reveal" }
 
static sr_state_tsr_state = NULL
 
static sr_disk_state_tsr_disk_state = NULL
 
static const char dstate_commit_key [] = "Commit"
 
static const char dstate_prev_srv_key [] = "SharedRandPreviousValue"
 
static const char dstate_cur_srv_key [] = "SharedRandCurrentValue"
 
static config_var_t state_vars []
 
static config_var_t state_extra_var
 
static const config_format_t state_format
 

Detailed Description

Functions and data structures for the state of the random protocol as defined in proposal #250.

Definition in file shared_random_state.c.

Macro Definition Documentation

◆ VAR

#define VAR (   name,
  conftype,
  member,
  initvalue 
)
Value:
{ name, CONFIG_TYPE_ ## conftype, offsetof(sr_disk_state_t, member), \
initvalue CONF_TEST_MEMBERS(sr_disk_state_t, conftype, member) }

Definition at line 55 of file shared_random_state.c.

Function Documentation

◆ DUMMY_TYPECHECK_INSTANCE()

DUMMY_TYPECHECK_INSTANCE ( sr_disk_state_t  )

dummy instance of sr_disk_state_t, used for type-checking its members with CONF_CHECK_VAR_TYPE.

Variable Documentation

◆ state_extra_var

config_var_t state_extra_var
static
Initial value:
= {
offsetof(sr_disk_state_t, ExtraLines), NULL
}

Definition at line 86 of file shared_random_state.c.

◆ state_format

const config_format_t state_format
static
Initial value:
= {
sizeof(sr_disk_state_t),
SR_DISK_STATE_MAGIC,
offsetof(sr_disk_state_t, magic_),
NULL,
NULL,
state_vars,
disk_state_validate_cb,
disk_state_free_cb,
}
static config_var_t state_extra_var
Definition: statefile.c:158

Definition at line 93 of file shared_random_state.c.

◆ state_vars

config_var_t state_vars[]
static
Initial value:
= {
V(Version, UINT, "0"),
V(TorVersion, STRING, NULL),
V(ValidAfter, ISOTIME, NULL),
V(ValidUntil, ISOTIME, NULL),
V(Commit, LINELIST, NULL),
V(SharedRandValues, LINELIST_V, NULL),
VAR("SharedRandPreviousValue",LINELIST_S, SharedRandValues, NULL),
VAR("SharedRandCurrentValue", LINELIST_S, SharedRandValues, NULL),
END_OF_CONFIG_VARS
}
#define VAR(name, conftype, member, initvalue)
Definition: config.c:257

Definition at line 70 of file shared_random_state.c.