]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Move circuit accessors to relay.c
authorNick Mathewson <nickm@torproject.org>
Thu, 17 Apr 2025 23:46:30 +0000 (19:46 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 5 May 2025 17:07:37 +0000 (13:07 -0400)
src/core/or/relay.c
src/core/or/relay.h
src/core/or/relay_msg.c
src/core/or/relay_msg.h

index e174f339e171a19e6fe732a6320cb7d4306138d2..aa8c64f1e269051a580c233ce13cfd51094eb309 100644 (file)
@@ -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);
+}
index 47dbd18ca4d54ecf363caa265579bea85f551d86..13716946a3226617e5b7d47020f6b501a3fc6594 100644 (file)
@@ -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,
index d5634a304b15312726569d86db6cd80267e1d087..f69f6b2667b915641589215ce8a4d2e87c0b02d0 100644 (file)
@@ -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);
-}
index 941c8896ef6d5cf9d22ab2458b81ef81f46e5c4c..3670bc5e9298363fc034245560c575bbb5b3002c 100644 (file)
@@ -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