networkstatus.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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-2016, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file networkstatus.h
  8. * \brief Header file for networkstatus.c.
  9. **/
  10. #ifndef TOR_NETWORKSTATUS_H
  11. #define TOR_NETWORKSTATUS_H
  12. #include "testsupport.h"
  13. void networkstatus_reset_warnings(void);
  14. void networkstatus_reset_download_failures(void);
  15. int router_reload_consensus_networkstatus(void);
  16. void routerstatus_free(routerstatus_t *rs);
  17. void networkstatus_vote_free(networkstatus_t *ns);
  18. networkstatus_voter_info_t *networkstatus_get_voter_by_id(
  19. networkstatus_t *vote,
  20. const char *identity);
  21. int networkstatus_check_consensus_signature(networkstatus_t *consensus,
  22. int warn);
  23. int networkstatus_check_document_signature(const networkstatus_t *consensus,
  24. document_signature_t *sig,
  25. const authority_cert_t *cert);
  26. int compare_digest_to_routerstatus_entry(const void *_key,
  27. const void **_member);
  28. int compare_digest_to_vote_routerstatus_entry(const void *_key,
  29. const void **_member);
  30. const routerstatus_t *networkstatus_vote_find_entry(networkstatus_t *ns,
  31. const char *digest);
  32. routerstatus_t *networkstatus_vote_find_mutable_entry(networkstatus_t *ns,
  33. const char *digest);
  34. int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
  35. const char *digest, int *found_out);
  36. MOCK_DECL(download_status_t *,
  37. networkstatus_get_dl_status_by_flavor,
  38. (consensus_flavor_t flavor));
  39. MOCK_DECL(download_status_t *,
  40. networkstatus_get_dl_status_by_flavor_bootstrap,
  41. (consensus_flavor_t flavor));
  42. MOCK_DECL(download_status_t *,
  43. networkstatus_get_dl_status_by_flavor_running,
  44. (consensus_flavor_t flavor));
  45. MOCK_DECL(smartlist_t *, router_get_descriptor_digests, (void));
  46. MOCK_DECL(download_status_t *,router_get_dl_status_by_descriptor_digest,
  47. (const char *d));
  48. const routerstatus_t *router_get_consensus_status_by_id(const char *digest);
  49. routerstatus_t *router_get_mutable_consensus_status_by_id(
  50. const char *digest);
  51. const routerstatus_t *router_get_consensus_status_by_descriptor_digest(
  52. networkstatus_t *consensus,
  53. const char *digest);
  54. MOCK_DECL(routerstatus_t *,
  55. router_get_mutable_consensus_status_by_descriptor_digest,
  56. (networkstatus_t *consensus, const char *digest));
  57. const routerstatus_t *router_get_consensus_status_by_nickname(
  58. const char *nickname,
  59. int warn_if_unnamed);
  60. const char *networkstatus_get_router_digest_by_nickname(const char *nickname);
  61. int networkstatus_nickname_is_unnamed(const char *nickname);
  62. void networkstatus_consensus_download_failed(int status_code,
  63. const char *flavname);
  64. void update_consensus_networkstatus_fetch_time(time_t now);
  65. int should_delay_dir_fetches(const or_options_t *options,const char **msg_out);
  66. void update_networkstatus_downloads(time_t now);
  67. void update_certificate_downloads(time_t now);
  68. int consensus_is_waiting_for_certs(void);
  69. int client_would_use_router(const routerstatus_t *rs, time_t now,
  70. const or_options_t *options);
  71. MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus,(void));
  72. MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus_by_flavor,
  73. (consensus_flavor_t f));
  74. MOCK_DECL(networkstatus_t *, networkstatus_get_live_consensus,(time_t now));
  75. networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now,
  76. int flavor);
  77. MOCK_DECL(int, networkstatus_consensus_is_bootstrapping,(time_t now));
  78. int networkstatus_consensus_can_use_multiple_directories(
  79. const or_options_t *options);
  80. MOCK_DECL(int, networkstatus_consensus_can_use_extra_fallbacks,(
  81. const or_options_t *options));
  82. int networkstatus_consensus_is_already_downloading(const char *resource);
  83. #define NSSET_FROM_CACHE 1
  84. #define NSSET_WAS_WAITING_FOR_CERTS 2
  85. #define NSSET_DONT_DOWNLOAD_CERTS 4
  86. #define NSSET_ACCEPT_OBSOLETE 8
  87. #define NSSET_REQUIRE_FLAVOR 16
  88. int networkstatus_set_current_consensus(const char *consensus,
  89. const char *flavor,
  90. unsigned flags,
  91. const char *source_dir);
  92. void networkstatus_note_certs_arrived(const char *source_dir);
  93. void routers_update_all_from_networkstatus(time_t now, int dir_version);
  94. void routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
  95. int reset_failures);
  96. void signed_descs_update_status_from_consensus_networkstatus(
  97. smartlist_t *descs);
  98. char *networkstatus_getinfo_helper_single(const routerstatus_t *rs);
  99. char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
  100. void networkstatus_dump_bridge_status_to_file(time_t now);
  101. int32_t networkstatus_get_param(const networkstatus_t *ns,
  102. const char *param_name,
  103. int32_t default_val, int32_t min_val,
  104. int32_t max_val);
  105. int getinfo_helper_networkstatus(control_connection_t *conn,
  106. const char *question, char **answer,
  107. const char **errmsg);
  108. int32_t networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight,
  109. int32_t default_val);
  110. const char *networkstatus_get_flavor_name(consensus_flavor_t flav);
  111. int networkstatus_parse_flavor_name(const char *flavname);
  112. void document_signature_free(document_signature_t *sig);
  113. document_signature_t *document_signature_dup(const document_signature_t *sig);
  114. void networkstatus_free_all(void);
  115. int networkstatus_get_weight_scale_param(networkstatus_t *ns);
  116. #ifdef NETWORKSTATUS_PRIVATE
  117. STATIC void vote_routerstatus_free(vote_routerstatus_t *rs);
  118. #ifdef TOR_UNIT_TESTS
  119. STATIC int networkstatus_set_current_consensus_from_ns(networkstatus_t *c,
  120. const char *flavor);
  121. #endif // TOR_UNIT_TESTS
  122. #endif
  123. #endif