diff options
author | Roger Dingledine <arma@torproject.org> | 2010-10-01 21:31:09 -0400 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2010-10-01 21:31:09 -0400 |
commit | 22f723e4a3fc32983480c7403af9d7e77a3200ea (patch) | |
tree | b33e4fec4ffa0e350e5c4193e050cb3441e2958e /src/or/connection_edge.c | |
parent | 165aaf560a7249a388e916659d55ec6fa1d2fd24 (diff) | |
download | tor-22f723e4a3fc32983480c7403af9d7e77a3200ea.tar.gz tor-22f723e4a3fc32983480c7403af9d7e77a3200ea.zip |
refactor all these tor_inet_ntoa idioms
but don't refactor the ones that look messy
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r-- | src/or/connection_edge.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 9627631ad9..e89bc66541 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -1185,7 +1185,6 @@ static char * addressmap_get_virtual_address(int type) { char buf[64]; - struct in_addr in; tor_assert(addressmap); if (type == RESOLVED_TYPE_HOSTNAME) { @@ -1206,9 +1205,7 @@ addressmap_get_virtual_address(int type) (next_virtual_addr & 0xff) == 0xff) { ++next_virtual_addr; } - in.s_addr = htonl(next_virtual_addr); - tor_inet_ntoa(&in, buf, sizeof(buf)); - if (!strmap_get(addressmap, buf)) { + if (!strmap_get(addressmap, fmt_addr32(next_virtual_addr))) { ++next_virtual_addr; break; } @@ -2298,13 +2295,11 @@ tell_controller_about_resolved_result(edge_connection_t *conn, answer_type == RESOLVED_TYPE_HOSTNAME)) { return; /* we already told the controller. */ } else if (answer_type == RESOLVED_TYPE_IPV4 && answer_len >= 4) { - struct in_addr in; - char buf[INET_NTOA_BUF_LEN]; - in.s_addr = get_uint32(answer); - tor_inet_ntoa(&in, buf, sizeof(buf)); + char *cp = tor_dup_ip(get_uint32(answer)); control_event_address_mapped(conn->socks_request->address, - buf, expires, NULL); - } else if (answer_type == RESOLVED_TYPE_HOSTNAME && answer_len <256) { + cp, expires, NULL); + tor_free(cp); + } else if (answer_type == RESOLVED_TYPE_HOSTNAME && answer_len < 256) { char *cp = tor_strndup(answer, answer_len); control_event_address_mapped(conn->socks_request->address, cp, expires, NULL); |