tor  0.4.2.0-alpha-dev
Data Fields
connection_t Struct Reference

#include <connection_st.h>

Data Fields

uint32_t magic
 
uint8_t state
 
unsigned int type:5
 
unsigned int purpose:5
 
unsigned int read_blocked_on_bw:1
 
unsigned int write_blocked_on_bw:1
 
unsigned int hold_open_until_flushed:1
 
unsigned int inbuf_reached_eof:1
 
unsigned int in_flushed_some:1
 
unsigned int in_connection_handle_write:1
 
unsigned int linked:1
 
unsigned int reading_from_linked_conn:1
 
unsigned int writing_to_linked_conn:1
 
unsigned int active_on_link:1
 
unsigned int linked_conn_is_closed:1
 
unsigned int proxy_state:4
 
tor_socket_t s
 
int conn_array_index
 
struct event * read_event
 
struct event * write_event
 
struct buf_t * inbuf
 
struct buf_t * outbuf
 
size_t outbuf_flushlen
 
time_t timestamp_last_read_allowed
 
time_t timestamp_last_write_allowed
 
time_t timestamp_created
 
int socket_family
 
tor_addr_t addr
 
uint16_t port
 
uint16_t marked_for_close
 
const char * marked_for_close_file
 
char * address
 
struct connection_tlinked_conn
 
uint64_t global_identifier
 
uint32_t n_read_conn_bw
 
uint32_t n_written_conn_bw
 

Detailed Description

Description of a connection to another host or process, and associated data.

A connection is named based on what it's connected to – an "OR connection" has a Tor node on the other end, an "exit connection" has a website or other server on the other end, and an "AP connection" has an application proxy (and thus a user) on the other end.

Every connection has a type and a state. Connections never change their type, but can go through many state changes in their lifetime.

Every connection has two associated input and output buffers. Listeners don't use them. For non-listener connections, incoming data is appended to conn->inbuf, and outgoing data is taken from conn->outbuf. Connections differ primarily in the functions called to fill and drain these buffers.

Definition at line 40 of file connection_st.h.

Field Documentation

◆ active_on_link

unsigned int connection_t::active_on_link

True iff we're currently able to read on the linked conn, and our read_event should be made active with libevent.

Definition at line 78 of file connection_st.h.

Referenced by connection_start_reading_from_linked_conn(), and connection_stop_reading_from_linked_conn().

◆ addr

tor_addr_t connection_t::addr

IP that socket "s" is directly connected to; may be the IP address for a proxy or pluggable transport, see "address" for the address of the final destination.

Definition at line 107 of file connection_st.h.

Referenced by conn_get_proxy_type(), connection_ap_handshake_attach_circuit(), connection_exit_connect(), connection_is_rate_limited(), connection_send_socks5_connect(), get_proxy_addrport(), and retry_listener_ports().

◆ address

char* connection_t::address

FQDN (or IP) and port of the final destination for this connection; this is always the remote address, it is passed to a proxy or pluggable transport if one in use. See "addr" and "port" for the address that socket "s" is directly connected to. strdup into this, because free_connection() frees it.

Definition at line 120 of file connection_st.h.

Referenced by connection_exit_begin_resolve(), MOCK_IMPL(), and retry_listener_ports().

◆ conn_array_index

int connection_t::conn_array_index

Index into the global connection array.

Definition at line 89 of file connection_st.h.

Referenced by circuit_dump_by_conn(), connection_add_impl(), connection_is_moribund(), and connection_unlink().

◆ global_identifier

uint64_t connection_t::global_identifier

Unique identifier for this connection on this Tor instance.

Definition at line 130 of file connection_st.h.

Referenced by control_event_conn_bandwidth(), and record_num_bytes_transferred_impl().

◆ hold_open_until_flushed

unsigned int connection_t::hold_open_until_flushed

Despite this connection's being marked for close, do we flush it before closing it?

Definition at line 56 of file connection_st.h.

Referenced by connection_expire_held_open(), and connection_may_write_to_buf().

◆ in_connection_handle_write

unsigned int connection_t::in_connection_handle_write

True if connection_handle_write is currently running on this connection.

Definition at line 66 of file connection_st.h.

