tor  0.4.2.0-alpha-dev
Public Member Functions | Data Fields
circuit_t Struct Reference

#include <circuit_st.h>

Public Member Functions

 HT_ENTRY (circuit_t) hs_circuitmap_node
 

Data Fields

uint32_t magic
 
channel_tn_chan
 
circid_t n_circ_id
 
cell_queue_t n_chan_cells
 
extend_info_tn_hop
 
unsigned int streams_blocked_on_n_chan: 1
 
unsigned int streams_blocked_on_p_chan: 1
 
unsigned int p_delete_pending: 1
 
unsigned int n_delete_pending: 1
 
unsigned int received_destroy: 1
 
unsigned int have_sent_sufficiently_random_cell: 1
 
uint8_t state
 
uint8_t purpose
 
int package_window
 
int deliver_window
 
uint16_t send_randomness_after_n_cells
 
smartlist_tsendme_last_digests
 
uint32_t age_tmp
 
struct create_cell_tn_chan_create_cell
 
struct timeval timestamp_began
 
struct timeval timestamp_created
 
time_t timestamp_dirty
 
uint16_t marked_for_close
 
const char * marked_for_close_file
 
int marked_for_close_reason
 
int marked_for_close_orig_reason
 
uint64_t dirreq_id
 
int global_circuitlist_idx
 
smartlist_ttesting_cell_stats
 
struct hs_token_t * hs_token
 
const struct circpad_machine_spec_tpadding_machine [CIRCPAD_MAX_MACHINES]
 
struct circpad_machine_runtime_tpadding_info [CIRCPAD_MAX_MACHINES]
 

Detailed Description

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 53 of file circuit_st.h.

Member Function Documentation

◆ HT_ENTRY()

circuit_t::HT_ENTRY ( circuit_t  )

Hashtable node: used to look up the circuit by its HS token using the HS circuitmap.

Field Documentation

◆ age_tmp

uint32_t circuit_t::age_tmp

Temporary field used during circuits_handle_oom.

Definition at line 139 of file circuit_st.h.

Referenced by circuits_compare_by_oldest_queued_item_().

◆ deliver_window

int circuit_t::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 110 of file circuit_st.h.

Referenced by init_circuit_base(), and sendme_circuit_consider_sending().

◆ dirreq_id

uint64_t circuit_t::dirreq_id

Unique ID for measuring tunneled network status requests.

Definition at line 193 of file circuit_st.h.

◆ global_circuitlist_idx

int circuit_t::global_circuitlist_idx

Index in smartlist of all circuits (global_circuitlist).

Definition at line 196 of file circuit_st.h.

Referenced by circuit_close_all_marked(), and init_circuit_base().

◆ have_sent_sufficiently_random_cell

unsigned int circuit_t::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 97 of file circuit_st.h.

Referenced by circuit_reset_sendme_randomness(), and connection_edge_get_inbuf_bytes_to_package().

◆ hs_token

struct hs_token_t* circuit_t::hs_token

If set, points to an HS token that this circuit might be carrying. Used by the HS circuitmap.

Definition at line 205 of file circuit_st.h.

◆ magic

uint32_t circuit_t::magic

For memory and type debugging: must equal ORIGIN_CIRCUIT_MAGIC or OR_CIRCUIT_MAGIC.

Definition at line 54 of file circuit_st.h.

Referenced by circuit_get_by_edge_conn(), circuitmux_find_map_entry(), MOCK_IMPL(), TO_OR_CIRCUIT(), and TO_ORIGIN_CIRCUIT().

◆ marked_for_close

uint16_t circuit_t::marked_for_close

◆ marked_for_close_file

const char* circuit_t::marked_for_close_file

For debugging: in which file was this circuit marked for close?

Definition at line 181 of file circuit_st.h.

◆ marked_for_close_orig_reason

int circuit_t::marked_for_close_orig_reason

As marked_for_close_reason, but reflects the underlying reason for closing this circuit.

Definition at line 190 of file circuit_st.h.

Referenced by circuit_about_to_free().

◆ marked_for_close_reason

int circuit_t::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 186 of file circuit_st.h.

Referenced by circuit_about_to_free().

◆ n_chan

channel_t* circuit_t::n_chan

◆ n_chan_cells

cell_queue_t circuit_t::n_chan_cells

◆ n_chan_create_cell

struct create_cell_t* circuit_t::n_chan_create_cell

For storage while n_chan is pending (state CIRCUIT_STATE_CHAN_WAIT).

Definition at line 142 of file circuit_st.h.

◆ n_circ_id

circid_t circuit_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 67 of file circuit_st.h.

Referenced by channel_note_destroy_pending(), circpad_estimate_circ_rtt_on_received(), circuit_dump_by_conn(), circuit_free_(), circuit_set_n_circid_chan(), circuitmux_find_map_entry(), format_cell_stats(), and MOCK_IMPL().

◆ n_delete_pending

unsigned int circuit_t::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 90 of file circuit_st.h.

Referenced by channel_note_destroy_pending(), circuit_set_n_circid_chan(), and MOCK_IMPL().

◆ n_hop

extend_info_t* circuit_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 76 of file circuit_st.h.

Referenced by circuit_get_all_pending_on_channel().

◆ p_delete_pending

unsigned int circuit_t::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 87 of file circuit_st.h.

Referenced by channel_note_destroy_pending(), circuit_set_p_circid_chan(), and MOCK_IMPL().

◆ package_window

int circuit_t::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 105 of file circuit_st.h.

Referenced by circuit_resume_edge_reading_helper(), and init_circuit_base().

◆ padding_info

struct circpad_machine_runtime_t* circuit_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 229 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(), and circpad_circuit_machineinfo_free_idx().

◆ padding_machine

const struct circpad_machine_spec_t* circuit_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 218 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().

◆ purpose

uint8_t circuit_t::purpose

◆ received_destroy

unsigned int circuit_t::received_destroy

True iff this circuit has received a DESTROY cell in either direction

Definition at line 93 of file circuit_st.h.

◆ send_randomness_after_n_cells

uint16_t circuit_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 116 of file circuit_st.h.

Referenced by circuit_reset_sendme_randomness(), and connection_edge_get_inbuf_bytes_to_package().

◆ sendme_last_digests

smartlist_t* circuit_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 136 of file circuit_st.h.

◆ state

uint8_t circuit_t::state

◆ streams_blocked_on_n_chan

unsigned int circuit_t::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 80 of file circuit_st.h.

Referenced by append_cell_to_circuit_queue(), circuit_queue_streams_are_blocked(), MOCK_IMPL(), and set_streams_blocked_on_circ().

◆ streams_blocked_on_p_chan

unsigned int circuit_t::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 83 of file circuit_st.h.

Referenced by append_cell_to_circuit_queue(), circuit_queue_streams_are_blocked(), MOCK_IMPL(), and set_streams_blocked_on_circ().

◆ testing_cell_stats

smartlist_t* circuit_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 201 of file circuit_st.h.

Referenced by circuit_clear_testing_cell_stats(), and sum_up_cell_stats_by_command().

◆ timestamp_began

struct timeval circuit_t::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 154 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().

◆ timestamp_created

struct timeval circuit_t::timestamp_created

This timestamp marks when the init_circuit_base constructor ran.

Definition at line 157 of file circuit_st.h.

Referenced by init_circuit_base(), and rep_hist_buffer_stats_add_circ().

◆ timestamp_dirty

time_t circuit_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 176 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().


The documentation for this struct was generated from the following file: