diff options
author | David Goulet <dgoulet@torproject.org> | 2019-01-11 11:36:08 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2019-04-29 12:17:57 -0400 |
commit | 8e38791baf48ca2a4c865f3b7fc264392e63f426 (patch) | |
tree | 8253f1fa78df87ac507efd2fd4c5060c86c46ff9 /src/core/or/sendme.c | |
parent | 2d3c600915c22f1e9a7e9dcbba8358556ef64505 (diff) | |
download | tor-8e38791baf48ca2a4c865f3b7fc264392e63f426.tar.gz tor-8e38791baf48ca2a4c865f3b7fc264392e63f426.zip |
sendme: Add helper functions for DATA cell packaging
When we are about to send a DATA cell, we have to decrement the package window
for both the circuit and stream level.
This commit adds helper functions to handle the package window decrement.
Part of #26288
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/or/sendme.c')
-rw-r--r-- | src/core/or/sendme.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/core/or/sendme.c b/src/core/or/sendme.c index 6d9f6f7d05..d7feb6bfc6 100644 --- a/src/core/or/sendme.c +++ b/src/core/or/sendme.c @@ -213,3 +213,40 @@ sendme_stream_data_received(edge_connection_t *conn) tor_assert(conn); return --conn->deliver_window; } + +/* Called when a relay DATA cell is packaged on the given circuit. If + * layer_hint is NULL, this means we are the Exit end point else we are the + * Client. Update the package window and return its new value. */ +int +sendme_circuit_data_packaged(circuit_t *circ, crypt_path_t *layer_hint) +{ + int package_window, domain; + + tor_assert(circ); + + if (CIRCUIT_IS_ORIGIN(circ)) { + /* Client side. */ + tor_assert(layer_hint); + --layer_hint->package_window; + package_window = layer_hint->package_window; + domain = LD_APP; + } else { + /* Exit side. */ + tor_assert(!layer_hint); + --circ->package_window; + package_window = circ->package_window; + domain = LD_EXIT; + } + + log_debug(domain, "Circuit package_window now %d.", package_window); + return package_window; +} + +/* Called when a relay DATA cell is packaged for the given edge connection + * conn. Update the package window and return its new value. */ +int +sendme_stream_data_packaged(edge_connection_t *conn) +{ + tor_assert(conn); + return --conn->package_window; +} |