networkstatus.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 networkstatus.h
  8. * \brief Header file for networkstatus.c.
  9. **/
  10. #ifndef _TOR_NETWORKSTATUS_H
  11. #define _TOR_NETWORKSTATUS_H
  12. /** How old do we allow a v2 network-status to get before removing it
  13. * completely? */
  14. #define MAX_NETWORKSTATUS_AGE (10*24*60*60)
  15. void networkstatus_reset_warnings(void);
  16. void networkstatus_reset_download_failures(void);
  17. int router_reload_v2_networkstatus(void);
  18. int router_reload_consensus_networkstatus(void);
  19. void routerstatus_free(routerstatus_t *rs);
  20. void networkstatus_v2_free(networkstatus_v2_t *ns);
  21. void networkstatus_vote_free(networkstatus_t *ns);
  22. networkstatus_voter_info_t *networkstatus_get_voter_by_id(
  23. networkstatus_t *vote,
  24. const char *identity);
  25. int networkstatus_check_consensus_signature(networkstatus_t *consensus,
  26. int warn);
  27. int networkstatus_check_document_signature(const networkstatus_t *consensus,
  28. document_signature_t *sig,
  29. const authority_cert_t *cert);
  30. char *networkstatus_get_cache_filename(const char *identity_digest);
  31. int router_set_networkstatus_v2(const char *s, time_t arrived_at,
  32. v2_networkstatus_source_t source,
  33. smartlist_t *requested_fingerprints);
  34. void networkstatus_v2_list_clean(time_t now);
  35. int compare_digest_to_routerstatus_entry(const void *_key,
  36. const void **_member);
  37. routerstatus_t *networkstatus_v2_find_entry(networkstatus_v2_t *ns,
  38. const char *digest);
  39. routerstatus_t *networkstatus_vote_find_entry(networkstatus_t *ns,
  40. const char *digest);
  41. int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
  42. const char *digest, int *found_out);
  43. const smartlist_t *networkstatus_get_v2_list(void);
  44. download_status_t *router_get_dl_status_by_descriptor_digest(const char *d);
  45. routerstatus_t *router_get_consensus_status_by_id(const char *digest);
  46. routerstatus_t *router_get_consensus_status_by_descriptor_digest(
  47. const char *digest);
  48. routerstatus_t *router_get_consensus_status_by_nickname(const char *nickname,
  49. int warn_if_unnamed);
  50. const char *networkstatus_get_router_digest_by_nickname(const char *nickname);
  51. int networkstatus_nickname_is_unnamed(const char *nickname);
  52. void networkstatus_consensus_download_failed(int status_code);
  53. void update_consensus_networkstatus_fetch_time(time_t now);
  54. int should_delay_dir_fetches(or_options_t *options);
  55. void update_networkstatus_downloads(time_t now);
  56. void update_certificate_downloads(time_t now);
  57. int consensus_is_waiting_for_certs(void);
  58. networkstatus_v2_t *networkstatus_v2_get_by_digest(const char *digest);
  59. networkstatus_t *networkstatus_get_latest_consensus(void);
  60. networkstatus_t *networkstatus_get_live_consensus(time_t now);
  61. networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now);
  62. #define NSSET_FROM_CACHE 1
  63. #define NSSET_WAS_WAITING_FOR_CERTS 2
  64. #define NSSET_DONT_DOWNLOAD_CERTS 4
  65. #define NSSET_ACCEPT_OBSOLETE 8
  66. #define NSSET_REQUIRE_FLAVOR 16
  67. int networkstatus_set_current_consensus(const char *consensus,
  68. const char *flavor,
  69. unsigned flags);
  70. void networkstatus_note_certs_arrived(void);
  71. void routers_update_all_from_networkstatus(time_t now, int dir_version);
  72. void routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
  73. int reset_failures);
  74. void signed_descs_update_status_from_consensus_networkstatus(
  75. smartlist_t *descs);
  76. char *networkstatus_getinfo_helper_single(routerstatus_t *rs);
  77. char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
  78. void networkstatus_dump_bridge_status_to_file(time_t now);
  79. int32_t get_net_param_from_list(smartlist_t *net_params, const char *name,
  80. int default_val);
  81. int32_t networkstatus_get_param(networkstatus_t *ns, const char *param_name,
  82. int32_t default_val);
  83. int getinfo_helper_networkstatus(control_connection_t *conn,
  84. const char *question, char **answer,
  85. const char **errmsg);
  86. int32_t networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight,
  87. int32_t default_val);
  88. const char *networkstatus_get_flavor_name(consensus_flavor_t flav);
  89. int networkstatus_parse_flavor_name(const char *flavname);
  90. void document_signature_free(document_signature_t *sig);
  91. document_signature_t *document_signature_dup(const document_signature_t *sig);
  92. void networkstatus_free_all(void);
  93. #endif