Back to index

tor  0.2.3.18-rc
circuitbuild.h
Go to the documentation of this file.
00001 /* Copyright (c) 2001 Matej Pfajfar.
00002  * Copyright (c) 2001-2004, Roger Dingledine.
00003  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00004  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00005 /* See LICENSE for licensing information */
00006 
00012 #ifndef _TOR_CIRCUITBUILD_H
00013 #define _TOR_CIRCUITBUILD_H
00014 
00016 typedef struct {
00018   int socks_version;
00020   char *name;
00022   tor_addr_t addr;
00024   uint16_t port;
00027   unsigned marked_for_removal : 1;
00028 } transport_t;
00029 
00030 char *circuit_list_path(origin_circuit_t *circ, int verbose);
00031 char *circuit_list_path_for_controller(origin_circuit_t *circ);
00032 void circuit_log_path(int severity, unsigned int domain,
00033                       origin_circuit_t *circ);
00034 void circuit_rep_hist_note_result(origin_circuit_t *circ);
00035 origin_circuit_t *origin_circuit_init(uint8_t purpose, int flags);
00036 origin_circuit_t *circuit_establish_circuit(uint8_t purpose,
00037                                             extend_info_t *exit,
00038                                             int flags);
00039 int circuit_handle_first_hop(origin_circuit_t *circ);
00040 void circuit_n_conn_done(or_connection_t *or_conn, int status);
00041 int inform_testing_reachability(void);
00042 int circuit_timeout_want_to_count_circ(origin_circuit_t *circ);
00043 int circuit_send_next_onion_skin(origin_circuit_t *circ);
00044 void circuit_note_clock_jumped(int seconds_elapsed);
00045 int circuit_extend(cell_t *cell, circuit_t *circ);
00046 int circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
00047                               int reverse);
00048 int circuit_finish_handshake(origin_circuit_t *circ, uint8_t cell_type,
00049                              const uint8_t *reply);
00050 int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer);
00051 int onionskin_answer(or_circuit_t *circ, uint8_t cell_type,
00052                      const char *payload, const char *keys);
00053 int circuit_all_predicted_ports_handled(time_t now, int *need_uptime,
00054                                         int *need_capacity);
00055 
00056 int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *info);
00057 int circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *info);
00058 void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
00059 extend_info_t *extend_info_alloc(const char *nickname, const char *digest,
00060                                  crypto_pk_t *onion_key,
00061                                  const tor_addr_t *addr, uint16_t port);
00062 extend_info_t *extend_info_from_router(const routerinfo_t *r,
00063                                        int for_direct_connect);
00064 extend_info_t *extend_info_from_node(const node_t *node,
00065                                      int for_direct_connect);
00066 extend_info_t *extend_info_dup(extend_info_t *info);
00067 void extend_info_free(extend_info_t *info);
00068 const node_t *build_state_get_exit_node(cpath_build_state_t *state);
00069 const char *build_state_get_exit_nickname(cpath_build_state_t *state);
00070 
00071 void entry_guards_compute_status(const or_options_t *options, time_t now);
00072 int entry_guard_register_connect_status(const char *digest, int succeeded,
00073                                         int mark_relay_status, time_t now);
00074 void entry_nodes_should_be_added(void);
00075 int entry_list_is_constrained(const or_options_t *options);
00076 const node_t *choose_random_entry(cpath_build_state_t *state);
00077 int entry_guards_parse_state(or_state_t *state, int set, char **msg);
00078 void entry_guards_update_state(or_state_t *state);
00079 int getinfo_helper_entry_guards(control_connection_t *conn,
00080                                 const char *question, char **answer,
00081                                 const char **errmsg);
00082 
00083 void mark_bridge_list(void);
00084 void sweep_bridge_list(void);
00085 void mark_transport_list(void);
00086 void sweep_transport_list(void);
00087 
00088 int routerinfo_is_a_configured_bridge(const routerinfo_t *ri);
00089 int node_is_a_configured_bridge(const node_t *node);
00090 void learned_router_identity(const tor_addr_t *addr, uint16_t port,
00091                              const char *digest);
00092 void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
00093                             const char *digest,
00094                             const char *transport_name);
00095 void retry_bridge_descriptor_fetch_directly(const char *digest);
00096 void fetch_bridge_descriptors(const or_options_t *options, time_t now);
00097 void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
00098 int any_bridge_descriptors_known(void);
00099 int any_pending_bridge_descriptor_fetches(void);
00100 int entries_known_but_down(const or_options_t *options);
00101 void entries_retry_all(const or_options_t *options);
00102 
00103 int any_bridges_dont_support_microdescriptors(void);
00104 
00105 void entry_guards_free_all(void);
00106 
00107 extern circuit_build_times_t circ_times;
00108 int circuit_build_times_enough_to_compute(circuit_build_times_t *cbt);
00109 void circuit_build_times_update_state(circuit_build_times_t *cbt,
00110                                       or_state_t *state);
00111 int circuit_build_times_parse_state(circuit_build_times_t *cbt,
00112                                     or_state_t *state);
00113 void circuit_build_times_count_timeout(circuit_build_times_t *cbt,
00114                                        int did_onehop);
00115 int circuit_build_times_count_close(circuit_build_times_t *cbt,
00116                                     int did_onehop, time_t start_time);
00117 void circuit_build_times_set_timeout(circuit_build_times_t *cbt);
00118 int circuit_build_times_add_time(circuit_build_times_t *cbt,
00119                                  build_time_t time);
00120 int circuit_build_times_needs_circuits(circuit_build_times_t *cbt);
00121 
00122 int circuit_build_times_needs_circuits_now(circuit_build_times_t *cbt);
00123 void circuit_build_times_init(circuit_build_times_t *cbt);
00124 void circuit_build_times_free_timeouts(circuit_build_times_t *cbt);
00125 void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
00126                                               networkstatus_t *ns);
00127 double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt);
00128 double circuit_build_times_close_rate(const circuit_build_times_t *cbt);
00129 
00130 #ifdef CIRCUIT_PRIVATE
00131 double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,
00132                                              double quantile);
00133 build_time_t circuit_build_times_generate_sample(circuit_build_times_t *cbt,
00134                                                  double q_lo, double q_hi);
00135 void circuit_build_times_initial_alpha(circuit_build_times_t *cbt,
00136                                        double quantile, double time_ms);
00137 int circuit_build_times_update_alpha(circuit_build_times_t *cbt);
00138 double circuit_build_times_cdf(circuit_build_times_t *cbt, double x);
00139 void circuitbuild_running_unit_tests(void);
00140 void circuit_build_times_reset(circuit_build_times_t *cbt);
00141 
00142 /* Network liveness functions */
00143 int circuit_build_times_network_check_changed(circuit_build_times_t *cbt);
00144 #endif
00145 
00146 /* Network liveness functions */
00147 void circuit_build_times_network_is_live(circuit_build_times_t *cbt);
00148 int circuit_build_times_network_check_live(circuit_build_times_t *cbt);
00149 void circuit_build_times_network_circ_success(circuit_build_times_t *cbt);
00150 
00151 /* DOCDOC circuit_build_times_get_bw_scale */
00152 int circuit_build_times_get_bw_scale(networkstatus_t *ns);
00153 
00154 void clear_transport_list(void);
00155 int transport_add_from_config(const tor_addr_t *addr, uint16_t port,
00156                                const char *name, int socks_ver);
00157 int transport_add(transport_t *t);
00158 void transport_free(transport_t *transport);
00159 transport_t *transport_new(const tor_addr_t *addr, uint16_t port,
00160                                       const char *name, int socks_ver);
00161 
00162 /* DOCDOC find_transport_name_by_bridge_addrport */
00163 const char *find_transport_name_by_bridge_addrport(const tor_addr_t *addr,
00164                                                    uint16_t port);
00165 
00166 int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
00167                                       const transport_t **transport);
00168 transport_t *transport_get_by_name(const char *name);
00169 
00170 #endif
00171