diff options
author | Adam Mitz <mitza@ociweb.com> | 2015-11-30 13:26:44 -0600 |
---|---|---|
committer | Adam Mitz <mitza@ociweb.com> | 2015-11-30 13:26:44 -0600 |
commit | b46349941bf532c2004fd25c53198e1489da19cb (patch) | |
tree | 30ef28171e16d383060286261d34c4eaa72031fb /ACE/ace/INET_Addr.cpp | |
parent | cd6ca119a66ee97d0314a6bfb7e972ca72a5d76c (diff) | |
download | ATCD-b46349941bf532c2004fd25c53198e1489da19cb.tar.gz |
ACE_INET_Addr::set - use inet_pton to detect cases that are numeric addresses and don't need hostname resolution.
Diffstat (limited to 'ACE/ace/INET_Addr.cpp')
-rw-r--r-- | ACE/ace/INET_Addr.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 20d815808e2..4c68959656b 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -370,11 +370,40 @@ ACE_INET_Addr::set (u_short port_number, if (address_family == AF_UNSPEC && !ACE::ipv6_enabled ()) address_family = AF_INET; #endif /* ACE_HAS_IPV6 && ACE_USES_IPV4_IPV6_MIGRATION */ -#ifndef ACE_HAS_IPV6 - if (address_family == AF_UNSPEC) - address_family = AF_INET; + +#ifdef ACE_HAS_IPV6 + if (address_family != AF_INET + && ACE_OS::inet_pton (AF_INET6, host_name, + &this->inet_addr_.in6_.sin6_addr) == 1) + { + this->base_set (AF_INET6, sizeof this->inet_addr_.in4_); +# ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN + this->inet_addr_.in6_.sin6_len = sizeof this->inet_addr_.in6_; +# endif + this->inet_addr_.in6_.sin6_family = AF_INET6; + this->set_size (sizeof this->inet_addr_.in6_); + this->set_type (AF_INET6); + this->set_port_number (port_number, encode); + return 0; + } +#else + address_family = AF_INET; #endif /* ACE_HAS_IPV6 */ + if (ACE_OS::inet_pton (AF_INET, host_name, + &this->inet_addr_.in4_.sin_addr) == 1) + { + this->base_set (AF_INET, sizeof this->inet_addr_.in4_); +#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN + this->inet_addr_.in4_.sin_len = sizeof this->inet_addr_.in4_; +#endif + this->inet_addr_.in4_.sin_family = AF_INET; + this->set_size (sizeof this->inet_addr_.in4_); + this->set_type (AF_INET); + this->set_port_number (port_number, encode); + return 0; + } + addrinfo hints; ACE_OS::memset (&hints, 0, sizeof hints); hints.ai_family = address_family; |