summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-07-16 10:11:13 -0400
committerNick Mathewson <nickm@torproject.org>2020-07-16 10:21:38 -0400
commitb3eb4091579e59e4bf311713a3bef0f85137b1b0 (patch)
treee69625b87c47bb9cada532ec54d1170be81a72f8
parent47a48e2f5a384450679a544e7a1f26f378a26a78 (diff)
downloadtor-b3eb4091579e59e4bf311713a3bef0f85137b1b0.tar.gz
tor-b3eb4091579e59e4bf311713a3bef0f85137b1b0.zip
Define const variants for our channel_tls_t* casts.
-rw-r--r--src/core/or/channeltls.c19
-rw-r--r--src/core/or/channeltls.h4
2 files changed, 23 insertions, 0 deletions
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);