Back to index

tor  0.2.3.19-rc
dirvote.h
Go to the documentation of this file.
00001 /* Copyright (c) 2001 Matej Pfajfar.
00002  * Copyright (c) 2001-2004, Roger Dingledine.
00003  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00004  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00005 /* See LICENSE for licensing information */
00006 
00012 #ifndef _TOR_DIRVOTE_H
00013 #define _TOR_DIRVOTE_H
00014 
00016 #define MIN_VOTE_SECONDS 20
00017 
00018 #define MIN_DIST_SECONDS 20
00019 
00020 #define MIN_VOTE_INTERVAL 300
00021 
00022 void dirvote_free_all(void);
00023 
00024 /* vote manipulation */
00025 char *networkstatus_compute_consensus(smartlist_t *votes,
00026                                       int total_authorities,
00027                                       crypto_pk_t *identity_key,
00028                                       crypto_pk_t *signing_key,
00029                                       const char *legacy_identity_key_digest,
00030                                       crypto_pk_t *legacy_signing_key,
00031                                       consensus_flavor_t flavor);
00032 int networkstatus_add_detached_signatures(networkstatus_t *target,
00033                                           ns_detached_signatures_t *sigs,
00034                                           const char *source,
00035                                           int severity,
00036                                           const char **msg_out);
00037 char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
00038 void ns_detached_signatures_free(ns_detached_signatures_t *s);
00039 
00040 /* cert manipulation */
00041 authority_cert_t *authority_cert_dup(authority_cert_t *cert);
00042 
00043 /* vote scheduling */
00044 void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
00045 time_t dirvote_get_start_of_next_interval(time_t now, int interval);
00046 void dirvote_recalculate_timing(const or_options_t *options, time_t now);
00047 void dirvote_act(const or_options_t *options, time_t now);
00048 
00049 /* invoked on timers and by outside triggers. */
00050 struct pending_vote_t * dirvote_add_vote(const char *vote_body,
00051                                          const char **msg_out,
00052                                          int *status_out);
00053 int dirvote_add_signatures(const char *detached_signatures_body,
00054                            const char *source,
00055                            const char **msg_out);
00056 
00057 /* Item access */
00058 const char *dirvote_get_pending_consensus(consensus_flavor_t flav);
00059 const char *dirvote_get_pending_detached_signatures(void);
00060 #define DGV_BY_ID 1
00061 #define DGV_INCLUDE_PENDING 2
00062 #define DGV_INCLUDE_PREVIOUS 4
00063 const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
00064 void set_routerstatus_from_routerinfo(routerstatus_t *rs,
00065                                       node_t *node,
00066                                       routerinfo_t *ri, time_t now,
00067                                       int naming, int listbadexits,
00068                                       int listbaddirs, int vote_on_hsdirs);
00069 networkstatus_t *
00070 dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
00071                                         authority_cert_t *cert);
00072 
00073 microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri);
00074 ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
00075                                        const microdesc_t *md);
00076 
00077 int vote_routerstatus_find_microdesc_hash(char *digest256_out,
00078                                           const vote_routerstatus_t *vrs,
00079                                           int method,
00080                                           digest_algorithm_t alg);
00081 document_signature_t *voter_get_sig_by_algorithm(
00082                            const networkstatus_voter_info_t *voter,
00083                            digest_algorithm_t alg);
00084 
00085 #ifdef DIRVOTE_PRIVATE
00086 char *format_networkstatus_vote(crypto_pk_t *private_key,
00087                                  networkstatus_t *v3_ns);
00088 char *dirvote_compute_params(smartlist_t *votes, int method,
00089                              int total_authorities);
00090 #endif
00091 
00092 #endif
00093