From: Nick Mathewson Date: Thu, 17 Apr 2025 23:39:43 +0000 (-0400) Subject: Add a much-needed convenience accessor for max payload len. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ac3efda2fb27271307421d008f64787fdb12c8c;p=thirdparty%2Ftor.git Add a much-needed convenience accessor for max payload len. --- diff --git a/src/core/or/relay_msg.c b/src/core/or/relay_msg.c index 8abdc2182d..d5634a304b 100644 --- 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 index 0bc98f9f3c..941c8896ef 100644 --- 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