Tor  0.4.6.0-alpha-dev
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-2020, 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 
15 void circuit_expire_building(void);
17 void circuit_remove_handled_ports(smartlist_t *needed_ports);
19  int min);
21 #if 0
22 int circuit_conforms_to_options(const origin_circuit_t *circ,
23  const or_options_t *options);
24 #endif
25 void circuit_build_needed_circs(time_t now);
26 void circuit_expire_old_circs_as_needed(time_t now);
28 
30 
31 void reset_bandwidth_test(void);
33 
37 
38 /** Flag to set when a circuit should have only a single hop. */
39 #define CIRCLAUNCH_ONEHOP_TUNNEL (1<<0)
40 /** Flag to set when a circuit needs to be built of high-uptime nodes */
41 #define CIRCLAUNCH_NEED_UPTIME (1<<1)
42 /** Flag to set when a circuit needs to be built of high-capacity nodes */
43 #define CIRCLAUNCH_NEED_CAPACITY (1<<2)
44 /** Flag to set when the last hop of a circuit doesn't need to be an
45  * exit node. */
46 #define CIRCLAUNCH_IS_INTERNAL (1<<3)
47 /** Flag to set when we are trying to launch a v3 rendezvous circuit. We need
48  * to apply some additional filters on the node picked. */
49 #define CIRCLAUNCH_IS_V3_RP (1<<4)
50 /** Flag to set when we are trying to launch a self-testing circuit to our
51  * IPv6 ORPort. We need to apply some additional filters on the second-last
52  * node in the circuit. (We are both the client and the last node in the
53  * circuit.) */
54 #define CIRCLAUNCH_IS_IPV6_SELFTEST (1<<5)
55 
57  extend_info_t *info,
58  int flags);
59 origin_circuit_t *circuit_launch(uint8_t purpose, int flags);
62  origin_circuit_t *circ,
63  crypt_path_t *cpath);
65 
66 void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose);
67 
69  const char *address);
71 
73 
74 /* Series of helper functions for hidden services. */
75 bool circuit_purpose_is_hs_client(const uint8_t purpose);
76 bool circuit_purpose_is_hs_service(const uint8_t purpose);
77 bool circuit_purpose_is_hs_vanguards(const uint8_t purpose);
78 
79 bool circuit_is_hs_v2(const circuit_t *circ);
80 bool circuit_is_hs_v3(const circuit_t *circ);
81 
82 int circuit_should_use_vanguards(uint8_t);
83 void circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
84 void circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len);
85 
86 #ifdef TOR_UNIT_TESTS
87 /* Used only by circuituse.c and test_circuituse.c */
88 
89 STATIC int circuit_is_available_for_use(const circuit_t *circ);
90 
91 STATIC int needs_exit_circuits(time_t now,
92  int *port_needs_uptime,
93  int *port_needs_capacity);
94 STATIC int needs_hs_server_circuits(time_t now,
95  int num_uptime_internal);
96 
97 STATIC int needs_hs_client_circuits(time_t now,
98  int *needs_uptime,
99  int *needs_capacity,
100  int num_internal,
101  int num_uptime_internal);
102 
103 STATIC int needs_circuits_for_build(int num);
104 
105 #endif /* defined(TOR_UNIT_TESTS) */
106 
107 #endif /* !defined(TOR_CIRCUITUSE_H) */
108 
circuit_launch
origin_circuit_t * circuit_launch(uint8_t purpose, int flags)
Definition: circuituse.c:1951
reset_bandwidth_test
void reset_bandwidth_test(void)
Definition: circuituse.c:1617
circuit_detach_stream
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
Definition: circuituse.c:1393
circuit_expire_waiting_for_better_guard
void circuit_expire_waiting_for_better_guard(void)
Definition: circuituse.c:859
circuit_should_use_vanguards
int circuit_should_use_vanguards(uint8_t)
Definition: circuituse.c:2044
circuit_purpose_is_hs_service
bool circuit_purpose_is_hs_service(const uint8_t purpose)
Definition: circuituse.c:2004
circuit_purpose_is_hs_client
bool circuit_purpose_is_hs_client(const uint8_t purpose)
Definition: circuituse.c:1996
circuit_change_purpose
void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
Definition: circuituse.c:3101
crypt_path_t
Definition: crypt_path_st.h:47
connection_ap_handshake_attach_circuit
int connection_ap_handshake_attach_circuit(entry_connection_t *conn)
Definition: circuituse.c:2853
connection_ap_handshake_attach_chosen_circuit
int connection_ap_handshake_attach_chosen_circuit(entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
Definition: circuituse.c:2768
hostname_in_track_host_exits
int hostname_in_track_host_exits(const or_options_t *options, const char *address)
Definition: circuituse.c:2708
circuit_read_valid_data
void circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len)
Definition: circuituse.c:3192
circuit_remove_handled_ports
void circuit_remove_handled_ports(smartlist_t *needed_ports)
Definition: circuituse.c:1015
circuit_purpose_is_hidden_service
int circuit_purpose_is_hidden_service(uint8_t)
Definition: circuituse.c:1974
origin_circuit_t
Definition: origin_circuit_st.h:79
circuit_build_needed_circs
void circuit_build_needed_circs(time_t now)
Definition: circuituse.c:1339
timeout
Definition: timeout.h:115
circuit_enough_testing_circs
int circuit_enough_testing_circs(void)
Definition: circuituse.c:1627
circuit_has_opened
void circuit_has_opened(origin_circuit_t *circ)
Definition: circuituse.c:1693
circuit_t
Definition: circuit_st.h:61
circuit_expire_old_circuits_serverside
void circuit_expire_old_circuits_serverside(time_t now)
Definition: circuituse.c:1578
circuit_launch_by_extend_info
origin_circuit_t * circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info, int flags)
Definition: circuituse.c:2121
mark_circuit_unusable_for_new_conns
void mark_circuit_unusable_for_new_conns(origin_circuit_t *circ)
Definition: circuituse.c:3147
circuit_reset_failure_count
void circuit_reset_failure_count(int timeout)
Definition: circuituse.c:2250
circuit_try_attaching_streams
void circuit_try_attaching_streams(origin_circuit_t *circ)
Definition: circuituse.c:1768
circuit_build_failed
void circuit_build_failed(origin_circuit_t *circ)
Definition: circuituse.c:1785
edge_connection_t
Definition: edge_connection_st.h:21
circuit_expire_old_circs_as_needed
void circuit_expire_old_circs_as_needed(time_t now)
Definition: circuituse.c:1362
circuit_purpose_is_hs_vanguards
bool circuit_purpose_is_hs_vanguards(const uint8_t purpose)
Definition: circuituse.c:2012
circuit_stream_is_being_handled
int circuit_stream_is_being_handled(entry_connection_t *conn, uint16_t port, int min)
Definition: circuituse.c:1040
circuit_log_ancient_one_hop_circuits
void circuit_log_ancient_one_hop_circuits(int age)
Definition: circuituse.c:883
circuit_expire_building
void circuit_expire_building(void)
Definition: circuituse.c:460
circuit_is_hs_v2
bool circuit_is_hs_v2(const circuit_t *circ)
Definition: circuituse.c:2019
or_options_t
Definition: or_options_st.h:64
STATIC
#define STATIC
Definition: testsupport.h:32
entry_connection_t
Definition: entry_connection_st.h:19
smartlist_t
Definition: smartlist_core.h:26
circuit_sent_valid_data
void circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len)
Definition: circuituse.c:3171
extend_info_t
Definition: extend_info_st.h:27
circuit_is_hs_v3
bool circuit_is_hs_v3(const circuit_t *circ)
Definition: circuituse.c:2027