◆ in_flushed_some

unsigned int connection_t::in_flushed_some

Set to 1 when we're inside connection_flushed_some to keep us from calling connection_handle_write() recursively.

Definition at line 63 of file connection_st.h.

Referenced by connection_flushed_some().

◆ inbuf

struct buf_t* connection_t::inbuf

◆ inbuf_reached_eof

unsigned int connection_t::inbuf_reached_eof

Boolean: did read() return 0 on this conn?

Definition at line 59 of file connection_st.h.

◆ linked

unsigned int connection_t::linked

◆ linked_conn

struct connection_t* connection_t::linked_conn

Another connection that's connected to this one in lieu of a socket.

Definition at line 127 of file connection_st.h.

Referenced by circuit_get_streams_max_data_age(), connection_dir_is_anonymous(), connection_link_connections(), connection_should_read_from_linked_conn(), connection_unlink(), and MOCK_IMPL().

◆ linked_conn_is_closed

unsigned int connection_t::linked_conn_is_closed

True iff we've called connection_close_immediate() on this linked connection.

Definition at line 81 of file connection_st.h.

Referenced by connection_dir_is_anonymous().

◆ magic

uint32_t connection_t::magic

For memory debugging: must equal one of *_CONNECTION_MAGIC.

Definition at line 41 of file connection_st.h.

Referenced by connection_ap_mark_as_pending_circuit_(), connection_dir_is_anonymous(), connection_free_minimal(), TO_CONTROL_CONN(), TO_DIR_CONN(), TO_EDGE_CONN(), TO_LISTENER_CONN(), and TO_OR_CONN().

◆ marked_for_close

uint16_t connection_t::marked_for_close

◆ marked_for_close_file

const char* connection_t::marked_for_close_file

For debugging: in which file were we marked for close?

Definition at line 118 of file connection_st.h.

◆ n_read_conn_bw

uint32_t connection_t::n_read_conn_bw

Bytes read since last call to control_event_conn_bandwidth_used(). Only used if we're configured to emit CONN_BW events.

Definition at line 134 of file connection_st.h.

Referenced by control_event_conn_bandwidth().

◆ n_written_conn_bw

uint32_t connection_t::n_written_conn_bw

Bytes written since last call to control_event_conn_bandwidth_used(). Only used if we're configured to emit CONN_BW events.

Definition at line 138 of file connection_st.h.

Referenced by control_event_conn_bandwidth().

◆ outbuf

struct buf_t* connection_t::outbuf

Buffer holding data to write over this connection.

Definition at line 94 of file connection_st.h.

Referenced by conn_get_buffer_age(), connection_buf_add_buf(), connection_should_read_from_linked_conn(), and MOCK_IMPL().

◆ outbuf_flushlen

size_t connection_t::outbuf_flushlen

How much data should we try to flush from the outbuf?

Definition at line 96 of file connection_st.h.

Referenced by connection_bucket_write_limit(), connection_outbuf_too_full(), connection_wants_to_flush(), and connection_write_to_buf_commit().

◆ port

uint16_t connection_t::port

If non-zero, port that socket "s" is directly connected to; may be the port for a proxy or pluggable transport, see "address" for the port at the final destination.

Definition at line 111 of file connection_st.h.

Referenced by conn_get_proxy_type(), connection_ap_handshake_attach_circuit(), connection_exit_connect(), connection_send_socks5_connect(), get_proxy_addrport(), MOCK_IMPL(), record_num_bytes_transferred_impl(), and retry_listener_ports().

◆ proxy_state

unsigned int connection_t::proxy_state

CONNECT/SOCKS proxy client handshake state (for outgoing connections).

Definition at line 84 of file connection_st.h.

◆ purpose

unsigned int connection_t::purpose

◆ read_blocked_on_bw

unsigned int connection_t::read_blocked_on_bw

Boolean: should we start reading again once the bandwidth throttler allows it?

Definition at line 51 of file connection_st.h.

Referenced by connection_read_bw_exhausted(), and reenable_blocked_connections_cb().

◆ read_event

struct event* connection_t::read_event

Libevent event structure.

Definition at line 91 of file connection_st.h.

