2010-07-22 01:21:00 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2012-06-05 02:58:17 +02:00
|
|
|
* Copyright (c) 2007-2012, The Tor Project, Inc. */
|
2010-07-22 01:21:00 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
2010-07-28 17:42:33 +02:00
|
|
|
* \file circuitbuild.h
|
2010-07-22 01:21:00 +02:00
|
|
|
* \brief Header file for circuitbuild.c.
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _TOR_CIRCUITBUILD_H
|
|
|
|
#define _TOR_CIRCUITBUILD_H
|
|
|
|
|
|
|
|
char *circuit_list_path(origin_circuit_t *circ, int verbose);
|
|
|
|
char *circuit_list_path_for_controller(origin_circuit_t *circ);
|
|
|
|
void circuit_log_path(int severity, unsigned int domain,
|
|
|
|
origin_circuit_t *circ);
|
|
|
|
void circuit_rep_hist_note_result(origin_circuit_t *circ);
|
|
|
|
origin_circuit_t *origin_circuit_init(uint8_t purpose, int flags);
|
|
|
|
origin_circuit_t *circuit_establish_circuit(uint8_t purpose,
|
|
|
|
extend_info_t *exit,
|
|
|
|
int flags);
|
|
|
|
int circuit_handle_first_hop(origin_circuit_t *circ);
|
|
|
|
void circuit_n_conn_done(or_connection_t *or_conn, int status);
|
|
|
|
int inform_testing_reachability(void);
|
2010-09-29 20:41:27 +02:00
|
|
|
int circuit_timeout_want_to_count_circ(origin_circuit_t *circ);
|
2010-07-22 01:21:00 +02:00
|
|
|
int circuit_send_next_onion_skin(origin_circuit_t *circ);
|
|
|
|
void circuit_note_clock_jumped(int seconds_elapsed);
|
|
|
|
int circuit_extend(cell_t *cell, circuit_t *circ);
|
|
|
|
int circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
|
|
|
|
int reverse);
|
|
|
|
int circuit_finish_handshake(origin_circuit_t *circ, uint8_t cell_type,
|
2010-12-16 04:47:28 +01:00
|
|
|
const uint8_t *reply);
|
2010-07-22 01:21:00 +02:00
|
|
|
int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer);
|
|
|
|
int onionskin_answer(or_circuit_t *circ, uint8_t cell_type,
|
|
|
|
const char *payload, const char *keys);
|
|
|
|
int circuit_all_predicted_ports_handled(time_t now, int *need_uptime,
|
|
|
|
int *need_capacity);
|
|
|
|
|
|
|
|
int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *info);
|
|
|
|
int circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *info);
|
|
|
|
void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
|
|
|
|
extend_info_t *extend_info_alloc(const char *nickname, const char *digest,
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *onion_key,
|
2010-07-22 01:21:00 +02:00
|
|
|
const tor_addr_t *addr, uint16_t port);
|
2011-11-24 18:29:56 +01:00
|
|
|
extend_info_t *extend_info_from_router(const routerinfo_t *r,
|
|
|
|
int for_direct_connect);
|
|
|
|
extend_info_t *extend_info_from_node(const node_t *node,
|
|
|
|
int for_direct_connect);
|
2010-07-22 01:21:00 +02:00
|
|
|
extend_info_t *extend_info_dup(extend_info_t *info);
|
|
|
|
void extend_info_free(extend_info_t *info);
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
const node_t *build_state_get_exit_node(cpath_build_state_t *state);
|
2010-07-22 01:21:00 +02:00
|
|
|
const char *build_state_get_exit_nickname(cpath_build_state_t *state);
|
|
|
|
|
2011-06-14 19:01:38 +02:00
|
|
|
void entry_guards_compute_status(const or_options_t *options, time_t now);
|
2010-07-22 01:21:00 +02:00
|
|
|
int entry_guard_register_connect_status(const char *digest, int succeeded,
|
|
|
|
int mark_relay_status, time_t now);
|
|
|
|
void entry_nodes_should_be_added(void);
|
2011-06-14 19:01:38 +02:00
|
|
|
int entry_list_is_constrained(const or_options_t *options);
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
const node_t *choose_random_entry(cpath_build_state_t *state);
|
2010-07-22 01:21:00 +02:00
|
|
|
int entry_guards_parse_state(or_state_t *state, int set, char **msg);
|
|
|
|
void entry_guards_update_state(or_state_t *state);
|
|
|
|
int getinfo_helper_entry_guards(control_connection_t *conn,
|
|
|
|
const char *question, char **answer,
|
|
|
|
const char **errmsg);
|
|
|
|
|
2011-05-15 18:46:26 +02:00
|
|
|
void mark_bridge_list(void);
|
|
|
|
void sweep_bridge_list(void);
|
2011-09-11 20:28:47 +02:00
|
|
|
|
2010-09-29 06:38:32 +02:00
|
|
|
int routerinfo_is_a_configured_bridge(const routerinfo_t *ri);
|
2011-06-02 19:05:00 +02:00
|
|
|
int node_is_a_configured_bridge(const node_t *node);
|
2011-05-15 18:46:26 +02:00
|
|
|
void learned_router_identity(const tor_addr_t *addr, uint16_t port,
|
2010-09-29 06:38:32 +02:00
|
|
|
const char *digest);
|
2010-07-22 01:21:00 +02:00
|
|
|
void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
|
2011-06-12 16:41:32 +02:00
|
|
|
const char *digest,
|
2011-06-11 23:20:39 +02:00
|
|
|
const char *transport_name);
|
2010-07-22 01:21:00 +02:00
|
|
|
void retry_bridge_descriptor_fetch_directly(const char *digest);
|
2011-06-14 19:01:38 +02:00
|
|
|
void fetch_bridge_descriptors(const or_options_t *options, time_t now);
|
2010-07-22 01:21:00 +02:00
|
|
|
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
|
|
|
|
int any_bridge_descriptors_known(void);
|
|
|
|
int any_pending_bridge_descriptor_fetches(void);
|
2011-06-14 19:01:38 +02:00
|
|
|
int entries_known_but_down(const or_options_t *options);
|
|
|
|
void entries_retry_all(const or_options_t *options);
|
2010-07-22 01:21:00 +02:00
|
|
|
|
2012-01-26 00:54:59 +01:00
|
|
|
int any_bridges_dont_support_microdescriptors(void);
|
|
|
|
|
2010-07-22 01:21:00 +02:00
|
|
|
void entry_guards_free_all(void);
|
|
|
|
|
|
|
|
extern circuit_build_times_t circ_times;
|
2010-09-30 00:01:22 +02:00
|
|
|
int circuit_build_times_enough_to_compute(circuit_build_times_t *cbt);
|
2010-07-22 01:21:00 +02:00
|
|
|
void circuit_build_times_update_state(circuit_build_times_t *cbt,
|
|
|
|
or_state_t *state);
|
|
|
|
int circuit_build_times_parse_state(circuit_build_times_t *cbt,
|
2010-08-15 14:22:32 +02:00
|
|
|
or_state_t *state);
|
2010-07-22 01:21:00 +02:00
|
|
|
void circuit_build_times_count_timeout(circuit_build_times_t *cbt,
|
|
|
|
int did_onehop);
|
|
|
|
int circuit_build_times_count_close(circuit_build_times_t *cbt,
|
|
|
|
int did_onehop, time_t start_time);
|
|
|
|
void circuit_build_times_set_timeout(circuit_build_times_t *cbt);
|
|
|
|
int circuit_build_times_add_time(circuit_build_times_t *cbt,
|
|
|
|
build_time_t time);
|
|
|
|
int circuit_build_times_needs_circuits(circuit_build_times_t *cbt);
|
|
|
|
|
|
|
|
int circuit_build_times_needs_circuits_now(circuit_build_times_t *cbt);
|
|
|
|
void circuit_build_times_init(circuit_build_times_t *cbt);
|
2012-06-13 04:27:37 +02:00
|
|
|
void circuit_build_times_free_timeouts(circuit_build_times_t *cbt);
|
2010-07-22 01:21:00 +02:00
|
|
|
void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
|
|
|
|
networkstatus_t *ns);
|
|
|
|
double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt);
|
|
|
|
double circuit_build_times_close_rate(const circuit_build_times_t *cbt);
|
|
|
|
|
|
|
|
#ifdef CIRCUIT_PRIVATE
|
|
|
|
double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,
|
|
|
|
double quantile);
|
|
|
|
build_time_t circuit_build_times_generate_sample(circuit_build_times_t *cbt,
|
|
|
|
double q_lo, double q_hi);
|
|
|
|
void circuit_build_times_initial_alpha(circuit_build_times_t *cbt,
|
|
|
|
double quantile, double time_ms);
|
|
|
|
int circuit_build_times_update_alpha(circuit_build_times_t *cbt);
|
|
|
|
double circuit_build_times_cdf(circuit_build_times_t *cbt, double x);
|
|
|
|
void circuitbuild_running_unit_tests(void);
|
|
|
|
void circuit_build_times_reset(circuit_build_times_t *cbt);
|
|
|
|
|
|
|
|
/* Network liveness functions */
|
|
|
|
int circuit_build_times_network_check_changed(circuit_build_times_t *cbt);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Network liveness functions */
|
|
|
|
void circuit_build_times_network_is_live(circuit_build_times_t *cbt);
|
|
|
|
int circuit_build_times_network_check_live(circuit_build_times_t *cbt);
|
|
|
|
void circuit_build_times_network_circ_success(circuit_build_times_t *cbt);
|
|
|
|
|
2012-06-05 01:51:00 +02:00
|
|
|
/* DOCDOC circuit_build_times_get_bw_scale */
|
2010-12-30 19:54:13 +01:00
|
|
|
int circuit_build_times_get_bw_scale(networkstatus_t *ns);
|
|
|
|
|
2012-07-12 15:28:43 +02:00
|
|
|
/* DOCDOC find_transport_name_by_bridge_addrport */
|
|
|
|
const char *find_transport_name_by_bridge_addrport(const tor_addr_t *addr,
|
|
|
|
uint16_t port);
|
2012-07-19 15:04:24 +02:00
|
|
|
struct transport_t;
|
2011-06-22 23:28:11 +02:00
|
|
|
int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
|
2012-07-19 15:04:24 +02:00
|
|
|
const struct transport_t **transport);
|
2011-09-11 20:28:47 +02:00
|
|
|
|
2010-07-22 01:21:00 +02:00
|
|
|
#endif
|
|
|
|
|