Tor 0.4.9.13
Loading...
Searching...
No Matches
circuituse.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-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * \file circuituse.h
9 * \brief Header file for circuituse.c.
10 **/
11
12#ifndef TOR_CIRCUITUSE_H
13#define TOR_CIRCUITUSE_H
14
19 int min);
21#if 0
22int circuit_conforms_to_options(const origin_circuit_t *circ,
23 const or_options_t *options);
24#endif
25void circuit_build_needed_circs(time_t now);
28
30
31void reset_bandwidth_test(void);
33
38 const origin_circuit_t *src);
41
42/** Flag to set when a circuit should have only a single hop. */
43#define CIRCLAUNCH_ONEHOP_TUNNEL (1<<0)
44/** Flag to set when a circuit needs to be built of high-uptime nodes */
45#define CIRCLAUNCH_NEED_UPTIME (1<<1)
46/** Flag to set when a circuit needs to be built of high-capacity nodes */
47#define CIRCLAUNCH_NEED_CAPACITY (1<<2)
48/** Flag to set when the last hop of a circuit doesn't need to be an
49 * exit node. */
50#define CIRCLAUNCH_IS_INTERNAL (1<<3)
51/** Flag to set when we are trying to launch a self-testing circuit to our
52 * IPv6 ORPort. We need to apply some additional filters on the second-last
53 * node in the circuit. (We are both the client and the last node in the
54 * circuit.) */
55#define CIRCLAUNCH_IS_IPV6_SELFTEST (1<<5)
56/** Flag to set when a circuit needs the exit to support conflux. */
57#define CIRCLAUNCH_NEED_CONFLUX (1<<6)
58
59origin_circuit_t *circuit_launch_by_extend_info(uint8_t purpose,
60 extend_info_t *info,
61 int flags);
62origin_circuit_t *circuit_launch(uint8_t purpose, int flags);
65 origin_circuit_t *circ,
66 crypt_path_t *cpath);
68
69void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose);
70
72 const char *address);
74
76
77/* Series of helper functions for hidden services. */
78bool circuit_purpose_is_hs_client(const uint8_t purpose);
79bool circuit_purpose_is_hs_service(const uint8_t purpose);
80bool circuit_purpose_is_hs_vanguards(const uint8_t purpose);
81
82bool circuit_is_hs_v3(const circuit_t *circ);
83int circuit_is_acceptable(const origin_circuit_t *origin_circ,
84 const entry_connection_t *conn,
85 int must_be_open, uint8_t purpose,
86 int need_uptime, int need_internal,
87 time_t now);
88
90void circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
91void circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
92
93#ifdef TOR_UNIT_TESTS
94/* Used only by circuituse.c and test_circuituse.c */
95
96STATIC int circuit_is_available_for_use(const circuit_t *circ);
97
98STATIC int needs_exit_circuits(time_t now,
99 int *port_needs_uptime,
100 int *port_needs_capacity);
101STATIC int needs_hs_server_circuits(time_t now,
102 int num_uptime_internal);
103
104STATIC int needs_hs_client_circuits(time_t now,
105 int *needs_uptime,
106 int *needs_capacity,
107 int num_internal,
108 int num_uptime_internal);
109
110STATIC int needs_circuits_for_build(int num);
111
113 uint8_t desired_circuit_purpose, origin_circuit_t **circp);
115 int must_be_open,
116 uint8_t purpose,
117 int need_uptime,
118 int need_internal);
119
120#endif /* defined(TOR_UNIT_TESTS) */
121
122#endif /* !defined(TOR_CIRCUITUSE_H) */
123
STATIC origin_circuit_t * circuit_get_best(const entry_connection_t *conn, int must_be_open, uint8_t purpose, int need_uptime, int need_internal)
Definition circuituse.c:338
STATIC int circuit_get_open_circ_or_launch(entry_connection_t *conn, uint8_t desired_circuit_purpose, origin_circuit_t **circp)
void circuit_build_failed(origin_circuit_t *circ)
void circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len)
void circuit_expire_old_circuits_serverside(time_t now)
bool circuit_is_hs_v3(const circuit_t *circ)
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
bool circuit_purpose_is_hs_service(const uint8_t purpose)
origin_circuit_t * circuit_launch(uint8_t purpose, int flags)
void circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len)
void circuit_log_ancient_one_hop_circuits(int age)
Definition circuituse.c:855
void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
void circuit_expire_waiting_for_better_guard(void)
Definition circuituse.c:831
void circuit_expire_old_circs_as_needed(time_t now)
void reset_bandwidth_test(void)
int hostname_in_track_host_exits(const or_options_t *options, const char *address)
void circuit_sync_isolation(origin_circuit_t *circ)
int circuit_is_acceptable(const origin_circuit_t *origin_circ, const entry_connection_t *conn, int must_be_open, uint8_t purpose, int need_uptime, int need_internal, time_t now)
Definition circuituse.c:110
void circuit_reset_isolation(origin_circuit_t *circ)
void circuit_has_opened(origin_circuit_t *circ)
void circuit_expire_building(void)
Definition circuituse.c:448
void circuit_build_needed_circs(time_t now)
int circuit_purpose_is_hidden_service(uint8_t)
bool circuit_purpose_is_hs_vanguards(const uint8_t purpose)
int connection_ap_handshake_attach_circuit(entry_connection_t *conn)
void circuit_reset_failure_count(int timeout)
bool circuit_purpose_is_hs_client(const uint8_t purpose)
int connection_ap_handshake_attach_chosen_circuit(entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
int circuit_stream_is_being_handled(entry_connection_t *conn, uint16_t port, int min)
void circuit_copy_isolation(origin_circuit_t *dst, const origin_circuit_t *src)
void circuit_remove_handled_ports(smartlist_t *needed_ports)
Definition circuituse.c:987
int circuit_enough_testing_circs(void)
int circuit_should_use_vanguards(uint8_t)
void mark_circuit_unusable_for_new_conns(origin_circuit_t *circ)
void circuit_try_attaching_streams(origin_circuit_t *circ)
#define STATIC
Definition testsupport.h:32