commit b3eb4091579e59e4bf311713a3bef0f85137b1b0 Author: Nick Mathewson nickm@torproject.org Date: Thu Jul 16 10:11:13 2020 -0400
Define const variants for our channel_tls_t* casts. --- src/core/or/channeltls.c | 19 +++++++++++++++++++ src/core/or/channeltls.h | 4 ++++ 2 files changed, 23 insertions(+)
diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c index 082a035c3c..4a421462cc 100644 --- a/src/core/or/channeltls.c +++ b/src/core/or/channeltls.c @@ -389,6 +389,25 @@ channel_tls_from_base(channel_t *chan) return (channel_tls_t *)(chan); }
+/** + * Cast a const channel_tls_t to a const channel_t. + */ +const channel_t * +channel_tls_to_base_const(const channel_tls_t *tlschan) +{ + return channel_tls_to_base((channel_tls_t*) tlschan); +} + +/** + * Cast a const channel_t to a const channel_tls_t, with appropriate + * type-checking asserts. + */ +const channel_tls_t * +channel_tls_from_base_const(const channel_t *chan) +{ + return channel_tls_from_base((channel_t *)chan); +} + /******************************************** * Method implementations for channel_tls_t * *******************************************/ diff --git a/src/core/or/channeltls.h b/src/core/or/channeltls.h index f04ce0fa9c..e7010a51fc 100644 --- a/src/core/or/channeltls.h +++ b/src/core/or/channeltls.h @@ -19,6 +19,8 @@ struct curve25519_public_key_t;
#define BASE_CHAN_TO_TLS(c) (channel_tls_from_base((c))) #define TLS_CHAN_TO_BASE(c) (channel_tls_to_base((c))) +#define CONST_BASE_CHAN_TO_TLS(c) (channel_tls_from_base_const((c))) +#define CONST_TLS_CHAN_TO_BASE(c) (channel_tls_to_base_const((c)))
#define TLS_CHAN_MAGIC 0x8a192427U
@@ -44,6 +46,8 @@ channel_t * channel_tls_handle_incoming(or_connection_t *orconn);
channel_t * channel_tls_to_base(channel_tls_t *tlschan); channel_tls_t * channel_tls_from_base(channel_t *chan); +const channel_t * channel_tls_to_base_const(const channel_tls_t *tlschan); +const channel_tls_t * channel_tls_from_base_const(const channel_t *chan);
/* Things for connection_or.c to call back into */ void channel_tls_handle_cell(cell_t *cell, or_connection_t *conn);
tor-commits@lists.torproject.org