|
Tor 0.5.0.0-alpha-dev
|
#include <channel.h>
Public Types | |
| enum | { CHANNEL_NOT_CLOSING = 0 , CHANNEL_CLOSE_REQUESTED , CHANNEL_CLOSE_FROM_BELOW , CHANNEL_CLOSE_FOR_ERROR } |
| enum | { SCHED_CHAN_IDLE = 0 , SCHED_CHAN_WAITING_FOR_CELLS , SCHED_CHAN_WAITING_TO_WRITE , SCHED_CHAN_PENDING } |
Public Member Functions | |
| HT_ENTRY (channel_t) gidmap_node | |
| HANDLE_ENTRY (channel, channel_t) | |
| TOR_LIST_ENTRY (channel_t) next_with_same_id | |
Channel struct; see the channel_t typedef in or.h. A channel is an abstract interface for the OR-to-OR connection, similar to connection_or_t, but without the strong coupling to the underlying TLS implementation. They are constructed by calling a protocol-specific function to open a channel to a particular node, and once constructed support the abstract operations defined below.
| anonymous enum |
State variable for use by the scheduler
| HANDLE_ENTRY | ( | channel | , |
| channel_t | |||
| ) |
Handle entry for handle-based lookup
| HT_ENTRY | ( | channel_t | ) |
List entry for hashtable for global-identifier lookup.
| TOR_LIST_ENTRY | ( | channel_t | ) |
Linked list of channels with the same RSA identity digest, for use with the digest->channel map
| tor_addr_t addr_according_to_peer |
If not UNSPEC, the address that the peer says we have.
Definition at line 241 of file channel.h.
Referenced by channel_init(), and onionskin_answer().
| channel_cell_handler_fn_ptr cell_handler |
Registered handlers for incoming cells
Definition at line 326 of file channel.h.
Referenced by channel_get_cell_handler(), channel_process_cell(), and channel_set_cell_handlers().
| channel_usage_info_t channel_usage |
Has this channel ever been used for non-directory traffic? Used to decide what channels to pad, and when.
Definition at line 229 of file channel.h.
Referenced by channelpadding_decide_to_pad_channel(), circuit_send_first_onion_skin(), and circuit_update_channel_usage().
| circ_id_type_bitfield_t circ_id_type |
Circuit ID generation stuff for use by circuitbuild.c When we send CREATE cells along this connection, which half of the space should we use?
Definition at line 406 of file channel.h.
Referenced by channel_set_circid_type(), command_process_create_cell(), and get_unique_circ_id_by_chan().
| void(* close) (channel_t *) |
Close an open channel
Definition at line 319 of file channel.h.
Referenced by channel_mark_for_close(), and channel_tls_common_init().
| circuitmux_t* cmux |
Circuit mux for circuits sending on this channel
Definition at line 398 of file channel.h.
Referenced by channel_dump_statistics(), channel_flush_from_first_active_circuit(), channel_flush_some_cells(), channel_force_xfree(), channel_free_(), channel_more_to_flush(), channel_send_destroy(), channel_tls_common_init(), channel_tls_connect(), channel_unlink_all_circuits(), channelpadding_decide_to_pad_channel(), channelpadding_send_padding_cell_for_callback(), circuit_about_to_free(), circuit_about_to_free_atexit(), circuit_clear_cell_queue(), get_unique_circ_id_by_chan(), scheduler_compare_channels(), and update_circuit_on_cmux_().
| unsigned int currently_padding |
Cached value of our decision to pad (to avoid expensive checks during critical path statistics counting).
Definition at line 219 of file channel.h.
Referenced by channelpadding_decide_to_pad_channel().
| const char *(* describe_peer) (const channel_t *) |
Get a human-readable text description of the remote endpoint, for logging.
Definition at line 347 of file channel.h.
Referenced by channel_describe_peer(), and channel_tls_common_init().
| const char *(* describe_transport) (channel_t *) |
Describe the transport subclass for this channel
Definition at line 321 of file channel.h.
Referenced by channel_describe_transport(), and channel_tls_common_init().
| uint64_t dirreq_id |
Unique ID for measuring direct network status requests;vtunneled ones come over a circuit_t, which has a dirreq_id field as well, but is a distinct namespace.
Definition at line 454 of file channel.h.
Referenced by channel_flush_from_first_active_circuit(), channel_notify_flushed(), and handle_relay_msg().
| void(* dumpstats) (channel_t *, int) |
Optional method to dump transport-specific statistics on the channel
Definition at line 323 of file channel.h.
Referenced by channel_dump_transport_statistics().
| struct ed25519_public_key_t ed25519_identity |
Ed25519 key for the other side of this channel – or zeroes if we don't have an Ed25519 identity in mind for the other side, and it hasn't shown us one.
Note that this is the identity that we hope the other side has – not necessarily its true identity. Don't believe this identity unless authentication has happened.
Definition at line 389 of file channel.h.
Referenced by channel_remote_identity_matches(), channel_set_identity_digest(), connection_or_client_learned_peer_id(), connection_or_get_alleged_ed25519_id(), and connection_or_set_identity_digest().
| void(* free_fn) (channel_t *) |
Free a channel
Definition at line 317 of file channel.h.
Referenced by channel_force_xfree(), channel_free_(), and channel_tls_common_init().
| double(* get_overhead_estimate) (channel_t *) |
Ask the lower layer for an estimate of the average overhead for transmissions on this channel.
Definition at line 334 of file channel.h.
Referenced by channel_tls_common_init().
| int(* get_remote_addr) (const channel_t *, tor_addr_t *) |
| int(* get_transport_name) (channel_t *chan, char **transport_out) |
| uint64_t global_identifier |
Globally unique ID number for a channel over the lifetime of a Tor process. This may not be 0.
Definition at line 198 of file channel.h.
Referenced by channel_add_to_digest_map(), channel_change_state_(), channel_clear_identity_digest(), channel_clear_remote_end(), channel_close_from_lower_layer(), channel_dump_statistics(), channel_find_by_global_id(), channel_force_xfree(), channel_free_(), channel_init(), channel_listener_process_incoming(), channel_listener_queue_incoming(), channel_mark_for_close(), channel_process_cell(), channel_register(), channel_remove_from_digest_map(), channel_send_destroy(), channel_set_identity_digest(), channel_tls_connect(), channel_tls_get_overhead_estimate_method(), channel_tls_handle_incoming(), channel_tls_has_queued_writes_method(), channel_tls_matches_extend_info_method(), channel_tls_matches_target_method(), channel_tls_update_marks(), channel_tls_write_cell_method(), channel_tls_write_packed_cell_method(), channel_tls_write_var_cell_method(), channel_write_packed_cell(), channelpadding_reduce_padding_on_channel(), channelpadding_send_padding_cell_for_callback(), channelpadding_update_padding_for_channel(), circpad_estimate_circ_rtt_on_received(), circpad_machine_schedule_padding(), circuit_chan_publish(), circuit_get_by_circid_channel_impl(), circuitmux_attach_circuit(), circuitmux_detach_circuit(), circuitmux_find_map_entry(), command_process_create_cell(), connection_free_minimal(), format_cell_stats(), run_connection_housekeeping(), and scheduler_set_channel_state().
| unsigned int has_been_open |
has this channel ever been open?
Definition at line 204 of file channel.h.
Referenced by channel_change_state_open(), channel_closed(), and channel_init().
| int(* has_queued_writes) (channel_t *) |
Check if the lower layer has queued writes
Definition at line 349 of file channel.h.
Referenced by channel_has_queued_writes(), channel_tls_common_init(), channelpadding_decide_to_pad_channel(), and channelpadding_send_padding_cell_for_callback().
| char identity_digest[DIGEST_LEN] |
Hash of the public RSA key for the other side's RSA identity key – or zeroes if we don't have an RSA identity in mind for the other side, and it hasn't shown us one.
Note that this is the RSA identity that we hope the other side has – not necessarily its true identity. Don't believe this identity unless authentication has happened.
Definition at line 379 of file channel.h.
Referenced by channel_add_to_digest_map(), channel_change_state_(), channel_clear_identity_digest(), channel_clear_remote_end(), channel_do_open_actions(), channel_dump_statistics(), channel_get_for_extend(), channel_register(), channel_remote_identity_matches(), channel_remove_from_digest_map(), channel_set_identity_digest(), channel_unregister(), channelpadding_send_padding_cell_for_callback(), channelpadding_update_padding_for_channel(), circuit_get_all_pending_on_channel(), circuit_send_first_onion_skin(), command_process_create_cell(), connection_exit_begin_conn(), and pathbias_count_build_attempt().
| unsigned int is_bad_for_new_circs |
True iff this channel shouldn't get any new circs attached to it, because the connection is too old, or because there's a better one. More generally, this flag is used to note an unhealthy connection; for example, if a bad connection fails we shouldn't assume that the router itself has a problem.
Definition at line 420 of file channel.h.
Referenced by channel_is_bad_for_new_circs(), channel_mark_bad_for_new_circs(), and circuit_build_failed().
| int(* is_canonical) (channel_t *) |
Ask the lower layer if this is 'canonical', for a transport-specific definition of canonical.
Definition at line 354 of file channel.h.
Referenced by channel_check_for_duplicates(), channel_is_canonical(), channel_tls_common_init(), circuit_deliver_create_cell(), and circuit_n_chan_done().
| unsigned int is_canonical_to_peer |
Is our peer likely to consider this channel canonical?
Definition at line 225 of file channel.h.
Referenced by channel_check_for_duplicates(), and channel_is_better().
| unsigned int is_client |
True iff we have decided that the other end of this connection is a client or bridge relay. Connections with this flag set should never be used to satisfy an EXTEND request.
Definition at line 425 of file channel.h.
Referenced by channel_clear_client(), channel_is_client(), and channel_mark_client().
| unsigned int is_incoming |
Set if the channel was initiated remotely (came from a listener)
Definition at line 428 of file channel.h.
Referenced by channel_is_incoming(), channel_is_outgoing(), channel_mark_incoming(), and channel_mark_outgoing().
| unsigned int is_local |
Set by lower layer if this is local; i.e., everything it communicates with for this channel returns true for is_local_addr(). This is used to decide whether to declare reachability when we receive something on this channel in circuitbuild.c
Definition at line 435 of file channel.h.
Referenced by channel_is_local(), channel_mark_local(), and channel_mark_remote().
| ratelim_t last_warned_circ_ids_exhausted |
Have we logged a warning about circID exhaustion on this channel? If so, when?
Definition at line 439 of file channel.h.
Referenced by channel_init(), and get_unique_circ_id_by_chan().
| uint32_t magic |
Magic number for type-checking cast macros
Definition at line 184 of file channel.h.
Referenced by channel_mark_as_used_for_origin_circuit(), channel_tls_common_init(), and channel_tls_from_base().
| int(* matches_extend_info) (channel_t *, extend_info_t *) |
Check if this channel matches a specified extend_info_t
Definition at line 356 of file channel.h.
Referenced by channel_matches_extend_info(), and channel_tls_common_init().
| int(* matches_target) (channel_t *, const tor_addr_t *) |
Check if this channel matches a target address when extending
Definition at line 358 of file channel.h.
Referenced by channel_matches_target_addr_for_extend(), and channel_tls_common_init().
| uint64_t n_cells_recved |
Channel counters for cells and bytes we have received.
Definition at line 457 of file channel.h.
Referenced by channel_dump_statistics(), and channel_process_cell().
| uint64_t n_cells_xmitted |
Channel counters for cells and bytes we have sent.
Definition at line 459 of file channel.h.
Referenced by channel_dump_statistics(), and write_packed_cell().
| monotime_coarse_t next_padding_time |
When should we send a cell for netflow padding? 0 means no padding is scheduled.
Definition at line 233 of file channel.h.
Referenced by channel_timestamp_active(), channel_timestamp_recv(), channel_timestamp_xmit(), and channelpadding_send_padding_cell_for_callback().
| unsigned int num_n_circuits |
For how many circuits are we n_chan? What about p_chan?
Definition at line 411 of file channel.h.
Referenced by channel_num_circuits(), channel_unlink_all_circuits(), and get_unique_circ_id_by_chan().
| unsigned int padding_enabled |
This field indicates if the other side has enabled or disabled padding via either the link protocol version or channelpadding_negotiate cells.
Clients can override this with ConnectionPadding in torrc to disable or force padding to relays, but relays cannot override the client's request.
Definition at line 215 of file channel.h.
Referenced by channel_do_open_actions(), channelpadding_decide_to_pad_channel(), channelpadding_disable_padding_on_channel(), channelpadding_reduce_padding_on_channel(), channelpadding_update_padding_for_channel(), and write_packed_cell().
| uint16_t padding_timeout_low_ms |
These two fields specify the minimum and maximum negotiated timeout values for inactivity (send or receive) before we decide to pad a channel. These fields can be set either via a PADDING_NEGOTIATE cell, or the torrc option ReducedConnectionPadding. The consensus parameters nf_ito_low and nf_ito_high are used to ensure that padding can only be negotiated to be less frequent than what is specified in the consensus. (This is done to prevent wingnut clients from requesting excessive padding).
The actual timeout value is randomly chosen between these two values as per the table in channelpadding_get_netflow_inactive_timeout_ms(), after ensuring that these values do not specify lower timeouts than the consensus parameters.
If these are 0, we have not negotiated or specified custom padding times, and instead use consensus defaults.
Definition at line 260 of file channel.h.
Referenced by channelpadding_get_netflow_inactive_timeout_ms(), channelpadding_reduce_padding_on_channel(), and channelpadding_update_padding_for_channel().
| struct tor_timer_t* padding_timer |
The callback pointer for the padding callbacks
Definition at line 236 of file channel.h.
Referenced by channel_force_xfree(), channel_free_(), and channelpadding_schedule_padding().
| unsigned int pending_padding_callback |
Is there a pending netflow padding callback?
Definition at line 222 of file channel.h.
Referenced by channelpadding_decide_to_pad_channel(), channelpadding_schedule_padding(), and channelpadding_send_padding_cell_for_callback().
| enum { ... } reason_for_closing |
Why did we close?
Referenced by channel_change_state_(), channel_close_for_error(), channel_close_from_lower_layer(), channel_closed(), channel_mark_for_close(), channel_tls_connect(), circuit_unlink_all_from_channel(), and pathbias_check_close().
| unsigned char registered |
Should we expect to see this channel in the channel lists?
Definition at line 201 of file channel.h.
Referenced by channel_change_state_(), channel_clear_identity_digest(), channel_clear_remote_end(), channel_free_(), channel_register(), channel_set_identity_digest(), and channel_unregister().
| int sched_heap_idx |
Heap index for use by the scheduler
Definition at line 296 of file channel.h.
Referenced by channel_init(), scheduler_channel_has_waiting_cells(), and scheduler_channel_wants_writes().
| enum { ... } scheduler_state |
State variable for use by the scheduler
Referenced by channel_init(), scheduler_channel_doesnt_want_writes(), scheduler_channel_has_waiting_cells(), scheduler_channel_wants_writes(), and scheduler_set_channel_state().
| channel_state_t state |
Current channel state
Definition at line 193 of file channel.h.
Referenced by channel_add_to_digest_map(), channel_change_state_(), channel_dump_statistics(), channel_num_cells_writeable(), channel_register(), channel_remove_from_digest_map(), channel_send_destroy(), channel_tls_common_init(), channelpadding_decide_to_pad_channel(), channelpadding_send_padding_cell_for_callback(), and circuit_deliver_create_cell().
| struct channel_handle_t* timer_handle |
The handle to this channel (to free on canceled timers)
Definition at line 238 of file channel.h.
Referenced by channel_force_xfree(), channel_free_(), and channelpadding_schedule_padding().
| time_t timestamp_client |
Channel timestamps for cell channels
Definition at line 442 of file channel.h.
Referenced by channel_dump_statistics(), channel_timestamp_client(), and channel_when_last_client().
| time_t timestamp_created |
Timestamps for both cell channels and listeners
Definition at line 299 of file channel.h.
Referenced by channel_dump_statistics(), channel_timestamp_created(), channel_when_created(), and get_unique_circ_id_by_chan().
| time_t timestamp_last_had_circuits |
Timestamp for run_connection_housekeeping(). We update this once a second when we run housekeeping and find a circuit on this channel, and whenever we add a circuit to the channel.
Definition at line 449 of file channel.h.
Referenced by channel_init(), circuit_set_n_circid_chan(), circuit_set_p_circid_chan(), and run_connection_housekeeping().
| time_t timestamp_recv |
Cell received from lower layer
Definition at line 443 of file channel.h.
Referenced by channel_dump_statistics(), and channel_timestamp_recv().
| monotime_coarse_t timestamp_xfer |
This is a monotonic timestamp that marks when we believe the channel has actually sent or received data to/from the wire. Right now, it is used to determine when we should send a padding cell for channelpadding.
XXX: Are we setting timestamp_xfer_ms in the right places to accurately reflect actual network data transfer? Or might this be very wrong wrt when bytes actually go on the wire?
Definition at line 312 of file channel.h.
Referenced by channel_timestamp_active(), channel_timestamp_recv(), channel_timestamp_xmit(), and channelpadding_send_padding_cell_for_callback().
| time_t timestamp_xmit |
Cell sent to lower layer
Definition at line 444 of file channel.h.
Referenced by channel_dump_statistics(), channel_timestamp_xmit(), and channel_when_last_xmit().
| int(* write_packed_cell) (channel_t *, packed_cell_t *) |
Write a packed cell to an open channel
Definition at line 366 of file channel.h.
Referenced by channel_tls_common_init(), and write_packed_cell().
| int(* write_var_cell) (channel_t *, var_cell_t *) |
Write a variable-length cell to an open channel
Definition at line 368 of file channel.h.
Referenced by channel_tls_common_init().