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-2013, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
8 * \file connection_or.h
9 * \brief Header file for connection_or.c.
12 #ifndef TOR_CONNECTION_OR_H
13 #define TOR_CONNECTION_OR_H
15 void connection_or_remove_from_identity_map(or_connection_t
*conn
);
16 void connection_or_clear_identity_map(void);
17 void clear_broken_connection_map(int disable
);
18 or_connection_t
*connection_or_get_for_extend(const char *digest
,
19 const tor_addr_t
*target_addr
,
22 void connection_or_set_bad_connections(const char *digest
, int force
);
24 void connection_or_block_renegotiation(or_connection_t
*conn
);
25 int connection_or_reached_eof(or_connection_t
*conn
);
26 int connection_or_process_inbuf(or_connection_t
*conn
);
27 int connection_or_flushed_some(or_connection_t
*conn
);
28 int connection_or_finished_flushing(or_connection_t
*conn
);
29 int connection_or_finished_connecting(or_connection_t
*conn
);
30 void connection_or_about_to_close(or_connection_t
*conn
);
31 int connection_or_digest_is_known_relay(const char *id_digest
);
32 void connection_or_update_token_buckets(smartlist_t
*conns
,
33 const or_options_t
*options
);
35 void connection_or_connect_failed(or_connection_t
*conn
,
36 int reason
, const char *msg
);
37 void connection_or_notify_error(or_connection_t
*conn
,
38 int reason
, const char *msg
);
39 or_connection_t
*connection_or_connect(const tor_addr_t
*addr
, uint16_t port
,
40 const char *id_digest
,
43 void connection_or_close_normally(or_connection_t
*orconn
, int flush
);
44 void connection_or_close_for_error(or_connection_t
*orconn
, int flush
);
46 void connection_or_report_broken_states(int severity
, int domain
);
48 MOCK_DECL(int,connection_tls_start_handshake
,(or_connection_t
*conn
,
50 int connection_tls_continue_handshake(or_connection_t
*conn
);
51 void connection_or_set_canonical(or_connection_t
*or_conn
,
54 int connection_init_or_handshake_state(or_connection_t
*conn
,
56 void connection_or_init_conn_from_address(or_connection_t
*conn
,
57 const tor_addr_t
*addr
,
59 const char *id_digest
,
61 int connection_or_client_learned_peer_id(or_connection_t
*conn
,
62 const uint8_t *peer_id
);
63 time_t connection_or_client_used(or_connection_t
*conn
);
64 int connection_or_get_num_circuits(or_connection_t
*conn
);
65 void or_handshake_state_free(or_handshake_state_t
*state
);
66 void or_handshake_state_record_cell(or_connection_t
*conn
,
67 or_handshake_state_t
*state
,
70 void or_handshake_state_record_var_cell(or_connection_t
*conn
,
71 or_handshake_state_t
*state
,
72 const var_cell_t
*cell
,
75 int connection_or_set_state_open(or_connection_t
*conn
);
76 void connection_or_write_cell_to_buf(const cell_t
*cell
,
77 or_connection_t
*conn
);
78 void connection_or_write_var_cell_to_buf(const var_cell_t
*cell
,
79 or_connection_t
*conn
);
80 int connection_or_send_versions(or_connection_t
*conn
, int v3_plus
);
81 int connection_or_send_netinfo(or_connection_t
*conn
);
82 int connection_or_send_certs_cell(or_connection_t
*conn
);
83 int connection_or_send_auth_challenge_cell(or_connection_t
*conn
);
84 int connection_or_compute_authenticate_cell_body(or_connection_t
*conn
,
85 uint8_t *out
, size_t outlen
,
86 crypto_pk_t
*signing_key
,
88 int connection_or_send_authenticate_cell(or_connection_t
*conn
, int type
);
90 int is_or_protocol_version_known(uint16_t version
);
92 void cell_pack(packed_cell_t
*dest
, const cell_t
*src
, int wide_circ_ids
);
93 int var_cell_pack_header(const var_cell_t
*cell
, char *hdr_out
,
95 var_cell_t
*var_cell_new(uint16_t payload_len
);
96 void var_cell_free(var_cell_t
*cell
);
99 #define MIN_LINK_PROTO_FOR_WIDE_CIRC_IDS 4