From: Nick Mathewson Date: Thu, 17 Apr 2025 13:39:06 +0000 (-0400) Subject: prop359: Introduce an enum for cell format. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c2364790c5a1cf836c15227a9f28b948918d8d3;p=thirdparty%2Ftor.git prop359: Introduce an enum for cell format. (Using u8 everywhere makes me nervous.) --- diff --git a/src/core/or/or.h b/src/core/or/or.h index 9c6f690a71..88954be32c 100644 --- a/src/core/or/or.h +++ b/src/core/or/or.h @@ -472,6 +472,14 @@ typedef enum { /** Maximum length of a header on a variable-length cell. */ #define VAR_CELL_MAX_HEADER_SIZE 7 +/** Which format should we use for relay cells? */ +typedef enum relay_cell_fmt_t { + /** Our original format, with 2 byte recognized field and a 4-byte digest */ + RELAY_CELL_FORMAT_V0, + /** New format introduced for CGO, with 16 byte tag. */ + RELAY_CELL_FORMAT_V1, +} relay_cell_fmt_t; + static int get_cell_network_size(int wide_circ_ids); static inline int get_cell_network_size(int wide_circ_ids) { diff --git a/src/core/or/relay_msg_st.h b/src/core/or/relay_msg_st.h index 4cdaa75d6d..75292b7f89 100644 --- a/src/core/or/relay_msg_st.h +++ b/src/core/or/relay_msg_st.h @@ -20,10 +20,10 @@ * This CAN NOT be made opaque so to avoid heap allocation in the fast path. */ typedef struct relay_msg_t { /* Relay cell protocol version of this message. */ - uint8_t relay_cell_proto; + relay_cell_fmt_t relay_cell_proto; /* Relay command of a message. */ uint8_t command; - /* Length of payload. */ + /* Length of the message body. */ uint16_t length; /* Optional routing header: stream ID of a message or 0. */ streamid_t stream_id;