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.
|
2013-01-16 07:54:56 +01:00
|
|
|
* Copyright (c) 2007-2013, 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.
|
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_DIRVOTE_H
|
|
|
|
#define TOR_DIRVOTE_H
|
2010-07-22 12:19:28 +02:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
|
2012-08-31 23:02:19 +02:00
|
|
|
/** The highest consensus method that we currently support. */
|
2012-05-16 23:04:51 +02:00
|
|
|
#define MAX_SUPPORTED_CONSENSUS_METHOD 17
|
2012-08-31 23:02:19 +02:00
|
|
|
|
|
|
|
/** Lowest consensus method that contains a 'directory-footer' marker */
|
|
|
|
#define MIN_METHOD_FOR_FOOTER 9
|
|
|
|
|
|
|
|
/** Lowest consensus method that contains bandwidth weights */
|
|
|
|
#define MIN_METHOD_FOR_BW_WEIGHTS 9
|
|
|
|
|
|
|
|
/** Lowest consensus method that contains consensus params */
|
|
|
|
#define MIN_METHOD_FOR_PARAMS 7
|
|
|
|
|
|
|
|
/** Lowest consensus method that generates microdescriptors */
|
|
|
|
#define MIN_METHOD_FOR_MICRODESC 8
|
|
|
|
|
2013-03-26 22:15:58 +01:00
|
|
|
/** Lowest consensus method that doesn't count bad exits as exits for weight */
|
|
|
|
#define MIN_METHOD_TO_CUT_BADEXIT_WEIGHT 11
|
|
|
|
|
2012-08-31 23:02:19 +02:00
|
|
|
/** Lowest consensus method that ensures a majority of authorities voted
|
|
|
|
* for a param. */
|
|
|
|
#define MIN_METHOD_FOR_MAJORITY_PARAMS 12
|
|
|
|
|
|
|
|
/** Lowest consensus method where microdesc consensuses omit any entry
|
|
|
|
* with no microdesc. */
|
|
|
|
#define MIN_METHOD_FOR_MANDATORY_MICRODESC 13
|
|
|
|
|
|
|
|
/** Lowest consensus method that contains "a" lines. */
|
|
|
|
#define MIN_METHOD_FOR_A_LINES 14
|
|
|
|
|
2012-10-25 04:34:55 +02:00
|
|
|
/** Lowest consensus method where microdescs may include a "p6" line. */
|
|
|
|
#define MIN_METHOD_FOR_P6_LINES 15
|
|
|
|
|
2012-12-04 21:58:18 +01:00
|
|
|
/** Lowest consensus method where microdescs may include an onion-key-ntor
|
|
|
|
* line */
|
|
|
|
#define MIN_METHOD_FOR_NTOR_KEY 16
|
|
|
|
|
2012-05-16 23:04:51 +02:00
|
|
|
/** Lowest consensus method that ensures that authorities output an
|
|
|
|
* Unmeasured=1 flag for unmeasured bandwidths */
|
|
|
|
#define MIN_METHOD_TO_CLIP_UNMEASURED_BW 17
|
|
|
|
|
2013-02-19 15:20:29 +01:00
|
|
|
/** Default bandwidth to clip unmeasured bandwidths to using method >=
|
|
|
|
* MIN_METHOD_TO_CLIP_UNMEASURED_BW */
|
2013-04-11 17:43:40 +02:00
|
|
|
#define DEFAULT_MAX_UNMEASURED_BW_KB 20
|
2013-02-19 15:20:29 +01:00
|
|
|
|
2010-07-22 12:19:28 +02:00
|
|
|
void dirvote_free_all(void);
|
|
|
|
|
|
|
|
/* vote manipulation */
|
|
|
|
char *networkstatus_compute_consensus(smartlist_t *votes,
|
|
|
|
int total_authorities,
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *identity_key,
|
|
|
|
crypto_pk_t *signing_key,
|
2010-07-22 12:19:28 +02:00
|
|
|
const char *legacy_identity_key_digest,
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *legacy_signing_key,
|
2010-07-22 12:19:28 +02:00
|
|
|
consensus_flavor_t flavor);
|
|
|
|
int networkstatus_add_detached_signatures(networkstatus_t *target,
|
|
|
|
ns_detached_signatures_t *sigs,
|
2012-01-08 16:03:46 +01:00
|
|
|
const char *source,
|
|
|
|
int severity,
|
2010-07-22 12:19:28 +02:00
|
|
|
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);
|
2011-06-14 19:01:38 +02:00
|
|
|
void dirvote_recalculate_timing(const or_options_t *options, time_t now);
|
|
|
|
void dirvote_act(const or_options_t *options, time_t now);
|
2010-07-22 12:19:28 +02:00
|
|
|
|
|
|
|
/* 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,
|
2011-05-10 11:06:07 +02:00
|
|
|
int listbaddirs, int vote_on_hsdirs);
|
2010-07-22 12:19:28 +02:00
|
|
|
networkstatus_t *
|
2012-01-18 21:53:30 +01:00
|
|
|
dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
|
2010-07-22 12:19:28 +02:00
|
|
|
authority_cert_t *cert);
|
|
|
|
|
2012-09-05 19:40:15 +02:00
|
|
|
microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri,
|
|
|
|
int consensus_method);
|
2010-07-22 12:19:28 +02:00
|
|
|
ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
|
2012-08-31 23:02:19 +02:00
|
|
|
const microdesc_t *md,
|
|
|
|
int consensus_method_low,
|
|
|
|
int consensus_method_high);
|
2013-02-08 17:52:51 +01:00
|
|
|
vote_microdesc_hash_t *dirvote_format_all_microdesc_vote_lines(
|
|
|
|
const routerinfo_t *ri,
|
|
|
|
time_t now,
|
|
|
|
smartlist_t *microdescriptors_out);
|
|
|
|
|
2010-07-22 12:19:28 +02:00
|
|
|
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
|
2012-01-18 21:53:30 +01:00
|
|
|
char *format_networkstatus_vote(crypto_pk_t *private_key,
|
2010-07-22 12:19:28 +02:00
|
|
|
networkstatus_t *v3_ns);
|
2011-02-21 03:05:17 +01:00
|
|
|
char *dirvote_compute_params(smartlist_t *votes, int method,
|
|
|
|
int total_authorities);
|
2010-07-22 12:19:28 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|