]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fold relay_cell.h into relay_msg.h
authorNick Mathewson <nickm@torproject.org>
Thu, 17 Apr 2025 20:47:39 +0000 (16:47 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 5 May 2025 17:07:37 +0000 (13:07 -0400)
It no longer needs an independent existence.

src/core/or/include.am
src/core/or/relay.c
src/core/or/relay_cell.h [deleted file]
src/core/or/relay_msg.c
src/core/or/relay_msg.h
src/feature/client/circpathbias.c
src/test/test_sendme.c

index 0b9323b90916939e26a00bc146db2e4cfc715959..9b8f2952973e08b9872848d5a03380f2d5cac4be 100644 (file)
@@ -105,7 +105,6 @@ noinst_HEADERS +=                                   \
        src/core/or/protover.h                          \
        src/core/or/reasons.h                           \
        src/core/or/relay.h                             \
-       src/core/or/relay_cell.h                        \
        src/core/or/relay_crypto_st.h                   \
        src/core/or/relay_msg.h                         \
        src/core/or/relay_msg_st.h                      \
index a32416b314e4670497043628f0c753fc4151cb3d..1f2ef34fdd2bde5f6ff03b7f5f739da101df467a 100644 (file)
@@ -85,7 +85,6 @@
 #include "core/or/scheduler.h"
 #include "feature/hs/hs_metrics.h"
 #include "feature/stats/rephist.h"
-#include "core/or/relay_cell.h"
 #include "core/or/relay_msg.h"
 
 #include "core/or/cell_st.h"
diff --git a/src/core/or/relay_cell.h b/src/core/or/relay_cell.h
deleted file mode 100644 (file)
index ca3db7a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (c) 2023, The Tor Project, Inc. */
-/* See LICENSE for licensing information */
-
-/**
- * \file relay_cell.h
- * \brief Header file for relay_cell.c.
- **/
-
-#ifndef TOR_RELAY_CELL_H
-#define TOR_RELAY_CELL_H
-
-#include "core/or/or.h"
-
-#include "core/or/cell_st.h"
-
-/* TODO #41051: Fold this file into relay_msg.h */
-
-/*
- * NOTE: The following are inlined for performance reasons. These values are
- * accessed everywhere and so, even if not expensive, we avoid a function call.
- */
-
-/** Return true iff 'cmd' uses a stream ID when using
- * the v1 relay message format. */
-static bool
-relay_cmd_expects_streamid_in_v1(uint8_t relay_command)
-{
-  switch (relay_command) {
-    case RELAY_COMMAND_BEGIN:
-    case RELAY_COMMAND_BEGIN_DIR:
-    case RELAY_COMMAND_CONNECTED:
-    case RELAY_COMMAND_DATA:
-    case RELAY_COMMAND_END:
-    case RELAY_COMMAND_RESOLVE:
-    case RELAY_COMMAND_RESOLVED:
-    case RELAY_COMMAND_XOFF:
-    case RELAY_COMMAND_XON:
-      return true;
-    default:
-      return false;
-  }
-}
-
-/** Return the size of the relay cell payload for the given relay
- * cell format. */
-static inline size_t
-relay_cell_max_payload_size(relay_cell_fmt_t format,
-                            uint8_t relay_command)
-{
-  switch (format) {
-    case RELAY_CELL_FORMAT_V0:
-      return CELL_PAYLOAD_SIZE - RELAY_HEADER_SIZE_V0;
-    case RELAY_CELL_FORMAT_V1: {
-      if (relay_cmd_expects_streamid_in_v1(relay_command)) {
-        return CELL_PAYLOAD_SIZE - RELAY_HEADER_SIZE_V1_WITH_STREAM_ID;
-      } else {
-        return CELL_PAYLOAD_SIZE - RELAY_HEADER_SIZE_V1_NO_STREAM_ID;
-      }
-    }
-    default:
-      tor_fragile_assert();
-      return 0;
-  }
-}
-
-#ifdef RELAY_CELL_PRIVATE
-
-#endif /* RELAY_CELL_PRIVATE */
-
-#endif /* TOR_RELAY_CELL_H */
index 97091dcd59bc8f052068eb2757591f673d1c28ee..5b40a680579081aad55fa97eef202b266c977e9a 100644 (file)
@@ -13,9 +13,7 @@
 #include "core/or/cell_st.h"
 #include "core/or/circuitlist.h"
 #include "core/or/relay.h"
-#include "core/or/relay_cell.h"
 #include "core/or/relay_msg.h"
-#include "core/or/relay_cell.h"
 #include "lib/crypt_ops/crypto_rand.h"
 
 #include "core/or/cell_st.h"
index cec56d6b28fff96433fb8f71e8548dbc0be2607b..4943ab0090f05e0c91d45cba11f9958f29f07dff 100644 (file)
@@ -35,8 +35,53 @@ relay_msg_t *relay_msg_decode_cell(
 relay_cell_fmt_t relay_msg_get_format(const circuit_t *circ,
                                       const crypt_path_t *cpath);
 
-/* Helpers. */
-void relay_msg_free_messages(smartlist_t *messages);
+/*
+ * NOTE: The following are inlined for performance reasons. These values are
+ * accessed everywhere and so, even if not expensive, we avoid a function call.
+ */
+
+/** Return true iff 'cmd' uses a stream ID when using
+ * the v1 relay message format. */
+static bool
+relay_cmd_expects_streamid_in_v1(uint8_t relay_command)
+{
+  switch (relay_command) {
+    case RELAY_COMMAND_BEGIN:
+    case RELAY_COMMAND_BEGIN_DIR:
+    case RELAY_COMMAND_CONNECTED:
+    case RELAY_COMMAND_DATA:
+    case RELAY_COMMAND_END:
+    case RELAY_COMMAND_RESOLVE:
+    case RELAY_COMMAND_RESOLVED:
+    case RELAY_COMMAND_XOFF:
+    case RELAY_COMMAND_XON:
+      return true;
+    default:
+      return false;
+  }
+}
+
+/** Return the size of the relay cell payload for the given relay
+ * cell format. */
+static inline size_t
+relay_cell_max_payload_size(relay_cell_fmt_t format,
+                            uint8_t relay_command)
+{
+  switch (format) {
+    case RELAY_CELL_FORMAT_V0:
+      return CELL_PAYLOAD_SIZE - RELAY_HEADER_SIZE_V0;
+    case RELAY_CELL_FORMAT_V1: {
+      if (relay_cmd_expects_streamid_in_v1(relay_command)) {
+        return CELL_PAYLOAD_SIZE - RELAY_HEADER_SIZE_V1_WITH_STREAM_ID;
+      } else {
+        return CELL_PAYLOAD_SIZE - RELAY_HEADER_SIZE_V1_NO_STREAM_ID;
+      }
+    }
+    default:
+      tor_fragile_assert();
+      return 0;
+  }
+}
 
 #ifdef RELAY_MSG_PRIVATE
 
index c7b42ecfaee38bbb9b6417dd1fb45813a85b1dfb..e388c5512551595058c7f8c5a28000e25fb419d0 100644 (file)
@@ -34,7 +34,6 @@
 #include "feature/client/entrynodes.h"
 #include "feature/nodelist/networkstatus.h"
 #include "core/or/relay.h"
-#include "core/or/relay_cell.h"
 #include "core/or/relay_msg.h"
 #include "lib/math/fp.h"
 #include "lib/math/laplace.h"
index 7ece88c2ccbf44a4ec4267fe72843fc5d71c1a89..93a828643b4640a0f771936b9604ec8e06f901bc 100644 (file)
@@ -14,7 +14,6 @@
 #include "core/or/origin_circuit_st.h"
 #include "core/or/circuitlist.h"
 #include "core/or/relay.h"
-#include "core/or/relay_cell.h"
 #include "core/or/sendme.h"
 
 #include "feature/nodelist/networkstatus.h"