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