123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- #ifndef TOR_DIRVOTE_H
- #define TOR_DIRVOTE_H
- #include "testsupport.h"
- #define MIN_VOTE_SECONDS 2
- #define MIN_VOTE_SECONDS_TESTING 2
- #define MIN_DIST_SECONDS 2
- #define MIN_DIST_SECONDS_TESTING 2
- #define MIN_VOTE_INTERVAL 300
- #define MIN_VOTE_INTERVAL_TESTING \
- (((MIN_VOTE_SECONDS_TESTING)+(MIN_DIST_SECONDS_TESTING)+1)*2)
- #define MIN_VOTE_INTERVAL_TESTING_INITIAL \
- ((MIN_VOTE_SECONDS_TESTING)+(MIN_DIST_SECONDS_TESTING)+1)
- #define MIN_SUPPORTED_CONSENSUS_METHOD 13
- #define MAX_SUPPORTED_CONSENSUS_METHOD 25
- #define MIN_METHOD_FOR_MANDATORY_MICRODESC 13
- #define MIN_METHOD_FOR_A_LINES 14
- #define MIN_METHOD_FOR_P6_LINES 15
- #define MIN_METHOD_FOR_NTOR_KEY 16
- #define MIN_METHOD_TO_CLIP_UNMEASURED_BW 17
- #define MIN_METHOD_FOR_ID_HASH_IN_MD 18
- #define MIN_METHOD_FOR_PACKAGE_LINES 19
- #define MIN_METHOD_FOR_GUARDFRACTION 20
- #define MIN_METHOD_FOR_ED25519_ID_IN_MD 21
- #define MIN_METHOD_FOR_ED25519_ID_VOTING 22
- #define MIN_METHOD_FOR_SHARED_RANDOM 23
- #define MIN_METHOD_FOR_EXCLUDING_INVALID_NODES 24
- #define MIN_METHOD_FOR_RECOMMENDED_PROTOCOLS 25
- #define MIN_METHOD_FOR_RS_PROTOCOLS 25
- #define DEFAULT_MAX_UNMEASURED_BW_KB 20
- void dirvote_free_all(void);
- char *networkstatus_compute_consensus(smartlist_t *votes,
- int total_authorities,
- crypto_pk_t *identity_key,
- crypto_pk_t *signing_key,
- const char *legacy_identity_key_digest,
- crypto_pk_t *legacy_signing_key,
- consensus_flavor_t flavor);
- int networkstatus_add_detached_signatures(networkstatus_t *target,
- ns_detached_signatures_t *sigs,
- const char *source,
- int severity,
- const char **msg_out);
- char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
- void ns_detached_signatures_free(ns_detached_signatures_t *s);
- authority_cert_t *authority_cert_dup(authority_cert_t *cert);
- typedef struct {
-
- time_t voting_starts;
-
- time_t fetch_missing_votes;
-
- time_t voting_ends;
-
- time_t fetch_missing_signatures;
-
- time_t interval_starts;
-
- int have_voted;
-
- int have_fetched_missing_votes;
-
- int have_built_consensus;
-
- int have_fetched_missing_signatures;
-
- int have_published_consensus;
- } voting_schedule_t;
- voting_schedule_t *get_voting_schedule(const or_options_t *options,
- time_t now, int severity);
- void voting_schedule_free(voting_schedule_t *voting_schedule_to_free);
- void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
- time_t dirvote_get_start_of_next_interval(time_t now,
- int interval,
- int offset);
- void dirvote_recalculate_timing(const or_options_t *options, time_t now);
- void dirvote_act(const or_options_t *options, time_t now);
- time_t get_next_valid_after_time(time_t now);
- 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);
- MOCK_DECL(const char*, dirvote_get_pending_consensus,
- (consensus_flavor_t flav));
- MOCK_DECL(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,
- node_t *node,
- routerinfo_t *ri, time_t now,
- int listbadexits);
- networkstatus_t *
- dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
- authority_cert_t *cert);
- microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri,
- int consensus_method);
- ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
- const microdesc_t *md,
- int consensus_method_low,
- int consensus_method_high);
- vote_microdesc_hash_t *dirvote_format_all_microdesc_vote_lines(
- const routerinfo_t *ri,
- time_t now,
- smartlist_t *microdescriptors_out);
- 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
- STATIC int32_t dirvote_get_intermediate_param_value(
- const smartlist_t *param_list,
- const char *keyword,
- int32_t default_val);
- STATIC char *format_networkstatus_vote(crypto_pk_t *private_key,
- networkstatus_t *v3_ns);
- STATIC smartlist_t *dirvote_compute_params(smartlist_t *votes, int method,
- int total_authorities);
- STATIC char *compute_consensus_package_lines(smartlist_t *votes);
- STATIC char *make_consensus_method_list(int low, int high, const char *sep);
- #endif
- #endif
|