Referenced by connection_is_reading(), connection_unregister_events(), MOCK_IMPL(), and set_streams_blocked_on_circ().

◆ reading_from_linked_conn

unsigned int connection_t::reading_from_linked_conn

True iff we'd like to be notified about read events from the linked conn.

Definition at line 73 of file connection_st.h.

Referenced by connection_is_reading(), connection_should_read_from_linked_conn(), connection_unlink(), and MOCK_IMPL().

◆ s

tor_socket_t connection_t::s

Our socket; set to TOR_INVALID_SOCKET if this connection is closed, or has no socket.

Definition at line 88 of file connection_st.h.

Referenced by assert_all_pending_dns_resolves_ok(), conn_write_callback(), connection_add_impl(), connection_expire_held_open(), connection_finished_connecting(), connection_link_connections(), dnsserv_configure_listener(), and MOCK_IMPL().

◆ socket_family

int connection_t::socket_family

Address family of this connection's socket. Usually AF_INET, but it can also be AF_UNIX, or AF_INET6

Definition at line 105 of file connection_st.h.

Referenced by check_sockaddr_family_match(), and retry_listener_ports().

◆ state

uint8_t connection_t::state

◆ timestamp_created

time_t connection_t::timestamp_created

When was this connection_t created?

Definition at line 103 of file connection_st.h.

Referenced by connection_ap_handshake_attach_circuit(), and connection_or_single_set_badness_().

◆ timestamp_last_read_allowed

time_t connection_t::timestamp_last_read_allowed

When was the last time libevent said we could read?

Definition at line 98 of file connection_st.h.

Referenced by connection_handle_read_impl().

◆ timestamp_last_write_allowed

time_t connection_t::timestamp_last_write_allowed

When was the last time libevent said we could write?

Definition at line 100 of file connection_st.h.

Referenced by connection_expire_held_open().

◆ type

unsigned int connection_t::type

What kind of connection is this?

Definition at line 45 of file connection_st.h.

Referenced by ap_stream_wants_exit_attention(), assert_connection_ok(), circuit_detach_stream(), connection_about_to_close_connection(), connection_add_impl(), connection_ap_handshake_process_socks(), connection_ap_handshake_send_resolve(), connection_bucket_read_limit(), connection_bucket_write_limit(), connection_check_event(), connection_counts_as_relayed_traffic(), connection_dir_finished_connecting(), connection_dir_finished_flushing(), connection_dir_process_inbuf(), connection_dns_remove(), connection_edge_finished_connecting(), connection_edge_package_raw_inbuf(), connection_expire_held_open(), connection_ext_or_transition(), connection_finished_connecting(), connection_finished_flushing(), connection_flushed_some(), connection_free_minimal(), connection_handle_read_impl(), connection_init_accepted_conn(), connection_is_listener(), connection_mark_all_noncontrol_connections(), connection_mark_all_noncontrol_listeners(), connection_mark_for_close_(), connection_or_get_state_description(), connection_or_nonopen_was_started_here(), connection_process_inbuf(), connection_reached_eof(), connection_state_is_connecting(), connection_state_is_open(), connection_unlink(), control_event_conn_bandwidth(), directory_handle_command(), dnsserv_close_listener(), dnsserv_configure_listener(), get_stream(), MOCK_IMPL(), oos_victim_comparator(), record_num_bytes_transferred_impl(), and retry_listener_ports().

◆ write_blocked_on_bw

unsigned int connection_t::write_blocked_on_bw

Boolean: should we start writing again once the bandwidth throttler allows writes?

Definition at line 53 of file connection_st.h.

Referenced by connection_write_bw_exhausted(), and reenable_blocked_connections_cb().

◆ write_event

struct event* connection_t::write_event

Libevent event structure.

Definition at line 92 of file connection_st.h.

Referenced by connection_is_writing(), connection_write_to_buf_commit(), and MOCK_IMPL().

◆ writing_to_linked_conn

unsigned int connection_t::writing_to_linked_conn

True iff we're willing to write to the linked conn.

Definition at line 75 of file connection_st.h.

Referenced by connection_is_writing(), connection_should_read_from_linked_conn(), and MOCK_IMPL().


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