[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Merge remote branch 'origin/maint-0.2.2'
commit 26009a3ed06549b7d7def9b96b327b906db16bd8
Merge: 176e8a0 3bd83b8
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon Mar 7 17:12:08 2011 -0500
Merge remote branch 'origin/maint-0.2.2'
changes/bug2660 | 7 +++++++
src/common/address.c | 18 +++++++++---------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --combined src/common/address.c
index 1f94377,a2780fb..756abff
--- a/src/common/address.c
+++ b/src/common/address.c
@@@ -53,7 -53,9 +53,7 @@@
* socklen object in *<b>sa_out</b> of object size <b>len</b>. If not enough
* room is free, or on error, return -1. Else return the length of the
* sockaddr. */
-/* XXXX021 This returns socklen_t. socklen_t is sometimes unsigned. This
- * function claims to return -1 sometimes. Problematic! */
-socklen_t
+int
tor_addr_to_sockaddr(const tor_addr_t *a,
uint16_t port,
struct sockaddr *sa_out,
@@@ -309,7 -311,7 +309,7 @@@ tor_addr_is_internal(const tor_addr_t *
* brackets.
*/
const char *
-tor_addr_to_str(char *dest, const tor_addr_t *addr, int len, int decorate)
+tor_addr_to_str(char *dest, const tor_addr_t *addr, size_t len, int decorate)
{
const char *ptr;
tor_assert(addr && dest);
@@@ -925,19 -927,6 +925,19 @@@ fmt_addr(const tor_addr_t *addr
return buf;
}
+/** Like fmt_addr(), but takes <b>addr</b> as a host-order IPv4
+ * addresses. Also not thread-safe, also clobbers its return buffer on
+ * repeated calls. */
+const char *
+fmt_addr32(uint32_t addr)
+{
+ static char buf[INET_NTOA_BUF_LEN];
+ struct in_addr in;
+ in.s_addr = htonl(addr);
+ tor_inet_ntoa(&in, buf, sizeof(buf));
+ return buf;
+}
+
/** Convert the string in <b>src</b> to a tor_addr_t <b>addr</b>. The string
* may be an IPv4 address, an IPv6 address, or an IPv6 address surrounded by
* square brackets.
@@@ -1036,27 -1025,28 +1036,28 @@@ get_interface_address6(int severity, sa
{
int sock=-1, r=-1;
struct sockaddr_storage my_addr, target_addr;
- socklen_t my_addr_len;
+ socklen_t addr_len;
tor_assert(addr);
memset(addr, 0, sizeof(tor_addr_t));
memset(&target_addr, 0, sizeof(target_addr));
- my_addr_len = (socklen_t)sizeof(my_addr);
- /* Use the "discard" service port */
- ((struct sockaddr_in*)&target_addr)->sin_port = 9;
/* Don't worry: no packets are sent. We just need to use a real address
* on the actual Internet. */
if (family == AF_INET6) {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)&target_addr;
+ /* Use the "discard" service port */
+ sin6->sin6_port = htons(9);
sock = tor_open_socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP);
- my_addr_len = (socklen_t)sizeof(struct sockaddr_in6);
+ addr_len = (socklen_t)sizeof(struct sockaddr_in6);
sin6->sin6_family = AF_INET6;
S6_ADDR16(sin6->sin6_addr)[0] = htons(0x2002); /* 2002:: */
} else if (family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in*)&target_addr;
+ /* Use the "discard" service port */
+ sin->sin_port = htons(9);
sock = tor_open_socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
- my_addr_len = (socklen_t)sizeof(struct sockaddr_in);
+ addr_len = (socklen_t)sizeof(struct sockaddr_in);
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(0x12000001); /* 18.0.0.1 */
} else {
@@@ -1069,14 -1059,13 +1070,13 @@@
goto err;
}
- if (connect(sock,(struct sockaddr *)&target_addr,
- (socklen_t)sizeof(target_addr))<0) {
+ if (connect(sock,(struct sockaddr *)&target_addr, addr_len) < 0) {
int e = tor_socket_errno(sock);
log_fn(severity, LD_NET, "connect() failed: %s", tor_socket_strerror(e));
goto err;
}
- if (getsockname(sock,(struct sockaddr*)&my_addr, &my_addr_len)) {
+ if (getsockname(sock,(struct sockaddr*)&my_addr, &addr_len)) {
int e = tor_socket_errno(sock);
log_fn(severity, LD_NET, "getsockname() to determine interface failed: %s",
tor_socket_strerror(e));
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits