2010-07-22 10:43:02 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2012-06-05 02:58:17 +02:00
|
|
|
* Copyright (c) 2007-2012, The Tor Project, Inc. */
|
2010-07-22 10:43:02 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file connection_edge.h
|
|
|
|
* \brief Header file for connection_edge.c.
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _TOR_CONNECTION_EDGE_H
|
|
|
|
#define _TOR_CONNECTION_EDGE_H
|
|
|
|
|
|
|
|
#define connection_mark_unattached_ap(conn, endreason) \
|
|
|
|
_connection_mark_unattached_ap((conn), (endreason), __LINE__, _SHORT_FILE_)
|
|
|
|
|
2011-07-20 18:55:42 +02:00
|
|
|
void _connection_mark_unattached_ap(entry_connection_t *conn, int endreason,
|
2010-07-22 10:43:02 +02:00
|
|
|
int line, const char *file);
|
|
|
|
int connection_edge_reached_eof(edge_connection_t *conn);
|
|
|
|
int connection_edge_process_inbuf(edge_connection_t *conn,
|
|
|
|
int package_partial);
|
|
|
|
int connection_edge_destroy(circid_t circ_id, edge_connection_t *conn);
|
|
|
|
int connection_edge_end(edge_connection_t *conn, uint8_t reason);
|
|
|
|
int connection_edge_end_errno(edge_connection_t *conn);
|
2011-03-14 22:48:45 +01:00
|
|
|
int connection_edge_flushed_some(edge_connection_t *conn);
|
2010-07-22 10:43:02 +02:00
|
|
|
int connection_edge_finished_flushing(edge_connection_t *conn);
|
|
|
|
int connection_edge_finished_connecting(edge_connection_t *conn);
|
|
|
|
|
2011-07-20 18:55:42 +02:00
|
|
|
void connection_ap_about_to_close(entry_connection_t *edge_conn);
|
2011-06-22 19:57:19 +02:00
|
|
|
void connection_exit_about_to_close(edge_connection_t *edge_conn);
|
|
|
|
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_ap_handshake_send_begin(entry_connection_t *ap_conn);
|
|
|
|
int connection_ap_handshake_send_resolve(entry_connection_t *ap_conn);
|
2010-07-22 10:43:02 +02:00
|
|
|
|
2011-07-20 18:55:42 +02:00
|
|
|
entry_connection_t *connection_ap_make_link(connection_t *partner,
|
2009-08-11 21:16:16 +02:00
|
|
|
char *address, uint16_t port,
|
2010-07-22 10:43:02 +02:00
|
|
|
const char *digest,
|
2011-07-08 21:54:30 +02:00
|
|
|
int session_group,
|
|
|
|
int isolation_flags,
|
2010-07-22 10:43:02 +02:00
|
|
|
int use_begindir, int want_onehop);
|
2011-07-20 18:55:42 +02:00
|
|
|
void connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply,
|
2010-07-22 10:43:02 +02:00
|
|
|
size_t replylen,
|
|
|
|
int endreason);
|
2011-07-20 18:55:42 +02:00
|
|
|
void connection_ap_handshake_socks_resolved(entry_connection_t *conn,
|
2010-07-22 10:43:02 +02:00
|
|
|
int answer_type,
|
|
|
|
size_t answer_len,
|
2010-12-16 04:47:28 +01:00
|
|
|
const uint8_t *answer,
|
2010-07-22 10:43:02 +02:00
|
|
|
int ttl,
|
|
|
|
time_t expires);
|
|
|
|
|
|
|
|
int connection_exit_begin_conn(cell_t *cell, circuit_t *circ);
|
|
|
|
int connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ);
|
|
|
|
void connection_exit_connect(edge_connection_t *conn);
|
|
|
|
int connection_edge_is_rendezvous_stream(edge_connection_t *conn);
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_ap_can_use_exit(const entry_connection_t *conn,
|
2011-04-27 20:36:30 +02:00
|
|
|
const node_t *exit);
|
2010-07-22 10:43:02 +02:00
|
|
|
void connection_ap_expire_beginning(void);
|
|
|
|
void connection_ap_attach_pending(void);
|
|
|
|
void connection_ap_fail_onehop(const char *failed_digest,
|
|
|
|
cpath_build_state_t *build_state);
|
|
|
|
void circuit_discard_optional_exit_enclaves(extend_info_t *info);
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_ap_detach_retriable(entry_connection_t *conn,
|
2010-07-22 10:43:02 +02:00
|
|
|
origin_circuit_t *circ,
|
|
|
|
int reason);
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_ap_process_transparent(entry_connection_t *conn);
|
2010-07-22 10:43:02 +02:00
|
|
|
|
|
|
|
int address_is_invalid_destination(const char *address, int client);
|
|
|
|
|
|
|
|
void addressmap_init(void);
|
2011-06-14 19:01:38 +02:00
|
|
|
void addressmap_clear_excluded_trackexithosts(const or_options_t *options);
|
|
|
|
void addressmap_clear_invalid_automaps(const or_options_t *options);
|
2010-07-22 10:43:02 +02:00
|
|
|
void addressmap_clean(time_t now);
|
|
|
|
void addressmap_clear_configured(void);
|
|
|
|
void addressmap_clear_transient(void);
|
|
|
|
void addressmap_free_all(void);
|
2012-05-11 23:00:41 +02:00
|
|
|
int addressmap_rewrite(char *address, size_t maxlen, time_t *expires_out,
|
|
|
|
addressmap_entry_source_t *exit_source_out);
|
2010-07-22 10:43:02 +02:00
|
|
|
int addressmap_have_mapping(const char *address, int update_timeout);
|
|
|
|
|
|
|
|
void addressmap_register(const char *address, char *new_address,
|
2011-09-08 17:54:24 +02:00
|
|
|
time_t expires, addressmap_entry_source_t source,
|
2012-05-14 19:05:00 +02:00
|
|
|
const int address_wildcard,
|
|
|
|
const int new_address_wildcard);
|
2010-07-22 10:43:02 +02:00
|
|
|
int parse_virtual_addr_network(const char *val, int validate_only,
|
|
|
|
char **msg);
|
|
|
|
int client_dns_incr_failures(const char *address);
|
|
|
|
void client_dns_clear_failures(const char *address);
|
|
|
|
void client_dns_set_addressmap(const char *address, uint32_t val,
|
|
|
|
const char *exitname, int ttl);
|
|
|
|
const char *addressmap_register_virtual_address(int type, char *new_address);
|
|
|
|
void addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
|
|
|
|
time_t max_expires, int want_expiry);
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_ap_rewrite_and_attach_if_allowed(entry_connection_t *conn,
|
2010-08-06 21:29:15 +02:00
|
|
|
origin_circuit_t *circ,
|
|
|
|
crypt_path_t *cpath);
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
2010-07-22 10:43:02 +02:00
|
|
|
origin_circuit_t *circ,
|
|
|
|
crypt_path_t *cpath);
|
|
|
|
|
|
|
|
/** Possible return values for parse_extended_hostname. */
|
|
|
|
typedef enum hostname_type_t {
|
|
|
|
NORMAL_HOSTNAME, ONION_HOSTNAME, EXIT_HOSTNAME, BAD_HOSTNAME
|
|
|
|
} hostname_type_t;
|
2012-05-11 23:00:41 +02:00
|
|
|
hostname_type_t parse_extended_hostname(char *address);
|
2010-07-22 10:43:02 +02:00
|
|
|
|
|
|
|
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
|
|
|
|
int get_pf_socket(void);
|
|
|
|
#endif
|
|
|
|
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_edge_compatible_with_circuit(const entry_connection_t *conn,
|
2011-07-06 22:03:47 +02:00
|
|
|
const origin_circuit_t *circ);
|
2011-07-20 18:55:42 +02:00
|
|
|
int connection_edge_update_circuit_isolation(const entry_connection_t *conn,
|
2011-07-06 22:03:47 +02:00
|
|
|
origin_circuit_t *circ,
|
|
|
|
int dry_run);
|
Launch sufficient circuits to satisfy pending isolated streams
Our old "do we need to launch a circuit for stream S" logic was,
more or less, that if we had a pending circuit that could handle S,
we didn't need to launch a new one.
But now that we have streams isolated from one another, we need
something stronger here: It's possible that some pending C can
handle either S1 or S2, but not both.
This patch reuses the existing isolation logic for a simple
solution: when we decide during circuit launching that some pending
C would satisfy stream S1, we "hypothetically" mark C as though S1
had been connected to it. Now if S2 is incompatible with S1, it
won't be something that can attach to C, and so we'll launch a new
stream.
When the circuit becomes OPEN for the first time (with no streams
attached to it), we reset the circuit's isolation status. I'm not
too sure about this part: I wanted some way to be sure that, if all
streams that would have used a circuit die before the circuit is
done, the circuit can still get used. But I worry that this
approach could also lead to us launching too many circuits. Careful
thought needed here.
2011-07-07 16:40:23 +02:00
|
|
|
void circuit_clear_isolation(origin_circuit_t *circ);
|
2011-07-06 22:03:47 +02:00
|
|
|
|
2010-07-22 10:43:02 +02:00
|
|
|
#endif
|
|
|
|
|