Report only the top 10 ports in exit-port stats.
[tor/rransom.git] / src / or / dirvote.h
blobe384dc53b37f7e34b92c2c25a48db80b526087bb
1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2010, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file dirvote.h
9 * \brief Header file for dirvote.c.
10 **/
12 #ifndef _TOR_DIRVOTE_H
13 #define _TOR_DIRVOTE_H
15 /** Lowest allowable value for VoteSeconds. */
16 #define MIN_VOTE_SECONDS 20
17 /** Lowest allowable value for DistSeconds. */
18 #define MIN_DIST_SECONDS 20
19 /** Smallest allowable voting interval. */
20 #define MIN_VOTE_INTERVAL 300
22 /** Precision multiplier for the Bw weights */
23 #define BW_WEIGHT_SCALE 10000
25 void dirvote_free_all(void);
27 /* vote manipulation */
28 char *networkstatus_compute_consensus(smartlist_t *votes,
29 int total_authorities,
30 crypto_pk_env_t *identity_key,
31 crypto_pk_env_t *signing_key,
32 const char *legacy_identity_key_digest,
33 crypto_pk_env_t *legacy_signing_key,
34 consensus_flavor_t flavor);
35 int networkstatus_add_detached_signatures(networkstatus_t *target,
36 ns_detached_signatures_t *sigs,
37 const char **msg_out);
38 char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
39 void ns_detached_signatures_free(ns_detached_signatures_t *s);
41 /* cert manipulation */
42 authority_cert_t *authority_cert_dup(authority_cert_t *cert);
44 /* vote scheduling */
45 void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
46 time_t dirvote_get_start_of_next_interval(time_t now, int interval);
47 void dirvote_recalculate_timing(or_options_t *options, time_t now);
48 void dirvote_act(or_options_t *options, time_t now);
50 /* invoked on timers and by outside triggers. */
51 struct pending_vote_t * dirvote_add_vote(const char *vote_body,
52 const char **msg_out,
53 int *status_out);
54 int dirvote_add_signatures(const char *detached_signatures_body,
55 const char *source,
56 const char **msg_out);
58 /* Item access */
59 const char *dirvote_get_pending_consensus(consensus_flavor_t flav);
60 const char *dirvote_get_pending_detached_signatures(void);
61 #define DGV_BY_ID 1
62 #define DGV_INCLUDE_PENDING 2
63 #define DGV_INCLUDE_PREVIOUS 4
64 const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
65 void set_routerstatus_from_routerinfo(routerstatus_t *rs,
66 routerinfo_t *ri, time_t now,
67 int naming, int listbadexits,
68 int listbaddirs);
69 void router_clear_status_flags(routerinfo_t *ri);
70 networkstatus_t *
71 dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
72 authority_cert_t *cert);
74 microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri);
75 ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
76 const microdesc_t *md);
78 int vote_routerstatus_find_microdesc_hash(char *digest256_out,
79 const vote_routerstatus_t *vrs,
80 int method,
81 digest_algorithm_t alg);
82 document_signature_t *voter_get_sig_by_algorithm(
83 const networkstatus_voter_info_t *voter,
84 digest_algorithm_t alg);
86 #ifdef DIRVOTE_PRIVATE
87 char *format_networkstatus_vote(crypto_pk_env_t *private_key,
88 networkstatus_t *v3_ns);
89 char *dirvote_compute_params(smartlist_t *votes);
90 #endif
92 #endif