aboutsummaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-08-05 20:08:19 +0000
committerNick Mathewson <nickm@torproject.org>2008-08-05 20:08:19 +0000
commit960a0f0a994ba23480e14ffe5179160194fd9616 (patch)
tree250494775699fda2f0f543a350b02e89c5a77a03 /src/or/command.c
parent750bb795ac1fcb5b76b6488690400c77fbff0a3f (diff)
downloadtor-960a0f0a994ba23480e14ffe5179160194fd9616.tar.gz
tor-960a0f0a994ba23480e14ffe5179160194fd9616.zip
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
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c21
1 files changed, 9 insertions, 12 deletions
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;
}