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-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
9 * \brief Header file for circuitbuild.c.
12 #ifndef TOR_CIRCUITBUILD_H
13 #define TOR_CIRCUITBUILD_H
15 struct ed25519_public_key_t
;
16 struct curve25519_public_key_t
;
18 int route_len_for_purpose(uint8_t purpose
, extend_info_t
*exit_ei
);
19 char *circuit_list_path(origin_circuit_t
*circ
, int verbose
);
20 char *circuit_list_path_for_controller(origin_circuit_t
*circ
);
21 void circuit_log_path(int severity
, unsigned int domain
,
22 origin_circuit_t
*circ
);
23 origin_circuit_t
*origin_circuit_init(uint8_t purpose
, int flags
);
24 origin_circuit_t
*circuit_establish_circuit(uint8_t purpose
,
27 MOCK_DECL(origin_circuit_t
*, circuit_establish_circuit_conflux
, (
33 struct circuit_guard_state_t
*origin_circuit_get_guard_state(
34 origin_circuit_t
*circ
);
35 int circuit_handle_first_hop(origin_circuit_t
*circ
);
36 void circuit_n_chan_done(channel_t
*chan
, int status
,
37 int close_origin_circuits
);
38 int circuit_timeout_want_to_count_circ(const origin_circuit_t
*circ
);
39 int circuit_send_next_onion_skin(origin_circuit_t
*circ
);
40 void circuit_note_clock_jumped(int64_t seconds_elapsed
, bool was_idle
);
41 struct created_cell_t
;
42 int circuit_finish_handshake(origin_circuit_t
*circ
,
43 const struct created_cell_t
*created_cell
);
44 int circuit_truncated(origin_circuit_t
*circ
, int reason
);
45 MOCK_DECL(int, circuit_all_predicted_ports_handled
, (time_t now
,
49 int circuit_append_new_exit(origin_circuit_t
*circ
, extend_info_t
*info
);
50 int circuit_extend_to_new_exit(origin_circuit_t
*circ
, extend_info_t
*info
);
51 int circuit_has_usable_onion_key(const origin_circuit_t
*circ
);
52 const uint8_t *build_state_get_exit_rsa_id(cpath_build_state_t
*state
);
53 MOCK_DECL(const node_t
*,
54 build_state_get_exit_node
,(cpath_build_state_t
*state
));
55 const char *build_state_get_exit_nickname(cpath_build_state_t
*state
);
57 struct circuit_guard_state_t
;
59 const node_t
*choose_good_entry_server(const origin_circuit_t
*circ
,
61 cpath_build_state_t
*state
,
62 struct circuit_guard_state_t
**guard_state_out
);
63 void circuit_upgrade_circuits_from_guard_wait(void);
65 MOCK_DECL(channel_t
*, channel_connect_for_circuit
,(const extend_info_t
*ei
));
69 circuit_deliver_create_cell
,(circuit_t
*circ
,
70 const struct create_cell_t
*create_cell
,
73 int client_circ_negotiation_message(const extend_info_t
*ei
,
77 #ifdef CIRCUITBUILD_PRIVATE
78 STATIC circid_t
get_unique_circ_id_by_chan(channel_t
*chan
);
79 STATIC
int new_route_len(uint8_t purpose
, extend_info_t
*exit_ei
,
80 const smartlist_t
*nodes
);
81 MOCK_DECL(STATIC
int, count_acceptable_nodes
, (const smartlist_t
*nodes
,
84 STATIC
int onion_extend_cpath(origin_circuit_t
*circ
);
87 onion_pick_cpath_exit(origin_circuit_t
*circ
, extend_info_t
*exit_ei
,
88 int is_hs_v3_rp_circuit
);
89 STATIC
int cpath_build_state_to_crn_flags(const cpath_build_state_t
*state
);
90 STATIC
int cpath_build_state_to_crn_ipv6_extend_flag(
91 const cpath_build_state_t
*state
,
94 #endif /* defined(CIRCUITBUILD_PRIVATE) */
96 #endif /* !defined(TOR_CIRCUITBUILD_H) */