tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 8ac3efda2fb27271307421d008f64787fdb12c8c
parent 1d2a4ac27a90415e16fdd4f7053033b7d7bcebc9
Author: Nick Mathewson <nickm@torproject.org>
Date:   Thu, 17 Apr 2025 19:39:43 -0400

Add a much-needed convenience accessor for max payload len.

Diffstat:
Msrc/core/or/relay_msg.c | 12++++++++++++
Msrc/core/or/relay_msg.h | 3+++
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/core/or/relay_msg.c b/src/core/or/relay_msg.c @@ -300,3 +300,15 @@ circuit_get_relay_format(const circuit_t *circ, const crypt_path_t *cpath) tor_assert_unreached(); } } + +/** + * Return the maximum relay payload that can be sent to the chosen + * point, with the specified command. + */ +size_t +circuit_get_max_relay_payload(const circuit_t *circ, const crypt_path_t *cpath, + uint8_t relay_command) +{ + relay_cell_fmt_t fmt = circuit_get_relay_format(circ, cpath); + return relay_cell_max_payload_size(fmt, relay_command); +} diff --git a/src/core/or/relay_msg.h b/src/core/or/relay_msg.h @@ -34,6 +34,9 @@ relay_msg_t *relay_msg_decode_cell( /* Getters */ relay_cell_fmt_t circuit_get_relay_format(const circuit_t *circ, const crypt_path_t *cpath); +size_t circuit_get_max_relay_payload(const circuit_t *circ, + const crypt_path_t *cpath, + uint8_t relay_command); /* * NOTE: The following are inlined for performance reasons. These values are