entry_connection_st.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 ENTRY_CONNECTION_ST_H
  7. #define ENTRY_CONNECTION_ST_H
  8. #include "core/or/edge_connection_st.h"
  9. /** Subtype of edge_connection_t for an "entry connection" -- that is, a SOCKS
  10. * connection, a DNS request, a TransPort connection or a NATD connection */
  11. struct entry_connection_t {
  12. struct edge_connection_t edge_;
  13. /** Nickname of planned exit node -- used with .exit support. */
  14. /* XXX prop220: we need to make chosen_exit_name able to encode Ed IDs too.
  15. * That's logically part of the UI parts for prop220 though. */
  16. char *chosen_exit_name;
  17. socks_request_t *socks_request; /**< SOCKS structure describing request (AP
  18. * only.) */
  19. /* === Isolation related, AP only. === */
  20. entry_port_cfg_t entry_cfg;
  21. /** AP only: The newnym epoch in which we created this connection. */
  22. unsigned nym_epoch;
  23. /** AP only: The original requested address before we rewrote it. */
  24. char *original_dest_address;
  25. /* Other fields to isolate on already exist. The ClientAddr is addr. The
  26. ClientProtocol is a combination of type and socks_request->
  27. socks_version. SocksAuth is socks_request->username/password.
  28. DestAddr is in socks_request->address. */
  29. /** Number of times we've reassigned this application connection to
  30. * a new circuit. We keep track because the timeout is longer if we've
  31. * already retried several times. */
  32. uint8_t num_socks_retries;
  33. /** For AP connections only: buffer for data that we have sent
  34. * optimistically, which we might need to re-send if we have to
  35. * retry this connection. */
  36. struct buf_t *pending_optimistic_data;
  37. /* For AP connections only: buffer for data that we previously sent
  38. * optimistically which we are currently re-sending as we retry this
  39. * connection. */
  40. struct buf_t *sending_optimistic_data;
  41. /** If this is a DNSPort connection, this field holds the pending DNS
  42. * request that we're going to try to answer. */
  43. struct evdns_server_request *dns_server_request;
  44. #define DEBUGGING_17659
  45. #ifdef DEBUGGING_17659
  46. uint16_t marked_pending_circ_line;
  47. const char *marked_pending_circ_file;
  48. #endif
  49. #define NUM_CIRCUITS_LAUNCHED_THRESHOLD 10
  50. /** Number of times we've launched a circuit to handle this stream. If
  51. * it gets too high, that could indicate an inconsistency between our
  52. * "launch a circuit to handle this stream" logic and our "attach our
  53. * stream to one of the available circuits" logic. */
  54. unsigned int num_circuits_launched:4;
  55. /** True iff this stream must attach to a one-hop circuit (e.g. for
  56. * begin_dir). */
  57. unsigned int want_onehop:1;
  58. /** True iff this stream should use a BEGIN_DIR relay command to establish
  59. * itself rather than BEGIN (either via onehop or via a whole circuit). */
  60. unsigned int use_begindir:1;
  61. /** For AP connections only. If 1, and we fail to reach the chosen exit,
  62. * stop requiring it. */
  63. unsigned int chosen_exit_optional:1;
  64. /** For AP connections only. If non-zero, this exit node was picked as
  65. * a result of the TrackHostExit, and the value decrements every time
  66. * we fail to complete a circuit to our chosen exit -- if it reaches
  67. * zero, abandon the associated mapaddress. */
  68. unsigned int chosen_exit_retries:3;
  69. /** True iff this is an AP connection that came from a transparent or
  70. * NATd connection */
  71. unsigned int is_transparent_ap:1;
  72. /** For AP connections only: Set if this connection's target exit node
  73. * allows optimistic data (that is, data sent on this stream before
  74. * the exit has sent a CONNECTED cell) and we have chosen to use it.
  75. */
  76. unsigned int may_use_optimistic_data : 1;
  77. };
  78. /** Cast a entry_connection_t subtype pointer to a edge_connection_t **/
  79. #define ENTRY_TO_EDGE_CONN(c) (&(((c))->edge_))
  80. #endif