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.)
This commit is contained in:
Nick Mathewson 2020-07-10 08:41:00 -04:00
parent c5db7667d6
commit a81827d99f
4 changed files with 8 additions and 7 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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"));