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-2010, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
9 * \brief Header file for circuitbuild.c.
12 #ifndef _TOR_CIRCUITBUILD_H
13 #define _TOR_CIRCUITBUILD_H
15 char *circuit_list_path(origin_circuit_t
*circ
, int verbose
);
16 char *circuit_list_path_for_controller(origin_circuit_t
*circ
);
17 void circuit_log_path(int severity
, unsigned int domain
,
18 origin_circuit_t
*circ
);
19 void circuit_rep_hist_note_result(origin_circuit_t
*circ
);
20 origin_circuit_t
*origin_circuit_init(uint8_t purpose
, int flags
);
21 origin_circuit_t
*circuit_establish_circuit(uint8_t purpose
,
24 int circuit_handle_first_hop(origin_circuit_t
*circ
);
25 void circuit_n_conn_done(or_connection_t
*or_conn
, int status
);
26 int inform_testing_reachability(void);
27 int circuit_timeout_want_to_count_circ(origin_circuit_t
*circ
);
28 int circuit_send_next_onion_skin(origin_circuit_t
*circ
);
29 void circuit_note_clock_jumped(int seconds_elapsed
);
30 int circuit_extend(cell_t
*cell
, circuit_t
*circ
);
31 int circuit_init_cpath_crypto(crypt_path_t
*cpath
, const char *key_data
,
33 int circuit_finish_handshake(origin_circuit_t
*circ
, uint8_t cell_type
,
35 int circuit_truncated(origin_circuit_t
*circ
, crypt_path_t
*layer
);
36 int onionskin_answer(or_circuit_t
*circ
, uint8_t cell_type
,
37 const char *payload
, const char *keys
);
38 int circuit_all_predicted_ports_handled(time_t now
, int *need_uptime
,
41 int circuit_append_new_exit(origin_circuit_t
*circ
, extend_info_t
*info
);
42 int circuit_extend_to_new_exit(origin_circuit_t
*circ
, extend_info_t
*info
);
43 void onion_append_to_cpath(crypt_path_t
**head_ptr
, crypt_path_t
*new_hop
);
44 extend_info_t
*extend_info_alloc(const char *nickname
, const char *digest
,
45 crypto_pk_env_t
*onion_key
,
46 const tor_addr_t
*addr
, uint16_t port
);
47 extend_info_t
*extend_info_from_router(routerinfo_t
*r
);
48 extend_info_t
*extend_info_dup(extend_info_t
*info
);
49 void extend_info_free(extend_info_t
*info
);
50 routerinfo_t
*build_state_get_exit_router(cpath_build_state_t
*state
);
51 const char *build_state_get_exit_nickname(cpath_build_state_t
*state
);
53 void entry_guards_compute_status(or_options_t
*options
, time_t now
);
54 int entry_guard_register_connect_status(const char *digest
, int succeeded
,
55 int mark_relay_status
, time_t now
);
56 void entry_nodes_should_be_added(void);
57 int entry_list_is_constrained(or_options_t
*options
);
58 routerinfo_t
*choose_random_entry(cpath_build_state_t
*state
);
59 int entry_guards_parse_state(or_state_t
*state
, int set
, char **msg
);
60 void entry_guards_update_state(or_state_t
*state
);
61 int getinfo_helper_entry_guards(control_connection_t
*conn
,
62 const char *question
, char **answer
,
65 void clear_bridge_list(void);
66 int routerinfo_is_a_configured_bridge(routerinfo_t
*ri
);
68 learned_router_identity(tor_addr_t
*addr
, uint16_t port
, const char *digest
);
69 void bridge_add_from_config(const tor_addr_t
*addr
, uint16_t port
,
71 void retry_bridge_descriptor_fetch_directly(const char *digest
);
72 void fetch_bridge_descriptors(or_options_t
*options
, time_t now
);
73 void learned_bridge_descriptor(routerinfo_t
*ri
, int from_cache
);
74 int any_bridge_descriptors_known(void);
75 int any_pending_bridge_descriptor_fetches(void);
76 int entries_known_but_down(or_options_t
*options
);
77 void entries_retry_all(or_options_t
*options
);
79 void entry_guards_free_all(void);
81 extern circuit_build_times_t circ_times
;
82 int circuit_build_times_enough_to_compute(circuit_build_times_t
*cbt
);
83 void circuit_build_times_update_state(circuit_build_times_t
*cbt
,
85 int circuit_build_times_parse_state(circuit_build_times_t
*cbt
,
87 void circuit_build_times_count_timeout(circuit_build_times_t
*cbt
,
89 int circuit_build_times_count_close(circuit_build_times_t
*cbt
,
90 int did_onehop
, time_t start_time
);
91 void circuit_build_times_set_timeout(circuit_build_times_t
*cbt
);
92 int circuit_build_times_add_time(circuit_build_times_t
*cbt
,
94 int circuit_build_times_needs_circuits(circuit_build_times_t
*cbt
);
96 int circuit_build_times_needs_circuits_now(circuit_build_times_t
*cbt
);
97 void circuit_build_times_init(circuit_build_times_t
*cbt
);
98 void circuit_build_times_new_consensus_params(circuit_build_times_t
*cbt
,
100 double circuit_build_times_timeout_rate(const circuit_build_times_t
*cbt
);
101 double circuit_build_times_close_rate(const circuit_build_times_t
*cbt
);
103 #ifdef CIRCUIT_PRIVATE
104 double circuit_build_times_calculate_timeout(circuit_build_times_t
*cbt
,
106 build_time_t
circuit_build_times_generate_sample(circuit_build_times_t
*cbt
,
107 double q_lo
, double q_hi
);
108 void circuit_build_times_initial_alpha(circuit_build_times_t
*cbt
,
109 double quantile
, double time_ms
);
110 int circuit_build_times_update_alpha(circuit_build_times_t
*cbt
);
111 double circuit_build_times_cdf(circuit_build_times_t
*cbt
, double x
);
112 void circuitbuild_running_unit_tests(void);
113 void circuit_build_times_reset(circuit_build_times_t
*cbt
);
115 /* Network liveness functions */
116 int circuit_build_times_network_check_changed(circuit_build_times_t
*cbt
);
119 /* Network liveness functions */
120 void circuit_build_times_network_is_live(circuit_build_times_t
*cbt
);
121 int circuit_build_times_network_check_live(circuit_build_times_t
*cbt
);
122 void circuit_build_times_network_circ_success(circuit_build_times_t
*cbt
);