dirvote.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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-2011, 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. void router_clear_status_flags(routerinfo_t *ri);
  61. networkstatus_t *
  62. dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
  63. authority_cert_t *cert);
  64. microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri);
  65. ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
  66. const microdesc_t *md);
  67. int vote_routerstatus_find_microdesc_hash(char *digest256_out,
  68. const vote_routerstatus_t *vrs,
  69. int method,
  70. digest_algorithm_t alg);
  71. document_signature_t *voter_get_sig_by_algorithm(
  72. const networkstatus_voter_info_t *voter,
  73. digest_algorithm_t alg);
  74. #ifdef DIRVOTE_PRIVATE
  75. char *format_networkstatus_vote(crypto_pk_t *private_key,
  76. networkstatus_t *v3_ns);
  77. char *dirvote_compute_params(smartlist_t *votes, int method,
  78. int total_authorities);
  79. #endif
  80. #endif