From 960a0f0a994ba23480e14ffe5179160194fd9616 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 5 Aug 2008 20:08:19 +0000 Subject: r17641@31-33-44: nickm | 2008-08-05 16:07:53 -0400 Initial conversion of uint32_t addr to tor_addr_t addr in connection_t and related types. Most of the Tor wire formats using these new types are in, but the code to generate and use it is not. This is a big patch. Let me know what it breaks for you. svn:r16435 --- src/or/command.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/or/command.c') diff --git a/src/or/command.c b/src/or/command.c index 89bc72ef1f..476501ffcf 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -576,22 +576,19 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn) while (n_other_addrs && cp < end-2) { /* Consider all the other addresses; if any matches, this connection is * "canonical." */ - uint8_t other_addr_type = (uint8_t) *cp++; - uint8_t other_addr_len = (uint8_t) *cp++; - if (cp + other_addr_len >= end) { - log_fn(LOG_PROTOCOL_WARN, LD_OR, - "Address too long in netinfo cell; closing connection."); + tor_addr_t addr; + const char *next = decode_address_from_payload(&addr, cp, end-cp); + if (next == NULL) { + log_fn(LOG_PROTOCOL_WARN, LD_OR, + "Bad ddress in netinfo cell; closing connection."); connection_mark_for_close(TO_CONN(conn)); return; } - if (other_addr_type == RESOLVED_TYPE_IPV4 && other_addr_len == 4) { - uint32_t addr = ntohl(get_uint32(cp)); - if (addr == conn->real_addr) { - conn->is_canonical = 1; - break; - } + if (tor_addr_eq(&addr, &conn->real_addr)) { + conn->is_canonical = 1; + break; } - cp += other_addr_len; + cp = next; --n_other_addrs; } -- cgit v1.2.3-54-g00ecf