tor  0.4.2.0-alpha-dev
connection_or.h
Go to the documentation of this file.
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-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_CONNECTION_OR_H
13 #define TOR_CONNECTION_OR_H
14 
16 struct ed25519_keypair_t;
17 
19 
20 #include "core/or/orconn_event.h"
21 
24 void clear_broken_connection_map(int disable);
25 or_connection_t *connection_or_get_for_extend(const char *digest,
26  const tor_addr_t *target_addr,
27  const char **msg_out,
28  int *launch_out);
29 
38 int connection_or_digest_is_known_relay(const char *id_digest);
40  const or_options_t *options);
41 
43  int reason, const char *msg);
45  int reason, const char *msg);
47  connection_or_connect,
48  (const tor_addr_t *addr, uint16_t port,
49  const char *id_digest,
50  const struct ed25519_public_key_t *ed_id,
51  channel_tls_t *chan));
52 
53 void connection_or_close_normally(or_connection_t *orconn, int flush);
54 MOCK_DECL(void,connection_or_close_for_error,
55  (or_connection_t *orconn, int flush));
56 
57 void connection_or_report_broken_states(int severity, int domain);
58 
60  or_conn_status_event_t tp, int reason);
61 
62 MOCK_DECL(int,connection_tls_start_handshake,(or_connection_t *conn,
63  int receiving));
65 void connection_or_set_canonical(or_connection_t *or_conn,
66  int is_canonical);
67 
69  int started_here);
71  const tor_addr_t *addr,
72  uint16_t port,
73  const char *rsa_id_digest,
74  const struct ed25519_public_key_t *ed_id,
75  int started_here);
77  const uint8_t *rsa_peer_id,
78  const struct ed25519_public_key_t *ed_peer_id);
80 MOCK_DECL(int, connection_or_get_num_circuits, (or_connection_t *conn));
82 #define or_handshake_state_free(state) \
83  FREE_AND_NULL(or_handshake_state_t, or_handshake_state_free_, (state))
85  or_handshake_state_t *state,
86  const cell_t *cell,
87  int incoming);
89  or_handshake_state_t *state,
90  const var_cell_t *cell,
91  int incoming);
92 
95  or_connection_t *conn);
96 MOCK_DECL(void,connection_or_write_var_cell_to_buf,(const var_cell_t *cell,
97  or_connection_t *conn));
98 int connection_or_send_versions(or_connection_t *conn, int v3_plus);
99 MOCK_DECL(int,connection_or_send_netinfo,(or_connection_t *conn));
102 int authchallenge_type_is_supported(uint16_t challenge_type);
103 int authchallenge_type_is_better(uint16_t challenge_type_a,
104  uint16_t challenge_type_b);
106  or_connection_t *conn,
107  const int authtype,
108  crypto_pk_t *signing_key,
109  const struct ed25519_keypair_t *ed_signing_key,
110  int server);
111 MOCK_DECL(int,connection_or_send_authenticate_cell,
112  (or_connection_t *conn, int type));
113 
114 int is_or_protocol_version_known(uint16_t version);
115 
116 void cell_pack(packed_cell_t *dest, const cell_t *src, int wide_circ_ids);
117 int var_cell_pack_header(const var_cell_t *cell, char *hdr_out,
118  int wide_circ_ids);
119 var_cell_t *var_cell_new(uint16_t payload_len);
120 var_cell_t *var_cell_copy(const var_cell_t *src);
121 void var_cell_free_(var_cell_t *cell);
122 #define var_cell_free(cell) FREE_AND_NULL(var_cell_t, var_cell_free_, (cell))
123 
124 /* DOCDOC */
125 #define MIN_LINK_PROTO_FOR_WIDE_CIRC_IDS 4
126 #define MIN_LINK_PROTO_FOR_CHANNEL_PADDING 5
127 #define MAX_LINK_PROTO MIN_LINK_PROTO_FOR_CHANNEL_PADDING
128 
129 int connection_or_single_set_badness_(time_t now,
130  or_connection_t *or_conn,
131  int force);
132 void connection_or_group_set_badness_(smartlist_t *group, int force);
133 
134 #ifdef CONNECTION_OR_PRIVATE
135 STATIC int should_connect_to_relay(const or_connection_t *or_conn);
136 STATIC void note_or_connect_failed(const or_connection_t *or_conn);
137 #endif
138 
139 #ifdef TOR_UNIT_TESTS
140 extern int certs_cell_ed25519_disabled_for_testing;
141 extern int testing__connection_or_pretend_TLSSECRET_is_supported;
142 #endif
143 
144 #endif /* !defined(TOR_CONNECTION_OR_H) */
int connection_or_digest_is_known_relay(const char *id_digest)
void connection_or_connect_failed(or_connection_t *conn, int reason, const char *msg)
void cell_pack(packed_cell_t *dest, const cell_t *src, int wide_circ_ids)
int connection_or_finished_connecting(or_connection_t *conn)
int connection_or_set_state_open(or_connection_t *conn)
void connection_or_group_set_badness_(smartlist_t *group, int force)
void or_handshake_state_record_cell(or_connection_t *conn, or_handshake_state_t *state, const cell_t *cell, int incoming)
void connection_or_clear_identity_map(void)
int connection_or_process_inbuf(or_connection_t *conn)
void connection_or_close_normally(or_connection_t *orconn, int flush)
void or_handshake_state_record_var_cell(or_connection_t *conn, or_handshake_state_t *state, const var_cell_t *cell, int incoming)
void connection_or_report_broken_states(int severity, int domain)
Definition: cell_st.h:12
void connection_or_notify_error(or_connection_t *conn, int reason, const char *msg)
void connection_or_event_status(or_connection_t *conn, or_conn_status_event_t tp, int reason)
void or_handshake_state_free_(or_handshake_state_t *state)
int authchallenge_type_is_supported(uint16_t challenge_type)
void connection_or_init_conn_from_address(or_connection_t *conn, const tor_addr_t *addr, uint16_t port, const char *id_digest, const ed25519_public_key_t *ed_id, int started_here)
Header file for orconn_event.c.
int connection_or_reached_eof(or_connection_t *conn)
int authchallenge_type_is_better(uint16_t challenge_type_a, uint16_t challenge_type_b)
int connection_or_send_versions(or_connection_t *conn, int v3_plus)
var_cell_t * var_cell_copy(const var_cell_t *src)
var_cell_t * connection_or_compute_authenticate_cell_body(or_connection_t *conn, const int authtype, crypto_pk_t *signing_key, const ed25519_keypair_t *ed_signing_key, int server)
time_t connection_or_client_used(or_connection_t *conn)
int connection_or_flushed_some(or_connection_t *conn)
int is_or_protocol_version_known(uint16_t version)
int connection_or_client_learned_peer_id(or_connection_t *conn, const uint8_t *rsa_peer_id, const ed25519_public_key_t *ed_peer_id)
int connection_or_send_certs_cell(or_connection_t *conn)
ssize_t connection_or_num_cells_writeable(or_connection_t *conn)
int connection_or_send_auth_challenge_cell(or_connection_t *conn)
int connection_tls_continue_handshake(or_connection_t *conn)
void connection_or_block_renegotiation(or_connection_t *conn)
void clear_broken_connection_map(int disable)
void connection_or_clear_identity(or_connection_t *conn)
var_cell_t * var_cell_new(uint16_t payload_len)
void var_cell_free_(var_cell_t *cell)
void connection_or_update_token_buckets(smartlist_t *conns, const or_options_t *options)
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94
int connection_or_finished_flushing(or_connection_t *conn)
int connection_or_single_set_badness_(time_t now, or_connection_t *or_conn, int force)
int connection_init_or_handshake_state(or_connection_t *conn, int started_here)
or_conn_status_event_t
Definition: orconn_event.h:59
int var_cell_pack_header(const var_cell_t *cell, char *hdr_out, int wide_circ_ids)
or_connection_t * TO_OR_CONN(connection_t *)
void connection_or_about_to_close(or_connection_t *conn)
void connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn)