dirvote.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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-2012, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file dirvote.h
  8. * \brief Header file for dirvote.c.
  9. **/
  10. #ifndef _TOR_DIRVOTE_H
  11. #define _TOR_DIRVOTE_H
  12. /** Lowest allowable value for VoteSeconds. */
  13. #define MIN_VOTE_SECONDS 20
  14. /** Lowest allowable value for DistSeconds. */
  15. #define MIN_DIST_SECONDS 20
  16. /** Smallest allowable voting interval. */
  17. #define MIN_VOTE_INTERVAL 300
  18. void dirvote_free_all(void);
  19. /* vote manipulation */
  20. char *networkstatus_compute_consensus(smartlist_t *votes,
  21. int total_authorities,
  22. crypto_pk_t *identity_key,
  23. crypto_pk_t *signing_key,
  24. const char *legacy_identity_key_digest,
  25. crypto_pk_t *legacy_signing_key,
  26. consensus_flavor_t flavor);
  27. int networkstatus_add_detached_signatures(networkstatus_t *target,
  28. ns_detached_signatures_t *sigs,
  29. const char *source,
  30. int severity,
  31. const char **msg_out);
  32. char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
  33. void ns_detached_signatures_free(ns_detached_signatures_t *s);
  34. /* cert manipulation */
  35. authority_cert_t *authority_cert_dup(authority_cert_t *cert);
  36. /* vote scheduling */
  37. void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
  38. time_t dirvote_get_start_of_next_interval(time_t now, int interval);
  39. void dirvote_recalculate_timing(const or_options_t *options, time_t now);
  40. void dirvote_act(const or_options_t *options, time_t now);
  41. /* invoked on timers and by outside triggers. */
  42. struct pending_vote_t * dirvote_add_vote(const char *vote_body,
  43. const char **msg_out,
  44. int *status_out);
  45. int dirvote_add_signatures(const char *detached_signatures_body,
  46. const char *source,
  47. const char **msg_out);
  48. /* Item access */
  49. const char *dirvote_get_pending_consensus(consensus_flavor_t flav);
  50. const char *dirvote_get_pending_detached_signatures(void);
  51. #define DGV_BY_ID 1
  52. #define DGV_INCLUDE_PENDING 2
  53. #define DGV_INCLUDE_PREVIOUS 4
  54. const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
  55. void set_routerstatus_from_routerinfo(routerstatus_t *rs,
  56. node_t *node,
  57. routerinfo_t *ri, time_t now,
  58. int naming, int listbadexits,
  59. int listbaddirs, int vote_on_hsdirs);
  60. networkstatus_t *
  61. dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
  62. authority_cert_t *cert);
  63. microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri);
  64. ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
  65. const microdesc_t *md);
  66. int vote_routerstatus_find_microdesc_hash(char *digest256_out,
  67. const vote_routerstatus_t *vrs,
  68. int method,
  69. digest_algorithm_t alg);
  70. document_signature_t *voter_get_sig_by_algorithm(
  71. const networkstatus_voter_info_t *voter,
  72. digest_algorithm_t alg);
  73. #ifdef DIRVOTE_PRIVATE
  74. char *format_networkstatus_vote(crypto_pk_t *private_key,
  75. networkstatus_t *v3_ns);
  76. char *dirvote_compute_params(smartlist_t *votes, int method,
  77. int total_authorities);
  78. #endif
  79. #endif