dirvote.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_env_t *identity_key,
  23. crypto_pk_env_t *signing_key,
  24. const char *legacy_identity_key_digest,
  25. crypto_pk_env_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 **msg_out);
  30. char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
  31. void ns_detached_signatures_free(ns_detached_signatures_t *s);
  32. /* cert manipulation */
  33. authority_cert_t *authority_cert_dup(authority_cert_t *cert);
  34. /* vote scheduling */
  35. void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
  36. time_t dirvote_get_start_of_next_interval(time_t now, int interval);
  37. void dirvote_recalculate_timing(const or_options_t *options, time_t now);
  38. void dirvote_act(const or_options_t *options, time_t now);
  39. /* invoked on timers and by outside triggers. */
  40. struct pending_vote_t * dirvote_add_vote(const char *vote_body,
  41. const char **msg_out,
  42. int *status_out);
  43. int dirvote_add_signatures(const char *detached_signatures_body,
  44. const char *source,
  45. const char **msg_out);
  46. /* Item access */
  47. const char *dirvote_get_pending_consensus(consensus_flavor_t flav);
  48. const char *dirvote_get_pending_detached_signatures(void);
  49. #define DGV_BY_ID 1
  50. #define DGV_INCLUDE_PENDING 2
  51. #define DGV_INCLUDE_PREVIOUS 4
  52. const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
  53. void set_routerstatus_from_routerinfo(routerstatus_t *rs,
  54. node_t *node,
  55. routerinfo_t *ri, time_t now,
  56. int naming, int listbadexits,
  57. int listbaddirs);
  58. void router_clear_status_flags(routerinfo_t *ri);
  59. networkstatus_t *
  60. dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
  61. authority_cert_t *cert);
  62. microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri);
  63. ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
  64. const microdesc_t *md);
  65. int vote_routerstatus_find_microdesc_hash(char *digest256_out,
  66. const vote_routerstatus_t *vrs,
  67. int method,
  68. digest_algorithm_t alg);
  69. document_signature_t *voter_get_sig_by_algorithm(
  70. const networkstatus_voter_info_t *voter,
  71. digest_algorithm_t alg);
  72. #ifdef DIRVOTE_PRIVATE
  73. char *format_networkstatus_vote(crypto_pk_env_t *private_key,
  74. networkstatus_t *v3_ns);
  75. char *dirvote_compute_params(smartlist_t *votes);
  76. #endif
  77. #endif