connection_or.h 4.92 KB
Newer Older
Sebastian Hahn's avatar
Sebastian Hahn committed
1
2
3
/* Copyright (c) 2001 Matej Pfajfar.
 * Copyright (c) 2001-2004, Roger Dingledine.
 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4
 * Copyright (c) 2007-2013, The Tor Project, Inc. */
Sebastian Hahn's avatar
Sebastian Hahn committed
5
6
7
8
9
10
11
/* See LICENSE for licensing information */

/**
 * \file connection_or.h
 * \brief Header file for connection_or.c.
 **/

12
13
#ifndef TOR_CONNECTION_OR_H
#define TOR_CONNECTION_OR_H
Sebastian Hahn's avatar
Sebastian Hahn committed
14
15
16

void connection_or_remove_from_identity_map(or_connection_t *conn);
void connection_or_clear_identity_map(void);
17
void clear_broken_connection_map(int disable);
Sebastian Hahn's avatar
Sebastian Hahn committed
18
19
20
21
or_connection_t *connection_or_get_for_extend(const char *digest,
                                              const tor_addr_t *target_addr,
                                              const char **msg_out,
                                              int *launch_out);
22
void connection_or_set_bad_connections(const char *digest, int force);
Sebastian Hahn's avatar
Sebastian Hahn committed
23

24
void connection_or_block_renegotiation(or_connection_t *conn);
Sebastian Hahn's avatar
Sebastian Hahn committed
25
26
int connection_or_reached_eof(or_connection_t *conn);
int connection_or_process_inbuf(or_connection_t *conn);
27
ssize_t connection_or_num_cells_writeable(or_connection_t *conn);
Sebastian Hahn's avatar
Sebastian Hahn committed
28
29
30
int connection_or_flushed_some(or_connection_t *conn);
int connection_or_finished_flushing(or_connection_t *conn);
int connection_or_finished_connecting(or_connection_t *conn);
31
void connection_or_about_to_close(or_connection_t *conn);
Sebastian Hahn's avatar
Sebastian Hahn committed
32
int connection_or_digest_is_known_relay(const char *id_digest);
33
void connection_or_update_token_buckets(smartlist_t *conns,
34
                                        const or_options_t *options);
Sebastian Hahn's avatar
Sebastian Hahn committed
35
36
37

void connection_or_connect_failed(or_connection_t *conn,
                                  int reason, const char *msg);
38
39
void connection_or_notify_error(or_connection_t *conn,
                                int reason, const char *msg);
Sebastian Hahn's avatar
Sebastian Hahn committed
40
or_connection_t *connection_or_connect(const tor_addr_t *addr, uint16_t port,
41
42
43
44
45
                                       const char *id_digest,
                                       channel_tls_t *chan);

void connection_or_close_normally(or_connection_t *orconn, int flush);
void connection_or_close_for_error(or_connection_t *orconn, int flush);
Sebastian Hahn's avatar
Sebastian Hahn committed
46

47
48
void connection_or_report_broken_states(int severity, int domain);

49
50
MOCK_DECL(int,connection_tls_start_handshake,(or_connection_t *conn,
                                              int receiving));
Sebastian Hahn's avatar
Sebastian Hahn committed
51
int connection_tls_continue_handshake(or_connection_t *conn);
52
53
void connection_or_set_canonical(or_connection_t *or_conn,
                                 int is_canonical);
Sebastian Hahn's avatar
Sebastian Hahn committed
54

55
56
int connection_init_or_handshake_state(or_connection_t *conn,
                                       int started_here);
57
void connection_or_init_conn_from_address(or_connection_t *conn,
58
59
                                          const tor_addr_t *addr,
                                          uint16_t port,
60
61
62
63
                                          const char *id_digest,
                                          int started_here);
int connection_or_client_learned_peer_id(or_connection_t *conn,
                                         const uint8_t *peer_id);
64
65
time_t connection_or_client_used(or_connection_t *conn);
int connection_or_get_num_circuits(or_connection_t *conn);
Sebastian Hahn's avatar
Sebastian Hahn committed
66
void or_handshake_state_free(or_handshake_state_t *state);
67
68
void or_handshake_state_record_cell(or_connection_t *conn,
                                    or_handshake_state_t *state,
69
70
                                    const cell_t *cell,
                                    int incoming);
71
72
void or_handshake_state_record_var_cell(or_connection_t *conn,
                                        or_handshake_state_t *state,
73
74
75
                                        const var_cell_t *cell,
                                        int incoming);

Sebastian Hahn's avatar
Sebastian Hahn committed
76
77
78
79
80
int connection_or_set_state_open(or_connection_t *conn);
void connection_or_write_cell_to_buf(const cell_t *cell,
                                     or_connection_t *conn);
void connection_or_write_var_cell_to_buf(const var_cell_t *cell,
                                         or_connection_t *conn);
81
int connection_or_send_versions(or_connection_t *conn, int v3_plus);
Sebastian Hahn's avatar
Sebastian Hahn committed
82
int connection_or_send_netinfo(or_connection_t *conn);
83
int connection_or_send_certs_cell(or_connection_t *conn);
84
int connection_or_send_auth_challenge_cell(or_connection_t *conn);
85
86
int connection_or_compute_authenticate_cell_body(or_connection_t *conn,
                                                 uint8_t *out, size_t outlen,
87
                                                 crypto_pk_t *signing_key,
88
                                                 int server);
89
int connection_or_send_authenticate_cell(or_connection_t *conn, int type);
90

Sebastian Hahn's avatar
Sebastian Hahn committed
91
92
int is_or_protocol_version_known(uint16_t version);

93
94
95
void cell_pack(packed_cell_t *dest, const cell_t *src, int wide_circ_ids);
int var_cell_pack_header(const var_cell_t *cell, char *hdr_out,
                         int wide_circ_ids);
Sebastian Hahn's avatar
Sebastian Hahn committed
96
97
98
var_cell_t *var_cell_new(uint16_t payload_len);
void var_cell_free(var_cell_t *cell);

99
100
101
/** DOCDOC */
#define MIN_LINK_PROTO_FOR_WIDE_CIRC_IDS 4

Sebastian Hahn's avatar
Sebastian Hahn committed
102
103
#endif