circuitlist.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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-2016, 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 circuit_clear_testing_cell_stats(circuit_t *circ);
  68. void channel_note_destroy_pending(channel_t *chan, circid_t id);
  69. MOCK_DECL(void, channel_note_destroy_not_pending,
  70. (channel_t *chan, circid_t id));
  71. #ifdef CIRCUITLIST_PRIVATE
  72. STATIC void circuit_free(circuit_t *circ);
  73. STATIC size_t n_cells_in_circ_queues(const circuit_t *c);
  74. STATIC uint32_t circuit_max_queued_data_age(const circuit_t *c, uint32_t now);
  75. STATIC uint32_t circuit_max_queued_cell_age(const circuit_t *c, uint32_t now);
  76. STATIC uint32_t circuit_max_queued_item_age(const circuit_t *c, uint32_t now);
  77. #endif
  78. #endif