diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-07-16 10:07:21 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-07-16 10:08:15 -0400 |
commit | 47a48e2f5a384450679a544e7a1f26f378a26a78 (patch) | |
tree | a9848573bd201bca1017fd711f6388328dbe6f32 /src/core/or/connection_edge.c | |
parent | b0d7b100886ef14a785f6ca1de968df9a884d0a7 (diff) | |
download | tor-47a48e2f5a384450679a544e7a1f26f378a26a78.tar.gz tor-47a48e2f5a384450679a544e7a1f26f378a26a78.zip |
Define new CONST_TO_*_CONN() functions for const-to-const casts
These names are analogous to the CONST_TO_*_CIRC() functions we have
for circuits.
Part of #40046.
Diffstat (limited to 'src/core/or/connection_edge.c')
-rw-r--r-- | src/core/or/connection_edge.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index 30cfb18f0f..ed27fb1b57 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -181,6 +181,18 @@ TO_EDGE_CONN(connection_t *c) } /** + * Cast a `const connection_t *` to a `const edge_connection_t *`. + * + * Exit with an assertion failure if the input is not an + * `edge_connection_t`. + **/ +const edge_connection_t * +CONST_TO_EDGE_CONN(const connection_t *c) +{ + return TO_EDGE_CONN((connection_t *)c); +} + +/** * Cast a `connection_t *` to an `entry_connection_t *`. * * Exit with an assertion failure if the input is not an @@ -194,6 +206,18 @@ TO_ENTRY_CONN(connection_t *c) } /** + * Cast a `const connection_t *` to a `const entry_connection_t *`. + * + * Exit with an assertion failure if the input is not an + * `entry_connection_t`. + **/ +const entry_connection_t * +CONST_TO_ENTRY_CONN(const connection_t *c) +{ + return TO_ENTRY_CONN((connection_t*) c); +} + +/** * Cast an `edge_connection_t *` to an `entry_connection_t *`. * * Exit with an assertion failure if the input is not an @@ -206,6 +230,18 @@ EDGE_TO_ENTRY_CONN(edge_connection_t *c) return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_); } +/** + * Cast a `const edge_connection_t *` to a `const entry_connection_t *`. + * + * Exit with an assertion failure if the input is not an + * `entry_connection_t`. + **/ +const entry_connection_t * +CONST_EDGE_TO_ENTRY_CONN(const edge_connection_t *c) +{ + return EDGE_TO_ENTRY_CONN((edge_connection_t*)c); +} + /** An AP stream has failed/finished. If it hasn't already sent back * a socks reply, send one now (based on endreason). Also set * has_sent_end to 1, and mark the conn. |