commit 22d55e324900d34c970038fbd4e792f1e3d774d0
parent 3c5d23d1b6313e6dfe2a931a24039fb5466d0921
Author: Nick Mathewson <nickm@torproject.org>
Date: Thu, 17 Apr 2025 13:24:44 -0400
Add relay cell format field to circuits
For client circuits, it is a per-hop field;
for OR circuits, it is a per-circuit field.
Diffstat:
5 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/core/mainloop/cpuworker.c b/src/core/mainloop/cpuworker.c
@@ -451,6 +451,9 @@ cpuworker_onion_handshake_replyfn(void *work_)
}
}
+ // TODO CGO: Initialize this from a real handshake.
+ circ->relay_cell_format = RELAY_CELL_FORMAT_V0;
+
if (onionskin_answer(circ,
&rpl.created_cell,
(const char*)rpl.keys, sizeof(rpl.keys),
diff --git a/src/core/or/crypt_path.c b/src/core/or/crypt_path.c
@@ -71,6 +71,9 @@ cpath_append_hop(crypt_path_t **head_ptr, extend_info_t *choice)
hop->package_window = circuit_initial_package_window();
hop->deliver_window = CIRCWINDOW_START;
+ // TODO CGO: Initialize this from a real decision.
+ hop->relay_cell_format = RELAY_CELL_FORMAT_V0;
+
return 0;
}
diff --git a/src/core/or/crypt_path_st.h b/src/core/or/crypt_path_st.h
@@ -87,6 +87,9 @@ struct crypt_path_t {
/** Congestion control info */
struct congestion_control_t *ccontrol;
+ /** Format to use when exchanging relay cells with this relay. */
+ relay_cell_fmt_t relay_cell_format;
+
/*********************** Private members ****************************/
/** Private member: Cryptographic state used for encrypting and
diff --git a/src/core/or/or_circuit_st.h b/src/core/or/or_circuit_st.h
@@ -106,6 +106,10 @@ struct or_circuit_t {
/** RELAY_BEGIN and RELAY_RESOLVE cell bucket controlling how much can go on
* this circuit. Only used if this is the end of a circuit on an exit node.*/
token_bucket_ctr_t stream_limiter;
+
+ /** Format to use when exchanging relay cells with the client
+ * who built this circuit. */
+ relay_cell_fmt_t relay_cell_format;
};
#endif /* !defined(OR_CIRCUIT_ST_H) */
diff --git a/src/feature/hs/hs_circuit.c b/src/feature/hs/hs_circuit.c
@@ -110,6 +110,9 @@ create_rend_cpath(const uint8_t *ntor_key_seed, size_t seed_len,
cpath = tor_malloc_zero(sizeof(crypt_path_t));
cpath->magic = CRYPT_PATH_MAGIC;
+ // TODO CGO: Pick relay cell format based on capabilities.
+ cpath->relay_cell_format = RELAY_CELL_FORMAT_V0;
+
if (cpath_init_circuit_crypto(cpath, (char*)keys, sizeof(keys),
is_service_side, 1) < 0) {
tor_free(cpath);