dirvote.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. /** The highest consensus method that we currently support. */
  19. #define MAX_SUPPORTED_CONSENSUS_METHOD 15
  20. /** Lowest consensus method that contains a 'directory-footer' marker */
  21. #define MIN_METHOD_FOR_FOOTER 9
  22. /** Lowest consensus method that contains bandwidth weights */
  23. #define MIN_METHOD_FOR_BW_WEIGHTS 9
  24. /** Lowest consensus method that contains consensus params */
  25. #define MIN_METHOD_FOR_PARAMS 7
  26. /** Lowest consensus method that generates microdescriptors */
  27. #define MIN_METHOD_FOR_MICRODESC 8
  28. /** Lowest consensus method that ensures a majority of authorities voted
  29. * for a param. */
  30. #define MIN_METHOD_FOR_MAJORITY_PARAMS 12
  31. /** Lowest consensus method where microdesc consensuses omit any entry
  32. * with no microdesc. */
  33. #define MIN_METHOD_FOR_MANDATORY_MICRODESC 13
  34. /** Lowest consensus method that contains "a" lines. */
  35. #define MIN_METHOD_FOR_A_LINES 14
  36. /** Lowest consensus method where microdescs may include a "p6" line. */
  37. #define MIN_METHOD_FOR_P6_LINES 15
  38. void dirvote_free_all(void);
  39. /* vote manipulation */
  40. char *networkstatus_compute_consensus(smartlist_t *votes,
  41. int total_authorities,
  42. crypto_pk_t *identity_key,
  43. crypto_pk_t *signing_key,
  44. const char *legacy_identity_key_digest,
  45. crypto_pk_t *legacy_signing_key,
  46. consensus_flavor_t flavor);
  47. int networkstatus_add_detached_signatures(networkstatus_t *target,
  48. ns_detached_signatures_t *sigs,
  49. const char *source,
  50. int severity,
  51. const char **msg_out);
  52. char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
  53. void ns_detached_signatures_free(ns_detached_signatures_t *s);
  54. /* cert manipulation */
  55. authority_cert_t *authority_cert_dup(authority_cert_t *cert);
  56. /* vote scheduling */
  57. void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
  58. time_t dirvote_get_start_of_next_interval(time_t now, int interval);
  59. void dirvote_recalculate_timing(const or_options_t *options, time_t now);
  60. void dirvote_act(const or_options_t *options, time_t now);
  61. /* invoked on timers and by outside triggers. */
  62. struct pending_vote_t * dirvote_add_vote(const char *vote_body,
  63. const char **msg_out,
  64. int *status_out);
  65. int dirvote_add_signatures(const char *detached_signatures_body,
  66. const char *source,
  67. const char **msg_out);
  68. /* Item access */
  69. const char *dirvote_get_pending_consensus(consensus_flavor_t flav);
  70. const char *dirvote_get_pending_detached_signatures(void);
  71. #define DGV_BY_ID 1
  72. #define DGV_INCLUDE_PENDING 2
  73. #define DGV_INCLUDE_PREVIOUS 4
  74. const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
  75. void set_routerstatus_from_routerinfo(routerstatus_t *rs,
  76. node_t *node,
  77. routerinfo_t *ri, time_t now,
  78. int naming, int listbadexits,
  79. int listbaddirs, int vote_on_hsdirs);
  80. networkstatus_t *
  81. dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
  82. authority_cert_t *cert);
  83. microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri,
  84. int consensus_method);
  85. ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
  86. const microdesc_t *md,
  87. int consensus_method_low,
  88. int consensus_method_high);
  89. int vote_routerstatus_find_microdesc_hash(char *digest256_out,
  90. const vote_routerstatus_t *vrs,
  91. int method,
  92. digest_algorithm_t alg);
  93. document_signature_t *voter_get_sig_by_algorithm(
  94. const networkstatus_voter_info_t *voter,
  95. digest_algorithm_t alg);
  96. #ifdef DIRVOTE_PRIVATE
  97. char *format_networkstatus_vote(crypto_pk_t *private_key,
  98. networkstatus_t *v3_ns);
  99. char *dirvote_compute_params(smartlist_t *votes, int method,
  100. int total_authorities);
  101. #endif
  102. #endif