commit c85512cd5dd025ddad72e6ed453711cf7b47ee4f
parent 8ac3efda2fb27271307421d008f64787fdb12c8c
Author: Nick Mathewson <nickm@torproject.org>
Date: Thu, 17 Apr 2025 19:46:30 -0400
Move circuit accessors to relay.c
Diffstat:
4 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/src/core/or/relay.c b/src/core/or/relay.c
@@ -3540,3 +3540,32 @@ circuit_queue_streams_are_blocked(circuit_t *circ)
return circ->circuit_blocked_on_p_chan;
}
}
+
+/** Return the format to use.
+ *
+ * NULL can be passed but not for both. */
+relay_cell_fmt_t
+circuit_get_relay_format(const circuit_t *circ, const crypt_path_t *cpath)
+{
+ if (circ && CIRCUIT_IS_ORCIRC(circ)) {
+ return CONST_TO_OR_CIRCUIT(circ)->relay_cell_format;
+ } else if (cpath) {
+ return cpath->relay_cell_format;
+ } else {
+ /* We end up here when both params are NULL, which is not allowed, or when
+ * only an origin circuit is given (which again is not allowed). */
+ tor_assert_unreached();
+ }
+}
+
+/**
+ * Return the maximum relay payload that can be sent to the chosen
+ * point, with the specified command.
+ */
+size_t
+circuit_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.h b/src/core/or/relay.h
@@ -113,6 +113,12 @@ void circuit_clear_cell_queue(circuit_t *circ, channel_t *chan);
circid_t packed_cell_get_circid(const packed_cell_t *cell, int wide_circ_ids);
uint8_t packed_cell_get_command(const packed_cell_t *cell, int wide_circ_ids);
+relay_cell_fmt_t circuit_get_relay_format(const circuit_t *circ,
+ const crypt_path_t *cpath);
+size_t circuit_max_relay_payload(const circuit_t *circ,
+ const crypt_path_t *cpath,
+ uint8_t relay_command);
+
#ifdef RELAY_PRIVATE
STATIC int
handle_relay_msg(const relay_msg_t *msg, circuit_t *circ,
diff --git a/src/core/or/relay_msg.c b/src/core/or/relay_msg.c
@@ -283,32 +283,3 @@ relay_msg_decode_cell(relay_cell_fmt_t format,
return NULL;
}
}
-
-/** Return the format to use.
- *
- * NULL can be passed but not for both. */
-relay_cell_fmt_t
-circuit_get_relay_format(const circuit_t *circ, const crypt_path_t *cpath)
-{
- if (circ && CIRCUIT_IS_ORCIRC(circ)) {
- return CONST_TO_OR_CIRCUIT(circ)->relay_cell_format;
- } else if (cpath) {
- return cpath->relay_cell_format;
- } else {
- /* We end up here when both params are NULL, which is not allowed, or when
- * only an origin circuit is given (which again is not allowed). */
- 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
@@ -32,11 +32,6 @@ relay_msg_t *relay_msg_decode_cell(
FREE_AND_NULL(relay_msg_t, relay_msg_free_, (msg))
/* 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