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/feature/dircommon | |
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/feature/dircommon')
-rw-r--r-- | src/feature/dircommon/directory.c | 12 | ||||
-rw-r--r-- | src/feature/dircommon/directory.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/feature/dircommon/directory.c b/src/feature/dircommon/directory.c index bb9264eaf9..e92e6480af 100644 --- a/src/feature/dircommon/directory.c +++ b/src/feature/dircommon/directory.c @@ -92,6 +92,18 @@ TO_DIR_CONN(connection_t *c) return DOWNCAST(dir_connection_t, c); } +/** + * Cast a `const connection_t *` to a `const dir_connection_t *`. + * + * Exit with an assertion failure if the input is not a + * `dir_connection_t`. + **/ +const dir_connection_t * +CONST_TO_DIR_CONN(const connection_t *c) +{ + return TO_DIR_CONN((connection_t *)c); +} + /** Return false if the directory purpose <b>dir_purpose</b> * does not require an anonymous (three-hop) connection. * diff --git a/src/feature/dircommon/directory.h b/src/feature/dircommon/directory.h index 0f26cdeff9..0aa2ff53ef 100644 --- a/src/feature/dircommon/directory.h +++ b/src/feature/dircommon/directory.h @@ -13,6 +13,7 @@ #define TOR_DIRECTORY_H dir_connection_t *TO_DIR_CONN(connection_t *c); +const dir_connection_t *CONST_TO_DIR_CONN(const connection_t *c); #define DIR_CONN_STATE_MIN_ 1 /** State for connection to directory server: waiting for connect(). */ |