circuitlist.h 4.6 KB

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