Tor 0.4.9.1-alpha-dev
edge_connection_st.h
Go to the documentation of this file.
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 */
6
7/**
8 * @file edge_connection_st.h
9 * @brief Edge-connection structure.
10 **/
11
12#ifndef EDGE_CONNECTION_ST_H
13#define EDGE_CONNECTION_ST_H
14
15#include "core/or/or.h"
16
19
20/** Subtype of connection_t for an "edge connection" -- that is, an entry (ap)
21 * connection, or an exit. */
23 connection_t base_;
24
25 struct edge_connection_t *next_stream; /**< Points to the next stream at this
26 * edge, if any */
27 int package_window; /**< How many more relay cells can I send into the
28 * circuit? */
29 int deliver_window; /**< How many more relay cells can end at me? */
30
31 /** The circuit (if any) that this edge connection is using.
32 * Note that edges that use conflux should use the helpers
33 * in conflux_util.c instead of accessing this directly. */
35
36 /** A pointer to which node in the circ this conn exits at. Set for AP
37 * connections and for hidden service exit connections.
38 * Note that edges that use conflux should use the helpers
39 * in conflux_util.c instead of accessing this directly. */
41
42 /* Hidden service connection identifier for edge connections. Used by the HS
43 * client-side code to identify client SOCKS connections and by the
44 * service-side code to match HS circuits with their streams. */
45 struct hs_ident_edge_conn_t *hs_ident;
46
47 uint32_t address_ttl; /**< TTL for address-to-addr mapping on exit
48 * connection. Exit connections only. */
49 uint32_t begincell_flags; /** Flags sent or received in the BEGIN cell
50 * for this connection */
51
52 streamid_t stream_id; /**< The stream ID used for this edge connection on its
53 * circuit */
54
55 /** The reason why this connection is closing; passed to the controller. */
56 uint16_t end_reason;
57
58 /** Bytes read since last call to control_event_stream_bandwidth_used() */
59 uint32_t n_read;
60
61 /** Bytes written since last call to control_event_stream_bandwidth_used() */
62 uint32_t n_written;
63
64 /** True iff this connection is for a DNS request only. */
65 unsigned int is_dns_request:1;
66 /** True iff this connection is for a PTR DNS request. (exit only) */
67 unsigned int is_reverse_dns_lookup:1;
68
69 unsigned int edge_has_sent_end:1; /**< For debugging; only used on edge
70 * connections. Set once we've set the stream end,
71 * and check in connection_about_to_close_connection().
72 */
73
74 /** Unique ID for directory requests; this used to be in connection_t, but
75 * that's going away and being used on channels instead. We still tag
76 * edge connections with dirreq_id from circuits, so it's copied here. */
77 uint64_t dirreq_id;
78
79 /* The following are flow control fields */
80
81 /** Used for rate limiting the read side of this edge connection when
82 * congestion control is enabled on its circuit. The XON cell ewma_drain_rate
83 * parameter is used to set the bucket limits. */
85
86 /**
87 * Monotime timestamp of the last time we sent a flow control message
88 * for this edge, used to compute advisory rates */
90
91 /**
92 * Number of bytes written since we either emptied our buffers,
93 * or sent an advisory drate rate. Can wrap, buf if so,
94 * we must reset the usec timestamp above. (Or make this u64, idk).
95 */
96 uint32_t drained_bytes;
97 uint32_t prev_drained_bytes;
98
99 /**
100 * N_EWMA of the drain rate of writes on this edge conn
101 * while buffers were present.
102 */
104
105 /**
106 * The ewma drain rate the last time we sent an xon.
107 */
109
110 /**
111 * The following fields are used to count the total bytes sent on this
112 * stream, and compare them to the number of XON and XOFFs received, so
113 * that clients can check rate limits of XOFF/XON to prevent dropmark
114 * attacks. */
116
117 /** Number of XOFFs received */
119
120 /** Number of XONs received */
122
123 /**
124 * Flag that tells us if an XOFF has been sent; cleared when we send an XON.
125 * Used to avoid sending multiple */
126 uint8_t xoff_sent : 1;
127
128 /** Flag that tells us if an XOFF has been received; cleared when we get
129 * an XON. Used to ensure that this edge keeps reads on its edge socket
130 * disabled. */
131 uint8_t xoff_received : 1;
132};
133
134#endif /* !defined(EDGE_CONNECTION_ST_H) */
Base connection structure.
Master header file for Tor-specific functionality.
uint16_t streamid_t
Definition: or.h:499
unsigned int is_reverse_dns_lookup
struct crypt_path_t * cpath_layer
token_bucket_rw_t bucket
struct edge_connection_t * next_stream
unsigned int is_dns_request
unsigned int edge_has_sent_end
struct circuit_t * on_circuit
Headers for token_bucket.c.