2010-07-22 12:19:28 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2011-01-03 17:52:09 +01:00
|
|
|
* Copyright (c) 2007-2011, The Tor Project, Inc. */
|
2010-07-22 12:19:28 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file dirvote.h
|
|
|
|
* \brief Header file for dirvote.c.
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _TOR_DIRVOTE_H
|
|
|
|
#define _TOR_DIRVOTE_H
|
|
|
|
|
|
|
|
/** Lowest allowable value for VoteSeconds. */
|
|
|
|
#define MIN_VOTE_SECONDS 20
|
|
|
|
/** Lowest allowable value for DistSeconds. */
|
|
|
|
#define MIN_DIST_SECONDS 20
|
|
|
|
/** Smallest allowable voting interval. */
|
|
|
|
#define MIN_VOTE_INTERVAL 300
|
|
|
|
|
|
|
|
void dirvote_free_all(void);
|
|
|
|
|
|
|
|
/* vote manipulation */
|
|
|
|
char *networkstatus_compute_consensus(smartlist_t *votes,
|
|
|
|
int total_authorities,
|
|
|
|
crypto_pk_env_t *identity_key,
|
|
|
|
crypto_pk_env_t *signing_key,
|
|
|
|
const char *legacy_identity_key_digest,
|
|
|
|
crypto_pk_env_t *legacy_signing_key,
|
|
|
|
consensus_flavor_t flavor);
|
|
|
|
int networkstatus_add_detached_signatures(networkstatus_t *target,
|
|
|
|
ns_detached_signatures_t *sigs,
|
|
|
|
const char **msg_out);
|
|
|
|
char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
|
|
|
|
void ns_detached_signatures_free(ns_detached_signatures_t *s);
|
|
|
|
|
|
|
|
/* cert manipulation */
|
|
|
|
authority_cert_t *authority_cert_dup(authority_cert_t *cert);
|
|
|
|
|
|
|
|
/* vote scheduling */
|
|
|
|
void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
|
|
|
|
time_t dirvote_get_start_of_next_interval(time_t now, int interval);
|
|
|
|
void dirvote_recalculate_timing(or_options_t *options, time_t now);
|
|
|
|
void dirvote_act(or_options_t *options, time_t now);
|
|
|
|
|
|
|
|
/* invoked on timers and by outside triggers. */
|
|
|
|
struct pending_vote_t * dirvote_add_vote(const char *vote_body,
|
|
|
|
const char **msg_out,
|
|
|
|
int *status_out);
|
|
|
|
int dirvote_add_signatures(const char *detached_signatures_body,
|
|
|
|
const char *source,
|
|
|
|
const char **msg_out);
|
|
|
|
|
|
|
|
/* Item access */
|
|
|
|
const char *dirvote_get_pending_consensus(consensus_flavor_t flav);
|
|
|
|
const char *dirvote_get_pending_detached_signatures(void);
|
|
|
|
#define DGV_BY_ID 1
|
|
|
|
#define DGV_INCLUDE_PENDING 2
|
|
|
|
#define DGV_INCLUDE_PREVIOUS 4
|
|
|
|
const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
|
|
|
|
void set_routerstatus_from_routerinfo(routerstatus_t *rs,
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
node_t *node,
|
2010-07-22 12:19:28 +02:00
|
|
|
routerinfo_t *ri, time_t now,
|
|
|
|
int naming, int listbadexits,
|
|
|
|
int listbaddirs);
|
|
|
|
void router_clear_status_flags(routerinfo_t *ri);
|
|
|
|
networkstatus_t *
|
|
|
|
dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
|
|
|
|
authority_cert_t *cert);
|
|
|
|
|
|
|
|
microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri);
|
|
|
|
ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
|
|
|
|
const microdesc_t *md);
|
|
|
|
|
|
|
|
int vote_routerstatus_find_microdesc_hash(char *digest256_out,
|
|
|
|
const vote_routerstatus_t *vrs,
|
|
|
|
int method,
|
|
|
|
digest_algorithm_t alg);
|
|
|
|
document_signature_t *voter_get_sig_by_algorithm(
|
|
|
|
const networkstatus_voter_info_t *voter,
|
|
|
|
digest_algorithm_t alg);
|
|
|
|
|
|
|
|
#ifdef DIRVOTE_PRIVATE
|
|
|
|
char *format_networkstatus_vote(crypto_pk_env_t *private_key,
|
|
|
|
networkstatus_t *v3_ns);
|
|
|
|
char *dirvote_compute_params(smartlist_t *votes);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|