diff options
author | Phil Mesnier <mesnier_p@ociweb.com> | 2007-07-07 17:48:30 +0000 |
---|---|---|
committer | Phil Mesnier <mesnier_p@ociweb.com> | 2007-07-07 17:48:30 +0000 |
commit | 5bbbc256cf4af7bca2734b5f5df3ee41297aab4f (patch) | |
tree | 2c47c83142dd0857ad2efd141dd718aa87ccd818 /ACE/ace | |
parent | 17476bf6167b56b3faadb634f61d6e21e1d51572 (diff) | |
download | ATCD-5bbbc256cf4af7bca2734b5f5df3ee41297aab4f.tar.gz |
Sat Jul 7 17:45:34 UTC 2007 Phil Mesnier <mesnier_p@ociweb.com>
Diffstat (limited to 'ACE/ace')
-rw-r--r-- | ACE/ace/INET_Addr.cpp | 78 |
1 files changed, 58 insertions, 20 deletions
diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 26d42e0fac9..79889b8dabe 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -327,32 +327,70 @@ ACE_INET_Addr::set (u_short port_number, sizeof this->inet_addr_); #if defined (ACE_HAS_IPV6) - struct addrinfo hints, *res, *res0; - int error; - ACE_OS::memset (&hints, 0, sizeof (hints)); - - hints.ai_family = address_family; +# if defined (AIX) + struct hostent *h_ent; + int error_num = 0; + if (address_family == AF_UNSPEC || address_family == AF_INET6) + { + h_ent = ::getipnodebyname (host_name, AF_INET6, 0, &error_num); + if (h_ent == 0) + { + if (address_family == AF_INET6 || error_num != NO_ADDRESS) + return -1; + } + } + if (h_ent == 0) + { + h_ent = ::getipnodebyname (host_name, AF_INET, 0, &error_num); + if (h_ent == 0) + { + return -1; + } + } + this->set_type (h_ent->h_addrtype); + this->set_addr (h_ent->h_addr_list[0], h_ent->h_length); + this->set_port_number (port_number, encode); - error = getaddrinfo (host_name, 0, &hints, &res0); - if (error) - return -1; + ::freehostent (h_ent); + return 0; - int ret = -1; - for (res = res0; res != 0; res = res->ai_next) +# else + struct addrinfo hints; + struct addrinfo *res = 0; + int error = 0; + ACE_OS::memset (&hints, 0, sizeof (hints)); + if (address_family == AF_UNSPEC || address_family == AF_INET6) { - if (address_family == AF_UNSPEC || res->ai_family == address_family) + hints.ai_family = AF_INET6; + error = ::getaddrinfo (host_name, 0, &hints, &res); + if (error) { - this->set_type (res->ai_family); - this->set_addr (res->ai_addr, res->ai_addrlen); - this->set_port_number (port_number, encode); - ret = 0; - if (address_family == AF_UNSPEC && res->ai_family == AF_INET6) - break; + if (address_family == AF_INET6) + { + if (res) + ::freeaddrinfo(res); + return -1; + } + address_family = AF_INET; } } - freeaddrinfo (res0); - return ret; - + if (address_family == AF_INET) + { + hints.ai_family = AF_INET; + error = ::getaddrinfo (host_name, 0, &hints, &res); + if (error) + { + if (res) + ::freeaddrinfo(res); + return -1; + } + } + 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; +# endif /* AIX */ #else /* ACE_HAS_IPV6 */ // IPv6 not supported... insure the family is set to IPv4 |