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-2013, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
9 * \brief Header file for circuitlist.c.
12 #ifndef TOR_CIRCUITLIST_H
13 #define TOR_CIRCUITLIST_H
15 #include "testsupport.h"
17 TOR_LIST_HEAD(global_circuitlist_s
, circuit_t
);
19 MOCK_DECL(struct global_circuitlist_s
*, circuit_get_global_list
, (void));
20 const char *circuit_state_to_string(int state
);
21 const char *circuit_purpose_to_controller_string(uint8_t purpose
);
22 const char *circuit_purpose_to_controller_hs_state_string(uint8_t purpose
);
23 const char *circuit_purpose_to_string(uint8_t purpose
);
24 void circuit_dump_by_conn(connection_t
*conn
, int severity
);
25 void circuit_set_p_circid_chan(or_circuit_t
*circ
, circid_t id
,
27 void circuit_set_n_circid_chan(circuit_t
*circ
, circid_t id
,
29 void channel_mark_circid_unusable(channel_t
*chan
, circid_t id
);
30 void channel_mark_circid_usable(channel_t
*chan
, circid_t id
);
31 time_t circuit_id_when_marked_unusable_on_channel(circid_t circ_id
,
33 void circuit_set_state(circuit_t
*circ
, uint8_t state
);
34 void circuit_close_all_marked(void);
35 int32_t circuit_initial_package_window(void);
36 origin_circuit_t
*origin_circuit_new(void);
37 or_circuit_t
*or_circuit_new(circid_t p_circ_id
, channel_t
*p_chan
);
38 circuit_t
*circuit_get_by_circid_channel(circid_t circ_id
,
41 circuit_get_by_circid_channel_even_if_marked(circid_t circ_id
,
43 int circuit_id_in_use_on_channel(circid_t circ_id
, channel_t
*chan
);
44 circuit_t
*circuit_get_by_edge_conn(edge_connection_t
*conn
);
45 void circuit_unlink_all_from_channel(channel_t
*chan
, int reason
);
46 origin_circuit_t
*circuit_get_by_global_id(uint32_t id
);
47 origin_circuit_t
*circuit_get_ready_rend_circ_by_rend_data(
48 const rend_data_t
*rend_data
);
49 origin_circuit_t
*circuit_get_next_by_pk_and_purpose(origin_circuit_t
*start
,
50 const char *digest
, uint8_t purpose
);
51 or_circuit_t
*circuit_get_rendezvous(const uint8_t *cookie
);
52 or_circuit_t
*circuit_get_intro_point(const uint8_t *digest
);
53 void circuit_set_rendezvous_cookie(or_circuit_t
*circ
, const uint8_t *cookie
);
54 void circuit_set_intro_point_digest(or_circuit_t
*circ
, const uint8_t *digest
);
55 origin_circuit_t
*circuit_find_to_cannibalize(uint8_t purpose
,
56 extend_info_t
*info
, int flags
);
57 void circuit_mark_all_unused_circs(void);
58 void circuit_mark_all_dirty_circs_as_unusable(void);
59 MOCK_DECL(void, circuit_mark_for_close_
, (circuit_t
*circ
, int reason
,
60 int line
, const char *file
));
61 int circuit_get_cpath_len(origin_circuit_t
*circ
);
62 void circuit_clear_cpath(origin_circuit_t
*circ
);
63 crypt_path_t
*circuit_get_cpath_hop(origin_circuit_t
*circ
, int hopnum
);
64 void circuit_get_all_pending_on_channel(smartlist_t
*out
,
66 int circuit_count_pending_on_channel(channel_t
*chan
);
68 #define circuit_mark_for_close(c, reason) \
69 circuit_mark_for_close_((c), (reason), __LINE__, SHORT_FILE__)
71 void assert_cpath_layer_ok(const crypt_path_t
*cp
);
72 void assert_circuit_ok(const circuit_t
*c
);
73 void circuit_free_all(void);
74 void circuits_handle_oom(size_t current_allocation
);
76 void channel_note_destroy_pending(channel_t
*chan
, circid_t id
);
77 void channel_note_destroy_not_pending(channel_t
*chan
, circid_t id
);
79 #ifdef CIRCUITLIST_PRIVATE
80 STATIC
void circuit_free(circuit_t
*circ
);
81 STATIC
size_t n_cells_in_circ_queues(const circuit_t
*c
);
82 STATIC
uint32_t circuit_max_queued_data_age(const circuit_t
*c
, uint32_t now
);
83 STATIC
uint32_t circuit_max_queued_cell_age(const circuit_t
*c
, uint32_t now
);
84 STATIC
uint32_t circuit_max_queued_item_age(const circuit_t
*c
, uint32_t now
);