Tor
0.4.7.0-alpha-dev
|
#include <circuit_st.h>
Public Member Functions | |
HANDLE_ENTRY (circuit, circuit_t) | |
HT_ENTRY (circuit_t) hs_circuitmap_node | |
A circuit is a path over the onion routing network. Applications can connect to one end of the circuit, and can create exit connections at the other end of the circuit. AP and exit connections have only one circuit associated with them (and thus these connection types are closed when the circuit is closed), whereas OR connections multiplex many circuits at once, and stay standing even when there are no circuits running over them.
A circuit_t structure can fill one of two roles. First, a or_circuit_t links two connections together: either an edge connection and an OR connection, or two OR connections. (When joined to an OR connection, a circuit_t affects only cells sent to a particular circID on that connection. When joined to an edge connection, a circuit_t affects all data.)
Second, an origin_circuit_t holds the cipher keys and state for sending data along a given circuit. At the OP, it has a sequence of ciphers, each of which is shared with a single OR along the circuit. Separate ciphers are used for data going "forward" (away from the OP) and "backward" (towards the OP). At the OR, a circuit has only two stream ciphers: one for data going forward, and one for data going backward.
Definition at line 61 of file circuit_st.h.
HANDLE_ENTRY | ( | circuit | , |
circuit_t | |||
) |
Handle entry for handle-based lookup
HT_ENTRY | ( | circuit_t | ) |
Hashtable node: used to look up the circuit by its HS token using the HS circuitmap.
uint32_t age_tmp |
Temporary field used during circuits_handle_oom.
Definition at line 150 of file circuit_st.h.
Referenced by circuits_compare_by_oldest_queued_item_().
int deliver_window |
How many relay data cells will we deliver (write to edge streams) on this circuit? When deliver_window gets low, we send some circuit-level sendme cells to indicate that we're willing to accept more.
Definition at line 121 of file circuit_st.h.
Referenced by init_circuit_base(), and sendme_circuit_consider_sending().
uint64_t dirreq_id |
Unique ID for measuring tunneled network status requests.
Definition at line 204 of file circuit_st.h.
int global_circuitlist_idx |
Index in smartlist of all circuits (global_circuitlist).
Definition at line 207 of file circuit_st.h.
Referenced by circuit_close_all_marked(), and init_circuit_base().
unsigned int have_sent_sufficiently_random_cell |
True iff we have sent a sufficiently random data cell since last we reset send_randomness_after_n_cells.
Definition at line 108 of file circuit_st.h.
Referenced by circuit_reset_sendme_randomness(), and connection_edge_get_inbuf_bytes_to_package().
struct hs_token_t* hs_token |
If set, points to an HS token that this circuit might be carrying. Used by the HS circuitmap.
Definition at line 216 of file circuit_st.h.
Referenced by get_circuit_with_token(), hs_circ_cleanup_on_close(), hs_circ_cleanup_on_free(), hs_circ_cleanup_on_repurpose(), hs_circuit_hash_token(), hs_circuitmap_get_all_intro_circ_relay_side(), hs_circuitmap_register_impl(), hs_circuitmap_remove_circuit(), and hs_circuits_have_same_token().
uint32_t magic |
For memory and type debugging: must equal ORIGIN_CIRCUIT_MAGIC or OR_CIRCUIT_MAGIC.
Definition at line 62 of file circuit_st.h.
Referenced by assert_circuit_ok(), circuit_free_(), circuit_get_by_edge_conn(), circuitmux_detach_circuit(), circuitmux_find_map_entry(), and TO_ORIGIN_CIRCUIT().
uint16_t marked_for_close |
Should we close this circuit at the end of the main loop? (If true, holds the line number where this circuit was marked.)
Definition at line 189 of file circuit_st.h.
Referenced by append_cell_to_circuit_queue(), circpad_send_padding_cell_for_callback(), circuit_close_all_marked(), circuit_dump_by_conn(), circuit_get_all_pending_on_channel(), circuit_get_by_circid_channel(), circuit_get_by_global_id(), circuit_is_acceptable(), circuit_mark_all_dirty_circs_as_unusable(), circuit_mark_all_unused_circs(), circuit_mark_for_close_(), circuit_package_relay_cell(), circuit_receive_relay_cell(), hs_circuitmap_register_impl(), and marked_circuit_free_cells().
const char* marked_for_close_file |
For debugging: in which file was this circuit marked for close?
Definition at line 192 of file circuit_st.h.
int marked_for_close_orig_reason |
As marked_for_close_reason, but reflects the underlying reason for closing this circuit.
Definition at line 201 of file circuit_st.h.
Referenced by circuit_about_to_free(), and hs_client_circuit_cleanup_on_close().
int marked_for_close_reason |
For what reason (See END_CIRC_REASON...) is this circuit being closed? This field is set in circuit_mark_for_close and used later in circuit_about_to_free.
Definition at line 197 of file circuit_st.h.
Referenced by circuit_about_to_free().
channel_t* n_chan |
The channel that is next in this circuit.
Definition at line 69 of file circuit_st.h.
Referenced by channel_flush_from_first_active_circuit(), channel_note_destroy_not_pending(), channel_note_destroy_pending(), circpad_estimate_circ_rtt_on_received(), circuit_about_to_free_atexit(), circuit_clear_cell_queue(), circuit_deliver_create_cell(), circuit_is_acceptable(), circuit_package_relay_cell(), circuit_set_n_circid_chan(), circuit_unlink_all_from_channel(), circuitmux_attach_circuit(), circuitmux_detach_circuit(), circuitmux_find_map_entry(), format_cell_stats(), set_streams_blocked_on_circ(), and update_circuit_on_cmux_().
cell_queue_t n_chan_cells |
Queue of cells waiting to be transmitted on n_chan
Definition at line 81 of file circuit_st.h.
Referenced by append_cell_to_circuit_queue(), channel_flush_from_first_active_circuit(), circuit_clear_cell_queue(), circuit_max_queued_cell_age(), circuit_resume_edge_reading_helper(), circuitmux_attach_circuit(), init_circuit_base(), and n_cells_in_circ_queues().
struct create_cell_t* n_chan_create_cell |
For storage while n_chan is pending (state CIRCUIT_STATE_CHAN_WAIT).
Definition at line 153 of file circuit_st.h.
circid_t n_circ_id |
The circuit_id used in the next (forward) hop of this circuit; this is unique to n_chan, but this ordered pair is globally unique:
(n_chan->global_identifier, n_circ_id)
Definition at line 78 of file circuit_st.h.
Referenced by channel_note_destroy_not_pending(), channel_note_destroy_pending(), circpad_estimate_circ_rtt_on_received(), circuit_dump_by_conn(), circuit_free_(), circuit_set_n_circid_chan(), circuitmux_attach_circuit(), circuitmux_detach_circuit(), circuitmux_find_map_entry(), and format_cell_stats().
unsigned int n_delete_pending |
True iff we have queued a delete forwards on this circuit, but not put it on the output buffer.
Definition at line 101 of file circuit_st.h.
Referenced by channel_note_destroy_not_pending(), channel_note_destroy_pending(), and circuit_set_n_circid_chan().
extend_info_t* n_hop |
The hop to which we want to extend this circuit. Should be NULL if the circuit has attached to a channel.
Definition at line 87 of file circuit_st.h.
Referenced by circuit_get_all_pending_on_channel().
unsigned int p_delete_pending |
True iff we have queued a delete backwards on this circuit, but not put it on the output buffer.
Definition at line 98 of file circuit_st.h.
Referenced by channel_note_destroy_not_pending(), channel_note_destroy_pending(), and circuit_set_p_circid_chan().
int package_window |
How many relay data cells can we package (read from edge streams) on this circuit before we receive a circuit-level sendme cell asking for more?
Definition at line 116 of file circuit_st.h.
Referenced by circuit_resume_edge_reading_helper(), and init_circuit_base().
struct circpad_machine_runtime_t* padding_info[CIRCPAD_MAX_MACHINES] |
Adaptive Padding machine runtime info for above machines. This is the per-circuit mutable information, such as the current state and histogram token counts. Some of it is optional (aka NULL). If a machine is being shut down, these indexes can be NULL without the corresponding padding_machine being NULL, while we wait for the other end to respond to our shutdown request.
Each element of this array corresponds to a different padding machine, and we can have up to CIRCPAD_MAX_MACHINES such machines.
Definition at line 240 of file circuit_st.h.
Referenced by circpad_add_matching_machines(), circpad_cell_event_nonpadding_received(), circpad_cell_event_padding_received(), circpad_cell_event_padding_sent(), circpad_circuit_machineinfo_free_idx(), circpad_shutdown_old_machines(), and free_circ_machineinfos_with_machine_num().
const struct circpad_machine_spec_t* padding_machine[CIRCPAD_MAX_MACHINES] |
Adaptive Padding state machines: these are immutable. The state machines that come from the consensus are saved to a global structure, to avoid per-circuit allocations. This merely points to the global copy in origin_padding_machines or relay_padding_machines that should never change or get deallocated.
Each element of this array corresponds to a different padding machine, and we can have up to CIRCPAD_MAX_MACHINES such machines.
Definition at line 229 of file circuit_st.h.
Referenced by circpad_add_matching_machines(), circpad_machine_spec_transitioned_to_end(), circpad_padding_is_from_expected_hop(), circpad_shutdown_old_machines(), and free_circ_machineinfos_with_machine_num().
uint32_t padding_machine_ctr |
padding_machine_ctr increments each time a new padding machine is negotiated. It is used for shutdown conditions, to ensure that STOP commands actually correspond to the current machine, and not a previous one.
Definition at line 246 of file circuit_st.h.
uint8_t purpose |
Why are we creating this circuit?
Definition at line 111 of file circuit_st.h.
Referenced by assert_circuit_ok(), circpad_circuit_machineinfo_free_idx(), circpad_machine_spec_transitioned_to_end(), circpad_marked_circuit_for_padding(), circuit_build_times_handle_completed_hop(), circuit_change_purpose(), circuit_is_acceptable(), circuit_is_suitable_intro_point(), connection_ap_get_begincell_flags(), connection_ap_handshake_send_resolve(), connection_ap_supports_optimistic_data(), connection_exit_begin_conn(), handle_hs_exit_conn(), hs_circ_cleanup_on_close(), hs_circ_cleanup_on_free(), hs_circuitmap_get_all_intro_circ_relay_side(), hs_service_circuit_cleanup_on_close(), onion_extend_cpath(), pathbias_check_probe_response(), pathbias_count_collapse(), pathbias_count_successful_close(), pathbias_count_use_failed(), relay_send_end_cell_from_edge(), and warn_if_last_router_excluded().
unsigned int received_destroy |
True iff this circuit has received a DESTROY cell in either direction
Definition at line 104 of file circuit_st.h.
uint16_t send_randomness_after_n_cells |
How many cells do we have until we need to send one that contains sufficient randomness? Used to ensure that authenticated SENDME cells will reflect some unpredictable information.
Definition at line 127 of file circuit_st.h.
Referenced by circuit_reset_sendme_randomness(), and connection_edge_get_inbuf_bytes_to_package().
smartlist_t* sendme_last_digests |
FIFO containing the digest of the cells that are just before a SENDME is sent by the client. It is done at the last cell before our package_window goes down to 0 which is when we expect a SENDME.
Our current circuit package window is capped to 1000 (CIRCWINDOW_START_MAX) which is also the start value. The increment is set to 100 (CIRCWINDOW_INCREMENT) which means we don't allow more than 1000/100 = 10 outstanding SENDME cells worth of data. Meaning that this list can not contain more than 10 digests of DIGEST_LEN bytes (20).
At position i in the list, the digest corresponds to the (CIRCWINDOW_INCREMENT * i)-nth cell received since we expect a SENDME to be received containing that cell digest.
For example, position 2 (starting at 0) means that we've received 300 cells so the 300th cell digest is kept at index 2.
At maximum, this list contains 200 bytes plus the smartlist overhead.
Definition at line 147 of file circuit_st.h.
uint8_t state |
Current status of this circuit.
Definition at line 110 of file circuit_st.h.
Referenced by circpad_estimate_circ_rtt_on_received(), circpad_estimate_circ_rtt_on_send(), circuit_about_to_free(), circuit_get_all_pending_on_channel(), circuit_is_acceptable(), circuit_list_path_impl(), circuit_set_state(), circuit_try_clearing_isolation_state(), connection_ap_handshake_attach_chosen_circuit(), and connection_ap_supports_optimistic_data().
unsigned int streams_blocked_on_n_chan |
True iff we are waiting for n_chan_cells to become less full before allowing p_streams to add any more cells. (Origin circuit only.)
Definition at line 91 of file circuit_st.h.
Referenced by append_cell_to_circuit_queue(), channel_flush_from_first_active_circuit(), circuit_queue_streams_are_blocked(), and set_streams_blocked_on_circ().
unsigned int streams_blocked_on_p_chan |
True iff we are waiting for p_chan_cells to become less full before allowing n_streams to add any more cells. (OR circuit only.)
Definition at line 94 of file circuit_st.h.
Referenced by append_cell_to_circuit_queue(), channel_flush_from_first_active_circuit(), circuit_queue_streams_are_blocked(), and set_streams_blocked_on_circ().
smartlist_t* testing_cell_stats |
Various statistics about cells being added to or removed from this circuit's queues; used only if CELL_STATS events are enabled and cleared after being sent to control port.
Definition at line 212 of file circuit_st.h.
Referenced by circuit_clear_testing_cell_stats(), and sum_up_cell_stats_by_command().
struct timeval timestamp_began |
When did circuit construction actually begin (ie send the CREATE cell or begin cannibalization).
Note: This timer will get reset if we decide to cannibalize a circuit. It may also get reset during certain phases of hidden service circuit use.
We keep this timestamp with a higher resolution than most so that the circuit-build-time tracking code can get millisecond resolution.
Definition at line 153 of file circuit_st.h.
Referenced by circuit_build_times_handle_completed_hop(), circuit_extend_to_new_exit(), circuit_is_better(), and init_circuit_base().
struct timeval timestamp_created |
This timestamp marks when the init_circuit_base constructor ran.
Definition at line 153 of file circuit_st.h.
Referenced by init_circuit_base(), and rep_hist_buffer_stats_add_circ().
time_t timestamp_dirty |
When the circuit was first used, or 0 if the circuit is clean.
XXXX Note that some code will artificially adjust this value backward in time in order to indicate that a circuit shouldn't be used for new streams, but that it can stay alive as long as it has streams on it. That's a kludge we should fix.
XXX The CBT code uses this field to record when HS-related circuits entered certain states. This usage probably won't interfere with this field's primary purpose, but we should document it more thoroughly to make sure of that.
XXX The SocksPort option KeepaliveIsolateSOCKSAuth will artificially adjust this value forward each time a suitable stream is attached to an already constructed circuit, potentially keeping the circuit alive indefinitely.
Definition at line 187 of file circuit_st.h.
Referenced by circuit_is_acceptable(), circuit_is_better(), circuit_mark_all_dirty_circs_as_unusable(), circuit_mark_all_unused_circs(), connection_ap_handshake_attach_chosen_circuit(), and mark_circuit_unusable_for_new_conns().