1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2012, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
8 * \file connection_edge.h
9 * \brief Header file for connection_edge.c.
12 #ifndef _TOR_CONNECTION_EDGE_H
13 #define _TOR_CONNECTION_EDGE_H
15 #define connection_mark_unattached_ap(conn, endreason) \
16 _connection_mark_unattached_ap((conn), (endreason), __LINE__, _SHORT_FILE_)
18 void _connection_mark_unattached_ap(entry_connection_t
*conn
, int endreason
,
19 int line
, const char *file
);
20 int connection_edge_reached_eof(edge_connection_t
*conn
);
21 int connection_edge_process_inbuf(edge_connection_t
*conn
,
23 int connection_edge_destroy(circid_t circ_id
, edge_connection_t
*conn
);
24 int connection_edge_end(edge_connection_t
*conn
, uint8_t reason
);
25 int connection_edge_end_errno(edge_connection_t
*conn
);
26 int connection_edge_flushed_some(edge_connection_t
*conn
);
27 int connection_edge_finished_flushing(edge_connection_t
*conn
);
28 int connection_edge_finished_connecting(edge_connection_t
*conn
);
30 void connection_ap_about_to_close(entry_connection_t
*edge_conn
);
31 void connection_exit_about_to_close(edge_connection_t
*edge_conn
);
33 int connection_ap_handshake_send_begin(entry_connection_t
*ap_conn
);
34 int connection_ap_handshake_send_resolve(entry_connection_t
*ap_conn
);
36 entry_connection_t
*connection_ap_make_link(connection_t
*partner
,
37 char *address
, uint16_t port
,
41 int use_begindir
, int want_onehop
);
42 void connection_ap_handshake_socks_reply(entry_connection_t
*conn
, char *reply
,
45 void connection_ap_handshake_socks_resolved(entry_connection_t
*conn
,
48 const uint8_t *answer
,
52 int connection_exit_begin_conn(cell_t
*cell
, circuit_t
*circ
);
53 int connection_exit_begin_resolve(cell_t
*cell
, or_circuit_t
*circ
);
54 void connection_exit_connect(edge_connection_t
*conn
);
55 int connection_edge_is_rendezvous_stream(edge_connection_t
*conn
);
56 int connection_ap_can_use_exit(const entry_connection_t
*conn
,
58 void connection_ap_expire_beginning(void);
59 void connection_ap_attach_pending(void);
60 void connection_ap_fail_onehop(const char *failed_digest
,
61 cpath_build_state_t
*build_state
);
62 void circuit_discard_optional_exit_enclaves(extend_info_t
*info
);
63 int connection_ap_detach_retriable(entry_connection_t
*conn
,
64 origin_circuit_t
*circ
,
66 int connection_ap_process_transparent(entry_connection_t
*conn
);
68 int address_is_invalid_destination(const char *address
, int client
);
70 void addressmap_init(void);
71 void addressmap_clear_excluded_trackexithosts(const or_options_t
*options
);
72 void addressmap_clear_invalid_automaps(const or_options_t
*options
);
73 void addressmap_clean(time_t now
);
74 void addressmap_clear_configured(void);
75 void addressmap_clear_transient(void);
76 void addressmap_free_all(void);
77 int addressmap_rewrite(char *address
, size_t maxlen
, time_t *expires_out
,
78 addressmap_entry_source_t
*exit_source_out
);
79 int addressmap_have_mapping(const char *address
, int update_timeout
);
81 void addressmap_register(const char *address
, char *new_address
,
82 time_t expires
, addressmap_entry_source_t source
,
83 const int address_wildcard
,
84 const int new_address_wildcard
);
85 int parse_virtual_addr_network(const char *val
, int validate_only
,
87 int client_dns_incr_failures(const char *address
);
88 void client_dns_clear_failures(const char *address
);
89 void client_dns_set_addressmap(const char *address
, uint32_t val
,
90 const char *exitname
, int ttl
);
91 const char *addressmap_register_virtual_address(int type
, char *new_address
);
92 void addressmap_get_mappings(smartlist_t
*sl
, time_t min_expires
,
93 time_t max_expires
, int want_expiry
);
94 int connection_ap_rewrite_and_attach_if_allowed(entry_connection_t
*conn
,
95 origin_circuit_t
*circ
,
97 int connection_ap_handshake_rewrite_and_attach(entry_connection_t
*conn
,
98 origin_circuit_t
*circ
,
101 /** Possible return values for parse_extended_hostname. */
102 typedef enum hostname_type_t
{
103 NORMAL_HOSTNAME
, ONION_HOSTNAME
, EXIT_HOSTNAME
, BAD_HOSTNAME
105 hostname_type_t
parse_extended_hostname(char *address
);
107 #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
108 int get_pf_socket(void);
111 int connection_edge_compatible_with_circuit(const entry_connection_t
*conn
,
112 const origin_circuit_t
*circ
);
113 int connection_edge_update_circuit_isolation(const entry_connection_t
*conn
,
114 origin_circuit_t
*circ
,
116 void circuit_clear_isolation(origin_circuit_t
*circ
);