circuitbuild.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 circuitbuild.h
  8. * \brief Header file for circuitbuild.c.
  9. **/
  10. #ifndef _TOR_CIRCUITBUILD_H
  11. #define _TOR_CIRCUITBUILD_H
  12. /** Represents a pluggable transport proxy used by a bridge. */
  13. typedef struct {
  14. /** SOCKS version: One of PROXY_SOCKS4, PROXY_SOCKS5. */
  15. int socks_version;
  16. /** Name of pluggable transport protocol */
  17. char *name;
  18. /** Address of proxy */
  19. tor_addr_t addr;
  20. /** Port of proxy */
  21. uint16_t port;
  22. /** Boolean: We are re-parsing our transport list, and we are going to remove
  23. * this one if we don't find it in the list of configured transports. */
  24. unsigned marked_for_removal : 1;
  25. } transport_t;
  26. char *circuit_list_path(origin_circuit_t *circ, int verbose);
  27. char *circuit_list_path_for_controller(origin_circuit_t *circ);
  28. void circuit_log_path(int severity, unsigned int domain,
  29. origin_circuit_t *circ);
  30. void circuit_rep_hist_note_result(origin_circuit_t *circ);
  31. origin_circuit_t *origin_circuit_init(uint8_t purpose, int flags);
  32. origin_circuit_t *circuit_establish_circuit(uint8_t purpose,
  33. extend_info_t *exit,
  34. int flags);
  35. int circuit_handle_first_hop(origin_circuit_t *circ);
  36. void circuit_n_conn_done(or_connection_t *or_conn, int status);
  37. int inform_testing_reachability(void);
  38. int circuit_timeout_want_to_count_circ(origin_circuit_t *circ);
  39. int circuit_send_next_onion_skin(origin_circuit_t *circ);
  40. void circuit_note_clock_jumped(int seconds_elapsed);
  41. int circuit_extend(cell_t *cell, circuit_t *circ);
  42. int circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
  43. int reverse);
  44. int circuit_finish_handshake(origin_circuit_t *circ, uint8_t cell_type,
  45. const uint8_t *reply);
  46. int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer);
  47. int onionskin_answer(or_circuit_t *circ, uint8_t cell_type,
  48. const char *payload, const char *keys);
  49. int circuit_all_predicted_ports_handled(time_t now, int *need_uptime,
  50. int *need_capacity);
  51. int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *info);
  52. int circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *info);
  53. void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
  54. extend_info_t *extend_info_alloc(const char *nickname, const char *digest,
  55. crypto_pk_t *onion_key,
  56. const tor_addr_t *addr, uint16_t port);
  57. extend_info_t *extend_info_from_router(const routerinfo_t *r,
  58. int for_direct_connect);
  59. extend_info_t *extend_info_from_node(const node_t *node,
  60. int for_direct_connect);
  61. extend_info_t *extend_info_dup(extend_info_t *info);
  62. void extend_info_free(extend_info_t *info);
  63. const node_t *build_state_get_exit_node(cpath_build_state_t *state);
  64. const char *build_state_get_exit_nickname(cpath_build_state_t *state);
  65. void entry_guards_compute_status(const or_options_t *options, time_t now);
  66. int entry_guard_register_connect_status(const char *digest, int succeeded,
  67. int mark_relay_status, time_t now);
  68. void entry_nodes_should_be_added(void);
  69. int entry_list_is_constrained(const or_options_t *options);
  70. const node_t *choose_random_entry(cpath_build_state_t *state);
  71. int entry_guards_parse_state(or_state_t *state, int set, char **msg);
  72. void entry_guards_update_state(or_state_t *state);
  73. int getinfo_helper_entry_guards(control_connection_t *conn,
  74. const char *question, char **answer,
  75. const char **errmsg);
  76. void mark_bridge_list(void);
  77. void sweep_bridge_list(void);
  78. void mark_transport_list(void);
  79. void sweep_transport_list(void);
  80. int routerinfo_is_a_configured_bridge(const routerinfo_t *ri);
  81. int node_is_a_configured_bridge(const node_t *node);
  82. void learned_router_identity(const tor_addr_t *addr, uint16_t port,
  83. const char *digest);
  84. void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
  85. const char *digest,
  86. const char *transport_name);
  87. void retry_bridge_descriptor_fetch_directly(const char *digest);
  88. void fetch_bridge_descriptors(const or_options_t *options, time_t now);
  89. void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
  90. int any_bridge_descriptors_known(void);
  91. int any_pending_bridge_descriptor_fetches(void);
  92. int entries_known_but_down(const or_options_t *options);
  93. void entries_retry_all(const or_options_t *options);
  94. int any_bridges_dont_support_microdescriptors(void);
  95. void entry_guards_free_all(void);
  96. extern circuit_build_times_t circ_times;
  97. int circuit_build_times_enough_to_compute(circuit_build_times_t *cbt);
  98. void circuit_build_times_update_state(circuit_build_times_t *cbt,
  99. or_state_t *state);
  100. int circuit_build_times_parse_state(circuit_build_times_t *cbt,
  101. or_state_t *state);
  102. void circuit_build_times_count_timeout(circuit_build_times_t *cbt,
  103. int did_onehop);
  104. int circuit_build_times_count_close(circuit_build_times_t *cbt,
  105. int did_onehop, time_t start_time);
  106. void circuit_build_times_set_timeout(circuit_build_times_t *cbt);
  107. int circuit_build_times_add_time(circuit_build_times_t *cbt,
  108. build_time_t time);
  109. int circuit_build_times_needs_circuits(circuit_build_times_t *cbt);
  110. int circuit_build_times_needs_circuits_now(circuit_build_times_t *cbt);
  111. void circuit_build_times_init(circuit_build_times_t *cbt);
  112. void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
  113. networkstatus_t *ns);
  114. double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt);
  115. double circuit_build_times_close_rate(const circuit_build_times_t *cbt);
  116. #ifdef CIRCUIT_PRIVATE
  117. double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,
  118. double quantile);
  119. build_time_t circuit_build_times_generate_sample(circuit_build_times_t *cbt,
  120. double q_lo, double q_hi);
  121. void circuit_build_times_initial_alpha(circuit_build_times_t *cbt,
  122. double quantile, double time_ms);
  123. int circuit_build_times_update_alpha(circuit_build_times_t *cbt);
  124. double circuit_build_times_cdf(circuit_build_times_t *cbt, double x);
  125. void circuitbuild_running_unit_tests(void);
  126. void circuit_build_times_reset(circuit_build_times_t *cbt);
  127. /* Network liveness functions */
  128. int circuit_build_times_network_check_changed(circuit_build_times_t *cbt);
  129. #endif
  130. /* Network liveness functions */
  131. void circuit_build_times_network_is_live(circuit_build_times_t *cbt);
  132. int circuit_build_times_network_check_live(circuit_build_times_t *cbt);
  133. void circuit_build_times_network_circ_success(circuit_build_times_t *cbt);
  134. /* DOCDOC circuit_build_times_get_bw_scale */
  135. int circuit_build_times_get_bw_scale(networkstatus_t *ns);
  136. void clear_transport_list(void);
  137. int transport_add_from_config(const tor_addr_t *addr, uint16_t port,
  138. const char *name, int socks_ver);
  139. int transport_add(transport_t *t);
  140. void transport_free(transport_t *transport);
  141. transport_t *transport_new(const tor_addr_t *addr, uint16_t port,
  142. const char *name, int socks_ver);
  143. /* DOCDOC find_transport_name_by_bridge_addrport */
  144. const char *find_transport_name_by_bridge_addrport(const tor_addr_t *addr,
  145. uint16_t port);
  146. int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
  147. const transport_t **transport);
  148. transport_t *transport_get_by_name(const char *name);
  149. int validate_pluggable_transports_config(void);
  150. #endif