2010-07-22 09:46:23 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2018-06-20 14:13:28 +02:00
|
|
|
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
2010-07-22 09:46:23 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file circuitlist.h
|
|
|
|
* \brief Header file for circuitlist.c.
|
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_CIRCUITLIST_H
|
|
|
|
#define TOR_CIRCUITLIST_H
|
2010-07-22 09:46:23 +02:00
|
|
|
|
2013-07-10 21:07:32 +02:00
|
|
|
#include "testsupport.h"
|
2017-07-21 23:48:18 +02:00
|
|
|
#include "hs_ident.h"
|
2013-07-10 21:07:32 +02:00
|
|
|
|
2018-06-15 17:34:33 +02:00
|
|
|
/** Convert a circuit_t* to a pointer to the enclosing or_circuit_t. Assert
|
|
|
|
* if the cast is impossible. */
|
|
|
|
or_circuit_t *TO_OR_CIRCUIT(circuit_t *);
|
|
|
|
const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *);
|
|
|
|
/** Convert a circuit_t* to a pointer to the enclosing origin_circuit_t.
|
|
|
|
* Assert if the cast is impossible. */
|
|
|
|
origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *);
|
|
|
|
const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(const circuit_t *);
|
|
|
|
|
2014-08-15 21:42:14 +02:00
|
|
|
MOCK_DECL(smartlist_t *, circuit_get_global_list, (void));
|
2016-11-25 18:53:00 +01:00
|
|
|
smartlist_t *circuit_get_global_origin_circuit_list(void);
|
2017-12-07 01:04:09 +01:00
|
|
|
int circuit_any_opened_circuits(void);
|
|
|
|
int circuit_any_opened_circuits_cached(void);
|
|
|
|
void circuit_cache_opened_circuit_state(int circuits_are_opened);
|
|
|
|
|
2010-07-22 09:46:23 +02:00
|
|
|
const char *circuit_state_to_string(int state);
|
|
|
|
const char *circuit_purpose_to_controller_string(uint8_t purpose);
|
2011-06-24 02:28:59 +02:00
|
|
|
const char *circuit_purpose_to_controller_hs_state_string(uint8_t purpose);
|
2011-04-08 19:27:25 +02:00
|
|
|
const char *circuit_purpose_to_string(uint8_t purpose);
|
2010-07-22 09:46:23 +02:00
|
|
|
void circuit_dump_by_conn(connection_t *conn, int severity);
|
2012-08-08 15:02:47 +02:00
|
|
|
void circuit_set_p_circid_chan(or_circuit_t *circ, circid_t id,
|
|
|
|
channel_t *chan);
|
|
|
|
void circuit_set_n_circid_chan(circuit_t *circ, circid_t id,
|
|
|
|
channel_t *chan);
|
2013-03-14 17:13:45 +01:00
|
|
|
void channel_mark_circid_unusable(channel_t *chan, circid_t id);
|
|
|
|
void channel_mark_circid_usable(channel_t *chan, circid_t id);
|
2014-06-10 19:35:45 +02:00
|
|
|
time_t circuit_id_when_marked_unusable_on_channel(circid_t circ_id,
|
|
|
|
channel_t *chan);
|
2010-07-22 09:46:23 +02:00
|
|
|
void circuit_set_state(circuit_t *circ, uint8_t state);
|
|
|
|
void circuit_close_all_marked(void);
|
|
|
|
int32_t circuit_initial_package_window(void);
|
|
|
|
origin_circuit_t *origin_circuit_new(void);
|
2012-08-08 15:02:47 +02:00
|
|
|
or_circuit_t *or_circuit_new(circid_t p_circ_id, channel_t *p_chan);
|
|
|
|
circuit_t *circuit_get_by_circid_channel(circid_t circ_id,
|
|
|
|
channel_t *chan);
|
2012-10-01 23:22:53 +02:00
|
|
|
circuit_t *
|
|
|
|
circuit_get_by_circid_channel_even_if_marked(circid_t circ_id,
|
|
|
|
channel_t *chan);
|
2012-08-08 15:02:47 +02:00
|
|
|
int circuit_id_in_use_on_channel(circid_t circ_id, channel_t *chan);
|
2010-07-22 09:46:23 +02:00
|
|
|
circuit_t *circuit_get_by_edge_conn(edge_connection_t *conn);
|
2012-08-08 15:02:47 +02:00
|
|
|
void circuit_unlink_all_from_channel(channel_t *chan, int reason);
|
2010-07-22 09:46:23 +02:00
|
|
|
origin_circuit_t *circuit_get_by_global_id(uint32_t id);
|
2011-12-22 16:15:24 +01:00
|
|
|
origin_circuit_t *circuit_get_ready_rend_circ_by_rend_data(
|
|
|
|
const rend_data_t *rend_data);
|
2010-07-22 09:46:23 +02:00
|
|
|
origin_circuit_t *circuit_get_next_by_pk_and_purpose(origin_circuit_t *start,
|
2016-11-04 19:00:08 +01:00
|
|
|
const uint8_t *digest, uint8_t purpose);
|
2016-12-21 19:34:45 +01:00
|
|
|
origin_circuit_t *circuit_get_next_service_intro_circ(origin_circuit_t *start);
|
2017-02-03 21:30:46 +01:00
|
|
|
origin_circuit_t *circuit_get_next_service_rp_circ(origin_circuit_t *start);
|
2017-01-13 22:00:07 +01:00
|
|
|
origin_circuit_t *circuit_get_next_service_hsdir_circ(origin_circuit_t *start);
|
2010-07-22 09:46:23 +02:00
|
|
|
origin_circuit_t *circuit_find_to_cannibalize(uint8_t purpose,
|
|
|
|
extend_info_t *info, int flags);
|
|
|
|
void circuit_mark_all_unused_circs(void);
|
2013-02-20 00:37:03 +01:00
|
|
|
void circuit_mark_all_dirty_circs_as_unusable(void);
|
2014-01-13 15:52:07 +01:00
|
|
|
MOCK_DECL(void, circuit_mark_for_close_, (circuit_t *circ, int reason,
|
|
|
|
int line, const char *file));
|
2010-07-22 09:46:23 +02:00
|
|
|
int circuit_get_cpath_len(origin_circuit_t *circ);
|
2017-12-07 01:04:09 +01:00
|
|
|
int circuit_get_cpath_opened_len(const origin_circuit_t *);
|
2014-02-06 23:08:50 +01:00
|
|
|
void circuit_clear_cpath(origin_circuit_t *circ);
|
2010-07-22 09:46:23 +02:00
|
|
|
crypt_path_t *circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum);
|
2012-08-08 15:02:47 +02:00
|
|
|
void circuit_get_all_pending_on_channel(smartlist_t *out,
|
|
|
|
channel_t *chan);
|
|
|
|
int circuit_count_pending_on_channel(channel_t *chan);
|
2010-07-22 09:46:23 +02:00
|
|
|
|
|
|
|
#define circuit_mark_for_close(c, reason) \
|
2012-10-12 18:22:13 +02:00
|
|
|
circuit_mark_for_close_((c), (reason), __LINE__, SHORT_FILE__)
|
2010-07-22 09:46:23 +02:00
|
|
|
|
|
|
|
void assert_cpath_layer_ok(const crypt_path_t *cp);
|
2017-12-04 17:45:41 +01:00
|
|
|
MOCK_DECL(void, assert_circuit_ok,(const circuit_t *c));
|
2010-07-22 09:46:23 +02:00
|
|
|
void circuit_free_all(void);
|
2013-06-16 15:55:44 +02:00
|
|
|
void circuits_handle_oom(size_t current_allocation);
|
2010-07-22 09:46:23 +02:00
|
|
|
|
2016-03-28 16:37:22 +02:00
|
|
|
void circuit_clear_testing_cell_stats(circuit_t *circ);
|
|
|
|
|
2013-03-15 15:45:48 +01:00
|
|
|
void channel_note_destroy_pending(channel_t *chan, circid_t id);
|
2013-12-13 15:13:05 +01:00
|
|
|
MOCK_DECL(void, channel_note_destroy_not_pending,
|
|
|
|
(channel_t *chan, circid_t id));
|
2013-03-15 15:45:48 +01:00
|
|
|
|
2016-11-21 23:23:25 +01:00
|
|
|
smartlist_t *circuit_find_circuits_to_upgrade_from_guard_wait(void);
|
|
|
|
|
2013-07-10 21:07:32 +02:00
|
|
|
#ifdef CIRCUITLIST_PRIVATE
|
2017-11-21 14:29:42 +01:00
|
|
|
STATIC void circuit_free_(circuit_t *circ);
|
2017-12-07 16:44:04 +01:00
|
|
|
#define circuit_free(circ) FREE_AND_NULL(circuit_t, circuit_free_, (circ))
|
2013-07-18 17:21:27 +02:00
|
|
|
STATIC size_t n_cells_in_circ_queues(const circuit_t *c);
|
2014-01-13 21:25:28 +01:00
|
|
|
STATIC uint32_t circuit_max_queued_data_age(const circuit_t *c, uint32_t now);
|
|
|
|
STATIC uint32_t circuit_max_queued_cell_age(const circuit_t *c, uint32_t now);
|
|
|
|
STATIC uint32_t circuit_max_queued_item_age(const circuit_t *c, uint32_t now);
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* defined(CIRCUITLIST_PRIVATE) */
|
2013-07-10 21:07:32 +02:00
|
|
|
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* !defined(TOR_CIRCUITLIST_H) */
|
2010-07-22 09:46:23 +02:00
|
|
|
|