]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a much-needed convenience accessor for max payload len.
authorNick Mathewson <nickm@torproject.org>
Thu, 17 Apr 2025 23:39:43 +0000 (19:39 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 5 May 2025 17:07:37 +0000 (13:07 -0400)
src/core/or/relay_msg.c
src/core/or/relay_msg.h

index 8abdc2182d25e81cf717049777080e41a3ad64a5..d5634a304b15312726569d86db6cd80267e1d087 100644 (file)
@@ -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);
+}
index 0bc98f9f3c11d32c1c2d8a0cb06dd567d6a7d6ad..941c8896ef6d5cf9d22ab2458b81ef81f46e5c4c 100644 (file)
@@ -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