nodelist.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /* XXX duplicating code from tor_assert(). */
  13. #define node_assert_ok(n) STMT_BEGIN \
  14. if (PREDICT_UNLIKELY((n)->ri == NULL && (n)->rs == NULL)) { \
  15. log_err(LD_BUG, "%s:%d: %s: Node is invalid; aborting.", \
  16. _SHORT_FILE_, __LINE__, __func__); \
  17. fprintf(stderr, "%s:%d: %s: Node is invalid; aborting.\n", \
  18. _SHORT_FILE_, __LINE__, __func__); \
  19. abort(); \
  20. } STMT_END
  21. node_t *node_get_mutable_by_id(const char *identity_digest);
  22. const node_t *node_get_by_id(const char *identity_digest);
  23. const node_t *node_get_by_hex_id(const char *identity_digest);
  24. node_t *nodelist_set_routerinfo(routerinfo_t *ri, routerinfo_t **ri_old_out);
  25. node_t *nodelist_add_microdesc(microdesc_t *md);
  26. void nodelist_set_consensus(networkstatus_t *ns);
  27. void nodelist_remove_microdesc(const char *identity_digest, microdesc_t *md);
  28. void nodelist_remove_routerinfo(routerinfo_t *ri);
  29. void nodelist_purge(void);
  30. void nodelist_free_all(void);
  31. void nodelist_assert_ok(void);
  32. const node_t *node_get_by_nickname(const char *nickname, int warn_if_unnamed);
  33. void node_get_verbose_nickname(const node_t *node,
  34. char *verbose_name_out);
  35. int node_is_named(const node_t *node);
  36. int node_is_dir(const node_t *node);
  37. int node_has_descriptor(const node_t *node);
  38. int node_get_purpose(const node_t *node);
  39. #define node_is_bridge(node) \
  40. (node_get_purpose((node)) == ROUTER_PURPOSE_BRIDGE)
  41. int node_is_me(const node_t *node);
  42. int node_exit_policy_rejects_all(const node_t *node);
  43. smartlist_t *node_get_all_orports(const node_t *node);
  44. void node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out);
  45. void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out);
  46. void node_get_pref_ipv6_orport(const node_t *node, tor_addr_port_t *ap_out);
  47. uint32_t node_get_prim_addr_ipv4h(const node_t *node);
  48. int node_allows_single_hop_exits(const node_t *node);
  49. const char *node_get_nickname(const node_t *node);
  50. const char *node_get_platform(const node_t *node);
  51. void node_get_address_string(const node_t *node, char *cp, size_t len);
  52. long node_get_declared_uptime(const node_t *node);
  53. time_t node_get_published_on(const node_t *node);
  54. const smartlist_t *node_get_declared_family(const node_t *node);
  55. int node_ipv6_preferred(const node_t *node);
  56. smartlist_t *nodelist_get_list(void);
  57. /* Temporary during transition to multiple addresses. */
  58. void node_get_addr(const node_t *node, tor_addr_t *addr_out);
  59. #define node_get_addr_ipv4h(n) node_get_prim_addr_ipv4h((n))
  60. /* XXXX These need to move out of routerlist.c */
  61. void nodelist_refresh_countries(void);
  62. void node_set_country(node_t *node);
  63. void nodelist_add_node_and_family(smartlist_t *nodes, const node_t *node);
  64. int nodes_in_same_family(const node_t *node1, const node_t *node2);
  65. #endif