Tor  0.4.6.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-2020, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file connection_or.h
9  * \brief Header file for connection_or.c.
10  **/
11 
12 #ifndef TOR_CONNECTION_OR_H
13 #define TOR_CONNECTION_OR_H
14 
16 struct ed25519_keypair_t;
17 
20 
21 #include "core/or/orconn_event.h"
22 
25 void clear_broken_connection_map(int disable);
26 
35 int connection_or_digest_is_known_relay(const char *id_digest);
37  const or_options_t *options);
38 
40  int reason, const char *msg);
42  int reason, const char *msg);
45  (const tor_addr_t *addr, uint16_t port,
46  const char *id_digest,
47  const struct ed25519_public_key_t *ed_id,
48  channel_tls_t *chan));
49 
50 void connection_or_close_normally(or_connection_t *orconn, int flush);
52  (or_connection_t *orconn, int flush));
53 
54 void connection_or_report_broken_states(int severity, int domain);
55 
57  or_conn_status_event_t tp, int reason);
58 
60  int receiving));
62 void connection_or_set_canonical(or_connection_t *or_conn,
63  int is_canonical);
64 
66  int started_here);
68  const tor_addr_t *addr,
69  uint16_t port,
70  const char *rsa_id_digest,
71  const struct ed25519_public_key_t *ed_id,
72  int started_here);
74  const uint8_t *rsa_peer_id,
75  const struct ed25519_public_key_t *ed_peer_id);
77  const or_connection_t *conn);
81 #define or_handshake_state_free(state) \
82  FREE_AND_NULL(or_handshake_state_t, or_handshake_state_free_, (state))
84  or_handshake_state_t *state,
85  const cell_t *cell,
86  int incoming);
88  or_handshake_state_t *state,
89  const var_cell_t *cell,
90  int incoming);
91 
94  or_connection_t *conn);
96  or_connection_t *conn));
97 int connection_or_send_versions(or_connection_t *conn, int v3_plus);
99 
100 int is_or_protocol_version_known(uint16_t version);
101 
102 void cell_pack(packed_cell_t *dest, const cell_t *src, int wide_circ_ids);
103 int var_cell_pack_header(const var_cell_t *cell, char *hdr_out,
104  int wide_circ_ids);
105 var_cell_t *var_cell_new(uint16_t payload_len);
106 var_cell_t *var_cell_copy(const var_cell_t *src);
107 void var_cell_free_(var_cell_t *cell);
108 #define var_cell_free(cell) FREE_AND_NULL(var_cell_t, var_cell_free_, (cell))
109 
110 /* DOCDOC */
111 #define MIN_LINK_PROTO_FOR_WIDE_CIRC_IDS 4
112 #define MIN_LINK_PROTO_FOR_CHANNEL_PADDING 5
113 #define MAX_LINK_PROTO MIN_LINK_PROTO_FOR_CHANNEL_PADDING
114 
115 int connection_or_single_set_badness_(time_t now,
116  or_connection_t *or_conn,
117  int force);
118 void connection_or_group_set_badness_(smartlist_t *group, int force);
119 
120 #ifdef CONNECTION_OR_PRIVATE
121 STATIC int should_connect_to_relay(const or_connection_t *or_conn);
122 STATIC void note_or_connect_failed(const or_connection_t *or_conn);
123 #endif /* defined(CONNECTION_OR_PRIVATE) */
124 
125 /*
126  * Call this when changing connection state, so notifications to the owning
127  * channel can be handled.
128  */
130  (or_connection_t *conn, uint8_t state));
131 
132 #ifdef TOR_UNIT_TESTS
133 extern int testing__connection_or_pretend_TLSSECRET_is_supported;
134 #endif
135 
136 #endif /* !defined(TOR_CONNECTION_OR_H) */
connection_or_num_cells_writeable
ssize_t connection_or_num_cells_writeable(or_connection_t *conn)
Definition: connection_or.c:649
tor_addr_t
Definition: address.h:69
connection_or_close_for_error
void connection_or_close_for_error(or_connection_t *orconn, int flush)
Definition: connection_or.c:1618
connection_or_change_state
void connection_or_change_state(or_connection_t *conn, uint8_t state)
Definition: connection_or.c:418
connection_or_flushed_some
int connection_or_flushed_some(or_connection_t *conn)
Definition: connection_or.c:627
connection_or_client_learned_peer_id
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)
Definition: connection_or.c:1905
connection_or_report_broken_states
void connection_or_report_broken_states(int severity, int domain)
Definition: connection_or.c:331
connection_or_clear_identity_map
void connection_or_clear_identity_map(void)
Definition: connection_or.c:136
connection_or_process_inbuf
int connection_or_process_inbuf(or_connection_t *conn)
Definition: connection_or.c:567
var_cell_pack_header
int var_cell_pack_header(const var_cell_t *cell, char *hdr_out, int wide_circ_ids)
Definition: connection_or.c:490
clear_broken_connection_map
void clear_broken_connection_map(int disable)
Definition: connection_or.c:263
or_connection_t
Definition: or_connection_st.h:22
is_or_protocol_version_known
int is_or_protocol_version_known(uint16_t version)
Definition: connection_or.c:2427
connection_or_digest_is_known_relay
int connection_or_digest_is_known_relay(const char *id_digest)
Definition: connection_or.c:813
cell_t
Definition: cell_st.h:17
or_handshake_state_record_cell
void or_handshake_state_record_cell(or_connection_t *conn, or_handshake_state_t *state, const cell_t *cell, int incoming)
Definition: connection_or.c:2188
connection_or_send_versions
int connection_or_send_versions(or_connection_t *conn, int v3_plus)
Definition: connection_or.c:2446
TO_OR_CONN
or_connection_t * TO_OR_CONN(connection_t *)
Definition: connection_or.c:108
var_cell_copy
var_cell_t * var_cell_copy(const var_cell_t *src)
Definition: connection_or.c:525
connection_or_finished_flushing
int connection_or_finished_flushing(or_connection_t *conn)
Definition: connection_or.c:679
connection_tls_start_handshake
int connection_tls_start_handshake(or_connection_t *conn, int receiving)
Definition: connection_or.c:1643
connection_or_write_cell_to_buf
void connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn)
Definition: connection_or.c:2284
connection_or_set_state_open
int connection_or_set_state_open(or_connection_t *conn)
Definition: connection_or.c:2261
packed_cell_t
Definition: cell_queue_st.h:18
connection_or_single_set_badness_
int connection_or_single_set_badness_(time_t now, or_connection_t *or_conn, int force)
Definition: connection_or.c:1025
ed25519_public_key_t
Definition: crypto_ed25519.h:23
connection_or_get_num_circuits
int connection_or_get_num_circuits(or_connection_t *conn)
Definition: connection_or.c:434
connection_or_notify_error
void connection_or_notify_error(or_connection_t *conn, int reason, const char *msg)
Definition: connection_or.c:1410
connection_or_about_to_close
void connection_or_about_to_close(or_connection_t *conn)
Definition: connection_or.c:760
or_handshake_state_record_var_cell
void or_handshake_state_record_var_cell(or_connection_t *conn, or_handshake_state_t *state, const var_cell_t *cell, int incoming)
Definition: connection_or.c:2229
MOCK_DECL
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127
or_handshake_state_free_
void or_handshake_state_free_(or_handshake_state_t *state)
Definition: connection_or.c:2166
connection_or_finished_connecting
int connection_or_finished_connecting(or_connection_t *conn)
Definition: connection_or.c:724
var_cell_free_
void var_cell_free_(var_cell_t *cell)
Definition: connection_or.c:544
connection_t
Definition: connection_st.h:45
connection_or_update_token_buckets
void connection_or_update_token_buckets(smartlist_t *conns, const or_options_t *options)
Definition: connection_or.c:865
connection_or_client_used
time_t connection_or_client_used(or_connection_t *conn)
Definition: connection_or.c:2061
cell_pack
void cell_pack(packed_cell_t *dest, const cell_t *src, int wide_circ_ids)
Definition: connection_or.c:453
CONST_TO_OR_CONN
const or_connection_t * CONST_TO_OR_CONN(const connection_t *)
Definition: connection_or.c:120
or_handshake_state_t
Definition: or_handshake_state_st.h:18
connection_or_init_conn_from_address
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)
Definition: connection_or.c:906
connection_or_block_renegotiation
void connection_or_block_renegotiation(or_connection_t *conn)
Definition: connection_or.c:1684
connection_or_write_var_cell_to_buf
void connection_or_write_var_cell_to_buf(const var_cell_t *cell, or_connection_t *conn)
Definition: connection_or.c:2323
orconn_event.h
Header file for orconn_event.c.
connection_or_group_set_badness_
void connection_or_group_set_badness_(smartlist_t *group, int force)
Definition: connection_or.c:1067
or_conn_status_event_t
or_conn_status_event_t
Definition: orconn_event.h:59
connection_or_clear_identity
void connection_or_clear_identity(or_connection_t *conn)
Definition: connection_or.c:128
var_cell_new
var_cell_t * var_cell_new(uint16_t payload_len)
Definition: connection_or.c:510
connection_init_or_handshake_state
int connection_init_or_handshake_state(or_connection_t *conn, int started_here)
Definition: connection_or.c:2145
connection_tls_continue_handshake
int connection_tls_continue_handshake(or_connection_t *conn)
Definition: connection_or.c:1717
connection_or_connect_failed
void connection_or_connect_failed(or_connection_t *conn, int reason, const char *msg)
Definition: connection_or.c:1394
connection_or_event_status
void connection_or_event_status(or_connection_t *conn, or_conn_status_event_t tp, int reason)
Definition: connection_or.c:371
or_options_t
Definition: or_options_st.h:64
STATIC
#define STATIC
Definition: testsupport.h:32
connection_or_get_alleged_ed25519_id
const struct ed25519_public_key_t * connection_or_get_alleged_ed25519_id(const or_connection_t *conn)
Definition: connection_or.c:217
connection_or_connect
or_connection_t * connection_or_connect(const tor_addr_t *_addr, uint16_t port, const char *id_digest, const ed25519_public_key_t *ed_id, channel_tls_t *chan)
Definition: connection_or.c:1453
var_cell_t
Definition: var_cell_st.h:16
connection_or_close_normally
void connection_or_close_normally(or_connection_t *orconn, int flush)
Definition: connection_or.c:1597
smartlist_t
Definition: smartlist_core.h:26
connection_or_reached_eof
int connection_or_reached_eof(or_connection_t *conn)
Definition: connection_or.c:551
connection_or_send_netinfo
int connection_or_send_netinfo(or_connection_t *conn)
Definition: connection_or.c:2501
ed25519_keypair_t
Definition: crypto_ed25519.h:39