diff options
Diffstat (limited to 'dep/acelite/ace/INET_Addr.cpp')
-rw-r--r-- | dep/acelite/ace/INET_Addr.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/dep/acelite/ace/INET_Addr.cpp b/dep/acelite/ace/INET_Addr.cpp index 6dba7150f93..a41b0e4406f 100644 --- a/dep/acelite/ace/INET_Addr.cpp +++ b/dep/acelite/ace/INET_Addr.cpp @@ -1,4 +1,4 @@ -// $Id: INET_Addr.cpp 91683 2010-09-09 09:07:49Z johnnyw $ +// $Id: INET_Addr.cpp 95533 2012-02-14 22:59:17Z wotte $ // Defines the Internet domain address family address format. @@ -334,48 +334,67 @@ ACE_INET_Addr::set (u_short port_number, sizeof this->inet_addr_); #if defined (ACE_HAS_IPV6) - struct addrinfo hints; - struct addrinfo *res = 0; - int error = 0; - ACE_OS::memset (&hints, 0, sizeof (hints)); -# if defined (ACE_USES_IPV4_IPV6_MIGRATION) - if (address_family == AF_UNSPEC && !ACE::ipv6_enabled()) + // Let the IPv4 case fall through to the non-IPv6-capable section. + // We don't need the additional getaddrinfo() capability and the Linux + // getaddrinfo() is substantially slower than gethostbyname() w/ + // large vlans. +# if defined (ACE_USES_IPV4_IPV6_MIGRATION) + if (address_family == AF_UNSPEC && !ACE::ipv6_enabled ()) address_family = AF_INET; -# endif /* ACE_USES_IPV4_IPV6_MIGRATION */ - if (address_family == AF_UNSPEC || address_family == AF_INET6) +# endif /* ACE_USES_IPV4_IPV6_MIGRATION */ + if (address_family != AF_INET) { - hints.ai_family = AF_INET6; - error = ::getaddrinfo (host_name, 0, &hints, &res); - if (error) +# if defined (ACE_HAS_GETHOSTBYNAME2) + hostent hentry; + hostent *hp; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! + + if (0 == ::gethostbyname2_r (host_name, AF_INET6, &hentry, + buf, sizeof(buf), &hp, &h_error)) { - if (address_family == AF_INET6) + if (hp != 0) { - if (res) - ::freeaddrinfo(res); - errno = error; - return -1; + struct sockaddr_in6 v6; + ACE_OS::memset (&v6, 0, sizeof (v6)); + v6.sin6_family = AF_INET6; + (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, + hp->h_addr, + hp->h_length); + this->set_type (hp->h_addrtype); + this->set_addr (&v6, hp->h_length); + this->set_port_number (port_number, encode); + return 0; } - address_family = AF_INET; } - } - if (address_family == AF_INET) - { - hints.ai_family = AF_INET; - error = ::getaddrinfo (host_name, 0, &hints, &res); - if (error) + errno = h_error; + if (address_family == AF_INET6) + return -1; +# else + struct addrinfo hints; + struct addrinfo *res = 0; + int error = 0; + ACE_OS::memset (&hints, 0, sizeof (hints)); + hints.ai_family = AF_INET6; + if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) + { + this->set_type (res->ai_family); + this->set_addr (res->ai_addr, res->ai_addrlen); + this->set_port_number (port_number, encode); + ::freeaddrinfo (res); + return 0; + } + if (address_family == AF_INET6) { if (res) ::freeaddrinfo(res); errno = error; return -1; } +# endif /* ACE_HAS_GETHOSTBYNAME2 */ + // Let AF_UNSPEC try again w/ IPv4. } - this->set_type (res->ai_family); - this->set_addr (res->ai_addr, res->ai_addrlen); - this->set_port_number (port_number, encode); - ::freeaddrinfo (res); - return 0; -#else /* ACE_HAS_IPV6 */ +#endif /* ACE_HAS_IPV6 */ // IPv6 not supported... insure the family is set to IPv4 address_family = AF_INET; @@ -392,9 +411,6 @@ ACE_INET_Addr::set (u_short port_number, encode); else { -# if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME) - hostent *hp = ACE_OS::gethostbyname (host_name); -# else hostent hentry; ACE_HOSTENT_DATA buf; int h_error = 0; // Not the same as errno! @@ -403,7 +419,6 @@ ACE_INET_Addr::set (u_short port_number, buf, &h_error); if (hp == 0) errno = h_error; -# endif /* ACE_VXWORKS */ if (hp == 0) { @@ -419,7 +434,6 @@ ACE_INET_Addr::set (u_short port_number, encode); } } -#endif /* ACE_HAS_IPV6 */ } // Helper function to get a port number from a port name. @@ -839,19 +853,6 @@ ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const } else { -#if defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR) - ACE_UNUSED_ARG (len); - int error = - ::hostGetByAddr ((int) this->inet_addr_.in4_.sin_addr.s_addr, - hostname); - if (error == OK) - return 0; - else - { - errno = error; - return -1; - } -#else void* addr = this->ip_addr_pointer (); int size = this->ip_addr_size (); int type = this->get_type (); @@ -901,7 +902,6 @@ ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const ACE_OS::strcpy (hostname, hp->h_name); return 0; -#endif /* ACE_VXWORKS */ } } @@ -1008,7 +1008,7 @@ int ACE_INET_Addr::set_address (const char *ip_addr, } -#if (defined (__linux__) || defined (ACE_WIN32)) && defined (ACE_HAS_IPV6) +#if (defined (ACE_LINUX) || defined (ACE_WIN32)) && defined (ACE_HAS_IPV6) int ACE_INET_Addr::set_interface (const char *intf_name) { @@ -1016,7 +1016,7 @@ ACE_INET_Addr::set_interface (const char *intf_name) (IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr))) { -#if defined (__linux__) +#if defined (ACE_LINUX) this->inet_addr_.in6_.sin6_scope_id = ACE_OS::if_nametoindex (intf_name); #else @@ -1033,7 +1033,7 @@ ACE_INET_Addr::set_interface (const char *intf_name) return 0; } -#endif /* __linux && ACE_HAS_IPV6 */ +#endif /* ACE_LINUX && ACE_HAS_IPV6 */ const char * ACE_INET_Addr::get_host_addr (char *dst, int size) const @@ -1070,7 +1070,7 @@ ACE_INET_Addr::get_host_addr (char *dst, int size) const &this->inet_addr_.in6_.sin6_addr, dst, size); -#if defined (__linux__) +#if defined (ACE_LINUX) if ((IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr)) && this->inet_addr_.in6_.sin6_scope_id != 0) |