[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Make channel_get_addr_if_possible() take a const channel_t.



commit a81827d99ffdd36d87ca91637f022558783d44ac
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Jul 10 08:41:00 2020 -0400

    Make channel_get_addr_if_possible() take a const channel_t.
    
    (There is no reason that looking up the address of a channel should
    ever change it.)
---
 src/core/or/channel.c    | 2 +-
 src/core/or/channel.h    | 4 ++--
 src/core/or/channeltls.c | 7 ++++---
 src/test/test_dos.c      | 2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/core/or/channel.c b/src/core/or/channel.c
index a05554472..e21f5a12c 100644
--- a/src/core/or/channel.c
+++ b/src/core/or/channel.c
@@ -2849,7 +2849,7 @@ channel_get_canonical_remote_descr,(channel_t *chan))
  * doesn't let us do this.
  */
 MOCK_IMPL(int,
-channel_get_addr_if_possible,(channel_t *chan, tor_addr_t *addr_out))
+channel_get_addr_if_possible,(const channel_t *chan, tor_addr_t *addr_out))
 {
   tor_assert(chan);
   tor_assert(addr_out);
diff --git a/src/core/or/channel.h b/src/core/or/channel.h
index 4968c8714..79e5fea9c 100644
--- a/src/core/or/channel.h
+++ b/src/core/or/channel.h
@@ -335,7 +335,7 @@ struct channel_t {
    * provided tor_addr_t *, and return 1 if successful or 0 if no address
    * available.
    */
-  int (*get_remote_addr)(channel_t *, tor_addr_t *);
+  int (*get_remote_addr)(const channel_t *, tor_addr_t *);
   int (*get_transport_name)(channel_t *chan, char **transport_out);
 
 #define GRD_FLAG_ORIGINAL 1
@@ -723,7 +723,7 @@ MOCK_DECL(void, channel_dump_statistics, (channel_t *chan, int severity));
 void channel_dump_transport_statistics(channel_t *chan, int severity);
 const char * channel_get_actual_remote_descr(channel_t *chan);
 const char * channel_get_actual_remote_address(channel_t *chan);
-MOCK_DECL(int, channel_get_addr_if_possible, (channel_t *chan,
+MOCK_DECL(int, channel_get_addr_if_possible, (const channel_t *chan,
                                               tor_addr_t *addr_out));
 MOCK_DECL(const char *, channel_get_canonical_remote_descr,(channel_t *chan));
 int channel_has_queued_writes(channel_t *chan);
diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c
index 4db373097..ff4505acf 100644
--- a/src/core/or/channeltls.c
+++ b/src/core/or/channeltls.c
@@ -104,7 +104,8 @@ static const char * channel_tls_describe_transport_method(channel_t *chan);
 static void channel_tls_free_method(channel_t *chan);
 static double channel_tls_get_overhead_estimate_method(channel_t *chan);
 static int
-channel_tls_get_remote_addr_method(channel_t *chan, tor_addr_t *addr_out);
+channel_tls_get_remote_addr_method(const channel_t *chan,
+                                   tor_addr_t *addr_out);
 static int
 channel_tls_get_transport_name_method(channel_t *chan, char **transport_out);
 static const char *
@@ -515,10 +516,10 @@ channel_tls_get_overhead_estimate_method(channel_t *chan)
  * succeeds for this transport).
  */
 static int
-channel_tls_get_remote_addr_method(channel_t *chan, tor_addr_t *addr_out)
+channel_tls_get_remote_addr_method(const channel_t *chan, tor_addr_t *addr_out)
 {
   int rv = 0;
-  channel_tls_t *tlschan = BASE_CHAN_TO_TLS(chan);
+  const channel_tls_t *tlschan = BASE_CHAN_TO_TLS((channel_t*) chan);
 
   tor_assert(tlschan);
   tor_assert(addr_out);
diff --git a/src/test/test_dos.c b/src/test/test_dos.c
index 527e5bbe7..3be09047d 100644
--- a/src/test/test_dos.c
+++ b/src/test/test_dos.c
@@ -108,7 +108,7 @@ test_dos_conn_creation(void *arg)
 
 /** Helper mock: Place a fake IP addr for this channel in <b>addr_out</b> */
 static int
-mock_channel_get_addr_if_possible(channel_t *chan, tor_addr_t *addr_out)
+mock_channel_get_addr_if_possible(const channel_t *chan, tor_addr_t *addr_out)
 {
   (void)chan;
   tt_int_op(AF_INET,OP_EQ, tor_addr_parse(addr_out, "18.0.0.1"));



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits