X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/2d6dbe290c1ccc52b550753c4f9240ac716d5a24..6ab6d4bfc11512565c77ee6ab322b4e214d2074d:/socket.c diff --git a/socket.c b/socket.c index 02a25111..0ad8a169 100644 --- a/socket.c +++ b/socket.c @@ -26,10 +26,6 @@ #include "rsync.h" -#ifndef HAVE_GETADDRINFO -#include "lib/addrinfo.h" -#endif - /* Establish a proxy connection on an open socket to a web roxy by * using the CONNECT method. */ static int establish_proxy_connection(int fd, char *host, int port) @@ -302,6 +298,7 @@ static int open_socket_in(int type, int port, const char *bind_address, case EPROTONOSUPPORT: case EAFNOSUPPORT: case EPFNOSUPPORT: + case EINVAL: /* See if there's another address that will work... */ continue; } @@ -582,6 +579,12 @@ char *client_addr(int fd) } +static int get_sockaddr_family(const struct sockaddr_storage *ss) +{ + return ((struct sockaddr *) ss)->sa_family; +} + + /** * Return the DNS name of the client **/ @@ -610,7 +613,7 @@ char *client_name(int fd) } #ifdef INET6 - if (ss.ss_family == AF_INET6 && + if (get_sockaddr_family(&ss) == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&ss)->sin6_addr)) { struct sockaddr_in6 sin6; struct sockaddr_in *sin; @@ -654,7 +657,7 @@ char *client_name(int fd) /* XXX sin6_flowinfo and other fields */ for (res = res0; res; res = res->ai_next) { - if (res->ai_family != ss.ss_family) + if (res->ai_family != get_sockaddr_family(&ss)) continue; if (res->ai_addrlen != length) continue;