summaryrefslogtreecommitdiff
path: root/src/or/circuituse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-05-14 14:25:07 -0400
committerNick Mathewson <nickm@torproject.org>2018-05-14 14:25:07 -0400
commita394a2dd86579495797432114f62ea3265ed5ed0 (patch)
tree90da2ee5c31e850fb59ba978dcfaab1865f1945d /src/or/circuituse.c
parenta9ef335c1b220ad632aad1d75f671a2fcd2b0863 (diff)
parentfd504587d56d4062bccb0d815f4fd925fb8eb33c (diff)
downloadtor-a394a2dd86579495797432114f62ea3265ed5ed0.tar.gz
tor-a394a2dd86579495797432114f62ea3265ed5ed0.zip
Merge branch 'bug25903_v5_squashed'
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r--src/or/circuituse.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index ec09658282..8e007ce920 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -3106,3 +3106,41 @@ mark_circuit_unusable_for_new_conns(origin_circuit_t *circ)
circ->unusable_for_new_conns = 1;
}
+/**
+ * Add relay_body_len and RELAY_PAYLOAD_SIZE-relay_body_len to
+ * the valid delivered written fields and the overhead field,
+ * respectively.
+ */
+void
+circuit_sent_valid_data(origin_circuit_t *circ, uint16_t relay_body_len)
+{
+ if (!circ) return;
+
+ tor_assert_nonfatal(relay_body_len <= RELAY_PAYLOAD_SIZE);
+
+ circ->n_delivered_written_circ_bw =
+ tor_add_u32_nowrap(circ->n_delivered_written_circ_bw, relay_body_len);
+ circ->n_overhead_written_circ_bw =
+ tor_add_u32_nowrap(circ->n_overhead_written_circ_bw,
+ RELAY_PAYLOAD_SIZE-relay_body_len);
+}
+
+/**
+ * Add relay_body_len and RELAY_PAYLOAD_SIZE-relay_body_len to
+ * the valid delivered read field and the overhead field,
+ * respectively.
+ */
+void
+circuit_read_valid_data(origin_circuit_t *circ, uint16_t relay_body_len)
+{
+ if (!circ) return;
+
+ tor_assert_nonfatal(relay_body_len <= RELAY_PAYLOAD_SIZE);
+
+ circ->n_delivered_read_circ_bw =
+ tor_add_u32_nowrap(circ->n_delivered_read_circ_bw, relay_body_len);
+ circ->n_overhead_read_circ_bw =
+ tor_add_u32_nowrap(circ->n_overhead_read_circ_bw,
+ RELAY_PAYLOAD_SIZE-relay_body_len);
+}
+