diff options
author | Matthieu Herrb <matthieu.herrb@laas.fr> | 2009-11-01 11:40:40 +0100 |
---|---|---|
committer | Matthieu Herrb <matthieu.herrb@laas.fr> | 2009-11-01 11:40:40 +0100 |
commit | 84ad38d4d18253900ec387bb3d46a0b568e83e30 (patch) | |
tree | b78536d7221eee0ec40aeb118bad055dde56ca4e /Xtranssock.c | |
parent | cd9860ce5ea57e5d1bcddd4ef361b41685067716 (diff) | |
parent | f0f7c47055eecac35786ec616c7632604da204b5 (diff) |
Merge remote branch 'origin/master' into obsd
Conflicts:
Xtranssock.c
Diffstat (limited to 'Xtranssock.c')
-rw-r--r-- | Xtranssock.c | 67 |
1 files changed, 20 insertions, 47 deletions
diff --git a/Xtranssock.c b/Xtranssock.c index 519448a..18bbc5b 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -229,16 +229,6 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr); #endif /* - * This provides compatibility for apps linked against system libraries - * that don't have IPv6 support. - */ -#if defined(IPv6) && defined(AF_INET6) -static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT; -#pragma weak in6addr_any = local_in6addr_any -static int haveIPv6 = 1; -#endif - -/* * These are some utility function used by the real interface function below. */ @@ -271,25 +261,21 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) { #if defined(IPv6) && defined(AF_INET6) struct sockaddr_storage socknamev6; -#endif +#else struct sockaddr_in socknamev4; +#endif void *socknamePtr; SOCKLEN_T namelen; PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0); #if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) - { - namelen = sizeof(socknamev6); - socknamePtr = &socknamev6; - } - else + namelen = sizeof(socknamev6); + socknamePtr = &socknamev6; +#else + namelen = sizeof(socknamev4); + socknamePtr = &socknamev4; #endif - { - namelen = sizeof(socknamev4); - socknamePtr = &socknamev4; - } bzero(socknamePtr, namelen); @@ -317,15 +303,10 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) } #if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) - { - ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family; - } - else + ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family; +#else + ciptr->family = socknamev4.sin_family; #endif - { - ciptr->family = socknamev4.sin_family; - } ciptr->addrlen = namelen; memcpy (ciptr->addr, socknamePtr, ciptr->addrlen); @@ -350,7 +331,7 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) SOCKLEN_T namelen; #if defined(IPv6) && defined(AF_INET6) - if (haveIPv6 && ciptr->family == AF_INET6) + if (ciptr->family == AF_INET6) { namelen = sizeof(socknamev6); socknamePtr = &socknamev6; @@ -404,11 +385,6 @@ TRANS(SocketOpen) (int i, int type) PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0); -#if defined(IPv6) && defined(AF_INET6) - if (!haveIPv6 && Sockettrans2devtab[i].family == AF_INET6) - return NULL; -#endif - if ((ciptr = (XtransConnInfo) xcalloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { @@ -1477,7 +1453,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) #endif #if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) { + { if (addrlist != NULL) { if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) { if (addrlist->firstaddr) @@ -1619,8 +1595,8 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) addrlist->addr = addrlist->addr->ai_next; } } - } else -#endif + } +#else { /* * Build the socket name. @@ -1694,6 +1670,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) socketaddr = (struct sockaddr *) &sockname; socketaddrlen = sizeof(sockname); } +#endif /* * Turn on socket keepalive so the client process will eventually @@ -1744,7 +1721,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (olderrno == ECONNREFUSED || olderrno == EINTR #if defined(IPv6) && defined(AF_INET6) - || (haveIPv6 && ((addrlist->addr->ai_next != NULL) || + || (((addrlist->addr->ai_next != NULL) || (addrlist->addr != addrlist->firstaddr)) && (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT || olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT @@ -1790,7 +1767,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) } #if defined(IPv6) && defined(AF_INET6) - if (haveIPv6 && res != 0) { + if (res != 0) { addrlist->addr = addrlist->addr->ai_next; } #endif @@ -1819,10 +1796,8 @@ UnixHostReallyLocal (char *host) if (strcmp (hostnamebuf, host) == 0) { return (1); - } + } else { #if defined(IPv6) && defined(AF_INET6) - else if (haveIPv6) - { struct addrinfo *localhostaddr; struct addrinfo *otherhostaddr; struct addrinfo *i, *j; @@ -1868,10 +1843,7 @@ UnixHostReallyLocal (char *host) freeaddrinfo(localhostaddr); freeaddrinfo(otherhostaddr); return equiv; - } -#endif - else - { +#else /* * A host may have more than one network address. If any of the * network addresses of 'host' (specified to the connect call) @@ -1940,6 +1912,7 @@ UnixHostReallyLocal (char *host) i++; } return (equiv); +#endif } } |