nodelist.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 nodelist.h
  8. * \brief Header file for nodelist.c.
  9. **/
  10. #ifndef TOR_NODELIST_H
  11. #define TOR_NODELIST_H
  12. #define node_assert_ok(n) STMT_BEGIN { \
  13. tor_assert((n)->ri || (n)->rs); \
  14. } STMT_END
  15. node_t *node_get_mutable_by_id(const char *identity_digest);
  16. const node_t *node_get_by_id(const char *identity_digest);
  17. const node_t *node_get_by_hex_id(const char *identity_digest);
  18. node_t *nodelist_set_routerinfo(routerinfo_t *ri, routerinfo_t **ri_old_out);
  19. node_t *nodelist_add_microdesc(microdesc_t *md);
  20. void nodelist_set_consensus(networkstatus_t *ns);
  21. void nodelist_remove_microdesc(const char *identity_digest, microdesc_t *md);
  22. void nodelist_remove_routerinfo(routerinfo_t *ri);
  23. void nodelist_purge(void);
  24. void nodelist_free_all(void);
  25. void nodelist_assert_ok(void);
  26. const node_t *node_get_by_nickname(const char *nickname, int warn_if_unnamed);
  27. void node_get_verbose_nickname(const node_t *node,
  28. char *verbose_name_out);
  29. int node_is_named(const node_t *node);
  30. int node_is_dir(const node_t *node);
  31. int node_has_descriptor(const node_t *node);
  32. int node_get_purpose(const node_t *node);
  33. #define node_is_bridge(node) \
  34. (node_get_purpose((node)) == ROUTER_PURPOSE_BRIDGE)
  35. int node_is_me(const node_t *node);
  36. int node_exit_policy_rejects_all(const node_t *node);
  37. smartlist_t *node_get_all_orports(const node_t *node);
  38. int node_allows_single_hop_exits(const node_t *node);
  39. const char *node_get_nickname(const node_t *node);
  40. const char *node_get_platform(const node_t *node);
  41. uint32_t node_get_prim_addr_ipv4h(const node_t *node);
  42. void node_get_address_string(const node_t *node, char *cp, size_t len);
  43. long node_get_declared_uptime(const node_t *node);
  44. time_t node_get_published_on(const node_t *node);
  45. const smartlist_t *node_get_declared_family(const node_t *node);
  46. int node_ipv6_preferred(const node_t *node);
  47. int node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out);
  48. void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out);
  49. void node_get_pref_ipv6_orport(const node_t *node, tor_addr_port_t *ap_out);
  50. smartlist_t *nodelist_get_list(void);
  51. /* Temporary during transition to multiple addresses. */
  52. void node_get_addr(const node_t *node, tor_addr_t *addr_out);
  53. #define node_get_addr_ipv4h(n) node_get_prim_addr_ipv4h((n))
  54. void nodelist_refresh_countries(void);
  55. void node_set_country(node_t *node);
  56. void nodelist_add_node_and_family(smartlist_t *nodes, const node_t *node);
  57. int nodes_in_same_family(const node_t *node1, const node_t *node2);
  58. const node_t *router_find_exact_exit_enclave(const char *address,
  59. uint16_t port);
  60. int node_is_unreliable(const node_t *router, int need_uptime,
  61. int need_capacity, int need_guard);
  62. int router_exit_policy_all_nodes_reject(const tor_addr_t *addr, uint16_t port,
  63. int need_uptime);
  64. void router_set_status(const char *digest, int up);
  65. int router_have_minimum_dir_info(void);
  66. void router_dir_info_changed(void);
  67. const char *get_dir_info_status_string(void);
  68. int count_loading_descriptors_progress(void);
  69. #endif