or_circuit_st.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef OR_CIRCUIT_ST_H
  7. #define OR_CIRCUIT_ST_H
  8. #include "core/or/or.h"
  9. #include "core/or/circuit_st.h"
  10. #include "core/or/crypt_path_st.h"
  11. #include "lib/evloop/token_bucket.h"
  12. struct onion_queue_t;
  13. /** An or_circuit_t holds information needed to implement a circuit at an
  14. * OR. */
  15. struct or_circuit_t {
  16. circuit_t base_;
  17. /** Pointer to an entry on the onion queue, if this circuit is waiting for a
  18. * chance to give an onionskin to a cpuworker. Used only in onion.c */
  19. struct onion_queue_t *onionqueue_entry;
  20. /** Pointer to a workqueue entry, if this circuit has given an onionskin to
  21. * a cpuworker and is waiting for a response. Used to decide whether it is
  22. * safe to free a circuit or if it is still in use by a cpuworker. */
  23. struct workqueue_entry_s *workqueue_entry;
  24. /** The circuit_id used in the previous (backward) hop of this circuit. */
  25. circid_t p_circ_id;
  26. /** Queue of cells waiting to be transmitted on p_conn. */
  27. cell_queue_t p_chan_cells;
  28. /** The channel that is previous in this circuit. */
  29. channel_t *p_chan;
  30. /** Linked list of Exit streams associated with this circuit. */
  31. edge_connection_t *n_streams;
  32. /** Linked list of Exit streams associated with this circuit that are
  33. * still being resolved. */
  34. edge_connection_t *resolving_streams;
  35. /** Cryptographic state used for encrypting and authenticating relay
  36. * cells to and from this hop. */
  37. relay_crypto_t crypto;
  38. /** Points to spliced circuit if purpose is REND_ESTABLISHED, and circuit
  39. * is not marked for close. */
  40. struct or_circuit_t *rend_splice;
  41. /** Stores KH for the handshake. */
  42. char rend_circ_nonce[DIGEST_LEN];/* KH in tor-spec.txt */
  43. /** How many more relay_early cells can we send on this circuit, according
  44. * to the specification? */
  45. unsigned int remaining_relay_early_cells : 4;
  46. /* We have already received an INTRODUCE1 cell on this circuit. */
  47. unsigned int already_received_introduce1 : 1;
  48. /** If set, this circuit carries HS traffic. Consider it in any HS
  49. * statistics. */
  50. unsigned int circuit_carries_hs_traffic_stats : 1;
  51. /** Number of cells that were removed from circuit queue; reset every
  52. * time when writing buffer stats to disk. */
  53. uint32_t processed_cells;
  54. /** Total time in milliseconds that cells spent in both app-ward and
  55. * exit-ward queues of this circuit; reset every time when writing
  56. * buffer stats to disk. */
  57. uint64_t total_cell_waiting_time;
  58. /** If set, the DoS defenses are enabled on this circuit meaning that the
  59. * introduce2_bucket is initialized and used. */
  60. unsigned int introduce2_dos_defense_enabled : 1;
  61. /** INTRODUCE2 cell bucket controlling how much can go on this circuit. Only
  62. * used if this is a service introduction circuit at the intro point
  63. * (purpose = CIRCUIT_PURPOSE_INTRO_POINT). */
  64. token_bucket_ctr_t introduce2_bucket;
  65. };
  66. #endif /* !defined(OR_CIRCUIT_ST_H) */