Tor
0.4.7.0-alpha-dev
|
Header file for connection.c. More...
Go to the source code of this file.
Data Structures | |
struct | listener_replacement_t |
Macros | |
#define | CONN_TYPE_MIN_ 3 |
#define | CONN_TYPE_OR_LISTENER 3 |
#define | CONN_TYPE_OR 4 |
#define | CONN_TYPE_EXIT 5 |
#define | CONN_TYPE_AP_LISTENER 6 |
#define | CONN_TYPE_AP 7 |
#define | CONN_TYPE_DIR_LISTENER 8 |
#define | CONN_TYPE_DIR 9 |
#define | CONN_TYPE_CONTROL_LISTENER 11 |
#define | CONN_TYPE_CONTROL 12 |
#define | CONN_TYPE_AP_TRANS_LISTENER 13 |
#define | CONN_TYPE_AP_NATD_LISTENER 14 |
#define | CONN_TYPE_AP_DNS_LISTENER 15 |
#define | CONN_TYPE_EXT_OR 16 |
#define | CONN_TYPE_EXT_OR_LISTENER 17 |
#define | CONN_TYPE_AP_HTTP_CONNECT_LISTENER 18 |
#define | CONN_TYPE_METRICS_LISTENER 19 |
#define | CONN_TYPE_METRICS 20 |
#define | CONN_TYPE_MAX_ 21 |
#define | PROXY_INFANT 1 |
#define | PROXY_HTTPS_WANT_CONNECT_OK 2 |
#define | PROXY_SOCKS4_WANT_CONNECT_OK 3 |
#define | PROXY_SOCKS5_WANT_AUTH_METHOD_NONE 4 |
#define | PROXY_SOCKS5_WANT_AUTH_METHOD_RFC1929 5 |
#define | PROXY_SOCKS5_WANT_AUTH_RFC1929_OK 6 |
#define | PROXY_SOCKS5_WANT_CONNECT_OK 7 |
#define | PROXY_HAPROXY_WAIT_FOR_FLUSH 8 |
#define | PROXY_CONNECTED 9 |
#define | LISTENER_STATE_READY 0 |
#define | connection_free(conn) FREE_AND_NULL(struct connection_t, connection_free_, (conn)) |
#define | connection_mark_for_close(c) connection_mark_for_close_((c), __LINE__, SHORT_FILE__) |
#define | connection_mark_for_close_internal(c) connection_mark_for_close_internal_((c), __LINE__, SHORT_FILE__) |
#define | connection_mark_and_flush_internal_(c, line, file) |
#define | connection_mark_and_flush_internal(c) connection_mark_and_flush_internal_((c), __LINE__, SHORT_FILE__) |
#define | connection_mark_and_flush_(c, line, file) |
#define | connection_mark_and_flush(c) connection_mark_and_flush_((c), __LINE__, SHORT_FILE__) |
#define | MAX_SOCKS5_AUTH_FIELD_SIZE 255 |
#define | MAX_SOCKS5_AUTH_SIZE_TOTAL 2*MAX_SOCKS5_AUTH_FIELD_SIZE |
#define | CONN_LEN_AND_FREE_TEMPLATE(sl) |
#define | connection_speaks_cells(conn) (((conn)->type == CONN_TYPE_OR) || 0) |
#define | CONN_LOG_PROTECT(conn, stmt) |
Functions | |
struct listener_connection_t * | TO_LISTENER_CONN (struct connection_t *) |
const struct listener_connection_t * | CONST_TO_LISTENER_CONN (const struct connection_t *) |
const char * | conn_type_to_string (int type) |
const char * | conn_state_to_string (int type, int state) |
int | conn_listener_type_supports_af_unix (int type) |
const char * | connection_describe (const connection_t *conn) |
const char * | connection_describe_peer (const connection_t *conn) |
struct dir_connection_t * | dir_connection_new (int socket_family) |
struct or_connection_t * | or_connection_new (int type, int socket_family) |
struct edge_connection_t * | edge_connection_new (int type, int socket_family) |
struct entry_connection_t * | entry_connection_new (int type, int socket_family) |
struct control_connection_t * | control_connection_new (int socket_family) |
struct listener_connection_t * | listener_connection_new (int type, int socket_family) |
struct connection_t * | connection_new (int type, int socket_family) |
int | connection_init_accepted_conn (struct connection_t *conn, const struct listener_connection_t *listener) |
void | connection_link_connections (struct connection_t *conn_a, struct connection_t *conn_b) |
void | connection_free_ (struct connection_t *conn) |
void | connection_free_all (void) |
void | connection_about_to_close_connection (struct connection_t *conn) |
void | connection_close_immediate (struct connection_t *conn) |
void | connection_mark_for_close_ (struct connection_t *conn, int line, const char *file) |
void | connection_mark_for_close_internal_ (struct connection_t *conn, int line, const char *file) |
void | connection_expire_held_open (void) |
int | connection_connect (struct connection_t *conn, const char *address, const struct tor_addr_t *addr, uint16_t port, int *socket_error) |
int | connection_proxy_connect (struct connection_t *conn, int type) |
int | connection_read_proxy_handshake (struct connection_t *conn) |
void | log_failed_proxy_connection (struct connection_t *conn) |
int | get_proxy_addrport (struct tor_addr_t *addr, uint16_t *port, int *proxy_type, int *is_pt_out, const struct connection_t *conn) |
int | retry_all_listeners (struct smartlist_t *new_conns, int close_all_noncontrol) |
void | connection_mark_all_noncontrol_listeners (void) |
void | connection_mark_all_noncontrol_connections (void) |
ssize_t | connection_bucket_write_limit (struct connection_t *conn, time_t now) |
bool | connection_dir_is_global_write_low (const struct connection_t *conn, size_t attempt) |
void | connection_bucket_init (void) |
void | connection_bucket_adjust (const struct or_options_t *options) |
void | connection_bucket_refill_all (time_t now, uint32_t now_ts) |
void | connection_read_bw_exhausted (struct connection_t *conn, bool is_global_bw) |
void | connection_write_bw_exhausted (struct connection_t *conn, bool is_global_bw) |
void | connection_consider_empty_read_buckets (struct connection_t *conn) |
void | connection_consider_empty_write_buckets (struct connection_t *conn) |
int | connection_handle_read (struct connection_t *conn) |
int | connection_buf_get_bytes (char *string, size_t len, struct connection_t *conn) |
int | connection_buf_get_line (struct connection_t *conn, char *data, size_t *data_len) |
int | connection_fetch_from_buf_http (struct connection_t *conn, char **headers_out, size_t max_headerlen, char **body_out, size_t *body_used, size_t max_bodylen, int force_complete) |
int | connection_wants_to_flush (struct connection_t *conn) |
int | connection_outbuf_too_full (struct connection_t *conn) |
int | connection_handle_write (struct connection_t *conn, int force) |
int | connection_flush (struct connection_t *conn) |
void | connection_write_to_buf_impl_ (const char *string, size_t len, struct connection_t *conn, int zlib) |
static void | connection_buf_add (const char *string, size_t len, struct connection_t *conn) |
void | connection_dir_buf_add (const char *string, size_t len, struct dir_connection_t *dir_conn, int done) |
void | connection_buf_add_compress (const char *string, size_t len, struct dir_connection_t *conn, int done) |
void | connection_buf_add_buf (struct connection_t *conn, struct buf_t *buf) |
size_t | connection_get_inbuf_len (struct connection_t *conn) |
size_t | connection_get_outbuf_len (struct connection_t *conn) |
struct connection_t * | connection_get_by_global_id (uint64_t id) |
struct connection_t * | connection_get_by_type (int type) |
struct connection_t * | connection_get_by_type_nonlinked (int type) |
struct connection_t * | connection_get_by_type_addr_port_purpose (int type, const struct tor_addr_t *addr, uint16_t port, int purpose) |
struct connection_t * | connection_get_by_type_state (int type, int state) |
struct connection_t * | connection_get_by_type_state_rendquery (int type, int state, const char *rendquery) |
struct smartlist_t * | connection_list_by_type_state (int type, int state) |
struct smartlist_t * | connection_list_by_type_purpose (int type, int purpose) |
struct smartlist_t * | connection_dir_list_by_purpose_and_resource (int purpose, const char *resource) |
struct smartlist_t * | connection_dir_list_by_purpose_resource_and_state (int purpose, const char *resource, int state) |
static int | connection_dir_count_by_purpose_and_resource (int purpose, const char *resource) |
static int | connection_dir_count_by_purpose_resource_and_state (int purpose, const char *resource, int state) |
int | any_other_active_or_conns (const struct or_connection_t *this_conn) |
int | connection_is_listener (struct connection_t *conn) |
int | connection_state_is_open (struct connection_t *conn) |
int | connection_state_is_connecting (struct connection_t *conn) |
char * | alloc_http_authenticator (const char *authenticator) |
void | assert_connection_ok (struct connection_t *conn, time_t now) |
int | connection_or_nonopen_was_started_here (struct or_connection_t *conn) |
void | connection_dump_buffer_mem_stats (int severity) |
void | clock_skew_warning (const struct connection_t *conn, long apparent_skew, int trusted, log_domain_mask_t domain, const char *received, const char *source) |
int | connection_is_moribund (struct connection_t *conn) |
void | connection_check_oos (int n_socks, int failed) |
Header file for connection.c.
Definition in file connection.h.
#define CONN_LEN_AND_FREE_TEMPLATE | ( | sl | ) |
Definition at line 301 of file connection.h.
#define CONN_LOG_PROTECT | ( | conn, | |
stmt | |||
) |
Execute the statement stmt, which may log events concerning the connection conn. To prevent infinite loops, disable log messages being sent to controllers if conn is a control connection.
Stmt must not contain any return or goto statements.
Definition at line 367 of file connection.h.
#define CONN_TYPE_AP 7 |
A SOCKS proxy connection from the user application to the onion proxy.
Definition at line 51 of file connection.h.
#define CONN_TYPE_AP_DNS_LISTENER 15 |
Type for sockets listening for DNS requests.
Definition at line 68 of file connection.h.
#define CONN_TYPE_AP_HTTP_CONNECT_LISTENER 18 |
Type for sockets listening for HTTP CONNECT tunnel connections.
Definition at line 75 of file connection.h.
#define CONN_TYPE_AP_LISTENER 6 |
Type for sockets listening for SOCKS connections.
Definition at line 48 of file connection.h.
#define CONN_TYPE_AP_NATD_LISTENER 14 |
Type for sockets listening for transparent connections redirected by natd.
Definition at line 66 of file connection.h.
#define CONN_TYPE_AP_TRANS_LISTENER 13 |
Type for sockets listening for transparent connections redirected by pf or netfilter.
Definition at line 63 of file connection.h.
#define CONN_TYPE_CONTROL 12 |
Type for connections from user interface process.
Definition at line 60 of file connection.h.
#define CONN_TYPE_CONTROL_LISTENER 11 |
Type for listening for connections from user interface process.
Definition at line 58 of file connection.h.
#define CONN_TYPE_DIR 9 |
Type for HTTP connections to the directory server.
Definition at line 55 of file connection.h.
#define CONN_TYPE_DIR_LISTENER 8 |
Type for sockets listening for HTTP connections to the directory server.
Definition at line 53 of file connection.h.
#define CONN_TYPE_EXIT 5 |
A TCP connection from an onion router to a stream's destination.
Definition at line 46 of file connection.h.
#define CONN_TYPE_EXT_OR 16 |
Type for connections from the Extended ORPort.
Definition at line 71 of file connection.h.
#define CONN_TYPE_EXT_OR_LISTENER 17 |
Type for sockets listening for Extended ORPort connections.
Definition at line 73 of file connection.h.
#define CONN_TYPE_METRICS 20 |
Type for connections from metrics listener.
Definition at line 79 of file connection.h.
#define CONN_TYPE_METRICS_LISTENER 19 |
Type for sockets listening for Metrics query connections.
Definition at line 77 of file connection.h.
#define CONN_TYPE_OR 4 |
A bidirectional TLS connection transmitting a sequence of cells. May be from an OR to an OR, or from an OP to an OR.
Definition at line 44 of file connection.h.
#define CONN_TYPE_OR_LISTENER 3 |
Type for sockets listening for OR connections.
Definition at line 41 of file connection.h.
#define connection_mark_and_flush_ | ( | c, | |
line, | |||
file | |||
) |
Mark 'c' for close, but try to hold it open until all the data is written.
Definition at line 179 of file connection.h.
#define connection_mark_and_flush_internal_ | ( | c, | |
line, | |||
file | |||
) |
Mark 'c' for close, but try to hold it open until all the data is written. Use the _internal versions of connection_mark_for_close; this should be called when you either are sure that if this is an or_connection_t the controlling channel has been notified (e.g. with connection_or_notify_error()), or you actually are the connection_or_close_for_error() or connection_or_close_normally function. For all other cases, use connection_mark_and_flush() instead, which checks for struct or_connection_t properly, instead. See below.
Definition at line 166 of file connection.h.
#define LISTENER_STATE_READY 0 |
State for any listener connection.
Definition at line 108 of file connection.h.
#define MAX_SOCKS5_AUTH_FIELD_SIZE 255 |
Maximum size of information that we can fit into SOCKS5 username or password fields.
Definition at line 211 of file connection.h.
#define MAX_SOCKS5_AUTH_SIZE_TOTAL 2*MAX_SOCKS5_AUTH_FIELD_SIZE |
Total maximum size of information that we can fit into SOCKS5 username and password fields.
Definition at line 215 of file connection.h.
char* alloc_http_authenticator | ( | const char * | authenticator | ) |
Allocates a base64'ed authenticator for use in http or https auth, based on the input string authenticator. Returns it if success, else returns NULL.
Definition at line 4999 of file connection.c.
Referenced by connection_https_proxy_connect().
void assert_connection_ok | ( | connection_t * | conn, |
time_t | now | ||
) |
Verify that connection conn has all of its invariants correct. Trigger an assert if anything is invalid.
Definition at line 5571 of file connection.c.
Referenced by add_connection_to_closeable_list(), connection_close_immediate(), connection_mark_for_close_(), connection_mark_for_close_internal_(), connection_or_finished_flushing(), dns_resolve_impl(), and inform_pending_connections().
int conn_listener_type_supports_af_unix | ( | int | type | ) |
Return true iff the provided connection listener type supports AF_UNIX sockets.
Definition at line 759 of file connection.c.
const char* conn_state_to_string | ( | int | type, |
int | state | ||
) |
Return the human-readable name for the connection state state for the connection type type
Definition at line 302 of file connection.c.
Referenced by connection_describe(), connection_expire_held_open(), and connection_or_get_state_description().
const char* conn_type_to_string | ( | int | type | ) |
Return the human-readable name for the connection type type
Definition at line 268 of file connection.c.
Referenced by connection_describe(), and connection_expire_held_open().
void connection_about_to_close_connection | ( | connection_t * | conn | ) |
Called when we're about to finally unlink and free a connection: perform necessary accounting and cleanup
Definition at line 1012 of file connection.c.
Referenced by connection_unlink().
void connection_bucket_init | ( | void | ) |
Initialize the global buckets to the values configured in the options
Definition at line 3755 of file connection.c.
ssize_t connection_bucket_write_limit | ( | connection_t * | conn, |
time_t | now | ||
) |
How many bytes at most can we write onto this connection?
Definition at line 3476 of file connection.c.
void connection_buf_add_buf | ( | connection_t * | conn, |
buf_t * | buf | ||
) |
Add all bytes from buf to conn's outbuf, draining them from buf. (If the connection is marked and will soon be closed, nothing is drained.)
Definition at line 4731 of file connection.c.
int connection_buf_get_bytes | ( | char * | string, |
size_t | len, | ||
connection_t * | conn | ||
) |
A pass-through to fetch_from_buf.
Definition at line 4232 of file connection.c.
int connection_buf_get_line | ( | connection_t * | conn, |
char * | data, | ||
size_t * | data_len | ||
) |
As buf_get_line(), but read from a connection's input buffer.
Definition at line 4239 of file connection.c.
void connection_check_oos | ( | int | n_socks, |
int | failed | ||
) |
Out-of-Sockets handler; n_socks is the current number of open sockets, and failed is non-zero if a socket exhaustion related error immediately preceded this call. This is where to do circuit-killing heuristics as needed.
Definition at line 5438 of file connection.c.
void connection_close_immediate | ( | connection_t * | conn | ) |
Close the underlying socket for conn, so we don't try to flush it. Must be used in conjunction with (right before) connection_mark_for_close().
Definition at line 1043 of file connection.c.
void connection_consider_empty_read_buckets | ( | connection_t * | conn | ) |
If we have exhausted our global buckets, or the buckets for conn, stop reading.
Definition at line 3698 of file connection.c.
void connection_consider_empty_write_buckets | ( | connection_t * | conn | ) |
If we have exhausted our global buckets, or the buckets for conn, stop writing.
Definition at line 3727 of file connection.c.
const char* connection_describe | ( | const connection_t * | conn | ) |
Describe a connection for logging purposes.
Returns a pointer to a static buffer; future calls to connection_describe() will invalidate this buffer.
Nobody should parse the output of this function; it can and will change in future versions of tor.
Definition at line 543 of file connection.c.
Referenced by dumpstats().
const char* connection_describe_peer | ( | const connection_t * | conn | ) |
Describe the peer or address of connection conn in a human-readable manner.
Returns a pointer to a static buffer; future calls to connection_describe_peer() or connection_describe() will invalidate this buffer.
Nobody should parse the output of this function; it can and will change in future versions of tor.
Definition at line 528 of file connection.c.
Referenced by handle_response_fetch_consensus().
void connection_dir_buf_add | ( | const char * | string, |
size_t | len, | ||
dir_connection_t * | dir_conn, | ||
int | done | ||
) |
Write a string (of size len to directory connection dir_conn. Apply compression if connection is configured to use it and finalize it if done is true.
Definition at line 4707 of file connection.c.
|
inlinestatic |
Return a count of directory connections that are fetching the item described by purpose/resource.
Definition at line 311 of file connection.h.
Referenced by update_consensus_networkstatus_downloads().
|
inlinestatic |
Return a count of directory connections that are fetching the item described by purpose/resource/state.
Definition at line 324 of file connection.h.
struct smartlist_t* connection_dir_list_by_purpose_and_resource | ( | int | purpose, |
const char * | resource | ||
) |
Return a list of directory connections that are fetching the item described by purpose/resource. If there are none, return an empty list. This list must be freed using smartlist_free, but the pointers in it must not be freed. Note that this list should not be cached, as the pointers in it can be freed if their connections close.
Definition at line 4871 of file connection.c.
Referenced by connection_dir_count_by_purpose_and_resource().
struct smartlist_t* connection_dir_list_by_purpose_resource_and_state | ( | int | purpose, |
const char * | resource, | ||
int | state | ||
) |
Return a list of directory connections that are fetching the item described by purpose/resource/state. If there are none, return an empty list. This list must be freed using smartlist_free, but the pointers in it must not be freed. Note that this list should not be cached, as the pointers in it can be freed if their connections close.
Definition at line 4889 of file connection.c.
Referenced by connection_dir_count_by_purpose_resource_and_state().
void connection_dump_buffer_mem_stats | ( | int | severity | ) |
Log how many bytes are used by buffers of different kinds and sizes.
Definition at line 5522 of file connection.c.
Referenced by dumpmemusage().
void connection_expire_held_open | ( | void | ) |
Find each connection that has hold_open_until_flushed set to 1 but hasn't written in the past 15 seconds, and set hold_open_until_flushed to 0. This means it will get cleaned up in the next loop through close_if_marked() in main.c.
Definition at line 1159 of file connection.c.
Referenced by second_elapsed_callback().
int connection_fetch_from_buf_http | ( | connection_t * | conn, |
char ** | headers_out, | ||
size_t | max_headerlen, | ||
char ** | body_out, | ||
size_t * | body_used, | ||
size_t | max_bodylen, | ||
int | force_complete | ||
) |
As fetch_from_buf_http, but fetches from a connection's input buffer_t as appropriate.
Definition at line 4248 of file connection.c.
Referenced by directory_handle_command(), and metrics_connection_process_inbuf().
int connection_flush | ( | connection_t * | conn | ) |
Try to flush data that's waiting for a write on conn. Return -1 on failure, 0 on success.
Don't use this function for regular writing; the buffers system should be good enough at scheduling writes there. Instead, this function is for cases when we're about to exit or something and we want to report it right away.
Definition at line 4599 of file connection.c.
void connection_free_ | ( | connection_t * | conn | ) |
Make sure conn isn't in any of the global conn lists; then free it.
Definition at line 960 of file connection.c.
Referenced by circuit_free_all().
void connection_free_all | ( | void | ) |
Call connection_free_minimal() on every connection in our array, and release all storage held by connection.c.
Don't do the checks in connection_free(), because they will fail.
Definition at line 5818 of file connection.c.
struct connection_t* connection_get_by_global_id | ( | uint64_t | id | ) |
Return the stream with id id if it is not already marked for close.
Definition at line 4810 of file connection.c.
Referenced by get_stream().
struct connection_t* connection_get_by_type | ( | int | type | ) |
Return a connection of type type that is not marked for close.
Definition at line 4818 of file connection.c.
struct connection_t* connection_get_by_type_nonlinked | ( | int | type | ) |
Return a connection of type type that is not an internally linked connection, and is not marked for close.
Definition at line 4837 of file connection.c.
Referenced by check_network_participation_callback().
struct connection_t* connection_get_by_type_state | ( | int | type, |
int | state | ||
) |
Return a connection of type type that is in state state, and that is not marked for close.
Definition at line 4827 of file connection.c.
Referenced by directory_all_unreachable_cb().
int connection_is_listener | ( | connection_t * | conn | ) |
Return 1 if conn is a listener conn, else return 0.
Definition at line 4936 of file connection.c.
Referenced by connection_mark_all_noncontrol_listeners(), dumpstats(), and retry_all_listeners().
int connection_is_moribund | ( | connection_t * | conn | ) |
Check if a connection is on the way out so the OOS handler doesn't try to kill more than it needs.
Definition at line 5421 of file connection.c.
Referenced by connection_count_moribund().
void connection_link_connections | ( | connection_t * | conn_a, |
connection_t * | conn_b | ||
) |
Create a link between conn_a and conn_b.
Definition at line 745 of file connection.c.
void connection_mark_all_noncontrol_connections | ( | void | ) |
Mark every external connection not used for controllers for close.
Definition at line 3319 of file connection.c.
void connection_mark_all_noncontrol_listeners | ( | void | ) |
Mark every listener of type other than CONTROL_LISTENER to be closed.
Definition at line 3305 of file connection.c.
void connection_mark_for_close_ | ( | connection_t * | conn, |
int | line, | ||
const char * | file | ||
) |
Mark conn to be closed next time we loop through conn_close_if_marked() in main.c.
Definition at line 1076 of file connection.c.
Referenced by connection_mark_unattached_ap_().
void connection_mark_for_close_internal_ | ( | connection_t * | conn, |
int | line, | ||
const char * | file | ||
) |
Mark conn to be closed next time we loop through conn_close_if_marked() in main.c.
This _internal version bypasses the CONN_TYPE_OR checks; this should be called when you either are sure that if this is an or_connection_t the controlling channel has been notified (e.g. with connection_or_notify_error()), or you actually are the connection_or_close_for_error() or connection_or_close_normally() function. For all other cases, use connection_mark_and_flush() which checks for or_connection_t properly, instead. See below.
We want to keep this function simple and quick, since it can be called from quite deep in the call chain, and hence it should avoid having side-effects that interfere with its callers view of the connection.
Definition at line 1117 of file connection.c.
struct connection_t* connection_new | ( | int | type, |
int | socket_family | ||
) |
Allocate, initialize, and return a new connection_t subtype of type to make or receive connections of address family socket_family. The type should be one of the CONN_TYPE_* constants.
Definition at line 656 of file connection.c.
int connection_or_nonopen_was_started_here | ( | or_connection_t * | conn | ) |
Return 1 if we initiated this connection, or 0 if it started out as an incoming connection.
Definition at line 1774 of file connection_or.c.
Referenced by connection_or_launch_v3_or_handshake(), connection_tls_finish_handshake(), and enter_v3_handshake_with_cell().
int connection_outbuf_too_full | ( | connection_t * | conn | ) |
Are there too many bytes on edge connection conn's outbuf to send back a relay-level sendme yet? Return 1 if so, 0 if not. Used by connection_edge_consider_sending_sendme().
Definition at line 4269 of file connection.c.
int connection_proxy_connect | ( | connection_t * | conn, |
int | type | ||
) |
Write a proxy request of type (socks4, socks5, https, haproxy) to conn for conn->addr:conn->port, authenticating with the auth details given in the configuration (if available). SOCKS 5 and HTTP CONNECT proxies support authentication.
Returns -1 if conn->addr is incompatible with the proxy protocol, and 0 otherwise.
Use connection_read_proxy_handshake() to complete the handshake.
Definition at line 2750 of file connection.c.
void connection_read_bw_exhausted | ( | connection_t * | conn, |
bool | is_global_bw | ||
) |
Mark conn as needing to stop reading because bandwidth has been exhausted. If is_global_bw, it is closing because global bandwidth limit has been exhausted. Otherwise, it is closing because its own bandwidth limit has been exhausted.
Definition at line 3672 of file connection.c.
int connection_read_proxy_handshake | ( | connection_t * | conn | ) |
Call this from connection_*_process_inbuf() to advance the proxy handshake.
No matter what proxy protocol is used, if this function returns 1, the handshake is complete, and the data remaining on inbuf may contain the start of the communication with the requested server.
Returns 0 if the current buffer contains an incomplete response, and -1 on error.
Definition at line 2903 of file connection.c.
Referenced by connection_or_process_inbuf().
int connection_state_is_connecting | ( | connection_t * | conn | ) |
Return 1 if conn is in 'connecting' state, else return 0.
Definition at line 4976 of file connection.c.
int connection_state_is_open | ( | connection_t * | conn | ) |
Return 1 if conn is in state "open" and is not marked for close, else return 0.
Definition at line 4956 of file connection.c.
int connection_wants_to_flush | ( | connection_t * | conn | ) |
Return true if this connection has data to flush.
Definition at line 4259 of file connection.c.
void connection_write_bw_exhausted | ( | connection_t * | conn, |
bool | is_global_bw | ||
) |
Mark conn as needing to stop reading because write bandwidth has been exhausted. If is_global_bw, it is closing because global bandwidth limit has been exhausted. Otherwise, it is closing because its own bandwidth limit has been exhausted.
Definition at line 3687 of file connection.c.
void connection_write_to_buf_impl_ | ( | const char * | string, |
size_t | len, | ||
connection_t * | conn, | ||
int | zlib | ||
) |
Append len bytes of string onto conn's outbuf, and ask it to start writing.
If zlib is nonzero, this is a directory connection that should get its contents compressed or decompressed as they're written. If zlib is negative, this is the last data to be compressed, and the connection's zlib state should be flushed.
Definition at line 4675 of file connection.c.
struct control_connection_t* control_connection_new | ( | int | socket_family | ) |
Allocate and return a new control_connection_t, initialized as by connection_init().
Definition at line 632 of file connection.c.
struct dir_connection_t* dir_connection_new | ( | int | socket_family | ) |
Allocate and return a new dir_connection_t, initialized as by connection_init().
Definition at line 561 of file connection.c.
struct edge_connection_t* edge_connection_new | ( | int | type, |
int | socket_family | ||
) |
Allocate and return a new edge_connection_t, initialized as by connection_init().
Definition at line 621 of file connection.c.
Referenced by connection_exit_begin_resolve().
struct entry_connection_t* entry_connection_new | ( | int | type, |
int | socket_family | ||
) |
Allocate and return a new entry_connection_t, initialized as by connection_init().
Allocate space to store the socks_request.
Definition at line 602 of file connection.c.
Referenced by dnsserv_launch_request().
struct listener_connection_t* listener_connection_new | ( | int | type, |
int | socket_family | ||
) |
Allocate and return a new listener_connection_t, initialized as by connection_init().
Definition at line 644 of file connection.c.
void log_failed_proxy_connection | ( | connection_t * | conn | ) |
Log a failed connection to a proxy server. conn is the connection we use the proxy server for.
Definition at line 5777 of file connection.c.
struct or_connection_t* or_connection_new | ( | int | type, |
int | socket_family | ||
) |
Allocate and return a new or_connection_t, initialized as by connection_init().
Initialize active_circuit_pqueue.
Set active_circuit_pqueue_last_recalibrated to current cell_ewma tick.
Definition at line 576 of file connection.c.
int retry_all_listeners | ( | smartlist_t * | new_conns, |
int | close_all_noncontrol | ||
) |
Launch listeners for each port you should have open. Only launch listeners who are not already open, and only close listeners we no longer want.
Add all new connections to new_conns.
If close_all_noncontrol is true, then we only open control listeners, and we close all other listeners.
Definition at line 3203 of file connection.c.
Referenced by retry_listeners_callback().
struct listener_connection_t* TO_LISTENER_CONN | ( | connection_t * | c | ) |
Cast a connection_t *
to a listener_connection_t *
.
Exit with an assertion failure if the input is not a listener_connection_t
.
Definition at line 234 of file connection.c.
Referenced by CONST_TO_LISTENER_CONN(), dnsserv_close_listener(), and dnsserv_configure_listener().