circuitlist.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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-2015, 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. MOCK_DECL(smartlist_t *, circuit_get_global_list, (void));
  14. const char *circuit_state_to_string(int state);
  15. const char *circuit_purpose_to_controller_string(uint8_t purpose);
  16. const char *circuit_purpose_to_controller_hs_state_string(uint8_t purpose);
  17. const char *circuit_purpose_to_string(uint8_t purpose);
  18. void circuit_dump_by_conn(connection_t *conn, int severity);
  19. void circuit_set_p_circid_chan(or_circuit_t *circ, circid_t id,
  20. channel_t *chan);
  21. void circuit_set_n_circid_chan(circuit_t *circ, circid_t id,
  22. channel_t *chan);
  23. void channel_mark_circid_unusable(channel_t *chan, circid_t id);
  24. void channel_mark_circid_usable(channel_t *chan, circid_t id);
  25. time_t circuit_id_when_marked_unusable_on_channel(circid_t circ_id,
  26. channel_t *chan);
  27. void circuit_set_state(circuit_t *circ, uint8_t state);
  28. void circuit_close_all_marked(void);
  29. int32_t circuit_initial_package_window(void);
  30. origin_circuit_t *origin_circuit_new(void);
  31. or_circuit_t *or_circuit_new(circid_t p_circ_id, channel_t *p_chan);
  32. circuit_t *circuit_get_by_circid_channel(circid_t circ_id,
  33. channel_t *chan);
  34. circuit_t *
  35. circuit_get_by_circid_channel_even_if_marked(circid_t circ_id,
  36. channel_t *chan);
  37. int circuit_id_in_use_on_channel(circid_t circ_id, channel_t *chan);
  38. circuit_t *circuit_get_by_edge_conn(edge_connection_t *conn);
  39. void circuit_unlink_all_from_channel(channel_t *chan, int reason);
  40. origin_circuit_t *circuit_get_by_global_id(uint32_t id);
  41. origin_circuit_t *circuit_get_ready_rend_circ_by_rend_data(
  42. const rend_data_t *rend_data);
  43. origin_circuit_t *circuit_get_next_by_pk_and_purpose(origin_circuit_t *start,
  44. const char *digest, uint8_t purpose);
  45. or_circuit_t *circuit_get_rendezvous(const uint8_t *cookie);
  46. or_circuit_t *circuit_get_intro_point(const uint8_t *digest);
  47. void circuit_set_rendezvous_cookie(or_circuit_t *circ, const uint8_t *cookie);
  48. void circuit_set_intro_point_digest(or_circuit_t *circ, const uint8_t *digest);
  49. origin_circuit_t *circuit_find_to_cannibalize(uint8_t purpose,
  50. extend_info_t *info, int flags);
  51. void circuit_mark_all_unused_circs(void);
  52. void circuit_mark_all_dirty_circs_as_unusable(void);
  53. MOCK_DECL(void, circuit_mark_for_close_, (circuit_t *circ, int reason,
  54. int line, const char *file));
  55. int circuit_get_cpath_len(origin_circuit_t *circ);
  56. void circuit_clear_cpath(origin_circuit_t *circ);
  57. crypt_path_t *circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum);
  58. void circuit_get_all_pending_on_channel(smartlist_t *out,
  59. channel_t *chan);
  60. int circuit_count_pending_on_channel(channel_t *chan);
  61. #define circuit_mark_for_close(c, reason) \
  62. circuit_mark_for_close_((c), (reason), __LINE__, SHORT_FILE__)
  63. void assert_cpath_layer_ok(const crypt_path_t *cp);
  64. void assert_circuit_ok(const circuit_t *c);
  65. void circuit_free_all(void);
  66. void circuits_handle_oom(size_t current_allocation);
  67. void channel_note_destroy_pending(channel_t *chan, circid_t id);
  68. MOCK_DECL(void, channel_note_destroy_not_pending,
  69. (channel_t *chan, circid_t id));
  70. #ifdef CIRCUITLIST_PRIVATE
  71. STATIC void circuit_free(circuit_t *circ);
  72. STATIC size_t n_cells_in_circ_queues(const circuit_t *c);
  73. STATIC uint32_t circuit_max_queued_data_age(const circuit_t *c, uint32_t now);
  74. STATIC uint32_t circuit_max_queued_cell_age(const circuit_t *c, uint32_t now);
  75. STATIC uint32_t circuit_max_queued_item_age(const circuit_t *c, uint32_t now);
  76. #endif
  77. #endif