circuituse.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file circuituse.h
  8. * \brief Header file for circuituse.c.
  9. **/
  10. #ifndef TOR_CIRCUITUSE_H
  11. #define TOR_CIRCUITUSE_H
  12. void circuit_expire_building(void);
  13. void circuit_expire_waiting_for_better_guard(void);
  14. void circuit_remove_handled_ports(smartlist_t *needed_ports);
  15. int circuit_stream_is_being_handled(entry_connection_t *conn, uint16_t port,
  16. int min);
  17. void circuit_log_ancient_one_hop_circuits(int age);
  18. #if 0
  19. int circuit_conforms_to_options(const origin_circuit_t *circ,
  20. const or_options_t *options);
  21. #endif
  22. void circuit_build_needed_circs(time_t now);
  23. void circuit_expire_old_circs_as_needed(time_t now);
  24. void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn);
  25. void circuit_expire_old_circuits_serverside(time_t now);
  26. void reset_bandwidth_test(void);
  27. int circuit_enough_testing_circs(void);
  28. void circuit_has_opened(origin_circuit_t *circ);
  29. void circuit_try_attaching_streams(origin_circuit_t *circ);
  30. void circuit_build_failed(origin_circuit_t *circ);
  31. /** Flag to set when a circuit should have only a single hop. */
  32. #define CIRCLAUNCH_ONEHOP_TUNNEL (1<<0)
  33. /** Flag to set when a circuit needs to be built of high-uptime nodes */
  34. #define CIRCLAUNCH_NEED_UPTIME (1<<1)
  35. /** Flag to set when a circuit needs to be built of high-capacity nodes */
  36. #define CIRCLAUNCH_NEED_CAPACITY (1<<2)
  37. /** Flag to set when the last hop of a circuit doesn't need to be an
  38. * exit node. */
  39. #define CIRCLAUNCH_IS_INTERNAL (1<<3)
  40. /** Flag to set when we are trying to launch a v3 rendezvous circuit. We need
  41. * to apply some additional filters on the node picked. */
  42. #define CIRCLAUNCH_IS_V3_RP (1<<4)
  43. origin_circuit_t *circuit_launch_by_extend_info(uint8_t purpose,
  44. extend_info_t *info,
  45. int flags);
  46. origin_circuit_t *circuit_launch(uint8_t purpose, int flags);
  47. void circuit_reset_failure_count(int timeout);
  48. int connection_ap_handshake_attach_chosen_circuit(entry_connection_t *conn,
  49. origin_circuit_t *circ,
  50. crypt_path_t *cpath);
  51. int connection_ap_handshake_attach_circuit(entry_connection_t *conn);
  52. void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose);
  53. int hostname_in_track_host_exits(const or_options_t *options,
  54. const char *address);
  55. void mark_circuit_unusable_for_new_conns(origin_circuit_t *circ);
  56. int circuit_purpose_is_hidden_service(uint8_t);
  57. int circuit_should_use_vanguards(uint8_t);
  58. void circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
  59. void circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
  60. #ifdef TOR_UNIT_TESTS
  61. /* Used only by circuituse.c and test_circuituse.c */
  62. STATIC int circuit_is_available_for_use(const circuit_t *circ);
  63. STATIC int needs_exit_circuits(time_t now,
  64. int *port_needs_uptime,
  65. int *port_needs_capacity);
  66. STATIC int needs_hs_server_circuits(time_t now,
  67. int num_uptime_internal);
  68. STATIC int needs_hs_client_circuits(time_t now,
  69. int *needs_uptime,
  70. int *needs_capacity,
  71. int num_internal,
  72. int num_uptime_internal);
  73. STATIC int needs_circuits_for_build(int num);
  74. #endif /* defined(TOR_UNIT_TESTS) */
  75. #endif /* !defined(TOR_CIRCUITUSE_H) */